WebGL: Can I render multiple meshes using different programs?

Started by
1 comment, last by BitMaster 9 years, 3 months ago

Newbie question unsure.png If I use different shader programs for two different meshes within the same frame of the loop, would one of the objects disappear? My loop works like this:

- Scene.Draw()

- object.draw()

- object.draw()

- Loop!

I'm calling gl.useProgram() on each object.draw() too. I'm guessing it's a lot more optimal using the same shader program when possible.

Advertisement

Nevermind. The answer is no, and apparently an obvious no.

My experience with WebGL is extremely limited but there is no requirement to use the same shader program for all meshes in the scene in standard OpenGL. That would be a huge and annoying restriction.

If it does not work for you, you are doing something wrong. My guess is you forgot you need to specify all uniforms for all program individually. If both programs need the model-view-projection matrix they both need it set individually even if the uniform is called "mvp" in both.

This topic is closed to new replies.

Advertisement