Hello,
I’m trying to work on reusing the shader posted there:
and I’m able to get something pretty close, however I have this weird issue where a float I’m setting in the material is not read. I see the vertex shader has it equal to 0.0 instead of what I am putting. What am I missing?
my main in jme is like this
Geometry geom = new Geometry(“Box”, b);
mat = new Material(assetManager, “Materials/scrollingTexture.j3md”);
Texture tex = assetManager.loadTexture(“Textures/waterCartoonreal 1.png”);
tex.setWrap(Texture.WrapMode.Repeat);
mat.setTexture(“m_ColorMap”, tex);
mat.setFloat(“m_ScrollSpeed”, 2f);
geom.setMaterial(mat);
the material is set like this
MaterialDef Scroll Texture {
MaterialParameters {
Texture2D m_ColorMap
Float m_ScrollSpeed
Boolean m_YCoCg
Boolean m_LATC
Boolean m_Normalize
Boolean m_ShowAlpha
}
Technique {
WorldParameters {
WorldViewProjectionMatrix
Time
}
VertexShader GLSL100: Materials/scroller100.vert
FragmentShader GLSL100: Materials/SimpleTextured.frag
Defines {
DXT_YCOCG : m_YCoCg
NORMAL_LATC : m_LATC
NORMALIZE : m_Normalize
SHOW_ALPHA : m_ShowAlpha
}
}
Technique FixedFunc {
}
}
The .vert
uniform mat4 g_WorldViewProjectionMatrix;
uniform float m_ScrollSpeed;
uniform float g_Time;
attribute vec3 inPosition;
attribute vec2 inTexCoord;
varying vec2 texCoord;
void main(){
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
float offset = g_Time*m_ScrollSpeed-floor(g_Time*m_ScrollSpeed);
texCoord = vec2(inTexCoord[0] + offset, inTexCoord[1]);
}
The frag is the same as here
https://searchcode.com/codesearch/view/8139155/
if i replace m_ScrollSpeed in the vertex shader by a fixed value, it works well
I’m puzzled because the frag shader is able to read the m_ColorMap well, but the vertex doesnt get the float i’m passing
Any clue?
Thanks
Adrien