Shaders Do shaders respect depth?

cidwel

Member
Hi all!

Long story short, I have issues with some objects not being rendered above of others objects with more depth.
You can check it in this gif:



The balls that come to the actor apears below him. This does not happen when I disable the shader. Even the bursts that comes next to the balls are also being rendered below the actor.

Probably I'm missing something really important in my shaders but I can't figure what could be.

Do anyone know what is the value that I'm probably missing? Something that enables the shader to respect object depths
 

CMAllen

Member
Shaders are applied to whatever is drawn between when the shader is activated and when it is turned off again. It will respect 'depth' only as much as the objects being drawn respect it. Without know more about what you're drawing and how, it's difficult to ascertain what might be happening.
 

CloseRange

Member
Short answer no. But then again depth is just the draw order.
Depth works by drawing everything on the highest layer first then the next highest then the next and so on.

If you apply shaders to the application surface than defiantly not because the application surface is like a screenshot of everything on your screen. The screenshot has no depth so the shader will only draw the pixel of that 'screenshot'

If you put the shader on each sprite independantly then yes this should work because the sprite won't be drawn until the game is ready to draw on its own depth. So the shader will be applied to that depth (for that sprite) as well
 

kburkhart84

Firehammer Games
What object is drawing the "balls?" What depth is it at? What object is drawing the character? What depth is that one at? Knowing these 2 things should clarify the issue. If by chance they are drawn at the same time, in the same draw event, then you would need to swap the order you are calling the draw functions.

There is no way to control "depth" in your shaders. Everything, with or without shaders, is drawn in the depth order. When you say you disable the shader, and then the balls draw on top, are literally only commenting out the shader_set() function?
 

cidwel

Member
If you put the shader on each sprite independantly then yes this should work because the sprite won't be drawn until the game is ready to draw on its own depth.
Then.. if it is as simple as this it should be working. Probably I'm messing with depths, but as far as I remember I create these elements in a layer with more depth than the actor, and the actor is doing the shader by itself.

I'll check later when I return to home.

Many thanks for your responses!
 

CloseRange

Member
Then.. if it is as simple as this it should be working. Probably I'm messing with depths, but as far as I remember I create these elements in a layer with more depth than the actor, and the actor is doing the shader by itself.

I'll check later when I return to home.

Many thanks for your responses!
Make sure you have it right. The bigger the number the more it will be behind every other object.

You could also do like a draw_text(x, y, depth) for debugging to make sure all the depths are correct
 
Top