Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - VolatileParticleDev

Pages: [1]
1
Graphics / Using one shader with multiple sets of uniforms
« on: March 26, 2023, 12:53:26 pm »
I want to draw multiple drawables with the same fragment shader, but with different uniform values. I see two ways of achieving this:

1. Loading the shader once, and drawing all drawables with the same shader, but setting uniforms between each draw call.

2. Loading multiple instances of the same shader, and drawing every drawable with a separate shader instance, removing the need for constant updating of the uniforms.

Which of these are recommended, or is there another, better way to do it?

From my testing, solution 2 gives better performance overall, but has the disadvantage of causing a lag spike whenever I introduce a new drawable. It seems shader::loadFromFile is (understandably) quite slow, but since Shader instances are non-copyable, I don't see how I can avoid loading from file each time I want a fresh instance.

For context: I expect to draw between 1 and 20 drawables with the same shader.

Pages: [1]
anything