Skip to content

Simplify OSL shader generator for surfaceshader output#2509

Merged
ld-kerley merged 2 commits intoAcademySoftwareFoundation:mainfrom
ld-kerley:osl-shadergen-use-node-to-convert-surfaceshader
Sep 29, 2025
Merged

Simplify OSL shader generator for surfaceshader output#2509
ld-kerley merged 2 commits intoAcademySoftwareFoundation:mainfrom
ld-kerley:osl-shadergen-use-node-to-convert-surfaceshader

Conversation

@ld-kerley
Copy link
Copy Markdown
Contributor

Currently if the OSL shader generator is passed an element that outputs a single surfaceshader type, then it injects the shader code from the OSL implementation of surfacematerial node. Because the surfaceshader type is a struct and it needs to be resolved down to a closure color for output.

This PR modifies the shader generator to insert an instance of the surfacematerial node, instead of hardcoding the shader source in the shader generator. This decouples the library, and means we just have a single source of truth for the shader code in the surfacematerial node for OSL.

Adds a new API call on the ShaderGraph node to insert a node upstream of an output of the graph.

Copy link
Copy Markdown
Contributor

@niklasharrysson niklasharrysson left a comment

Choose a reason for hiding this comment

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

This looks good to me, thank @ld-kerley

Copy link
Copy Markdown
Member

@jstone-lucasfilm jstone-lucasfilm left a comment

Choose a reason for hiding this comment

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

Other than the minor notes I've added inline, this change looks good to me.

I'd probably recommend that we hold this change in reserve for 1.39.5, since it's a substantial change in logic.

Comment thread source/MaterialXGenOsl/OslShaderGenerator.cpp Outdated
Comment thread source/MaterialXGenShader/ShaderGraph.cpp Outdated
@ld-kerley ld-kerley force-pushed the osl-shadergen-use-node-to-convert-surfaceshader branch from 367ade5 to d6b1106 Compare September 29, 2025 21:48
@ld-kerley ld-kerley merged commit b48cb28 into AcademySoftwareFoundation:main Sep 29, 2025
32 checks passed
@ld-kerley ld-kerley deleted the osl-shadergen-use-node-to-convert-surfaceshader branch November 21, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants