Problem with GLSL shaders on objects that share mesh

Hi, I have a little problem with shaders I discovered when was playing with an edited version of a martinsh’s shader. I simplify It:


Those three cubes share the same material, so they shared the same shader. The shader just change the color to red.
As you can see, two cubes are not colored, and their shading change: there’s a hemi lamp (the vierport is set to GLSL), This is as it look without the shader:


Another weird thing is That if you move the camera (viewport) sometimes the colored cube is other.

The problem is not related to shared materials, because when you duplicate the mesh (but not the material), everything looks right.

Also if you leave the three cubes like that, and copy just one duplicating the mesh, and leaving the other three cubes sharing the mesh. Everything looks right. Apparently, you have to leave two object to share the material, even if that object is in a hidden layer.

So, I can fix it by leaving another mesh (in another layer, or actual layer) share the material of the object with the shader, but Is This considered a bug?

File:
shader problem.blend (86.2 KB)

What is happening?

Your blend was corrupt I guess…
Either that or it is a bug…
In your file I got the same results as you. I created a new blend and used your code in it, and got this:


They all use the same mesh data like yours did

ShaderProblem.blend (507 KB)

EDIT: Nevermind…
Not sure why I did, but after I posted this I tested it in fullscreen and only one lit up. Must be a bug…
The above file works in with the embedded player, but not standalone.

I think it depends on the how the objects are duplicated. ALT+D (sharing all data) instead of with SHIFT+D.
If you duplicate only one object with SHIFT+D the shader will work on all objects.

Please make a bug report.