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 dont recognize 8U #30396

Closed
Makio64 opened this issue Jan 26, 2025 · 0 comments · Fixed by #30410
Closed

tsl transpiler dont recognize 8U #30396

Makio64 opened this issue Jan 26, 2025 · 0 comments · Fixed by #30410
Labels
TSL Three.js Shading Language
Milestone

Comments

@Makio64
Copy link
Contributor

Makio64 commented Jan 26, 2025

Description

While transpiling this code i discover the 8U isnt correctly understand by the transpiler.

Reproduction steps

In tsl transpiler :

8U ->int( 8U )
expected
8U -> uint( 8 )

also in the following example it seems the mul of x as uvec3 by uint not working correctly

// hash33 by iq https://www.shadertoy.com/view/XlXcW4
const uint k = 1103515245U;  // GLIB C

vec3 hash33( uvec3 x )
{
    x = ((x>>8U)^x.yzx)*k;
    x = ((x>>8U)^x.yzx)*k;
    x = ((x>>8U)^x.yzx)*k;
    
    return vec3(x)*(1.0/float(0xffffffffU));
}

result :

// Three.js Transpiler r172

import { int, uint, uvec3, vec3, float, div, Fn } from 'three/tsl';

const k = uint( int( 1103515245U ) );

export const hash33 = /*#__PURE__*/ Fn( ( [ x_immutable ] ) => {

	const x = uvec3( x_immutable ).toVar();
	x.assign( x.shiftRight( int( 8U ) ).bitXor( x.yzx ).mul( k ) );
	x.assign( x.shiftRight( int( 8U ) ).bitXor( x.yzx ).mul( k ) );
	x.assign( x.shiftRight( int( 8U ) ).bitXor( x.yzx ).mul( k ) );

	return vec3( x ).mul( div( 1.0, float( int( 0xffffffffU ) ) ) );

} ).setLayout( {
	name: 'hash33',
	type: 'vec3',
	inputs: [
		{ name: 'x', type: 'uvec3' }
	]
} );

Code

X

Live example

https://threejs.org/examples/webgpu_tsl_transpiler.html

Screenshots

No response

Version

r172

Device

No response

Browser

No response

OS

No response

@mrdoob mrdoob added the TSL Three.js Shading Language label Jan 26, 2025
@Mugen87 Mugen87 added this to the r173 milestone Jan 27, 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

Successfully merging a pull request may close this issue.

3 participants