# Read cubeTexture in TSL

**URL:** <https://discourse.threejs.org/t/read-cubetexture-in-tsl/74481>\
**Category:** Questions\
**Tags:** tsl\
**Created:** [November 27, 2024, 9:09am UTC](https://discourse.threejs.org/t/read-cubetexture-in-tsl/74481 "2024-11-27T09:09:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackInk](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@blackInk](https://discourse.threejs.org/u/blackInk)\
**Post date:** [November 27, 2024, 9:09am UTC](https://discourse.threejs.org/t/read-cubetexture-in-tsl/74481/1 "2024-11-27T09:09:56Z")

</div>

Hi,

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

```javascript
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?

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [November 27, 2024, 9:46am UTC](https://discourse.threejs.org/t/read-cubetexture-in-tsl/74481/2 "2024-11-27T09:46:17Z")

</div>

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](https://jsfiddle.net/zp4rjg0x/)

The relevant part is:

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

```

---

<div class="post-metadata">

**Author:** ![blackInk](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@blackInk](https://discourse.threejs.org/u/blackInk)\
**Post date:** [November 27, 2024, 10:00am UTC](https://discourse.threejs.org/t/read-cubetexture-in-tsl/74481/3 "2024-11-27T10:00:43Z")

</div>

harrrrr…

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

---

<div class="post-metadata">

**Author:** ![blackInk](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@blackInk](https://discourse.threejs.org/u/blackInk)\
**Post date:** [November 27, 2024, 10:03am UTC](https://discourse.threejs.org/t/read-cubetexture-in-tsl/74481/4 "2024-11-27T10:03:13Z")

</div>

Another question. If I try to transpile:

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

```

via [three.js examples](https://threejs.org/examples/?q=tsl#webgpu_tsl_transpiler)

it gives me

```javascript
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?

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [November 27, 2024, 10:35pm UTC](https://discourse.threejs.org/t/read-cubetexture-in-tsl/74481/5 "2024-11-27T22:35:16Z")

</div>

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