FirstPersonKSP / FreeIva

Work in progress mod for Kerbal Space Program which allows getting out of your seat and moving around the vessel while on IVA.
GNU General Public License v2.0
25 stars 8 forks source link

Windows in distant parts will show the part exterior instead #41

Open JonnyOThan opened 1 year ago

JonnyOThan commented 1 year ago

Currently, looking into a part that has windows will render the outside of that part where the windows are. We should be able to solve this with depth masks.

JonnyOThan commented 1 year ago

Actually...in issue #114 these meshes seemed to be making the space outside the ship visible. Was this pulling from an old framebuffer, or was it just a consequence of being able to see through the backfaces of the part you were inside?

I am skeptical that depth masks are a solution to this problem, because they'd have to be drawn before the parts are rendered but we can't know if that window should actually be visible or not.

JonnyOThan commented 8 months ago

Idea from Sofie:

We could use the mesh cutting tech to do cuts for hatches on the EXTERNAL models. The cut geometry would be put in a separate submesh which could be toggled on or off depending on whether a hatch is connected there.

The hatch cutout shapes could be transformed into external space, but they may not quite touch the external model (since internals are typically slightly smaller). The cutout geometry could be moved along the attachnode direction to try to make this better.

JonnyOThan commented 8 months ago

Depth mask idea:

If we could make sure that adjacent parts are the LAST thing to be drawn, then we could draw a depth mask quad or something over any open hatches in the current part before drawing the part's external model. This works when you're looking into a single part that has a window, but wouldn't work if you had a chain of parts. Could we somehow sort parts based on number of connections and draw depth masks before each one?