- Home /
Overwrite "_LightBuffer" Rendertexture
Hi there,
is it possible to overwrite the _LightBuffer Texture using Command Buffers? I want to exchange it with a different Render Texture.
Thanks in advance!
-lightbuffer.png
(33.6 kB)
Comment
Best Answer
Answer by Namey5 · Jun 09, 2020 at 03:05 AM
The deferred lighting buffer contains both emission & lighting info and can be found in one of two places just before the camera lighting pass (deferred combination). If you are using HDR rendering it will be drawn directly into the camera's rendertarget, otherwise you can find it in GBuffer3.
Camera cam;
CommandBuffer buffer;
public Texture2D replacementTex;
void OnEnable ()
{
cam = GetComponent<Camera>();
//Create a new command buffer and just overwrite the lighting buffer with our replacement tex
buffer = new CommandBuffer () { name = "Lighting Replacement" };
buffer.Blit (replacementTex, BuiltinRenderTextureType.CameraTarget);
//Use this if you are working in LDR
//buffer.Blit (replacementTex, BuiltinRenderTextureType.GBuffer3);
//Add the command buffer just before the final deferred pass
cam.AddCommandBuffer (CameraEvent.BeforeLighting, buffer);
}
void OnDisable ()
{
//Cleanup the command buffer
if (buffer != null)
{
if (cam)
cam.RemoveCommandBuffer (CameraEvent.BeforeLighting, buffer);
buffer = null;
}
}
Your answer
Follow this Question
Related Questions
Feeding a GBuffer to a camera 0 Answers
Applying full screen image effects to UI only 2 Answers
HDRP clamps output values at 65504 0 Answers