Skip to main content
Added backticks, tagged as draw-order / depth-buffer
Source Link

Order independent-independent rendering of 2d2D sprites

I am using openglOpenGL to render sprites, using an orthographic projection.

Each sprite has a position: (xx, yy, zz). I need to be able to set the order of rendering, so that certain sprites are rendered on top of the others. For this reason, I also have a zz value in the position;

The rendering pseudocode looks like this:

Renderer.begin(camera.projection)
Renderer.draw(sprite1)
Renderer.draw(sprite2)
...
Renderer.end()

For the correct layering of sprites, I would need to sort them by their position.zposition.z value.

I would love to find a way around that: I plan to extend my system so that sprites can have custom materials, which will use custom shaders. Therefore, I would like to sort by their material index, in order to minimize shader switches;.

Is there a way to utilize the depth buffer in order to make the layering work, so that I can just sort by material index?

Order independent rendering of 2d sprites

I am using opengl to render sprites, using an orthographic projection.

Each sprite has a position: (x, y, z). I need to be able to set the order of rendering, so that certain sprites are rendered on top of the others. For this reason, I also have a z value in the position;

The rendering pseudocode looks like this:

Renderer.begin(camera.projection)
Renderer.draw(sprite1)
Renderer.draw(sprite2)
...
Renderer.end()

For the correct layering of sprites, I would need to sort them by their position.z value.

I would love to find a way around that: I plan to extend my system so that sprites can have custom materials, which will use custom shaders. Therefore, I would like to sort by their material index, in order to minimize shader switches;

Is there a way to utilize the depth buffer in order to make the layering work, so that I can just sort by material index?

Order-independent rendering of 2D sprites

I am using OpenGL to render sprites, using an orthographic projection.

Each sprite has a position: (x, y, z). I need to be able to set the order of rendering, so that certain sprites are rendered on top of the others. For this reason, I also have a z value in the position;

The rendering pseudocode looks like this:

Renderer.begin(camera.projection)
Renderer.draw(sprite1)
Renderer.draw(sprite2)
...
Renderer.end()

For the correct layering of sprites, I would need to sort them by their position.z value.

I would love to find a way around that: I plan to extend my system so that sprites can have custom materials, which will use custom shaders. Therefore, I would like to sort by their material index, in order to minimize shader switches.

Is there a way to utilize the depth buffer in order to make the layering work, so that I can just sort by material index?

added 3 characters in body
Source Link
Kromster
  • 10.7k
  • 4
  • 55
  • 67

I am using opengl to render sprites, using an orthographic projection.

Each sprite has a position: (x, y, z). I need to be able to set the order of rendering, so that certain sprites are rendered on top of the others. For this reason, I also have a z value in the position;

The rendering pseudocode looks like this:

Renderer.begin(camera.projection) Renderer.draw(sprite1) Renderer.draw(sprite2) ... Renderer.end()

Renderer.begin(camera.projection)
Renderer.draw(sprite1)
Renderer.draw(sprite2)
...
Renderer.end()

For the correct layering of sprites, I would need to sort them by their position.z value.

I would love to find a way around that: I plan to extend my system so that sprites can have custom materials, which will use custom shaders. Therefore, I would like to sort by their material index, in order to minimize shader switches;

Is there a way to utilize the depth buffer in order to make the layering work, so that I can just sort by material index?

I am using opengl to render sprites, using an orthographic projection.

Each sprite has a position: (x, y, z). I need to be able to set the order of rendering, so that certain sprites are rendered on top of the others. For this reason, I also have a z value in the position;

The rendering pseudocode looks like this:

Renderer.begin(camera.projection) Renderer.draw(sprite1) Renderer.draw(sprite2) ... Renderer.end()

For the correct layering of sprites, I would need to sort them by their position.z value.

I would love to find a way around that: I plan to extend my system so that sprites can have custom materials, which will use custom shaders. Therefore, I would like to sort by their material index, in order to minimize shader switches;

Is there a way to utilize the depth buffer in order to make the layering work, so that I can just sort by material index?

I am using opengl to render sprites, using an orthographic projection.

Each sprite has a position: (x, y, z). I need to be able to set the order of rendering, so that certain sprites are rendered on top of the others. For this reason, I also have a z value in the position;

The rendering pseudocode looks like this:

Renderer.begin(camera.projection)
Renderer.draw(sprite1)
Renderer.draw(sprite2)
...
Renderer.end()

For the correct layering of sprites, I would need to sort them by their position.z value.

I would love to find a way around that: I plan to extend my system so that sprites can have custom materials, which will use custom shaders. Therefore, I would like to sort by their material index, in order to minimize shader switches;

Is there a way to utilize the depth buffer in order to make the layering work, so that I can just sort by material index?

Source Link

Order independent rendering of 2d sprites

I am using opengl to render sprites, using an orthographic projection.

Each sprite has a position: (x, y, z). I need to be able to set the order of rendering, so that certain sprites are rendered on top of the others. For this reason, I also have a z value in the position;

The rendering pseudocode looks like this:

Renderer.begin(camera.projection) Renderer.draw(sprite1) Renderer.draw(sprite2) ... Renderer.end()

For the correct layering of sprites, I would need to sort them by their position.z value.

I would love to find a way around that: I plan to extend my system so that sprites can have custom materials, which will use custom shaders. Therefore, I would like to sort by their material index, in order to minimize shader switches;

Is there a way to utilize the depth buffer in order to make the layering work, so that I can just sort by material index?