You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thank you for creating this excellent library! I've been banging my head against the wall for some time trying to get proper transparency rendering.
While implementing three-wboit with React Three Fiber, I ran into some challenges and wanted to share a working solution that might help others.
Here's a minimal working example:
// WBOITPass.jsx - Separate component to handle WBOIT setupfunctionWBOITPass(){const{ gl, scene, camera }=useThree();useEffect(()=>{constwboitPass=newWboitPass(gl,scene,camera,0,1.0);constoriginalRender=gl.render.bind(gl);letisRendering=false;gl.render=function(...args){if(isRendering){returnoriginalRender.apply(this,args);}isRendering=true;wboitPass.render(gl);isRendering=false;};return()=>{gl.render=originalRender;};},[gl,scene,camera]);returnnull;}// Usage in your scenefunctionApp(){return(<Canvasgl={{alpha: true}}><WBOITPass/>{/* Your scene content */}</Canvas>);}// Patching materialsconstmaterial=useMemo(()=>{constmaterial=newTHREE.MeshStandardMaterial({transparent: true,opacity: 0.5});WboitUtils.patch(material);returnmaterial;},[]);
The key points:
Create a separate component to handle WBOIT setup
Use a rendering flag to prevent recursion
Patch materials inside useMemo to prevent recreation
Add the WBOITPass component to your Canvas
Hope this helps future R3F users!
The text was updated successfully, but these errors were encountered:
First, thank you for creating this excellent library! I've been banging my head against the wall for some time trying to get proper transparency rendering.
While implementing three-wboit with React Three Fiber, I ran into some challenges and wanted to share a working solution that might help others.
Here's a minimal working example:
The key points:
Hope this helps future R3F users!
The text was updated successfully, but these errors were encountered: