Align channel promotion of image nodes with specification - #3073
Open
jstone-lucasfilm wants to merge 1 commit into
Open
jstone-lucasfilm wants to merge 1 commit into
jstone-lucasfilm wants to merge 1 commit into
Conversation
This changelist fixes the channel promotion of `image` nodes in hardware shading languages when sampling a file with fewer channels than the node type, following up on the OSL alpha alignment in AcademySoftwareFoundation#2985. The specification states that channels beyond those in the image file should be populated with zero, aside from the fourth channel which should be populated with one, so a `color3` `image` reading a grayscale file should return its value in the red channel alone. Previously, the GLSL and MSL backends replicated the red channel of a single-channel image across RGB, so the same `image` node returned a gray result rather than a red one. The following specific changes are included: - Remove the channel swizzles from `GLTextureHandler` and `MetalTextureHandler`. The default sampling of one and two-channel textures in OpenGL and Metal, the default sampling of three-channel textures in OpenGL, and the existing RGBA expansion of three-channel images in Metal all follow the promotion rule of the specification, matching the behavior of the OSL `texture` function. This also removes an inconsistency in Metal, where the swizzle was applied only when mipmaps were generated. - Update the `brass_wire_mesh` test material to read its single-channel albedo texture as a `float` and convert it to `color3`, preserving its appearance under the specified promotion rule. - Add an `image_channels` example to the texture test suite, reading a single-channel image through each output type, so that the promoted channels can be compared across shader generators in the render tests. Note that content reading a single-channel file through a `color3` `image` node will now render with its value in the red channel alone in GLSL and MSL, as it already did in OSL. Content that intends a gray result should read the file as a `float` `image` and promote it with a `convert` node, as shown in the updated `brass_wire_mesh` material.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changelist fixes the channel promotion of
imagenodes in hardware shading languages when sampling a file with fewer channels than the node type, following up on the OSL alpha alignment in #2985. The specification states that channels beyond those in the image file should be populated with zero, aside from the fourth channel which should be populated with one, so acolor3imagereading a grayscale file should return its value in the red channel alone. Previously, the GLSL and MSL backends replicated the red channel of a single-channel image across RGB, so the sameimagenode returned a gray result rather than a red one.The following specific changes are included:
GLTextureHandlerandMetalTextureHandler. The default sampling of one and two-channel textures in OpenGL and Metal, the default sampling of three-channel textures in OpenGL, and the existing RGBA expansion of three-channel images in Metal all follow the promotion rule of the specification, matching the behavior of the OSLtexturefunction. This also removes an inconsistency in Metal, where the swizzle was applied only when mipmaps were generated.brass_wire_meshtest material to read its single-channel albedo texture as afloatand convert it tocolor3, preserving its appearance under the specified promotion rule.image_channelsexample to the texture test suite, reading a single-channel image through each output type, so that the promoted channels can be compared across shader generators in the render tests.Note that content reading a single-channel file through a
color3imagenode will now render with its value in the red channel alone in GLSL and MSL, as it already did in OSL. Content that intends a gray result should read the file as afloatimageand promote it with aconvertnode, as shown in the updatedbrass_wire_meshmaterial.