[SOLVED] Passing custom parameters to shader

Hi guys,
this may be a pretty dumb question but I read the tutorial (http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:jme3_shaders) over and over again and I don’t get what I am doing wrong. When I try to use my custom material I get the folliwing exception:

0(11) : error C1008: undefined variable "StartColor"
0(11) : error C1008: undefined variable "EndColor"
0(11) : error C1008: undefined variable "StartColor"
0(11) : error C1008: undefined variable "EndColor"

Here is my material:

MaterialDef MatFieldview {
    MaterialParameters {
        Vector2 StartColor
        Vector2 EndColor
        Vector4 Color
    }
    Technique {
        VertexShader GLSL120 : MatDefs/Shaders/matFieldview.vert
        FragmentShader GLSL120 : MatDefs/Shaders/matFieldview.frag

        WorldParameters {
            WorldViewProjectionMatrix
        }

    RenderState{
            Blend Alpha
        }
    }
}

and here my fragment shader:

uniform vec2 m_StartColor;
uniform vec2 m_EndColor;
uniform vec4 m_Color;

varying vec3 vertPos;

void main(){

    if(vertPos.x > StartColor.x && vertPos.x < EndColor.x && vertPos.y > StartColor.y && vertPos.y < EndColor.y)
        gl_FragColor = m_Color;
    else if((mod(vertPos.x, 1) > 0.49 && mod(vertPos.x, 1) < 0.51) || (mod(vertPos.z, 1) > 0.49 && mod(vertPos.z, 1) < 0.51))
        gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
    else
        gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}

As you see I added the parameters in my material and with “m_” in front I added them to the shader. The rest of the shader (displaying a grid) works, I just don’t know what I missed adding the parameters.

Here is the vertex shader too, if that is important even thought I don’t need the parameters there:

uniform mat4 g_WorldViewProjectionMatrix;
uniform mat4 g_WorldMatrix;

attribute vec3 inPosition;
attribute vec3 inTexCoord;

varying vec3 vertPos;

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

Thank you and sorry for that stupid question…

this. you just forgot to put the m_… m_StartColor.x && … m_EndColor…

Okay, I knew it was dumb :smiley: Thank you :slight_smile: