Skip to content

Align OSL image alpha with texture conventions#2985

Merged
jstone-lucasfilm merged 1 commit into
AcademySoftwareFoundation:mainfrom
jstone-lucasfilm:dev_image_alpha
Jun 22, 2026
Merged

Align OSL image alpha with texture conventions#2985
jstone-lucasfilm merged 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

@meshula meshula left a comment

Copy link
Copy Markdown

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, populating an un-supplied alpha with one will make users happy and matches the convention we use in Hydra!

@jstone-lucasfilm jstone-lucasfilm merged commit b92c1d5 into AcademySoftwareFoundation:main Jun 22, 2026
36 checks passed
@jstone-lucasfilm jstone-lucasfilm deleted the dev_image_alpha branch June 22, 2026 22:34
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.

2 participants