{"id":14981277,"url":"https://github.com/stevinz/three-wboit","last_synced_at":"2026-03-08T16:31:37.825Z","repository":{"id":62389024,"uuid":"557034207","full_name":"stevinz/three-wboit","owner":"stevinz","description":"Weighted, blended order independent transparency pass for use with three.js.","archived":false,"fork":false,"pushed_at":"2023-08-03T01:18:44.000Z","size":5490,"stargazers_count":38,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-29T05:22:14.699Z","etag":null,"topics":["effect-composer","oit","order-independent-transparency","pass","render-pass","renderer","three-js","threejs","transparent","wboit","webgl","weighted-blended"],"latest_commit_sha":null,"homepage":"https://stevinz.github.io/three-wboit","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stevinz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-25T00:55:10.000Z","updated_at":"2024-07-10T07:09:05.000Z","dependencies_parsed_at":"2024-09-24T06:30:59.611Z","dependency_job_id":"7b75fdbb-2689-47d1-a485-18e784530618","html_url":"https://github.com/stevinz/three-wboit","commit_stats":{"total_commits":95,"total_committers":1,"mean_commits":95.0,"dds":0.0,"last_synced_commit":"d44c9450f8b240154cb840cb2bf503b1491b92eb"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevinz%2Fthree-wboit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevinz%2Fthree-wboit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevinz%2Fthree-wboit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevinz%2Fthree-wboit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevinz","download_url":"https://codeload.github.com/stevinz/three-wboit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219858317,"owners_count":16556047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["effect-composer","oit","order-independent-transparency","pass","render-pass","renderer","three-js","threejs","transparent","wboit","webgl","weighted-blended"],"created_at":"2024-09-24T14:03:14.912Z","updated_at":"2026-03-08T16:31:37.757Z","avatar_url":"https://github.com/stevinz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Three Wboit\n\nWeighted, Blended Order Independent Transparency ([paper](http://jcgt.org/published/0002/02/09/), [blog](http://casual-effects.blogspot.com/2015/03/implemented-weighted-blended-order.html)) for use with [three.js](https://threejs.org/). This implementation is designed as a rendering [Pass](https://github.com/mrdoob/three.js/blob/dev/examples/jsm/postprocessing/Pass.js). It can be used as a stand-alone replacement for a traditional render pass (i.e. `renderer.render`), or used as part of a larger rendering stack within [Effect Composer](https://threejs.org/docs/index.html?q=effec#examples/en/postprocessing/EffectComposer).\n\n## Examples\n\n- Stand-Alone\n    - \u003ca href='https://stevinz.github.io/three-wboit/WeightedBlended.html'\u003eGeneral Wboit Examples\u003c/a\u003e\n- Scene Composer\n    - \u003ca href='https://stevinz.github.io/three-wboit/PatchMaterials.html'\u003eEffect Composer w/Material Patching\u003c/a\u003e\n- Three Versions\n    - \u003ca href='https://stevinz.github.io/three-wboit/ModelTest148andUnder.html'\u003ePatching Three v148 and older\u003c/a\u003e\n    - \u003ca href='https://stevinz.github.io/three-wboit/ModelTest149to151.html'\u003ePatching Three v149 to v151\u003c/a\u003e\n    - \u003ca href='https://stevinz.github.io/three-wboit/ModelTest152andUp.html'\u003ePatching Three v152 and newer\u003c/a\u003e\n\n## More Info\n\nThere are several common techniques available for [order independent transparency](https://learnopengl.com/Guest-Articles/2020/OIT/Introduction). This implementation uses Weighted, Blended Order-Indepent Transparency (WBOIT), both for it's high performance and also compatibility on slower hardware. This implementation is WebGL 1 compatible and mobile friendly.\n\nOne of the biggest advantages of order independent transparency is for the rendering of detailed transparent models. Typically when rendering such a model, it is common for some faces to be depth culled. When rendering with WBOIT, all faces will be visible. WBOIT is approximate, though, and while it provides good results it may not be appropriate for all use cases.\n\nThere are a variety of weight functions available when rendering with WBOIT. This is partially due to inconsistencies in rendering overlapping pixels at varying depths. Some weight functions are better at incorporating camera near / far planes, some are better at handling larger groups of overlapping triangles. This implementation includes a `weight` modifier within `MeshWboitMaterial` that attempts to adjust the weight function for both opacity and color depending on the depth of the fragments.\n\nThe biggest downside of this method is that due to the blending method used, as `opacity` approaches `1.0` objects still retain an artifically high amount of transparency. WBOIT enabled materials can be made opaque during the render pass by setting the material property `transparent` to `false`.\n\n## Install\n\n- Option 1: Copy files from `src` directory into project, import from files...\n\n```javascript\nimport { MeshWboitMaterial } from './materials/MeshWboitMaterial.js';\nimport { WboitPass } from './WboitPass.js';\n```\n\n- Option 2: Install from [npm](https://www.npmjs.com/package/three-wboit), import from 'three-wboit'...\n```\nnpm install three-wboit\n```\n```javascript\nimport { MeshWboitMaterial, WboitPass } from 'three-wboit';\n```\n\n- Option 3: Import directly from CDN...\n```javascript\nimport { MeshWboitMaterial, WboitPass } from 'https://unpkg.com/three-wboit/build/index.module.js';\n```\n\n## Usage\n\nTo setup your scene to use WBOIT, create an instance of `WboitPass`.\n\nWhen creating `Mesh` objects intended to be transparent, use the included material `MeshWboitMaterial`. Objects using this material have WBOIT enabled by default. WBOIT can be turned on / off on each object by setting the material's `transparent` property. The material is functionaly equivalent to `MeshBasicMaterial`, and supports all it's [methods and properties](https://threejs.org/docs/#api/en/materials/MeshBasicMaterial).\n\nWhen rendering your scene, instead of calling `renderer.render()`, call `wboitPass.render( renderer )`. Enjoy.\n\n```javascript\nimport * as THREE from 'three';\n\nimport { MeshWboitMaterial, WboitPass } from 'three-wboit';\n\nconst renderer = new THREE.WebGLRenderer( { preserveDrawingBuffer: true } );\n\nconst camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.10, 100 );\n\nconst scene = new THREE.Scene();\nscene.add( new THREE.BoxGeometry(), new MeshWboitMaterial( { opacity: 0.5 } ) );\n\nconst wboitPass = new WboitPass( renderer, scene, camera, 0 /* optional clear color */, 1.0 /* optional clear alpha */);\n\n...\n\nrender() {\n\n    // OLD:\n    //  renderer.render( scene, camera );\n\n    // NEW:\n    wboitPass.render( renderer );\n\n}\n\n```\n\n## Patching Materials\n\nTo use `WboitPass` with any existing material, use the included utility function `WboitUtils.patch()`\n\n```javascript\nimport * as THREE from 'three';\n\nimport { WboitUtils } from 'three-wboit';\n\nconst material = new THREE.MeshStandardMaterial();\nWboitUtils.patch( material );\n\nconst myMesh = new THREE.Mesh( new THREE.BoxGeometry(), material );\n\n```\n\nNOTE: Three.js has made some changes to the renderer from versions v148 through v152, including how it renders transparent objects and how it deals with color space. For versions prior to 152 it is recommended to use the [version](https://www.npmjs.com/package/three-wboit?activeTab=versions) of this library `v1.0.13`.\n\n## Acknowledgements\n\n- Weighted, Blended Order-Independent Transparency by Morgan McGuire and Louis Bavoil - [Paper](http://jcgt.org/published/0002/02/09/)\n- Weighted, Blended WebGL 2 Example by Tarek Sherif [@tsherif](https://github.com/tsherif) - [Repo](https://github.com/tsherif/webgl2examples/blob/master/oit.html)\n- Weighted, Blended Three.js Example by Alexander Rose [@arose](https://github.com/arose) - [Issue](https://github.com/mrdoob/three.js/issues/4814)\n- Depth Peel Three.js Example by Dusan Bosnjak [@pailhead](https://github.com/pailhead) - [Pull](https://github.com/mrdoob/three.js/pull/15490)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevinz%2Fthree-wboit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevinz%2Fthree-wboit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevinz%2Fthree-wboit/lists"}