chunky-dev / chunky

A path tracer to create realistic images of your Minecraft worlds.
https://chunky-dev.github.io/docs
GNU General Public License v3.0
637 stars 76 forks source link

Fix refraction and material transitions. #1673

Open ConsueTerra opened 8 months ago

ConsueTerra commented 8 months ago

This PR fixes #1515, in a way that is less hacky than #1601 by defining octree type and modifying the intersection logic based on which octree we are in. Also recovers total internal reflections. This is because Air has different contexts depending on location. Current changes fix solid block refractions, and partially addresses sub block refractions like glass panes. Currently I cant figure out a good methodology for fixing glass panes that does not break intersection logic. Additionally there are quite a few edge cases to consider like partially water logged glass panes.

Before After
image image
image image
image image

Now this makes for some weird views, dont know if these are correct but the above tests makes it seems so, in any case that is a function of refraction and Fresnel code than intersection code image

Glass panes are still wrong example: image

ConsueTerra commented 8 months ago

I would suggest changing Ray.prevMaterial to Ray.insideMaterial or something like that..? why? because prev material is confusing (ie the past surface or where we are?), and because even though refractions are fixed, it is not applying the right material at the boundary.