SOLARIS - UsdPreviewSurface texture scale

   1960   5   0
User Avatar
Member
39 posts
Joined: Jan. 2012
Offline
I am trying to scale textures in SOLARIS using the UsdPreviewSurface.

I have models/uv's/texture/st working fine. As soon as I wire in a UsdTransform2d the texture read stops displaying.

Try this example from here https://graphics.pixar.com/usd/docs/Simple-Shading-in-USD.html [graphics.pixar.com] in a python_lop.
I'm not 100% sure the wiring is correct;

node = hou.pwd()
stage = node.editableStage()

from pxr import Gf, Kind, Sdf, Usd, UsdGeom, UsdShade

modelRoot = UsdGeom.Xform.Define(stage, "/TexModel")
Usd.ModelAPI(modelRoot).SetKind(Kind.Tokens.component)

billboard = UsdGeom.Mesh.Define(stage, "/TexModel/card")
billboard.CreatePointsAttr([(-430, -145, 0), (430, -145, 0), (430, 145, 0), (-430, 145, 0)])
billboard.CreateFaceVertexCountsAttr([4])
billboard.CreateFaceVertexIndicesAttr([0,1,2,3])
billboard.CreateExtentAttr([(-430, -145, 0), (430, 145, 0)])
texCoords = billboard.CreatePrimvar("st", Sdf.ValueTypeNames.TexCoord2fArray, UsdGeom.Tokens.varying)
texCoords.Set([(0, 0), (1, 0), (1,1), (0, 1)])

material = UsdShade.Material.Define(stage, '/TexModel/boardMat')

pbrShader = UsdShade.Shader.Define(stage, '/TexModel/boardMat/PBRShader')
pbrShader.CreateIdAttr("UsdPreviewSurface")
pbrShader.CreateInput("roughness", Sdf.ValueTypeNames.Float).Set(0.4)
pbrShader.CreateInput("metallic", Sdf.ValueTypeNames.Float).Set(0.0)

material.CreateSurfaceOutput().ConnectToSource(pbrShader, "surface")

stReader = UsdShade.Shader.Define(stage, '/TexModel/boardMat/stReader')
stReader.CreateIdAttr('UsdPrimvarReader_float2')
stInput = material.CreateInput('frame:stPrimvarName', Sdf.ValueTypeNames.Token)
stInput.Set('st')
stReader.CreateInput('varname',Sdf.ValueTypeNames.Token).ConnectToSource(stInput)

#Texture2d node, bypassing this in the diffuseTextureSampler will work
transform_2d = UsdShade.Shader.Define(stage, '/TexModel/boardMat/transform_2d')
transform_2d.CreateIdAttr('UsdTransform2d')
transform_2d.CreateInput("in", Sdf.ValueTypeNames.Float2).ConnectToSource(stReader, 'result')
transform_2d.CreateInput("scale", Sdf.ValueTypeNames.Float2).Set((0.5, 0.5))

diffuseTextureSampler = UsdShade.Shader.Define(stage,'/TexModel/boardMat/diffuseTexture')
diffuseTextureSampler.CreateIdAttr('UsdUVTexture')
diffuseTextureSampler.CreateInput('file', Sdf.ValueTypeNames.Asset).Set("$HFS/houdini/pic/texture/bricks001_basecolor.rat")
diffuseTextureSampler.CreateInput("st", Sdf.ValueTypeNames.Float2).ConnectToSource(transform_2d, 'result')
pbrShader.CreateInput("diffuseColor", Sdf.ValueTypeNames.Color3f).ConnectToSource(diffuseTextureSampler, 'rgb')

UsdShade.MaterialBindingAPI(billboard).Bind(material)
www.aaronauty.com
User Avatar
Member
39 posts
Joined: Jan. 2012
Offline
Looking at the version of the bundled USD included with Houdini, it looks like we are using 19.11.
I have seen mixed reports of this shader not working before 20.08, so that could be the issue.
www.aaronauty.com
User Avatar
Staff
1448 posts
Joined: July 2005
Offline
UsdTransform2d is a recent addition to the USD standard, and I'd say it is somewhat in an experimental/beta state:
on one hand it has been re-affirmed as official on the USD forum:
https://groups.google.com/d/msg/usd-interest/gpxbadR8AUY/e9R4Gck5AgAJ [groups.google.com]
and on the other hand it has not been officially added as a USD schema in:
pxr/usdImaging/plugin/usdShaders/shaders/shaderDefs.usda

Although that USD formu thread mentions that there is some movement on it in USD 20.08, but indeed H18.0 is using 19.11

And, even with 20.08, I suspect not all the renderers will support it immediately (by virtue of using 20.08 libraries; the renderers will need to implement the shader handling themselves).
User Avatar
Member
39 posts
Joined: Jan. 2012
Offline
Hey Rafal. Very clear, understood.

As the work I am currently doing in SOLARIS is scene assembly, not final pixels, I am looking at options for preview shaders only.

The Houdini GL delegate, is it limited to what USDShade currently provides? Without creating custom Schemas, is it currently possible to write missing functionality using inline code?

I noticed when I import a VOPNET from /mat, the VEX code for the shader lives under the attribute uniform string info:sourceCode. There is no way for the delegate to interpret this right?
www.aaronauty.com
User Avatar
Staff
1448 posts
Joined: July 2005
Offline
No, you won't be able to get Houdini GL to handle the missing functionality.

The VEX code is used only in Karma, so again it won't help in Houdini GL.

Off hand, you can try building a simple shader for Karma, using VEX/VOPs where you can tweak UVs programaticaly. Karma rendering may be fast enough for preview too. Or maybe do the texture transormation in geometry. Either in SOPs or in LOPs (with a Wrangle LOP operating on the st attribute). I realize both suggestions are very crude, but might work in your situation.
User Avatar
Member
39 posts
Joined: Jan. 2012
Offline
Low quality Karma sounds like the right solution for material visualisation, cheers, I'll look into it.
www.aaronauty.com
  • Quick Links