Derpius / gmod-dxr

Garry's Mod rendered using DirectX Raytracing
MIT License
30 stars 0 forks source link

[feature] Nested transparent objects #2

Open Derpius opened 3 years ago

Derpius commented 3 years ago

Describe the solution you'd like Use a stack to store the current mediums we’ve entered, then when we enter a medium, use the value at the top of the stack as the current medium, and the hit medium for refraction calcs, then push the hit medium to the stack.
When we exit a medium, pop from the stack (ie the medium we’re exiting), use the hit medium as the current medium (hit will be a backface of the thing we’re inside for exiting), and the new top of the stack as the medium we’re entering.

The only problem with this is that it assumes we start in whatever our default medium is (for most cases this will be air, or more likely vacuum), even if the camera is placed inside another medium in the scene, however allowing the user to set the default medium would mitigate this issue for most use cases, for instance an underwater render.