0
$\begingroup$

I generate a normal GBuffer in my engine, and I store it using a R16G16B16A16_SNORM format like this:

input.normal = normalize(input.normal);
input.tangent = normalize(input.tangent);
float3 binormal = normalize(cross(input.tangent, input.normal));

float3 normal = (normalMap.Sample(SampleType, input.tex).rgb * 2.0) - 1.0f;
float3x3 texSpace = float3x3(input.tangent, binormal, input.normal);
float3 finalNormal = normalize(mul(normal, texSpace));

output.normals = float4(finalNormal.rgb, 1.0f);

But when debugging the frame in RenderDoc, I notice that the 3rd component of the frame (Z, or blue channel) is always 0.0

enter image description here

As you can see, both the blue and alpha components come back as zero, even though the alpha is explicitly set to 1.0 in the shader. The frame visually contains information in the blue channel, so why is it coming up as 0.0?

$\endgroup$
2
  • 2
    $\begingroup$ If you compute $sqrt(0.86633^2+0.49866^2)$ the result is 0.99959 which is what you would expect for a normalized direction vector. So something seems to be up with which texel is being picked by the debugger. Also, if you tell directx that the format is snorm then doesn't it take care of the *2-1 bit on behalf of the shader so the hlsl code can skip it. $\endgroup$
    – pmw1234
    Oct 25, 2021 at 19:39
  • $\begingroup$ @pmw1234 Thanks I wasn't aware of the * 2.0 - 1.0 part, first time using a SNORM texture format. I submitted an issue on the renderdoc github maybe they can figure it out. $\endgroup$
    – H3XXX
    Oct 26, 2021 at 16:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.