question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong GLSL generated when ENVMAP_TYPE_CUBE_UV is defined

See original GitHub issue

While trying to use the CubeUVReflectionMapping option on my envmap, I noticed GLSL compilation errors appearing in my log :

THREE.WebGLProgram: Shader Error 1282 - VALIDATE_STATUS false

Program Info Log: Fragment shader is not compiled.

FRAGMENT

ERROR: 0:484: '0.276' : syntax error

Below is an excerpt of the GLSL source code that is being compiled.

My understanding is that :

  1. a #define v1 0.276 is done in cube_uv_reflection_fragment.glsl.js
  2. no #undef follows
  3. later a parameter is named v1 in bsdfs.glsl.js for LTC_EdgeVectorFormFactor function
  4. This v1 is replaced by 0.276 which gives the syntax error
...
320: #ifdef ENVMAP_TYPE_CUBE_UV
...
389: 	#define r0 1.0
390: 	#define v0 0.339
391: 	#define m0 - 2.0
392: 	#define r1 0.8
393: 	#define v1 0.276
394: 	#define m1 - 1.0
395: 	#define r4 0.4
396: 	#define v4 0.046
397: 	#define m4 2.0
398: 	#define r5 0.305
399: 	#define v5 0.016
400: 	#define m5 3.0
401: 	#define r6 0.21
402: 	#define v6 0.0038
403: 	#define m6 4.0
404: 	float roughnessToMip( float roughness ) {
405: 		float mip = 0.0;
406: 		if ( roughness >= r1 ) {
407: 			mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
408: 		} else if ( roughness >= r4 ) {
409: 			mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
410: 		} else if ( roughness >= r5 ) {
411: 			mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
412: 		} else if ( roughness >= r6 ) {
413: 			mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
414: 		} else {
415: 			mip = - 2.0 * log2( 1.16 * roughness );		}
416: 		return mip;
417: 	}
...
484: vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
...

Platform:

  • Device: Desktop
  • OS: Windows
  • Browser: Chrome
  • Three.js version: r133

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
WestLangleycommented, Oct 25, 2021

So ‘THREE.CubeUVReflectionMapping’ is not supposed to be used ?

Typically, not by the user.

You can get more help if you need it at https://discourse.threejs.org.

1reaction
WestLangleycommented, Oct 25, 2021

Do this, instead.

envTexture.mapping = THREE.EquirectangularReflectionMapping;
Read more comments on GitHub >

github_iconTop Results From Across the Web

GLSL : common mistakes - OpenGL Wiki
The following article discusses common mistakes made in the ... It is legal to have the same uniform defined in different shader stages....
Read more >
GLSL Linker Error: Definition for "void main()" not found
Whenever I try to link the program, I encounter an error. Output: ERROR: definition for "void main()" not found. Vertex shader: #version 330...
Read more >
Debugging - LearnOpenGL
Within OpenGL's function documentation you can always find the error codes a function generates the moment it is incorrectly used. For instance, if...
Read more >
OpenGL Error when linking GLSL shaders due to variables ...
ERROR : Input of fragment shader '_input' not written by vertex shader. The error is generated by the following glsl code lines:
Read more >
Use of deprecated texture2D() in OpenGL 3.1+ shaders
[OpenGL] Error high : SHADER_ID_COMPILE error has been generated. GLSL compile failed for shader 24, "": ERROR: 2:442: 'function' : is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found