Post

Replies

Boosts

Views

Activity

Seeking clarification on SwiftUI Shader color spaces
Suppose I'm writing a Metal shader function for a color effect. The documentation states that the input color is in the destination color space and elsewhere states that this space is "typically extended sRGB." Ordinarily, we want to perform color math in linear space. My question is: does the typical destination color space include the sRGB transfer function ("gamma"), meaning we need to perform explicit sRGB-to-linear conversion (and vice-versa) if we want to work in a linear color space in our shader functions? Second, is there a way to know in the context of SwiftUI code what the actual destination color space is, so shaders can be parameterized on this information? Finally, when sampling from a SwiftUI::Layer in a shader function, should we assume the sampled color is in a linear space, or is it also in the destination color space (assuming the two are different)?
0
0
289
Sep ’23