Read cubeTexture in TSL

Hi,

I am trying to use an cubeMap in TSL. By now I am trying like this:

this.materialParams = {
	cubeTex: this.textureCube,
}

const customShaderNode = tslFn( ( input ) => {
        const rayVec = vec3(0.0,0.0,0.0).toVar();
	const col = vec4( cubeTexture( input.cubeTex, rayVec ) ).toVar();
});

let material = new MeshBasicNodeMaterial();
material.colorNode = customShaderNode( this.materialParams );

…but “col” does not get the cubeTexture´s rgb-values but console throws an error. Am I doing things wrong in how to access the cubeMap via TSL / uniforms?

I’ve tried to reproduce the issue but with no luck. Try it with the code from the fiddle: three.js dev template - module - JSFiddle - Code Playground

The relevant part is:

const uvNode = vec3( 0.0, 0.0, 0.0 ); // custom uv
material.colorNode = cubeTexture( envMap, uvNode );

harrrrr…

thanks - I simply did not import cubeTexture from ‘three/tsl’ …

Another question. If I try to transpile:

vec2 p = (-iResolution.xy+2.0*fragCoord.xy) / iResolution.y;

via three.js examples

it gives me

const p = vec2( iResolution.xy.negate().add( mul( 2.0, fragCoord.xy ) ).div( iResolution.y ) ).toVar();

Which seems to be “off” from what should be transpiled, no?

The output looks correct to me. What is wrong from your point of view?

1 Like