6

I try to simulate light reflection, refraction, etc. in a fish tank and I need water material and glass material.

Actually I use no water and a phong material for the glass because I haven't found better for now, a testing demo can be see here: http://ledohm.free.fr/test_webgl/

For the water I don't need to simulate the waves, which means I can use the same material as the glass but with differents values for opacity, reflexion and refractive index.

I've found this example which seems to perfectly simulate glass but I don't understand how to adapt the material for my needs. From what I understood the refraction is computed from the envMap but I've no texture. I just want a wall of glass which simulate reflexion/refraction/... like in the reality as much as possible. How I can create (or find) a material like this?


Edit 1:

green: water total internal reflection
red: glass reflection

glass and water reflection


1: refracted by water
2: refracted by water + glass
3 & 4: lost

glass and water reflection and refraction


Edit 2:

Thanks to this tutorial I've unsdertood how shaders works and more specifically this example but, if I understand correctly, I can't use a shader to simulate light in a material with a thickness because shaders apply only on the surfaces of a mesh, I'm right?

Edric
  • 24,639
  • 13
  • 81
  • 91
Biduleohm
  • 734
  • 2
  • 10
  • 19
  • You should include an image of what you're trying to achieve in your question. – mrdoob Mar 28 '14 at 02:19
  • I've added images and explanations of what I want, thanks for your suggestion. – Biduleohm Mar 28 '14 at 14:01
  • 2
    You mean as in http://madebyevan.com/webgl-water/ -- or do you just want to post-process your scene so it looks like you are looking through glass? – WestLangley Mar 28 '14 at 15:24
  • This demo isn't like "post-process your scene so it looks like you are looking through glass" ? the main goal is to simulate the reality for light reflection and refraction. If I put a spot light I need to have the light from it reflected and refracted in the water and glass. – Biduleohm Mar 28 '14 at 15:25
  • Like this http://madebyevan.com/webgl-water/ but I don't need to simulate waves and water displacement, just reflection and refraction in the water and the glass. – Biduleohm Mar 28 '14 at 15:31
  • Unfortunately there is no easy way to do raytracing in realtime in a general way. – mrdoob Mar 28 '14 at 22:09
  • But how he do it on this demo http://madebyevan.com/webgl-water/ ? all the physics and the optical properties of the water are perfectly simulated and moreover it doesn't lag. – Biduleohm Mar 28 '14 at 22:53
  • 1
    You have to basically write a raytracer to do what evan does. Is not an easy thing to do yet. – mrdoob Apr 02 '14 at 21:17
  • @mrdoob Ok, thanks. But if I give up the refraction in the glass, keep juste the reflection and just the refraction at the water/air interface it's possible to do it with a "classic" shader? – Biduleohm Apr 02 '14 at 21:25
  • 1
    You'll have to render the inside into a renderTarget. Then use that renderTarget in a shader that does the reflection and refraction out of the normal of the fish tank. – mrdoob Apr 03 '14 at 00:35
  • @mrdoob I'll read doc and tutorials on renderTarget, tanks a lot. – Biduleohm Apr 03 '14 at 00:47

0 Answers0