_CameraGBufferTexture3 output in shaderlab

When I sample the _CameraGBufferTexture in the fragment shader inside unity shaderlab using :

return tex2D(_CameraGBufferTexture3,i.uv);

I get the following output:

Original Image: Imgur: The magic of the Internet

Frag output: Imgur: The magic of the Internet

What I expected was the opposite values, that is bright spots on the bright parts of the ring. since this texture according to Unity stores the Emission + lighting + lightmaps + reflection probes buffer. Am I expecting something wrong.

What I want :: I just wanted the light color value to be outputed through my shader, that is the value of the light color that is being reflected from various surfaces seen in the scene. Is this method correct?

Thanks in advance!

When HDR is disabled that gbuffer is stored in a peculiar way:
color = exp2(-color);

You will want to add something like this to your code:

#if UNITY_HDR_ON
return tex2D(_CameraGBufferTexture3, i.uv);
#else
return -log2(tex2D(_CameraGBufferTexture3, i.uv));
#endif

1 Like

I am not using HDR at the moment, so I am returning :

return -log2(tex2D(_CameraGBufferTexture3, i.uv));

I get the same output as I see in the original Image : Imgur: The magic of the Internet

what is the difference between the 2 then ? I mean

return -log2(tex2D(_CameraGBufferTexture3, i.uv));
return tex2D(_MainTex, i.uv);