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

LOOKDEVX-2352 Fix incorrect tangent fixup #3559

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/mayaUsd/render/vp2RenderDelegate/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,16 +906,17 @@ void _AddMissingTangents(mx::DocumentPtr& mtlxDoc)
transformVectorToObject = _createTransformVector(_mtlxTokens->object);
}
replaceWithPassthru(tangentNode, transformVectorToObject);
continue;
} else if (spaceInput->getValueString() == _mtlxTokens->model.GetString()) {
if (!transformVectorToModel) {
transformVectorToModel = _createTransformVector(_mtlxTokens->model);
}
replaceWithPassthru(tangentNode, transformVectorToModel);
} else {
// Default to world.
replaceWithPassthru(tangentNode, tangentGenerator);
continue;
}
}
// Default to world.
replaceWithPassthru(tangentNode, tangentGenerator);
}
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions test/testSamples/MaterialX/DemoQuads.usda
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,41 @@ def Scope "mtl"
float2 outputs:out
}
}

def Material "standard_surface3"
{
token outputs:mtlx:surface.connect = </mtl/standard_surface3/standard_surface1.outputs:out>

def Shader "standard_surface1"
{
uniform token info:id = "ND_standard_surface_surfaceshader"
color3f inputs:base_color = (0.6, 0.0, 0.0)
float3 inputs:normal.connect = </mtl/standard_surface3/normalmap1.outputs:out>
token outputs:out
}

def Shader "normalmap1"
{
uniform token info:id = "ND_normalmap"
float3 inputs:normal.connect = </mtl/standard_surface3/image1.outputs:out>
float3 inputs:tangent.connect = </mtl/standard_surface3/tangent1.outputs:out>
float3 outputs:out
}

def Shader "tangent1"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This material will cause a crash without the fix.

{
uniform token info:id = "ND_tangent_vector3"
float3 outputs:out
}

def Shader "image1"
{
uniform token info:id = "ND_image_vector3"
asset inputs:file = @textures/mesh_wire_norm.png@
string inputs:filtertype = "closest"
float3 outputs:out
}
}
}

def Mesh "Background" (
Expand Down Expand Up @@ -744,3 +779,43 @@ def Mesh "pMultiUVPlane6" (
uniform token[] xformOpOrder = ["xformOp:translate"]
}

def Mesh "pMultiUVPlane7" (
prepend apiSchemas = ["MaterialBindingAPI"]
kind = "component"
)
{
uniform bool doubleSided = 1
float3[] extent = [(-0.5, 0, -0.5), (0.5, 0, 0.5)]
int[] faceVertexCounts = [4]
int[] faceVertexIndices = [0, 1, 3, 2]
rel material:binding = </mtl/standard_surface3>
point3f[] points = [(-0.5, 0, 0.5), (0.5, 0, 0.5), (-0.5, 0, -0.5), (0.5, 0, -0.5)]
color3f[] primvars:displayColor = [(0.13320851, 0.13320851, 0.13320851)] (
customData = {
dictionary Maya = {
bool generated = 1
}
}
)
texCoord2f[] primvars:st1 = [(1.5051357, 0.5019881), (0.4980119, 1.5051357), (0.5019881, -0.50513566), (-0.50513566, 0.4980119)] (
customData = {
dictionary Maya = {
token name = "map1"
}
}
interpolation = "faceVarying"
)
texCoord2f[] primvars:st = [(0.50056624, -0.00038683414), (1.0003868, 0.50056624), (-0.00038683414, 0.49943376), (0.49943376, 1.0003868)] (
customData = {
dictionary Maya = {
token name = "uvSet1"
}
}
interpolation = "faceVarying"
)
int[] primvars:st1:indices = [0, 1, 3, 2]
int[] primvars:st:indices = [0, 1, 3, 2]
token visibility = "inherited"
double3 xformOp:translate = (-2.2, 0, -1.1)
uniform token[] xformOpOrder = ["xformOp:translate"]
}