I'm creating a modern style 2d engine, all those sprite effects and everything. Though due to lack of control over sprites I'm going to have to use 3d quads to represent 2d surfaces, even better would be to use 3d triangles or single polys for a surface for better performance, but let's just do quads for now. The advantage of 3d is pixel shaders and subdivided quads (so subdivided plains you could ripple or wave, which you could use vertex shaders). The major disadvantage (in DBP's case) of using 3d and shaders for alpha blending is lack of control over Z-Sorting. No matter what you do it's based off object creation order. A way round this I think:
- Every frame check if a new entity is introduced into the scene.
- Insert it into it's layer, then reset and assign every object after it to correct the draw order( so the entity with the greatest zdepth will be assign to object 1. You'd then run through each layer or depth greatest to lowest and assign an entity to a object starting from 1 and upwards)
The Z-sorting issue when using shaders is a pain. Even if you position the object well behind the other, it's still based off creation order, even the Object Creation command doesn't help. I opted to not change the depth(z position) of the objects because they don't clip each when using a pixel shader for alpha blending, plus there's no point because of the Z-sorting issue.
Anyway, I should actually ask for what I needed: How do you scale and position a quad to fit a 2d size. So if you had a box 128x128 in pixels at position x:256 y:128, how would you represent that using a 3d quad?
A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.