Sign in to follow this  
lomateron

webGL updating view matix

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this