LGhassen / EnvironmentalVisualEnhancements

Visual enhancements including clouds, lights, etc.
76 stars 9 forks source link

Certain clouds don't render correctly in VR #22

Closed JonnyOThan closed 2 years ago

JonnyOThan commented 2 years ago

https://github.com/JonnyOThan/Kerbal-VR/issues/119

Can you point me to the code that draws these? I'm currently poking around DeferredVolumetricCloudsRenderer - am I way off base?

The distant clouds you can see from the launchpad and from space work great, it's just these...fluffy...billboardy ones that don't.

LGhassen commented 2 years ago

Yeah it's those. They are rendered in two steps, off-screen render to low res texture and then upscale and copy to the screen.

JonnyOThan commented 2 years ago

Gotcha, thanks. I tried clearing the render target before drawing to the right eye and it fixed the doubling up problem but not the “clipping region” and the terrain etc was missing. I can probably figure out how to make sure the terrain works, but would you mind explaining how the clouds decide where to not draw? Or rather does that come later when they are composited into the scene? Is it a stencil, depth buffer, etc?

Edit: ah I see some stuff in EnableForThisFrame that probably needs to be done per eye. Will bang on this for a bit.

LGhassen commented 2 years ago

Nicely done. So I guess you already understood how it works but the depth buffer is downscaled by picking the min value of 4 neighbours, and used to check for intersections, then for upscaling it compares the full res depth to the 4 nearest downscaled values and picks the color from the closest one to the current pixel.