View Full Version : Glass and water shaders?
Where can I find glass and water shaders with refraction, for things like the glass in HL2? There's got to be a huge resource of glsl textures on the web somewhere.
11-26-2006, 12:35 PM
What about this (with source):
Hmmm...it looks like that uses a cubemap. Is it possible to just read the pixels beneath whatever is being rendered, and distort those? Or do I have to do a special render-to-texture of whatever is behind the object?
11-26-2006, 03:28 PM
You can't read "what is behind" inside a shader.
But in HL2 it is most likely they copy to texture the already-rendered behind-water/glass part.
Do I have to render the scene once to an FBO, then use that as a texture on the glass object and distort the pixels, or is there a simpler way?
11-26-2006, 04:04 PM
mmh, and what did I say already ?
Render scene, glCopyTexSubImage2D to a large-enough texture. Guaranteed to work as long as your rendering window is not obscured.
11-27-2006, 03:25 PM
Do I have to render the scene once to an FBO, then use that as a texture on the glass object and distort the pixels, or is there a simpler way?Well, even if you render scene to texture, then you can't render that glass object to this texture and you would probably want this glass object to appear in the rendered scene :)
So you need a COPY of the scene (actually just the fragment that can be seen through glass object). This is why ZbuffeR suggested to copy fragment of framebuffer to texture and not render to texture.
I think I'll just implement a render-to-texture with an FBO. Then I can use the same routine for water reflections, glass, and security cameras.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.