Simply reflections?

Is there a way to make a simple reflection ?

There's a technique to follow ?

I want a box that reflect the objects over him.

I try to follow forum threads about water with reflection but i can't understang what i have to do ?

The specular property in them material how work ?


Reflection is a special effect done by inverting the reflected scene, clipping or stencilling to the reflecting objects outline, and blending.  We don't have an easy "set this parameter" method of doing it in jME yet.  Water is a special case.

is there any example?

i don't know how to inverting the reflected scene (maybe with a -1 somewhere?), clipping (?) or stencilling (?) to the reflecting objects outline (with texture rendering ?), and blending

Have a look at WaterRenderPass

maybe such a simple and nice feature should be included in jme

I agree, it gets my vote. :slight_smile:

We could call it Mirror. :slight_smile:

I agree, but why is the reflection brighter?

Gentleman Hal said:

I agree, but why is the reflection brighter?

Because the shader code actually opened a portal into a parallel universe where the 3D game world had TWO suns instead of one!


It might just be that the shader code is not taking account some factors in the current environment before "reflecting" it?  Or poosibly that the object having the shader applied is not receiving the same light state(s) as the rest of the scene?  It's under a different node or something?

…or possibly it's not brighter, but just the perspective on the scene that makes it appear brighter.

First, the shader code must be controlled.

Second the reflection seems to not take care of shadows.

I'm going to indagate in it later.

Considering that at the moment the code for mirror is indentical to WaterRenderPass, excetp for the shader and the movement of water it's possible to :

add a ReflectionRenderPass class wich implements Pass

add a class wich controls the effect in terms of shaders to pass the Spatial (s) and the kind of effect to apply

or simply add a ShaderRenderPass wich implements Pass and when an object is added to it you have to specify the kind of effect (I.E. : new ShaderRenderPass (camera, effectType, renderScale)

based on effect Type Shuld be loaded a shader instead of another (ET_REFLECTION, ET_REFRACTION, EF_WATER, EF_PWATER, and so on).

Hope my english is compresible.

…shimmering mirror.  :-o

I'm modifying WaterRender to make the simple reflectionas suggested.

How to stop the wave effect ?

I think I've stopped the movement, but there's a distrurb effect, does it depend on normal map ?

yes, you should modify the shaders as well. they do lots of stuff unecessary for a simple reflection

I was look at the code and to some articles…I found that you can replace the  :

gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;


gl_Position = ftransform();

Do you have some suggestion to avoid the refraction effect in shader ?

you can remove just about everything except

   vec4 localView = normalize(viewTangetSpace);

   vec4 fresnelTerm = 1.0 - vec4( dot(normalVector, localView ) );
   fresnelTerm = fresnelTerm * 0.65 + 0.3;

   vec4 projCoord = viewCoords / viewCoords.q;
   projCoord = (projCoord + 1.0) * 0.5;
   if ( abovewater == 1 ) {
      projCoord.x = 1.0 - projCoord.x;

   vec4 reflectionColor  = texture2D(reflection, projCoord.xy);
   if ( abovewater == 0 ) {
      reflectionColor *= vec4(0.5,0.6,0.7,1.0);

   vec4 endColor = mix(waterColor,reflectionColor,fresnelTerm);

   gl_FragColor = mix(endColor,reflectionColor,clamp((viewCoords.z-gl_Fog.start)*gl_Fog.scale,0.0,1.0));

Great Mr.Coder that’s for you :slight_smile:

i would not try to cram every possible effect into one class like that, would be ugly. if it's too much trouble just creating new instances of renderpasses you could create a ShaderEffectFactory separate from the renderspasses…

also, effects like that really need to be coded for exactly their purpose to be any efficient…so for a simple reflection i would scrap alot of the waterrenderpass code…

Humm…if shaders are not supported wich texture culd be shown ? A grey panel ?