GLSL Shared View Matrix

Started by
3 comments, last by Irlan Robson 9 years, 11 months ago

I'm upgrading all of my OpenGL code to support the newer specifications, as a result I don't want to use the standard matrices in my GLSL code, such as gl_ModelViewMatrix or gl_ModelViewProjectionMatrix.. I wish to use my own matrices, except the problem I see is I'm using many shaders in my engine. It would be counter productive to upload a seperate set of uniform view matrices to every shader therefore I would need to have shared matrices.

I know about Uniform Buffer Objects and Uniform Blocks... but have not use them yet, are these the only way of sharing data between different shaders? I'm just looking for someone with experience to shed some light on the subject.

Many thanks, Jon.

Advertisement

Uniform blocks are pretty much the best bet.

Unfortunately you can't do this with GLSL and standalone uniforms. Like RobTheBloke said, use a uniform block: you'll probably find that you've got a bunch of other data that never changes or changes relatively infrequently (once per frame) which it also makes sense to put in there (maybe lightstyle values, view vectors for billboarding, etc).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Fantastic, thanks guys! :)

UBO.

http://www.opengl.org/wiki/Main_Page

This topic is closed to new replies.

Advertisement