-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Conversation
|
||
setup() { | ||
|
||
return this.positionNode.sub( cameraPosition ).normalize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. :-)
There was a problem hiding this comment.
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.
three.js/examples/jsm/nodes/accessors/PositionNode.js
Lines 54 to 58 in b8b82d9
} 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
This reverts commit d5eea2b.
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 theviewDirectionWorld
is fixed for now.