Skip to content

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Feb 14, 2025

Related issue: #27538

Description

This PR adds basic texture support to the TSL Transpiler.

Texture nodes are often created with a texture value (meaning an instance of THREE.Texture). To accommodate that, the Transpiler uses placeholders like /* <THREE.Texture> */ when generating calls with texture(), cubeTexture() and texture3D(). For example the following GLSL:

uniform sampler2D diffuseMap;
vec4 color = texture2D(diffuseMap, vec2(0.5, 0.5));

is converted to:

import { texture, vec2, vec4 } from 'three/tsl';

const diffuseMap = texture( /* <THREE.Texture> */ );
const color = vec4( diffuseMap.sample( vec2( 0.5, 0.5 ) ) ).toVar();

That should make it hopefully more clear where users are supposed to pass textures to nodes.

@sunag sunag added this to the r174 milestone Feb 15, 2025
@sunag sunag merged commit 27a593b into mrdoob:dev Feb 15, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants