Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix refraction and material transitions. #1673

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ConsueTerra
Copy link
Contributor

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
Copy link
Contributor Author

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.

Comment on lines +563 to +565
if (currentBlock.refractive) {
//ray.setCurrentMaterial(currentBlock.waterlogged ? Water.INSTANCE : Air.INSTANCE);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either remove this or comment it alltogether.

Suggested change
if (currentBlock.refractive) {
//ray.setCurrentMaterial(currentBlock.waterlogged ? Water.INSTANCE : Air.INSTANCE);
}
// if (currentBlock.refractive) {
// ray.setCurrentMaterial(currentBlock.waterlogged ? Water.INSTANCE : Air.INSTANCE);
// }

@@ -539,9 +557,14 @@ public boolean enterBlock(Scene scene, Ray ray, BlockPalette palette) {
ray.distance += distance;
distance = 0;
if (currentBlock.intersect(ray, scene)) {
if (prevBlock != currentBlock)
if (prevBlock != currentBlock) { //|| (currentBlock.refractive)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@@ -484,6 +500,8 @@ public boolean enterBlock(Scene scene, Ray ray, BlockPalette palette) {
int depth = implementation.getDepth();

double distance = 0;
//tread air as a null block depending on octreetype and were we are in the trace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//tread air as a null block depending on octreetype and were we are in the trace
// Treat air as a null block depending on octreetype and were we are in the trace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refraction is incorrect
3 participants