PDA

View Full Version : Implementing Lens (refracting glass..) in CG



Freelancer
03-12-2005, 01:42 PM
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...

V-man
03-14-2005, 05:31 AM
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.

Silkut
03-20-2005, 01:15 PM
Maybe by using some Fresnel equations with GLSL ?
Try it out

kingjosh
03-21-2005, 10:09 AM
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 (http://www.shadertech.com) .


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

zed
03-21-2005, 11:01 AM
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)