Reflection.j3md only reflect the Skybox

A image of problem:

Reflection.j3md

[java]MaterialDef Cube Texture {
MaterialParameters {
TextureCubeMap Texture
Boolean SphereMap
}
Technique {
VertexShader GLSL100 : Shaders/Reflection/Reflection.vert
FragmentShader GLSL100 : Shaders/Reflection/Reflection.frag

    WorldParameters {
        WorldViewProjectionMatrix
        WorldMatrix
        NormalMatrix
        CameraPosition
    }

    Defines {
        SPHERE_MAP : SphereMap
    }
}

}[/java]

Reflection.vert

[java]uniform mat4 g_WorldViewProjectionMatrix;
uniform mat4 g_WorldMatrix;
uniform mat3 g_NormalMatrix;
uniform vec3 g_CameraPosition;

attribute vec3 inPosition;
attribute vec3 inNormal;

varying vec3 refVec;
varying vec3 rfrRed, rfrGreen, rfrBlue;
varying float refFactor;

void main(){
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition,1.0);

vec3 worldPos = (g_WorldMatrix * vec4(inPosition,1.0)).xyz;

// WARNING: Not allowed to create matrix from matrix
// mat3 worldMat3 = mat3(g_WorldMatrix);

vec3 I = normalize(worldPos - g_CameraPosition).xyz;
//vec3 N = normalize(worldMat3 * inNormal);
vec3 N = normalize( (g_WorldMatrix * vec4(inNormal, 0.0)).xyz );

float fresnelBias = 0.05;
float fresnelScale = 0.25;
float fresnelPower = 0.30;
vec3 etaRGB = vec3(0.86, 0.88, 0.91);
etaRGB = vec3(0.93, 0.94, 0.95);
//etaRGB = vec3(1.0);

refFactor = fresnelBias + fresnelScale * pow(1.0 + dot(I, N), fresnelPower);

refVec   = reflect(I, N);
rfrRed   = refract(I, N, etaRGB.r);
rfrGreen = refract(I, N, etaRGB.g);
rfrBlue  = refract(I, N, etaRGB.b);
//rfrRed   = E;
//rfrGreen = E;
//rfrBlue  = E;

}[/java]

Reflection.frag

[java]#import “Common/ShaderLib/Optics.glsllib”

varying vec3 refVec;
varying vec3 rfrRed, rfrGreen, rfrBlue;
varying float refFactor;

uniform ENVMAP m_Texture;

void main(){
vec4 refColor = Optics_GetEnvColor(m_Texture, refVec * vec3(-1.0));

vec4 rfrColor = vec4(0.0, 0.0, 0.0, 1.0);
rfrColor.r = Optics_GetEnvColor(m_Texture, rfrRed).r;
rfrColor.g = Optics_GetEnvColor(m_Texture, rfrGreen).g;
rfrColor.b = Optics_GetEnvColor(m_Texture, rfrBlue).b;
gl_FragColor = refColor;
//gl_FragColor = mix(rfrColor, refColor, refFactor);

}[/java]

And what texture are you passing to the shader?

That’s what the shader is designed for.
If you want full scene reflection, look on how the SimpleWaterProcessor is done (you may even be able to use it right away for your purpose).
Also look at TestSimpleWater

The problem is that SimpleWaterProcessor is a plane, so it´s only need a reflection texture. But If I want a cube with reflections then I need 6 reflection textures, but I don´t know how can i apply this textures in every cube face in the GLSL Fragment Shader.

Oh ok sorry, i didn’t realized the post about water on a cube was yours too.

Well, There may be another way, but that’s gonna be complicated, and too expensive if you have several cubes.
the reflection material use a cubemap for reflection. instead of feeding it with the skybox texture, you could have a processor render the environmental cube map of the scene and feed the material with it.
so basically you’d have to setup 6 viewports and render the scene 6 times by cube to have a something correct.

I found this example that render a scene to a Texturecubemap.
The problem is that the example uses only one viewport, but I need to use six, which render the scene to a same TextureCubeMap, to pass it to the GLSL Fragment shader as samplerCube.
How can I do this?