Search code examples
game-physicsraytracing

Ray refraction and how to keep track of the environment type?


Ray refraction and how to keep track of the environment type?

Should my Ray object know about the environment it is in? For example is it air, glass, or else? By knowing the environment, i mean knowing the refraction index. That way, when it hits a surface I can get the hit surface refraction index, and I can compute the refracted ray.

Any suggestions how to manage this whole thing, the ray moving through different environments?

Thanks


Solution

  • The question is really about code design finding the simplest answer for your needs. You might find this answer useful,

    How to deal with refraction when the rays start inside of a nested object

    It solves the same problem.