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

MaterialXLoader: Unlit Material #27575

Merged
merged 4 commits into from
Jan 17, 2024
Merged

MaterialXLoader: Unlit Material #27575

merged 4 commits into from
Jan 17, 2024

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Jan 17, 2024

Related issue: Closes #27494, #27496

Description

Initial support for NPR (non-photorealistic rendering) and viewDirectionWorld.

I was unable to reproduce different types of spaces in the official MaterialX Viewer for viewdirection, that's why the viewDirectionWorld is fixed for now.

@sunag sunag added this to the r161 milestone Jan 17, 2024
@sunag sunag linked an issue Jan 17, 2024 that may be closed by this pull request
@sunag sunag marked this pull request as ready for review January 17, 2024 03:37

setup() {

return this.positionNode.sub( cameraPosition ).normalize();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunag

In the shaders, we use this pattern consistently:

vec4 mvPosition = vec4( transformed, 1.0 );

vViewPosition = - mvPosition.xyz

vec3 viewDir = normalize( vViewPosition );

So the view direction is a unit vector from the vertex toward the camera.

Just making sure you are aware. :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this pattern through positionViewDirection and it is widely used in lighting models.

} else if ( scope === PositionNode.VIEW_DIRECTION ) {
const vertexPositionNode = positionView.negate();
outputNode = normalize( varying( vertexPositionNode ) );

In some tests that I did MaterialX seems uses viewdirection in world space for this node as default instead of view space, and apparently will have local/model space to select.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I think you may have misunderstood my comment...

The comment is only about ensuring the sign of "view direction" is correct, and consistent with historical convention, and how three.js defines it.

In the case of local vs. world space, the two definitions should be consistent with each other.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, is an important point, I'll revert this part for now and check this in other PR.

@sunag sunag changed the title MaterialXLoader: Unlit Material and viewDirectionWorld Jan 17, 2024
@sunag sunag merged commit 21b0b81 into mrdoob:dev Jan 17, 2024
11 checks passed
@sunag sunag deleted the dev-mtlx branch January 17, 2024 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants