Skip to content

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

@boytchev

Description

@boytchev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugTSLThree.js Shading Language

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions