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: Introduces cache hierarchy #28585

Merged
merged 7 commits into from
Jun 10, 2024
Merged

TSL: Introduces cache hierarchy #28585

merged 7 commits into from
Jun 10, 2024

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Jun 8, 2024

Related issue: Closes #28546

Description

The objective is that when using a node it will look in some parent if the variable has already been declared, similar to the block hierarchy adopted in JS for example.

@sunag sunag marked this pull request as ready for review June 8, 2024 04:26
@sunag sunag added this to the r166 milestone Jun 8, 2024
@RenaudRohlinger
Copy link
Collaborator

RenaudRohlinger commented Jun 9, 2024

Just tested as I had multiple times today the same issue as #28546 and this PR does seem to also introduce a small issue for the moment. 😁

Error comes from the CondNode I believe, when I call:

const hue2rgb = tslFn( ( [ p, q, t ] ) => {

	t = cond( t.lessThan( 0.0 ), t.add( 1.0 ), t );
	t = cond( t.greaterThan( 1.0 ), t.sub( 1.0 ), t );

	return cond(
		t.lessThan( 1.0 / 6.0 ),
		p.add( ( q.sub( p ) ).mul( 6.0 ).mul( t ) ),
		cond(
			t.lessThan( 1.0 / 2.0 ),
			q,
			cond(
				t.lessThan( 2.0 / 3.0 ),
				p.add( ( q.sub( p ) ).mul( float( 2.0 / 3.0 ).sub( t ) ).mul( 6.0 ) ),
				p
			)
		)
	);

} );

const palette = tslFn( ( [ t ] ) => {
    const color = hslToRgb(hue2rgb(...
    return color
})

particleMaterial.colorNode = palette( buffer.toAttribute().length() )

Screenshot 2024-06-09 at 18 38 03
Screenshot 2024-06-09 at 18 38 49

@sunag
Copy link
Collaborator Author

sunag commented Jun 9, 2024

@RenaudRohlinger Since declaration of attributes, variables etc are related to cache we may have some revisions after this. I just update this PR, could you please let me know if it fixed it for you? Thanks for reporting the problem! :)

@RenaudRohlinger
Copy link
Collaborator

It does fix my issue! Thanks @sunag

@sunag sunag merged commit 133da7c into mrdoob:dev Jun 10, 2024
11 checks passed
@sunag sunag deleted the dev-condnode-v2 branch June 10, 2024 03:50
sunag referenced this pull request in Mugen87/three.js Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants