Shader evaluation order

edited May 2015 in Help request
I just want to ask if one could define shader evaluation order for the objects.

Say I have object1, object2 and object3. Each has some shader attached. But I need to run the shader on the object3 as first, than on object1 and the last object2.

I'm going to implement the per-pixel sorting using custom depth map and I want to use fragment shader to write to the Z buffer. Because I'm using composited sprites (that is, one object is composed with multiple sprites where each sprite have some predefined order in which it is drawn) I also need to run the shader in the order in which the sprites are drawn.

Is it somehow possible or am I out of luck?

Edit: I know that shaders are basically run in parallel but want to be sure that there isn't any other method of achieving it.

Thank You


  • edited May 2015
    Hi Trigve,

    I'm not sure I follow entirely, so tell me if my answer is not the one you are expecting. :)

    Shaders attached to objects are used when those objects are rendered, they replace the default shader that orx uses (except where the static pipeline is still used, but that's going to disappear over time).

    So basically, you control the order of use of the shaders by controlling the order of rendering of your objects, be it by Z value or object group/camera.

    If you attach shaders on a viewport (usually for full screen shaders/Post-FX/compositing), the same rule apply: the shaders will be run in the same orders the viewports are evaluated, which, this time, is controlled by their order of creation.
  • edited May 2015
    Thansk for reply,
    I had an impression that the shader was evaluated in no defined order.

    And your answer is perfectly valid ;)
Sign In or Register to comment.