You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm trying to build a 2d game with this library and I have to use an FBO to stock the depth value of each pixel.
Here is my process :
first, I create a renderer, and several images that can be drawn to using GPU_LoadTarget(), then each frame :
I clear every FBO and the screen.
I draw the opaque objects of my world in an image called opaque_world_render, using depth testing in the process.
Then I copy opaque_world_render in an FBO and drawn on it all the transparent object of the scene, also using depth testing.
I draw the final result in the screen using post-processing shader to add some bloom and blur.
This process works fine to combine depth testing and transparency. What I want to add is the possibility for the shader that draws a transparent object to access the depth-value for each pixel. This is to add a notion of depth to water, for exemple. I've read that it is impossible to access the depth buffer in a fragment shader. I've also tried to store this in the value of every pixel, but the only value left is the alpha value and I need more precision than a single byte (my depth values range from 0 to about 8000). And I read that SDL_GPU isn't made to change how this works.
So my last resort is to use an FBO to store the depth value of each pixel in the opaque_world_renderer. But the issue with this approach is that my game is made for rendering a very high amount of sprites (500k+) and making a second draw call for each sprite is going to destroy the perfomances. What I want to do is to have 2 output in my fragment shader :
Hello, I'm trying to build a 2d game with this library and I have to use an FBO to stock the depth value of each pixel.
Here is my process :
first, I create a renderer, and several images that can be drawn to using GPU_LoadTarget(), then each frame :
This process works fine to combine depth testing and transparency. What I want to add is the possibility for the shader that draws a transparent object to access the depth-value for each pixel. This is to add a notion of depth to water, for exemple. I've read that it is impossible to access the depth buffer in a fragment shader. I've also tried to store this in the value of every pixel, but the only value left is the alpha value and I need more precision than a single byte (my depth values range from 0 to about 8000). And I read that SDL_GPU isn't made to change how this works.
So my last resort is to use an FBO to store the depth value of each pixel in the opaque_world_renderer. But the issue with this approach is that my game is made for rendering a very high amount of sprites (500k+) and making a second draw call for each sprite is going to destroy the perfomances. What I want to do is to have 2 output in my fragment shader :
But the frag shader doesn't draw in the FBO, here is the code I used to pass it to the shader :
If you know how to do this with SDL_GPU I would like to know.
The text was updated successfully, but these errors were encountered: