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: varyingProperty #27198

Merged
merged 2 commits into from
Nov 17, 2023
Merged

TSL: varyingProperty #27198

merged 2 commits into from
Nov 17, 2023

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Nov 17, 2023

Related issue: #26704

Description

varyingProperty declares varying without having to set an initial value as in varying, thus saving GPU resources.

This was used in some specific cases, such as Line2NodeMaterial and can now be used directly in WGSL if necessary.

const myVarying = varyingProperty( 'vec3', 'myVarying' );

const positionTransformFn = wgslFn( `
	fn positionTransformFn( position: vec3<f32> ) -> vec3<f32> {

		// varyings.* is the structure that will store all the varyings
		// you can use it to access/store your varying value

		varyings.myVarying = position;

		return position;

	}
`, [ myVarying ] );

material = new MeshBasicNodeMaterial();
material.colorNode = myVarying;
material.positionNode = positionTransformFn( { position: positionLocal } );

@sunag sunag added the TSL Three.js Shading Language label Nov 17, 2023
@sunag sunag added this to the r159 milestone Nov 17, 2023
@sunag
Copy link
Collaborator Author

sunag commented Nov 17, 2023

/cc @Spiri0

@sunag sunag marked this pull request as ready for review November 17, 2023 03:56
@sunag sunag merged commit 997c8b5 into mrdoob:dev Nov 17, 2023
11 checks passed
@sunag sunag deleted the dev-varyingProperty branch November 17, 2023 08:06
AdaRoseCannon pushed a commit to AdaRoseCannon/three.js that referenced this pull request Jan 15, 2024
* TSL: varyingProperty

* update example
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 this pull request may close these issues.

1 participant