🔒 Locked
Refraction in objects
Advertisement
Original Post
When you implement water refraction, you compute the texture offsets by computing refraction vector and with known height from water surface to ground. But how do you compute (or approximate) the refraction that produces a piece of glass? Light refracts twice, so you dont know the distance that light refracted vector travells within the object. I thought that maybe rendering backfaces from light's pov and storing normals instead of color, you could use it to search the light outgoing normal, but i haven't spared enough time to work it out. I saw the effect in HL2, near the end of the game, when that guy was opening the portal. Thanks for the answers.
Really? I think outgoing refraction can change a lot the look of the material. Its harder to see what is inside a swimming pool than behind a glass bottle.
Well, if anybody knows or has implemented that type of refraction, let me know.
Well, if anybody knows or has implemented that type of refraction, let me know.
Quote:
Original post by YengaMatiC
Light refracts twice, so you dont know the distance that light refracted vector travells within the object.
I remember in physics exercises I compute that distance... maybe you mean to do that in real-time?
However, in a physic exercice (not solved), the book asks to dimostrate that when the light passes through a piece of glass with parallel plane surfaces the outgoing ray is parallel to the incoming one. It says that the distance between the two parallel ray is x=t*theta*(n-1)/n where t is the width of the glass, theta is the incident angle respect to the normal, n is the refraction index. This is true for little value of theta (so in general I imagine is sen(theta) instead of only theta). So the only thing you have to do is to move a little what is seen throught the glass (per pixel, so I think you can do that with a pixel shader, maybe applying directly the formulae above (with some optimization since t and n are constants), calculating theta for each pixel (or for 2x2 or 4x4 pixel or more, depending on the size of the glass surface and on the distance of the viewer).
I hope that helps a little.
[Note: I may be wrong, but that's the way I'd do it! [grin]]
Quote:
Original post by YengaMatiC
Really? I think outgoing refraction can change a lot the look of the material. Its harder to see what is inside a swimming pool than behind a glass bottle.
Well, if anybody knows or has implemented that type of refraction, let me know.
true.
but since when is rasterizing about physical accuracy?
as long as your view though the object looks all warpy, youve got a nice refrection going on as far as immersiveness is concerned.
Wow! Thanks a lot, it looks like the way i thought it out. First rendering back facing geometry and storing the normals and depth, then rendering front facing geometry and getting distance modulated by the normal and a factor (not refraction factor).
Also it could be computed by not using snell's law, but an approximate method like adding the scaled normal to incident vector.
I'll look deeper in the paper and figure out how shadowing can be integrated with this algoritm (i suppose a third pass from lights pov).
Amazing though, thanks for the url :D
Also it could be computed by not using snell's law, but an approximate method like adding the scaled normal to incident vector.
I'll look deeper in the paper and figure out how shadowing can be integrated with this algoritm (i suppose a third pass from lights pov).
Amazing though, thanks for the url :D
You're welcome. I found the paper because I had the same idea, and figured someone must have thought of it before. No doubt there are lots of cool things you could add, I would like to see the effect using the same distance trick to reflect into a real scene instead of just an environment.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement