-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
WebGLRenderer: Modernized shadow mapping: native cube depth textures, Vogel disk sampling, and VSM improvements #32303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
We must be careful with this change. We did the same in |
|
This test now renders 2x faster on a Pixel 3a (8fps vs 18fps). |
Please test this PR in as many devices as you can 🙏 |
|
There's a problem with Line 1199 in 80dd1f9
The "Basic" depth does three.js/src/renderers/shaders/ShaderLib/depth.glsl.js Lines 95 to 98 in 80dd1f9
I suspect that's why this was needed. But now
Pretty annoying, but I'll probably have to add a new constant... I wouldn't want to call it Asked Gemini and it suggested So probably It's annoying that |
|
Nice! The good news is that my girlfriend has a Pixel 8a somewhere, I'll investigate tomorrow. |
|
Okay, I think it should work now. Can you test again? |
|
The broken examples work on the Pixel again. I've also checked the browser console and it is free from errors/warnings as well. 🎉 |


Related issue: #5554 #8577 #32180
This PR modernizes the
WebGLRenderershadow mapping with several significant improvements:Major Changes
1. Native Cube Depth Texture Support for PointLight Shadows
CubeDepthTextureclass for native cube shadow mapsPointLightShadowto render directly to cube faces instead of 2D viewportsWebGLTexturesto support cube depth texture binding2. Removed RGBA Depth Packing
samplerShadow/samplerCubeShadowfor PCF,samples/samplerCubefor Basic)distanceRGBA.glsl.js→distance.glsl.jscubeToUV()and RGBA packing code from shadersShadowMapViewerand related examples to work with native depth3. Vogel Disk + Interleaved Gradient Noise (IGN) Sampling
shadowmap_pars_fragment.glsl.jsPCFSoftShadowMapas the newPCFShadowMapis already soft4. VSM Shadow Map Improvements
5. WebGL Optimizations
WebGLUniforms: Prioritize shadow samplers (SAMPLER_2D_SHADOW,SAMPLER_CUBE_SHADOW) for Adreno GPUsWebGLUniforms: Support reversed depth buffer compare functionsWebGLLights: AddedshadowCameraNearandshadowCameraFaruniforms for PointLight shadowsFiles Changed
src/textures/CubeDepthTexture.jsdistanceRGBA.glsl.js→distance.glsl.jsshadowmap_pars_fragment.glsl.js,WebGLShadowMap.jsPointLightShadow.js,WebGLTextures.js,WebGLUniforms.jsTesting
Tested with DirectionalLight, SpotLight, and PointLight shadows across BasicShadowMap, PCFShadowMap, and VSMShadowMap types. Shadow map type switching works correctly, with appropriate warnings for VSM/PointLight combinations.
(Made with VS Code and Claude Sonnet 4.5)