grabbing ___.r or ___.a causes horrible banding
fixed4 mainColor = tex2D(_MainTex, uvoft);
fixed4 col = mainColor.r;
return col;
what do i need to read up on / examples with Tex2D() that explains UNorm conversion?
even if i tell the texture Type ‘Default’ and sRGB = true
output is clearly banding and brighter when compared to RGBA input and
fixed4 mainColor = tex2D(_MainTex, uvoft);
return mainColor;
i hoped to save memory with uncompressed single-channel format but the UNorm is linear color space? rather than gamma
(the banding is horrific and i’d rather learn to fix this code than go back to photoshop and curve my texture with a manual gamma)
---- I tested pow(col, 1.5) , yeah returns visuals ~sRGB 32bit [but a waste of arithmetic]
I’m guessing that there is a misunderstanding of how SRGB works somewhere:
- UNORM just means that the values are gonna be between 0 and 1
- UNORM is separate from SRGB. For example, there is DXGI_FORMAT_R8G8B8A8_UNORM and DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
- If you use a _SRGB texture format, you’re declaring that the texture is in SRGB format. In that case, the GPU will do a linearization when you’re sampling the texture. If you don’t use a _SRGB format, there won’t be any conversion when sampling.
- You also have to be aware what the texel format of the render target is. If it’s a SRGB format, the GPU will do a gamma conversion on the value that’s returned from the pixel shader.
- The alpha channel is always linear.
- Floating point texture formats are always linear
- Normal image files are almost always in SRGB format unless the texel values are not colors like in a normal map.
So if you have a SRGB texture and a SRGB render target and you’re not doing any calculations with the value in the shader, it’s just a lossless copy.
1 Like
ok thanks for all this
— I have to conclude Type (Default) sRGB=True is erroneous if you assign single channel format
Types both R8 or A8 single channel have no sRGB boolean anyway; They must be a linear formats and the practical solution would seem to manually gamma factor down my alpha8 textures in image editors
edit
im wrong, it seems without correcting fragment using a pow(input,x) i just can’t get it to work visually how I want
fixed4 mainColor = tex2D(_MainTex, uvoft);
fixed4 col = saturate(2.0f * i.color * _TintColor * pow(mainColor.a,2.0));
return col;
well… it visually works