Removing block that prevented volumetric and background nebulae from rendering simultaneously #6853
Conversation
Goober5000
left a comment
There was a problem hiding this comment.
Incredibly simple change, indeed, but I'd like @BMagnu to review this one. It's entirely possible the exclusion was deliberate.
BMagnu
left a comment
There was a problem hiding this comment.
It's not quite as simple here.
Mainly, because the fog step (both normal and volumetrics) also does image compositing in FSO. To understand that, have a look at the else block, if no type of fog is active:
It copies the image from GL_COLOR_ATTACHMENT5 (which, in FSO, is the result of the lighting pass, also called the composite buffer) to GL_COLOR_ATTACHMENT0, also called the color buffer, which is used to further draw the frame.
The fog works the same way. Both types of fog will read from the composite buffer (and some others) to then draw into the color buffer. If both fogs were active like this, they would both write into the color buffer in a way that overrides each other.
We could have both fogs active, but we need to take some precautions here:
- First render the fullneb fog if its requested.
- If we did have fullneb active, and we need to do volumetrics after, then we need to take the result of the fullneb fog, and copy it back to the composite buffer (this works by calling
glBlitFramebufferas done in the else block here, but with the draw framebuffer set toGL_COLOR_ATTACHMENT5, and the read framebuffer set toGL_COLOR_ATTACHMENT0) - Then we can do the volumetrics fog as it was done before.
- Only if neither of the two fog types were active, perform the manual composite step in the original else block with the
// Transfer the resolved lighting back to the color texturecomment
If we do it like this, we can probably have both fogs working correctly in parallel.
It might also be possible to change both fog shaders to work with additive blending to avoid that copy in step 2, but that's probably more trouble than its worth.
And just as an aside:
nebula_handle_alpha in neb.cpp, L1140 would probably need to be adjusted accordingly, though I'm not fully sure how both alpha's would combine if we render the nebulae as proposed above.
combatlombax
left a comment
There was a problem hiding this comment.
Alrighty! I think this should do what you need it to now. FWIW, I realized also, I messed up the boolean logic for the "else" case, so I cached out both those checks you had in there and if both are false, then we fall back into that case, so hopefully nothing gets messed up.
|
Yup, the nebula render section looks good now. |
Incredibly simple change that removes a logical condition that prevented volumetric nebulae and background nebulae from rendering at the same time. Line 525 of gropengldeferred.cpp.