Hi,
Here is a method that usually every game engine uses to render planar reflections.
Well Blender has already texture.ImageMirror(), but it works fine unless you need a bigger reflecting surface like a lake or ocean.
My method uses fragment (viewport) coordinates instead of geometry UV map to project reflected image to. It means that the reflecting surface size can be unlimited.
Here are some screenshots of an ocean shader utilizing this method:
reflection and refraction texture size is 512 px:
It is a work in progress, shader code is a big mess so I would not recommend using it for projects.
controls:
WASD + mouse, LMB - sungrab
P - exit game (my âEscâ key is dead)
changes since 1.0:
⢠much easier to include in your project
⢠fixed geometry clipping issue experienced on nvidia cards
features:
⢠reflection & refraction
⢠normal map displacement (no real geometry displacement yet)
⢠water sunlight scattering
⢠chromatic aberration of refraction
⢠accurate fresnel term
⢠multi-frequency waves
⢠wave choppyness simulation
⢠bunch of tweakables to control all of this stuff
It also has a hacky camera setup, because the reflection and refraction textures are rendered 1 frame after the scene rendering, so it has a noticeable delay, so i delayed also the first person camera to match the reflections.
I have to polish the ocean shader and I will post it here also.
Huh, very strange⌠I get a bunch of errors in the console upon loading the file saying âNode type so-and-so(such as material, camera data, etc.) doesnât exist anymore, removedâ. Then I get a gray(1st version) or black(second version) plane where the water should be. Definitely not a gpu problem. Do I need to have 2.6 for this? Because Iâm running 2.5. Your ocean shader look.
But anyway, your ocean shader looks absolutely amazing(in the screens), as good as almost any commercial game!
EDIT: Iâve found what the problem is: Blender is butchering your nodes setup, for whatever odd reason. I guess Iâll try it with 2.6
Itâs not a problem; He hasnât released a version WITH the oceanshader yet. What youâre seeing is the reflection and refraction!
That alone is awesome!
He will release the shader when itâs finished, then youâll see how good it is
For me, an ATI-User, it looks like on Toxaâs Screenshot and if it is officially stated to look like this, okay, but it just doesnât initially show the Refraction. Reflection yes, but there is no obvious Refraction. I tried using a cloudy Normalmap of Mine for the so called ÂťrefractionÂŤ Texture and it still did not show any Changes, so I guess it must be handled in a different Way, but until I get to know or coincidentially find it out myself, I see no Refraction.
The issue with the nodes was definitely just specific to a certain build I was using(accidentally- I thought I was using standard Blender). After switching to the regular Blender 2.5, that issue has resolved itself.
Unfortunately, it still doesnât work. I get an opaque black plane where the water should be. The issue lies in the âwatershaderâ glsl shader script that youâre running.
After disabling that script by deleting the logic controller that activates it, I do get the reflections, but theyâre tiled many times over the water plane in object or UV space(I attached an image). So RenderToTexture is working, however, your shader is notâŚ
My gpu is an Nvidia Geforce 6800, which I believe(correct me if Iâm wrong) should theoretically be able to handle any OpenGL effects that Blender can currently throw at it. Iâm able to run all kinds of glsl effects with it, so Iâm a bit puzzled as to why this one doesnât work.
EDIT: By playing around with the nodes setup you had already made, I managed to get properly aligned reflections and refractions on the second .blend you posted. However, the clipping of geometry below the water line(for reflections) doesnât work, for some reason(proabably due to the limitations of my gpu, nothing you could fix).