webGL updating view matix

Started by
1 comment, last by JohnnyCode 7 years, 11 months ago

If I have 10 different shaders for drawing 10 different shaded objects that need the same view matrix

do I need to update this view matrix for every shader which means that I have to call gl.uniformMatrix4fv() 10 times every frame?

In directx 10 in one file I can have 10 shaders and only one global "viewMatrix" variable which means I only need to update the view matrix one time per frame.

Can something similar be done in webGL?

Advertisement
You will need to call gl.uniformMatrix4fv 10 times.
My current game project Platform RPG

If I have 10 different shaders for drawing 10 different shaded objects that need the same view matrix

do I need to update this view matrix for every shader which means that I have to call gl.uniformMatrix4fv() 10 times every frame?

If it will be a different shader per object, yes, entire uniform states for a shader will drop if other shader gets bound. (and not only that)

You may heard about milking around with "some uniforms if matching will they not need to be set?" etc. but gpu takes batched data transfers.

This topic is closed to new replies.

Advertisement