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.

What about this (with source):
http://www.ozone3d.net/demos_projects/chromatic_aberration.php

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?

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?

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.

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 :slight_smile:
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.

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