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: UniformsNode support int/uint #28666

Merged
merged 4 commits into from
Jun 17, 2024

Conversation

RenaudRohlinger
Copy link
Collaborator

@RenaudRohlinger RenaudRohlinger commented Jun 16, 2024

Related issue: #27706

Description

const vectors = uniforms( [
	new THREE.Vector4( 1, 0, 1, 1 ),
	new THREE.Vector4( 0, 1, 0, 1 ),
	new THREE.Vector4( 0, 0, 1, 1 )
], 'ivec4' );

Allow to specify the bufferType to uniforms. Without it, the struct in the WGSL backend was always generating float vec4 which would then break some operation when using layouts.

This contribution is funded by Utsubo

@RenaudRohlinger RenaudRohlinger added this to the r166 milestone Jun 16, 2024
@sunag
Copy link
Collaborator

sunag commented Jun 16, 2024

What do you think about using builder.getComponentType() in setup and define bufferType there, so we could have a single parameter for type.

const vectors = uniforms( [
	new THREE.Vector4( 1, 0, 1, 1 ),
	new THREE.Vector4( 0, 1, 0, 1 ),
	new THREE.Vector4( 0, 0, 1, 1 )
], 'ivec4' );

@RenaudRohlinger
Copy link
Collaborator Author

Then since the best practice is to use vec4 with UBOs I guess I will need to do something like so:

const type = ...toLowerCase().charAt( 0 );

let _type = 'vec4';
if ( type === 'u' ) {

_type = 'uvec4';

} else if ( type === 'i' ) {

_type = 'ivec4';

}

@sunag
Copy link
Collaborator

sunag commented Jun 17, 2024

@RenaudRohlinger I imagined something like your example too 👍

I haven't tested this one maybe this work?
this.bufferType = builder.changeComponentType( 'vec4', builder.getComponentType( this.elementType ) )

@sunag sunag changed the title TSL: UniformsNode add bufferType TSL: UniformsNode support int/uint Jun 17, 2024
@sunag sunag merged commit 4e3656e into mrdoob:dev Jun 17, 2024
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.

None yet

2 participants