[gaffer-usd] Read SetVisualizer Data In Maya

45 views
Skip to first unread message

Sudarshan Havale

unread,
Jan 16, 2025, 5:40:35 AMJan 16
to gaffer-dev

Hi,

Is it possible to write and read SetVisualizer information in other applications? I tried adding SetVisualizer data to the LookDev USD layer but am unsure how to make Maya recognize the gl_surface_shaders.

Here’s the data written from Gaffer into my Look USD:

def Scope "gl_surface_shaders"
{
    def Shader "surface"
    {
        uniform token info:id = "gl:SetVisualiserSurface"
        color3f[] inputs:colors = [(0.07019112, 0.38683665, 0.30409783), (0, -5.3495846e32, 4.2e-43), (2.4e-44, 0, 2.5e-44), (0, 0, 0), (0.12881425, 2.0712247e29, -4.0125048e37), (2.7432184e-19, 1e-45, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)]
        string inputs:gl:fragmentSource = """#if __VERSION__ <= 120
#define in varying
#endif
uniform vec3 colors[9];uniform int numColors;uniform float stripeWidth;in vec3 fragmentN;in vec3 fragmentI;void main(){\tfloat f = abs( dot( normalize( fragmentI ), normalize( fragmentN ) ) );\tgl_FragColor = vec4( f, f, f, 1.0 );\tif( numColors > 0 )\t{\t\tfloat stripeIndex = floor( (gl_FragCoord.x - gl_FragCoord.y) / stripeWidth );\t\tstripeIndex = mod( stripeIndex, float(numColors) );\t\tgl_FragColor = ( gl_FragColor * 0.8 + 0.2 ) * vec4( colors[ int(stripeIndex) ], 1.0 );\t}}"""
        int inputs:numColors = 1
        float inputs:stripeWidth = 10
        token outputs:DEFAULT_OUTPUT
    }
}

How can I make Maya recognize this gl_surface_shaders data?

- Sudarshan

Sudarshan Havale

unread,
Jan 16, 2025, 5:43:14 AMJan 16
to gaffer-dev

Alternatively, Maybe we could embed the SetVisualizer information into the render:displayColor parameter, making it accessible to any application for reading the color data.

John Haddon

unread,
Jan 16, 2025, 9:22:08 AMJan 16
to gaffer-dev
Do you need the fancier aspects of the SerVisualiser, like the stripes for when an object is in multiple sets? If not, perhaps you can just use a SetFilter to assign a USDPreviewSurface?

Sudarshan Havale

unread,
Jan 16, 2025, 10:12:46 AMJan 16
to gaffer-dev
Hi Jhon,

No, I don’t need the advanced feature of displaying multiple color stripes for common elements across multiple sets. However, I was considering whether it might be possible to pass just the basic SetVisualizer color information into the render:displayColor parameter. That said, as you mentioned, a similar result can be achieved using an expression combined with USDPreviewSurface.

Thanks for the quick response :)
Reply all
Reply to author
Forward
0 new messages