Texture inverted if I load j3m

When apply this material .j3m to a object, the texture appears with inverted direction (Red object in the image). But if I load the shader and assign a texture, it appear perfectly (Blue object in the image)


[java]Material shiny bumpy rock : Shaders/SolidColor.j3md {
MaterialParameters {
Color: 1.0 0.0 0.0 1.0
ColorMap: Textures/ColoredTex/Monkey.png


[java]MaterialDef Solid Color {
//This is the complete list of user defined uniforms to be used in the
MaterialParameters {
Vector4 Color
Texture2D ColorMap
Technique {
//This is where the vertex and fragment shader files are
VertexShader GLSL150: Shaders/SolidColor.vert
FragmentShader GLSL150: Shaders/SolidColor.frag
//This is where you specify which global uniform you need for your
WorldParameters {




[java]//the global uniform World view projection matrix
//(more on global uniforms below)
uniform mat4 g_WorldViewProjectionMatrix;

//The attribute inPosition is the Object space position of the vertex
attribute vec3 inPosition;
attribute vec2 inTexCoord;

// El tipo varying conecta con otra variable del mismo nombre el el Fragment shader
varying vec2 texCoord1;

void main(){
texCoord1 = inTexCoord;
//Transformation of the object space coordinate to projection space
//- gl_Position is the standard GLSL variable holding projection space
//position. It must be filled in the vertex shader
//- To convert position we multiply the worldViewProjectionMatrix by
//by the position vector.
//The multiplication must be done in this order.
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);


[java]uniform vec4 m_Color;
uniform sampler2D m_ColorMap;

varying vec2 texCoord1;

void main(){
//returning the color of the pixel (here solid blue)
//- gl_FragColor is the standard GLSL variable that holds the pixel
//color. It must be filled in the Fragment Shader.
vec4 color = vec4(1.0);
#ifdef HAS_COLOR
color *= m_Color;

	color *= texture2D(m_ColorMap, texCoord1);

gl_FragColor = color;



[java] protected void initGeometry()
// Creamos una caja con un material cargado ya creado
Box boxshape1 = new Box(new Vector3f(-3f, 1.1f, 0f), 1f,1f,1f);
Geometry cube = new Geometry(“My Textured Box”, boxshape1);

    // Creamos una caja con un material que creamos aqui a partir de un shader
    Box boxshape2 = new Box(1f,1f,1f);
    Geometry cube2 = new Geometry("My Textured Box2", boxshape2);
    cube2.setLocalTranslation(3f, 0f, -1f);
    Material mat = new Material(assetManager,"Shaders/SolidColor.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    mat.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
}[/java] <a href="http://img89.imageshack.us/img89/3584/textureinvertedkxp.png"><img src="http://img89.imageshack.us/img89/3584/textureinvertedkxp.png" alt="" /></a>

Check the “flip texture” checkbox in the j3m editor.

1 Like