Extended Clouds incompatibility.

Hey im the developer behind Extended Clouds and my mod extends the clouds further than the render distance. Looking at it, it looks like the depth buffer gets reset when used by Distand Horizons which makes my clouds render above all of the lod terrain because the renderer believes there is nothing there.
No description
32 Replies
BackSun
BackSun2y ago
Hey, nice to meet you, You are correct, after DH renders we clear the depth buffer. This is because we have to use a different projection matrix than MC (changing the near and far clip planes to prevent Z-fighting at long distances) so keeping the same depth buffer would cause wacky rendering bugs. A more in-depth explanation can be found here: https://discord.com/channels/881614130614767666/881614131877269586/950537059213406259 Once DH 2.0 is released we'll be adding an API that includes event handlers that could be used in this situation. Specifically we will have an event that fires before DH starts rendering and passes in the projection matrix we use. If you wanted to work with DH, you could hook into our event, and render the clouds before DH. That way the depth would work correctly for the clouds and DH LODs. Granted this would prevent clouds from intersecting with vanilla terrain unless the clouds are rendered in two passes (one for DH and one for vanilla). If you have any other ideas on how we could fix this, or need more information from me, just ask.
notalpha
notalphaOP2y ago
Hm, i wonder if this is a dumb idea, but would it not be possible to map the depth buffer to the minecraft projection so instead of clearing it, you would just convert it to the minecraft values and possibly just lose some information Im confused however why that causes Z-fighting
BackSun
BackSun2y ago
Hmmm, Maybe? The hard part would be determining what the depth values would need to be mapped to.
notalpha
notalphaOP2y ago
If my math and theory is not fully dumb, it should just be this
MCNear + (((value - DHnear) / (DHfar - DHnear)) * (MCfar - MCnear))
MCNear + (((value - DHnear) / (DHfar - DHnear)) * (MCfar - MCnear))
no wait i think i am dumb yes give me a moment
BackSun
BackSun2y ago
If we kept MC's projection matrix we could only render a little bit farther than the vanilla render distance due to their far clip plane. So we need to extend the far clip plane. If we just extended MC's far clip plane we would have to deal with the depth buffer losing precision as we rendered farther from the camera; which manifests as flickering or Z-fighting. So we also have to extend the near clip plane. Mapping our depth values instead of clearing them is an interesting solution that is worth looking into. I'll have to see how best to do something like that (time to break out the GLSL :cou:).
notalpha
notalphaOP2y ago
((DHnear + (value * (DHfar - DHnear))) / (MCfar - MCnear)) - MCNear
((DHnear + (value * (DHfar - DHnear))) / (MCfar - MCnear)) - MCNear
^ now this is some very "i wrote some code off my head" type of code
BackSun
BackSun2y ago
Awesome, thanks 👍 If nothing else it is a good place to start @leetom what do you think of this idea? I think it has some merit, and is worth looking into at the very least.
notalpha
notalphaOP2y ago
v3
(((DHnear + (value * (DHfar - DHnear))) - MCNear) / (MCfar - MCnear))
(((DHnear + (value * (DHfar - DHnear))) - MCNear) / (MCfar - MCnear))
god this is some very mind intensive math
BackSun
BackSun2y ago
Gotta love 3D rendering 🙃
notalpha
notalphaOP2y ago
ikr just watch this not work on intel gpus for no apperent reason 🔥
BackSun
BackSun2y ago
😆
Hopefully it would be fine. I'd expect the depth buffer in OpenGL to be pretty similar between venders.
notalpha
notalphaOP2y ago
Also while im here, would it not be possible to implement SSAO so that the DH chunks get some form of AO
BackSun
BackSun2y ago
Possible: yes. Require more time than I have available: also yes.
notalpha
notalphaOP2y ago
hm, i would be up for trying to implement it
BackSun
BackSun2y ago
If you could that would be awesome! I'd be happy to merge in any changes you have. If you need any help or direction just let me know.
notalpha
notalphaOP2y ago
Is the rendering part of the mod in core -> com.seibel.lod.core.render? Or are there other places too that i should know? (also we should prob move into some dev channel)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
notalpha
notalphaOP2y ago
Why though? From my understanding the z value gets mapped by the projection matrix, the distance gets mapped like ((dist - near) * (far - near)) so its a value between 0 and 1, then we can just expand it back into the distance and apply the minecraft dist and near
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
BackSun
BackSun2y ago
something like this, if I remember correctly https://developer.nvidia.com/content/depth-precision-visualized
NVIDIA Developer
Depth Precision Visualized
Depth precision is a pain in the ass that every graphics programmer has to struggle with sooner or later.
No description
notalpha
notalphaOP2y ago
op oh "no"
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
BackSun
BackSun2y ago
I think they would be related if nothing else
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
BackSun
BackSun2y ago
Although it has been a while since I dug into OpenGL's depth buffer so my memory may be foggy :cou:
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
BackSun
BackSun2y ago
Hmm, something to look into after 2.0 has been released. I'll have to create a git issue so this isn't forgotten.
eden
eden2y ago
OMG OMG CAN I GET YOUR SIGNATURE big fan!!11!11
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
BackSun
BackSun2y ago
Unlikely to be changed any time soon, unless someone else decides to work on it.

Did you find this page helpful?