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

InstancedPointNodeMaterial: depth issue #30254

Open
Lafeu-p opened this issue Jan 3, 2025 · 2 comments
Open

InstancedPointNodeMaterial: depth issue #30254

Lafeu-p opened this issue Jan 3, 2025 · 2 comments
Labels

Comments

@Lafeu-p
Copy link

Lafeu-p commented Jan 3, 2025

Description

In the current InstancedPointNodeMaterial, the vertex offset is applied within the vertexNode, but the depth is calculated based on positionView.z, which is obtained before applying the offset. The depth calculation should use the positionView.z value after the offset is applied. This approach may result in incorrect depth values.
image
image
If the positionView is recalculated after applying the vertex offset in the vertexNode, the result will be correct.

//clipPos.xy += offset;
clipPos.addAssign( vec4( offset, 0, 0 ) );

positionView.assign( cameraProjectionMatrixInverse.mul( clipPos ) );

return clipPos;

image
image

Reproduction steps

Code

Live example

Screenshots

No response

Version

172

Device

Desktop

Browser

Chrome

OS

MacOS

@Mugen87 Mugen87 added the Nodes label Jan 4, 2025
@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 5, 2025

Instead of implementing vertexNode, I wonder if it isn't better to implement positionNode in InstancedPointsNodeMaterial instead and apply the offset in local space. In this way, we can update the existing positionLocal TSL object which means subsequent objects like positionView are automatically correct.

@RenaudRohlinger
Copy link
Collaborator

Unlike setupVertex, vertexNode won't assign nodes such as positionView. To fix your issue you could use setupVertex @Lafeu-p:

  material.setupVertex = (builder) => {
    builder.addStack();
    ... your code
     builder.context.vertex = builder.removeStack();
    return clipPos;
  };

To be honest I feel like this is something we should fix directly in vertexNode. /cc @sunag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants