<p>Typically in a deferred engine, you would render unlit objects directly to the color buffer, bypassing the lighting system entirely. You would likely also output zeroes to the G-buffer so that deferred lights don't add anything to those pixels (and possibly also mark them in the stencil buffer, to avoid running the lighting shaders on them, for efficiency).</p>

<p>Don't worry about switching PSOs for this. I'm guessing you're worried about the performance, but it's not a big deal. Game engines typically switch PSOs (or switch shaders, in DX11/GL) hundreds or thousands of times per frame. Switching a couple of times for an extra color rendering pass isn't even a blip on the radar.</p>

<p>However, if you want to really simplify your code (possibly at the expense of performance), you could just bind the color buffer together with your G-buffers and render to it all the time, as if it were an extra G-buffer. Ordinary deferred shaders would output zero to it, while unlit objects would output their color to it.</p>

CC BY-SA 3.0
2016-04-14T05:13:19.750Z
Thanks for your reply.
Idea with writing directly to color buffer sounds great. I will give it a try.
Derag
CC BY-SA 3.0
2016-04-14T03:21:57.747Z
2016-04-14T03:21:57.747Z
Nathan Reed
<p>What is the best way to draw unlit objects with deferred? Like skybox, particles or just glowing objects?
I thought about mask in alpha channel, check it in light pass and just set diffuse color but it won't work with light blending.
My second idea was stencil buffer with pass after light pass that only fill unlit space. But switching pso (dx12) only for color copy doesn't sound like a good idea.
And of course pass only for unlit objects after light pass, but I don't want to create another list only for this (and again, i have to switch pso).</p>

<lighting><deferred-rendering>
Unlit objects in deferred rendering
Derag
# Unlit objects in deferred rendering

(Asked by: username_0 on 2016-04-13)

What is the best way to draw unlit objects with deferred? Like skybox, particles or just glowing objects?
I thought about mask in alpha channel, check it in light pass and just set diffuse color but it won't work with light blending.
My second idea was stencil buffer with pass after light pass that only fill unlit space. But switching pso (dx12) only for color copy doesn't sound like a good idea.
And of course pass only for unlit objects after light pass, but I don't want to create another list only for this (and again, i have to switch pso).

**Tags:** lighting, deferred-rendering


---

## 1 answers

### Answer by username_1 on 2016-04-14. Score: 7 | Accepted answer

Typically in a deferred engine, you would render unlit objects directly to the color buffer, bypassing the lighting system entirely. You would likely also output zeroes to the G-buffer so that deferred lights don't add anything to those pixels (and possibly also mark them in the stencil buffer, to avoid running the lighting shaders on them, for efficiency).

Don't worry about switching PSOs for this. I'm guessing you're worried about the performance, but it's not a big deal. Game engines typically switch PSOs (or switch shaders, in DX11/GL) hundreds or thousands of times per frame. Switching a couple of times for an extra color rendering pass isn't even a blip on the radar.

However, if you want to really simplify your code (possibly at the expense of performance), you could just bind the color buffer together with your G-buffers and render to it all the time, as if it were an extra G-buffer. Ordinary deferred shaders would output zero to it, while unlit objects would output their color to it.

> **Comments:**
> **username_0**: Thanks for your reply. Idea with writing directly to color buffer sounds great. I will give it a try.  

---

