Hello,
I’m using a copy of Internal-DeferredShading.shader to customize some aspects of the deferred shading. My shader needs to access the emission data. Since the original Internal-DeferredShading.shader samples from _CameraGBufferTexture[0-2], I tried sampling from _CameraGBufferTexture3, but that didn’t work. (I got a red color for all pixels in that buffer).
So I tried another approach: using the new CommandBuffers (excellent idea, by the way!) to make a copy of the emission data to another buffer before the deferred shading pass.
But that didn’t work either. Using this technique, I’m able to copy the other 3 G-buffers and access them in the deferred shader, but not the emission buffer. When I try to do this:
commandBuffer.Blit(BuiltinRenderTextureType.GBuffer3, myTexture);
I get this warning in the console:
CommandBuffer: built-in render texture type 14 not found while executing Unnamed command buffer (Blit source)
For reference, here’s the code I’m using, in a component attached to the camera:
void Start()
{
CommandBuffer cb = new CommandBuffer();
int texName = Shader.PropertyToID(“_MyTex”);
cb.GetTemporaryRT(texName, -1, -1, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default, 1);
// This works with GBuffer[0-2], but I get a warning with GBuffer3:
// CommandBuffer: built-in render texture type 14 not found while executing Unnamed command buffer (Blit source)
cb.Blit(BuiltinRenderTextureType.GBuffer3, texName);
Camera.main.AddCommandBuffer(CameraEvent.AfterGBuffer, cb);
}
Is that a Unity 5 bug? Is there another way to access the emission buffer in the deferred shading pass?
I’m on beta 20, and the camera is configured to use HDR, if that makes a difference.
Thanks!