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

Check if inside Object #46

Closed
markusmoenig opened this issue Aug 3, 2021 · 2 comments
Closed

Check if inside Object #46

markusmoenig opened this issue Aug 3, 2021 · 2 comments

Comments

@markusmoenig
Copy link

Hi, I am writing an SDF modeler and for the ray marching to be correct I need to know if the path tracer state is currently inside or outside an object.

Would that be somehow evident from the State struct ?

Thanks

@knightcrawler25
Copy link
Owner

knightcrawler25 commented Aug 3, 2021

You can probably get that information from the surface normal. If state.normal and state.ffnormal are on the same side i.e. dot(state.normal, state.ffnormal) > 0 then the ray has hit the surface from the outside, otherwise the ray has hit the inner surface.

@markusmoenig
Copy link
Author

Thanks, that makes sense. I just need to make sure to inverse the ray marching direction when inside as otherwise I would trace back.

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

No branches or pull requests

2 participants