Using glsl shaders for jme3 materials

Let me get this straight, this is not supposed to work in JME3:


MaterialDef ColladaLambert {

    MaterialParameters {
   ... ambientColor, emissiveColor,
   ambientTexture, emissiveTexture and so on...
    }

    Technique {
   VertexShader GLSL100: jme3dae/materials/collada_lambert.vert
   FragmentShader GLSL100: jme3dae/materials/collada_lambert.frag

        WorldParameters {
            WorldViewProjectionMatrix
        }
    }
}



I ask this because the glsls shaders are perfectly working but it looks like they are not receiving geometric from the engine. Do i have to use some special name to access texture coordinates or normals or lights in jme3 shaders?

The material looks fine. What do you mean when you say it don't receive geometric?

To access the attributes you have to prepend the attribute type with "in". For example, VertexBuffer.Type.Position is "attribute vec3 inPosition".

See the other jme3 shaders for examples.

I'm trying to understand if JME3 can use arbitrary valid GLSL shaders or not. For example, is the vertex shaders uses the predefined GLSL variables: gl_Vertex, gl_Normal, gl_MultiTexCoord0, the shader doesn't work. The GLSL Hello world:


void main() {
    gl_Position = ftransform();
}



void main() {
    gl_FragColor = vec4(1, 0, 0, 1);
}



produces a black object in JME3 while declaring the vertex shader like:

attribute vec3 inPosition;

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



produces the desired effect. I'm no a GLSL expert so I have to ask: is this some kind of new GLSL way (maybe ftransform or gl_Vertex are deprecated or using the predefined variables is considered bad style) or is it a limit of JME3? I ask because a collada document can embed GLSL shaders.

Yeah, all those gl_*** parameters are deprecated in OpenGL3, so I had to use custom ones to maintain forward compatibility.