Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

One shader for several meshes; common uniforms

If I were to create a shader object and then assign it to ‘shader’ attribute of several mesh objects, will it be the same shader program? That is, if I then assign some value to a uniform in the original shader object, will it be accessible when rendering all these meshes?
On a related note, what is the best way to go about making one uniform, say, a texture, accessible from multiple shader programs? For example, I am using shadowmapping and therefore need all the objects in the scene to access the shadow map which changes every frame; obviously, I do not want to load it into every shader program for every object.

Tagged:

Comments

  • JohnJohn Admin Mod
    Posts: 572

    @SamTheMadRabbit That's exactly what you need to do. There is no global or shared uniform support in GLSL so you set it on every shader. You can share the same shader between multiple meshes (and they will use the current uniform values on the shader) though if that helps.

Sign In or Register to comment.