-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1617 from Autodesk/t_gamaj/UsdTexture2d_in_VP2
Implement UsdTexture2d support in VP2 render delegate
- Loading branch information
Showing
7 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!-- | ||
======================================================================== | ||
Copyright 2019 Autodesk | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
======================================================================== | ||
--> | ||
<fragment uiName="UsdTransform2d" name="UsdTransform2d" type="plumbing" class="ShadeFragment" version="1.0" feature_level="0"> | ||
<description> | ||
<![CDATA[VP2 implementation for transform 2d]]> | ||
</description> | ||
<properties> | ||
<float2 name="in" /> | ||
<float name="rotation" /> | ||
<float2 name="scale" /> | ||
<float2 name="translation" /> | ||
</properties> | ||
<outputs> | ||
<float2 name="result" /> | ||
</outputs> | ||
<implementation> | ||
<implementation render="OGSRenderer" language="GLSL" lang_version="3.0"> | ||
<function_name val="UsdTransform2d" /> | ||
<source> | ||
<![CDATA[ | ||
vec2 UsdTransform2d(vec2 uv, float rotation, vec2 scale, vec2 translation) | ||
{ | ||
float angleRad = rotation * 3.1415926f / 180.f; | ||
mat2 rotMat = mat2(cos(angleRad), sin(angleRad), | ||
-sin(angleRad), cos(angleRad)); | ||
return translation + rotMat * (scale * uv); | ||
} | ||
]]> | ||
</source> | ||
</implementation> | ||
<implementation render="OGSRenderer" language="HLSL" lang_version="11.0"> | ||
<function_name val="UsdTransform2d" /> | ||
<source> | ||
<![CDATA[ | ||
float2 UsdTransform2d(float2 uv, float rotation, float2 scale, float2 translation) | ||
{ | ||
float angleRad = rotation * 3.1415926f / 180.f; | ||
float2x2 rotMat = float2x2(cos(angleRad), sin(angleRad), | ||
-sin(angleRad), cos(angleRad)); | ||
return translation + mul(scale * uv, rotMat); | ||
} | ||
]]> | ||
</source> | ||
</implementation> | ||
<implementation render="OGSRenderer" language="Cg" lang_version="2.1"> | ||
<function_name val="UsdTransform2d" /> | ||
<source> | ||
<![CDATA[ | ||
float2 UsdTransform2d(float2 uv, float rotation, float2 scale, float2 translation) | ||
{ | ||
float angleRad = rotation * 3.1415926f / 180.f; | ||
mat2 rotMat = mat2(cos(angleRad), -sin(angleRad), | ||
sin(angleRad), cos(angleRad)); | ||
return translation + mul(rotMat, scale * uv); | ||
} | ||
]]> | ||
</source> | ||
</implementation> | ||
</implementation> | ||
</fragment> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+93.2 KB
...nderDelegate/VP2RenderDelegateUSDPreviewSurface/baseline/UsdTransform2dTest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
test/testSamples/UsdPreviewSurface/UsdTransform2dTest.usda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#usda 1.0 | ||
( | ||
defaultPrim = "pPlane1" | ||
metersPerUnit = 0.01 | ||
upAxis = "Y" | ||
) | ||
|
||
def Mesh "pPlane1" ( | ||
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 = </pPlane1/Looks/usdPreviewSurface1SG> | ||
point3f[] points = [(-0.5, 0, 0.5), (0.5, 0, 0.5), (-0.5, 0, -0.5), (0.5, 0, -0.5)] | ||
texCoord2f[] primvars:st = [(0, 0), (1, 0), (0, 1), (1, 1)] ( | ||
customData = { | ||
dictionary Maya = { | ||
token name = "map1" | ||
} | ||
} | ||
interpolation = "faceVarying" | ||
) | ||
int[] primvars:st:indices = [0, 1, 3, 2] | ||
float3 xformOp:rotateXYZ = (90, 0, 0) | ||
uniform token[] xformOpOrder = ["xformOp:rotateXYZ"] | ||
|
||
def Scope "Looks" | ||
{ | ||
def Material "usdPreviewSurface1SG" | ||
{ | ||
token inputs:file1:varname = "st" | ||
token outputs:surface.connect = </pPlane1/Looks/usdPreviewSurface1SG/usdPreviewSurface1.outputs:surface> | ||
|
||
def Shader "usdPreviewSurface1" | ||
{ | ||
uniform token info:id = "UsdPreviewSurface" | ||
color3f inputs:diffuseColor.connect = </pPlane1/Looks/usdPreviewSurface1SG/file1.outputs:rgb> | ||
token outputs:displacement | ||
token outputs:surface | ||
} | ||
|
||
def Shader "file1" | ||
{ | ||
uniform token info:id = "UsdUVTexture" | ||
float4 inputs:fallback = (0.5, 0.5, 0.5, 1) | ||
asset inputs:file = @grid.png@ | ||
token inputs:sourceColorSpace = "sRGB" | ||
float2 inputs:st.connect = </pPlane1/Looks/usdPreviewSurface1SG/file1/UsdTransform2d.outputs:result> | ||
token inputs:wrapS = "repeat" | ||
token inputs:wrapT = "repeat" | ||
float3 outputs:rgb | ||
|
||
def Shader "TexCoordReader" | ||
{ | ||
uniform token info:id = "UsdPrimvarReader_float2" | ||
token inputs:varname.connect = </pPlane1/Looks/usdPreviewSurface1SG.inputs:file1:varname> | ||
float2 outputs:result | ||
} | ||
|
||
def Shader "UsdTransform2d" | ||
{ | ||
uniform token info:id = "UsdTransform2d" | ||
float2 inputs:in.connect = </pPlane1/Looks/usdPreviewSurface1SG/file1/TexCoordReader.outputs:result> | ||
float inputs:rotation = 13 | ||
float2 inputs:scale = (0.3, 0.5) | ||
float2 inputs:translation = (0.1777373, 0.117708534) | ||
float2 outputs:result | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.