AcademySoftwareFoundation / AcademySoftwareFoundation/MaterialX
UsdPrimVar fails to generate code in GLSL
- Dominant language
- C++
- Stars
- 2.3k
- Forks
- 451
- Avg merge
- 6d 6h
- Merged PRs (30d)
- 5
Description
Unknown if this is a regression as there is not current test for this, but if you create a UsePrimVar and connect it to
a shader downstream then it seems to never pick up the interfacename value `varname` for the `geomprop` which
is used as the implementation. Instead it throws an exception when trying to get the ShaderNode value -- even though it's
connected.
Example graph (simpler code is with an unlit so that's hooked up). std surf (commented out) gives the same results.
```xml
```
Seems to work okay for OSL. You get this header:
```
shader surfacematerial
[[
string mtlx_category = "surfacematerial",
string mtlx_name = "surfacematerial"
]]
(
displacementshader displacementshader1 = vector(0.0),
string UsdPrimvarReader_vector3_varname = "geompropvalue_vector3",
vector UsdPrimvarReader_vector3_fallback = vector(0, 0, 0),
float surface_unlit_emission = 1
[[
string widget = "number"
]],
float surface_unlit_transmission = 0
[[
string widget = "number"
]],
color surface_unlit_transmission_color = color(1, 1, 1),
float surface_unlit_opacity = 1
[[
string widget = "number"
]],
output MATERIAL out = 0
)
```
Also for MDL
```
export material surfacematerial
(
float3 displacementshader = float3(0.0),
uniform string UsdPrimvarReader_vector3_varname = "geompropvalue_vector3",
float3 UsdPrimvarReader_vector3_fallback = float3(0, 0, 0),
float surface_unlit_emission = 1,
float surface_unlit_transmission = 0,
color surface_unlit_transmission_color = color(1, 1, 1),
float surface_unlit_opacity = 1
)
```
For GLSL you get this error:
```
"No 'geomprop' parameter found on geompropvalue node 'primvar'. Don't know what property to bind"
```
Contributor guide
Research direction
Reproduce the failure with the provided MaterialX XML graph, using the UsdPrimvarReader and its varname/geomprop connection as the entry point to GLSL generation. Compare the GLSL path with the working OSL and MDL output shown in the issue. Done means the graph generates GLSL without the missing geomprop parameter exception, with the connected primvar binding handled correctly; add a regression test because the issue notes that none currently exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100