ShadowMaterial doesn’t work when Fog is enabled

The simplest way to see this is to add Fog to the WebGL_Editor_Spline example – after line 88 add

scene.fog = new THREE.Fog(0xf7f7f7, 2000, 3000);

Then the ShadowMaterial fails to render and the console has the following error:

three.js:22912 Uncaught TypeError: Cannot set property 'value' of undefined
    at refreshUniformsFog (three.js:22912)
    at setProgram (three.js:22645)
    at WebGLRenderer.renderBufferDirect (three.js:21542)
    at renderObject (three.js:22272)
    at renderObjects (three.js:22245)
    at WebGLRenderer.render (three.js:22013)
    at render (webgl_geometry_spline_editor.html:432)
    at animate (webgl_geometry_spline_editor.html:421)

This line in WebGLRenderer is the cause of the error. So perhaps the ShadowMaterial is missing a uniform?

Author: Fantashit

1 thought on “ShadowMaterial doesn’t work when Fog is enabled

  1. ShadowMaterial is missing fog support.

    Not all materials support fog. One solution is to set fog:false in the ShadowMaterial constructor.

    The other solution is to support fog for this material. That seems reasonable to me.

Comments are closed.