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

USDShader fixes/improvements #6076

Open
wants to merge 2 commits into
base: 1.4_maintenance
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
1.4.x.x (relative to 1.4.14.0)
=======

Improvements
------------

- USDLight : Append the (Renderman) suffix to any USD Lux plugs with `ri:light:` prefix.

Fixes
-----

- ShaderView : Fixed crash caused by a SceneCreator returning `None`.
- USDShader : Fixed default preset values on IntPlugs that are intended to be enum indexes instead of string values.

1.4.14.0 (relative to 1.4.13.0)
========
Expand Down
25 changes: 21 additions & 4 deletions python/GafferUSDUI/USDShaderUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,23 @@ def __layoutSection( plug ) :

def __label( plug ) :

# When the Prman USD plugin is included with OpenUSD, the API
# schema for Lux lights gets applied but to match how other
# renderers label their custom plugs, we need to add the
# (Renderman) suffix to the label here.

suffix = ""
if plug.getName().startswith( "ri:light:" ) :
suffix = " (Renderman)"

property = __primProperty( plug )
if property :
return property.GetMetadata( "displayName" )
return property.GetMetadata( "displayName" ) + suffix

return __sdrProperty( plug ).GetLabel() or None
label = __sdrProperty( plug ).GetLabel() or None
if label :
label += suffix
return label

def __description( plug ) :

Expand Down Expand Up @@ -190,12 +202,17 @@ def __presetValues( plug ) :
property = __primProperty( plug )
if property :
allowedTokens = property.GetMetadata( "allowedTokens" )
return IECore.StringVectorData( allowedTokens ) if allowedTokens else None
if allowedTokens and isinstance( plug, Gaffer.IntPlug ) :
return IECore.IntVectorData( [ i for i in range( len( allowedTokens ) ) ] )
else :
return IECore.StringVectorData( allowedTokens ) if allowedTokens else None
Comment on lines +205 to +208
Copy link
Member

Choose a reason for hiding this comment

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

Could you give me an example of a shader where this is necessary? I want to refresh my memory and check that this isn't a symptom of a problem elsewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That one I didn't hit in my testing of MaterialX nodes but the check after it is the one which works for me, so this one might be redundant - the IntPlug check should keep it harmless to leave in though...

Copy link
Member

Choose a reason for hiding this comment

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

Yep, but what shader can I use to see the problem? I want to check that the problem isn't in the way we're loading the shader rather than in the UI...

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 think I was checking with gltf_surface with the alpha mode plug but there were other shaders I was coming across that needed it, I'll get back to you on a few more tomorrow. I did see from the mtlx schema that they register as integer and not token so I think the loading part was correct (I think token/string is a better approach if that enum list changes though).


property = __sdrProperty( plug )
options = property.GetOptions()
if options :
if len( options ) > 1 and all( o[1] == "" for o in options ) :
if isinstance( plug, Gaffer.IntPlug ) :
return IECore.IntVectorData( [ i for i in range( len( options ) ) ] )
elif len( options ) > 1 and all( o[1] == "" for o in options ) :
# USD's `_CreateSdrShaderProperty` method in `shaderDefUtils.cpp`
# always uses an empty string for the option value when converting
# from `allowedTokens`. Ignore that, and use the names as the values
Expand Down
Loading