Patch to use prefixed uniform names

In some places uniforms are being set without using the prefixed name

e.g. I have a j3md with a “time” MaterialParameter, so the uniform name in the shader is m_time, but the uniform is updated using the name “time” resulting in warnings like:



INFO: Uniform time is not declared in shader […]



This patch uses the prefixed name when updating the uniforms. I changed Technique.notifySetParam to take a MatParam because it needs the unprefixed name to lookup the define, and the prefixed name to update the shader uniform.



Patch is here:

4 Likes

@Momoko_Fan what do you think about that?



@rectalogic fyi there is a global uniform that can be passed to the shader you just have to declare a uniform float called g_Time in your shader.

Also you have to add “Time” in your global parameters section in your j3md. That saves you to use your own param.

@nehon said:
fyi there is a global uniform that can be passed to the shader you just have to declare a uniform float called g_Time in your shader.


Oh, yes - I chose a bad example. My "time" is not the same as the global Time uniform. So pretend my example was "foo" and "m_foo" :)
1 Like

@rectalogic: Can you provide the J3MD file where the issue you mentioned happens?

@rectalogic said:
Oh, yes - I chose a bad example. My "time" is not the same as the global Time uniform. So pretend my example was "foo" and "m_foo" :)

you know there is a global g_Foo you can use too....

nah kidding...i got your point we're gonna look into your patch thanks ;)
1 Like
@Momoko_Fan said:
Can you provide the J3MD file where the issue you mentioned happens?


Actually it happens with the builtin j3mds too, like Unshaded.j3md. Here is a patch to the TestBox samplecode that reproduces the issue. When you run jme3test.model.shape.TestBox you will get a warning:

Jun 8, 2012 6:22:20 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
INFO: Uniform Color is not declared in shader [ShaderSource[name=Common/MatDefs/Misc/Unshaded.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Misc/Unshaded.frag, defines, type=Fragment]].

Patch to reproduce the issue is here http://pastebin.com/HUVJGJLE
1 Like

You mean name errors like this?

Code:
INFO: Loaded material definition: FXAA Jun 09, 2012 2:43:18 AM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation INFO: Uniform g_WorldViewProjectionMatrix is not declared in shader [ShaderSource[name=Common/MatDefs/Post/Post.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Post/DepthOfField.frag, defines, type=Fragment]]. Jun 09, 2012 2:43:18 AM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation INFO: Uniform g_WorldViewProjectionMatrix is not declared in shader [ShaderSource[name=Common/MatDefs/Post/FXAA.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Post/FXAA.frag, defines, type=Fragment]]. Jun 09, 2012 2:43:18 AM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation INFO: Uniform m_VxOffset is not declared in shader [ShaderSource[name=Common/MatDefs/Post/FXAA.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Post/FXAA.frag, defines, type=Fragment]]. Jun 09, 2012 2:43:18 AM com.jme3.material.MaterialDef <init>
@EmpirePhoenix said:
You mean name errors like this?


No, that's different - those are all properly prefixed uniforms. The errors I'm referring to are for MaterialParameters declared in the J3MD. The problem is the MaterialParameter name (which does not have the "m_" prefix) is being used as the uniform name instead of the prefixed uniform name in some code paths.

In some code paths the uniform is updated with it's prefixed name and in others without. If you look in the debugger at Shader.getUniformMap you can see it ends up with both names in it's map because of this (e.g. both "Color" and "m_Color") - but only "m_Color" is a valid uniform name that can be used with the shader. So when LwglRenderer.updateShaderUniforms traverses the uniform map it sets both "Color" and "m_Color" and "Color" generates a warning.
1 Like

Aahh…

@Empire Phoenix, I get them all the time. Should I be worrying? :confused:

I dont know, I get tons of them. I currenlty get the logger named “” and set the level to Sever to supress console flooding.