Skip to content

Align OSL image alpha with texture conventions#2985

Open
jstone-lucasfilm wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
jstone-lucasfilm:dev_image_alpha
Open

Align OSL image alpha with texture conventions#2985
jstone-lucasfilm wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
jstone-lucasfilm:dev_image_alpha

Conversation

@jstone-lucasfilm

Copy link
Copy Markdown
Member

This changelist fixes the alpha output of the OSL image and hextiledimage nodes when sampling a file with fewer than four channels. The OSL texture function returns zero for channels not present in the file, so a color4 or vector4 image reading an RGB file returned a transparent rather than opaque result. The fix queries the channel count with gettextureinfo and sets the output alpha to one when fewer than four channels are present, matching the GLSL and MSL backends.

More broadly, this change aligns the image node with the established convention that a missing fourth channel resolves to one, as already followed by the MaterialX convert node, the OpenUSD UsdUVTexture node, and standard GPU texture sampling. The specification text for the image node, previously ambiguous on this point, has been clarified to note the fourth-channel exception.

This changelist fixes the alpha output of the OSL `image` and `hextiledimage` nodes when sampling a file with fewer than four channels.  The OSL `texture` function returns zero for channels not present in the file, so a `color4` or `vector4` `image` reading an RGB file returned a transparent rather than opaque result.  The fix queries the channel count with `gettextureinfo` and sets the output alpha to one when fewer than four channels are present, matching the GLSL and MSL backends.

More broadly, this change aligns the `image` node with the established convention that a missing fourth channel resolves to one, as already followed by the MaterialX `convert` node, the OpenUSD `UsdUVTexture` node, and standard GPU texture sampling.  The specification text for the `image` node, previously ambiguous on this point, has been clarified to note the fourth-channel exception.
@jstone-lucasfilm

Copy link
Copy Markdown
Member Author

From our automated render test suite, here are before and after comparisons of the color4 blur node, providing some visual intuition for the improved alignment across languages:

Blur Render Comparison (Before):

RenderComparisonOld

Blur Render Comparison (After):

RenderComparisonNew

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.

1 participant