Bug #1922
Sky model z-buffering not enabled
Description
Evidently something has broken down with sky model rendering as the sky in jimi's old "Hell City/Day in Hell" mod is no longer being drawn correctly. See: http://www.doomworld.com/idgames/index.php?file=levels/doom2/Ports/g-i/hellcity.zip
Judging by the order in which the models are declared in the Map Info, this add-on assumes that skies are drawn in reverse definition order, with depth testing enabled. However the sky model renderer doesn't agree.
Associated revisions
History
#1 Updated by skyjake almost 10 years ago
I checked the history of the sky renderer. It appears the current behavior (depth test disabled) goes all the way back to 1.9.7. In Beta6.9, sky models were rendered with depth testing enabled, but the depth buffer was then cleared after the models had been drawn.
Nowadays we can use a separate depth buffer for rendering this kind of "alternate layer" stuff (already being used with HUD models), so I will try the same mechanism for the sky models: depth test enabled, but in a separate Z buffer.
The drawing order has always been the same as the order of the definitions.
#2 Updated by skyjake almost 10 years ago
- Subject changed from Sky model vs z-buffer drawing glitches to Sky model z-buffering not enabled
- Assignee set to skyjake
- Target version changed from 49 to 1.15
#3 Updated by skyjake almost 10 years ago
- Status changed from New to In Progress
#4 Updated by skyjake almost 10 years ago
However, there is a problem. The depth and stencil buffers are stored on a single texture. The stencil buffer is used for determining which parts are sky, so switching the depth/stencil texture to an alternate one will cause this information to be lost, and sky clipping will malfunction.
(If the renderer was using shaders, one could check stencil values from the main FB texture. However, this would still require a bit of trickery because the sky model would need to use a shader that also does a stencil check. Perhaps it would be possible to set up a render target that uses stencil from the main depth/stencil texture but still uses its own depth texture.)
#5 Updated by skyjake almost 10 years ago
An adequate solution at this point is to simply clear the depth buffer after rendering the sky models. I'm still considering applying a more wholesale update of all depth test/mask state changes to be done via GLState.
#6 Updated by skyjake almost 10 years ago
- % Done changed from 0 to 40
#7 Updated by skyjake almost 10 years ago
- Status changed from In Progress to Resolved
- % Done changed from 40 to 100
#8 Updated by skyjake almost 10 years ago
- Status changed from Resolved to Closed
Fixed|Renderer: Z-buffering of sky models
3D models won't look right without Z buffering, however they must not
interfere with world geometry. This commit enables Z buffering for
sky models and clears the depth buffer afterwards.
Excessive clears of the depth buffer could be avoided by using a
separate depth buffer for the sky, however the sky stencil should be
drawn there as well. This could be a topic for a future refactoring.
IssueID #1922