Texture inverted if I load j3m

Hi!
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)

testMaterial.j3m

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

SolidColor.j3md

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

	Defines
	{
		HAS_COLOR:Color
		HAS_COLORMAP:ColorMap
	}
}

}[/java]

SolidColor.vert

[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
//coordinates.
//- 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]

SolidColor.frag

[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;
#endif

#ifdef HAS_COLORMAP
	color *= texture2D(m_ColorMap, texCoord1);
#endif

gl_FragColor = color;

}[/java]

Code.

[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);
cube.setMaterial(assetManager.loadMaterial(“Materials/testMaterial.j3m”));
rootNode.attachChild(cube);

    // 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"));
    
    cube2.setMaterial(mat);
    rootNode.attachChild(cube2);
}[/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

Thanks!!!