Undeclared identifier ‘IncidentLight’ on Windows

Hello,

I encountered weird, platform dependent problem, with most of default shaders. Everything works nice and dandy in Chromium on my Linux PC, but Chrome 49.0.2594.3 canary (64-bit) on Windows 7 fails to compile shaders with following log:

(index):218 GET http://www.google-analytics.com/ga.js net::ERR_BLOCKED_BY_CLIENT(anonymous function) @ (index):218(anonymous function) @ (index):219
(index):421     __     __
 __/ __\  / __\__   ____   _____   _____
/ __/  /\/ /  /___\/ ____\/ _____\/ _____\
\/_   __/ /   _   / /  __/ / __  / / __  /_   __   _____
/ /  / / /  / /  / /  / / /  ___/ /  ___/\ _\/ __\/ _____\
\/__/  \/__/\/__/\/__/  \/_____/\/_____/\/__/ /  / /  ___/
                                         / __/  /  \__  \
                                         \/____/\/_____/
three.min.js:639 THREE.WebGLRenderer 74
three.min.js:707 THREE.WebGLProgram: shader error:  0 gl.VALIDATE_STATUS false gl.getProgramInfoLog C:\fakepath(249,9-30): error X3004: undeclared identifier 'IncidentLight'

Warning: D3D shader compilation failed with default flags. (vs_3_0)
 Retrying with avoid flow control
C:\fakepath(249,9-30): error X3004: undeclared identifier 'webgl_45daf4aa877f103d'

Warning: D3D shader compilation failed with avoid flow control flags. (vs_3_0)
 Retrying with prefer flow control
C:\fakepath(249,9-30): error X3004: undeclared identifier 'webgl_45daf4aa877f103d'

Warning: D3D shader compilation failed with prefer flow control flags. (vs_3_0)
Failed to create D3D shaders.
  (anonymous function) @ three.min.js:707acquireProgram @ three.min.js:716t @ three.min.js:605renderBufferDirect @ three.min.js:651s @ three.min.js:603render @ three.min.js:663render @ material-browser.html:108(anonymous function) @ material-browser.html:121
three.min.js:608 WebGL: INVALID_OPERATION: useProgram: program not valid
three.min.js:678 WebGL: INVALID_OPERATION: drawArrays: no valid shader program in use
254three.min.js:678 WebGL: INVALID_OPERATION: drawArrays: no valid shader program in use
three.min.js:678 WebGL: too many errors, no more errors will be reported to the console for this context.

Problem is visible even on threejs.org doc pages, for example at
http://threejs.org/docs/#Reference/Materials/MeshLambertMaterial

As far as I’m able to tell, ‘IncidentLight’ structure is defined in common.glsl and it is included in generated shader.

// Edit:
here is generated fragment and generated vertex shader

Author: Fantashit

2 thoughts on “Undeclared identifier ‘IncidentLight’ on Windows

  1. I somehow managed to fix the problem;

    Compilation fails on functions IncidentLight getPointDirectLight and IncidentLight getDirectionalDirectLight. Modifying those functions to void types that modifies argument, as in

    void getDirectionalDirectLight( out IncidentLight directLight, const in DirectionalLight directionalLight, const in GeometricContext geometry );
    
    void getPointDirectLight( out IncidentLight directLight, const in PointLight pointLight, const in GeometricContext geometry );
    

    has same effect and compiles fine on Windows.

  2. @doexclusive I have an idea on how to avoid the compiler error. I think that the issue may be that compiler may be having problems with a struct (IncidentLight in this case) being returned by a function as its return value. We could reformulate those functions so that they take an “out” function parameter of IncidentLight instead. This doesn’t change the functionality at all, but it may allow us to work around what appears to be a compiler bug. I’ll try to get this change done later today. The functions that I would change are getDirectionalDirectLightIrradiance, getPointDirectLightIrradiance, an getSpotDirectLightIrradiance.

Comments are closed.