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 Transpiler: Missing elements #27538

Closed
RenaudRohlinger opened this issue Jan 10, 2024 · 1 comment
Closed

TSL Transpiler: Missing elements #27538

RenaudRohlinger opened this issue Jan 10, 2024 · 1 comment
Labels
TSL Three.js Shading Language
Milestone

Comments

@RenaudRohlinger
Copy link
Collaborator

RenaudRohlinger commented Jan 10, 2024

Description

The TSL Transpiler seems to lack a few elements such as mat3, mat4, texelFetch, texture2D and so on. I created a sample to quickly check what's missing.
image

Reproduction steps

Add a mat3, mat4 ect and the code will not transpile properly.

Code

Sample generated with AI:

float a = 1.0;
vec2 b;
vec3 c;
vec4 d;
mat3 e;
mat4 f;
vec4 g = texture2D();
vec4 h = texture2DArray();

// Basic arithmetic tests
float i = a + 0.5;
vec2 j = b + vec2(1.0, 2.0);
vec3 k = c - vec3(0.5, 0.5, 0.5);
vec4 l = d * vec4(2.0, 2.0, 2.0, 2.0);
mat3 m = e * mat3(1.0);
mat4 n = f + mat4(1.0);

// Vector and matrix multiplication tests
vec3 o = vec3(1.0, 0.0, 0.0) * e;
vec4 p = vec4(1.0, 0.0, 0.0, 1.0) * f;

// Function call tests
vec4 q = texture2D(g, vec2(0.5, 0.5));
vec4 r = texture2DArray(h, vec3(0.5, 0.5, 1.0));

// Conditional tests
if (a > 0.5) {
    a = 2.0;
}

// Loop tests
for (int s = 0; s < 5; s++) {
    a += 1.0;
}

// Texture access tests
vec4 t = texture2D(g, vec2(a, i));
vec4 u = texture2DArray(h, vec3(j.x, j.y, 0.0));

// Complex expression tests
vec4 v = mix(q, r, 0.5);
vec3 w = normalize(vec3(p.x, p.y, p.z));

// Uniform variable tests
uniform mat4 uMatrix;
vec4 x = uMatrix * vec4(1.0, 1.0, 1.0, 1.0);

// Sampler tests
uniform sampler2D uSampler;
vec4 y = texture2D(uSampler, vec2(0.5, 0.5));
// texelFetch tests
ivec2 texelCoord2D = ivec2(10, 20);
vec4 z = texelFetch(uSampler, texelCoord2D, 0);

// texture2DArray tests
uniform sampler2DArray uSampler2DArray;
vec4 aa = texture2DArray(uSampler2DArray, vec3(0.5, 0.5, 1.0));

// textureCube tests
uniform samplerCube uSamplerCube;
vec4 ab = textureCube(uSamplerCube, vec3(1.0, 0.0, 0.0));

// texture3D tests
uniform sampler3D uSampler3D;
vec4 ac = texture3D(uSampler3D, vec3(0.5, 0.5, 0.5));

// Shadow texture tests
uniform sampler2DShadow uSamplerShadow;
float shadowCoord = 0.5;
vec4 ad = shadow2D(uSamplerShadow, vec3(0.5, 0.5, shadowCoord));

// More complex texelFetch test
ivec3 texelCoord3D = ivec3(5, 5, 1);
vec4 ae = texelFetch(uSampler2DArray, texelCoord3D, 0);

// Texture sampling with varying coordinates
vec4 af = textureCube(uSamplerCube, normalize(c));

// Testing texture3D with non-uniform coordinates
vec3 nonUniformCoord = vec3(a, k.x, o.y);
vec4 ag = texture3D(uSampler3D, nonUniformCoord);

vec3 arr[2] = vec3[2](
  vec3(0.,0.,0.),
  vec3(0.,0.,0.),
);

#ifdef USE_UV
#endif

Live example

Version

r160

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 15, 2025

Most of the missing elements presented in this issue should be fixed by the latest PRs. If certain GLSL statements do not work yet, it's best to create separate issues.

@Mugen87 Mugen87 closed this as completed Feb 15, 2025
@Mugen87 Mugen87 added this to the r174 milestone Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TSL Three.js Shading Language
Projects
None yet
Development

No branches or pull requests

2 participants