Skip to content
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

TSL: Shader error in select(...,remap,remap) #30223

Closed
boytchev opened this issue Dec 28, 2024 · 1 comment · Fixed by #30229
Closed

TSL: Shader error in select(...,remap,remap) #30223

boytchev opened this issue Dec 28, 2024 · 1 comment · Fixed by #30229
Labels
Bug TSL Three.js Shading Language
Milestone

Comments

@boytchev
Copy link
Contributor

Description

When a TSL code contains select(...,remap,remap) the generated shader code uses null as a type of one of the variables. This fails the shader compilation.

The issue does not appear if:

  • only one remap is used
  • or both remap-s are used outside select
  • or the second remap is wrapped in float(select(...)).

The error message (when WebGL2 is used) is:

THREE.WebGLProgram: Shader Error 0 - VALIDATE_STATUS false

Program Info Log: Must have a compiled fragment shader attached:
SHADER_INFO_LOG:
ERROR: 0:48: 'null' : undeclared identifier
ERROR: 0:48: 'nodeVar1' : syntax error

FRAGMENT

ERROR: 0:48: 'null' : undeclared identifier
ERROR: 0:48: 'nodeVar1' : syntax error

  43: 
  44: void main() {
  45: 
  46: 	// vars
  47: 	vec4 DiffuseColor;
> 48: 	null nodeVar1;
  49: 	vec4 Output;
  50: 	vec4 nodeVar3;
  51: 
  52: 	// flow
  53: 	// code
  54: 

For WebGPU the error is conceptually the same, but explained with different words.

Reproduction steps

  1. See the live example at https://codepen.io/boytchev/pen/vEBJaLa?editors=0011
  2. Run it with opened console
  3. It should show the error
  4. Instead of remap(0, 0, 0, 0, 0) in line 21 use float(remap(0, 0, 0, 0, 0))
  5. The shader now compiles

Note: the demo program is not meaningful. It is only to demonstrate the compilation error.

Code

var test = Fn(() => {

	var k = select(
		0,
		remap(0, 0, 0, 0, 0),
		remap(0, 0, 0, 0, 0) // wrap it in float(...) and it will work
	);

	return vec3(k, 0, 0);

});

Live example

https://codepen.io/boytchev/pen/vEBJaLa?editors=0011

Screenshots

image

Version

r171

Device

Desktop

Browser

Chrome

OS

Windows

@linbingquan
Copy link
Contributor

linbingquan commented Dec 28, 2024

remap should be called with a chain operation, like: const k = float( 0.5 ).remap( 0, 1 )

no chain operation, we need to call remap(float(0.5), 0, 1)

@sunag sunag added Bug TSL Three.js Shading Language labels Dec 30, 2024
@sunag sunag added this to the r172 milestone Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug TSL Three.js Shading Language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants