How to create a custom emission buffer

I am looking to create a custom bloom effect where the color of the glow emmited by an object would be different from it’s albedo color.

Here is how i would like to achieve this effect:

  • I would add an emission texture/color property to the shaders used to render objects in my scene
  • The shaders would render normally using their main textures, colors, etc.
  • Then, those same shaders would also render the objects into a buffer (similar to a camera opaque texture) using the texture/color from the emission property instead
  • After everything is rendered, the emission buffer would be passed through the bloom shader and added on top of the ‘base’ rendered image using a fullscreen render pass.

My question is: how can i render objects into a buffer, and would it be possible to do so using the same shaders used to render the objects normally, but using different properties (the emission properties).

The reason i want it to use the same shader for the base and the buffer is so that whenever, for example, a shader scrolls a texture by multiplying the uv position by time, i would like the scrolling of the main texture and the emission texture to be controlled by the same shader code. Separating the base and the emission into different shaders would be very annoying to work with. If this is not possible, i would at least like to know how i could apply separate materials to objects, and use those to create the emission buffer.

I managed to mostly achieve the desired effect by using the “Render Objects” renderer feature before rendering opaques with a LightMode tag that corresponded to alternate passes within the shaders and then grabbing the contents of the screen with cameraColorTargetHandle and Blit. The only downside is that the shader code that displays the base colors and the emission is separate, but at least still within the same shader. If anyone has any idea how to make things work with one pass per shader i would love to hear it. I tried doing MRT but i couldn’t figure it out in URP. Also, i had to manually clear the contents of the frame buffer at the start of each frame to remove the contents of the previous frame so that the screen grab doesn’t contain them. Just wanted to mention that in case someone wants to do something similar.