Implementing Lens (refracting glass..) in CG

The question is short: how to implement Lens (refracting glass) in CG? (or simple vp/fp progs?) We’ve seen one in Half-Life 2 (Dr.Kleiner’s lab n the very beginning) - very cool…

Render the scene to a RTT, then bind it as a texture, render your lens and sample the texture.
In GLSL, you can use refract() function.

Maybe by using some Fresnel equations with GLSL ?
Try it out

In GLSL, you can use refract() function.
I just searched the OpenGL 2.0 specification, and found no mention of the refract() function. Upon further investigation, it appears that this is a Cg function, which nVidia includes in its “extended GLSL”. If you do use refract() in your GLSL code, it will not be true GLSL anymore, but your question was regarding Cg. Perhaps it would be better answered on another site that isn’t focused on Open standards . . . Cg is a proprietary language. There is a site out there that has a lot of Cg information, it is called ShaderTech .

Maybe by using some Fresnel equations with GLSL ?
Try it out
Now, this sounds like a great idea!

from glsl spec 1.10.59

Geometric Functions
These operate on vectors as vectors, not component-wise.
genType refract(genType I, genType N,float eta)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.