ID:2542840
 
Applies to:Dream Daemon
Status: Open

Issue hasn't been assigned a status value.
Currently, doing 3d effects is very much possible using transforms and clever trickery:





However, this is very much a hack, and has two big problems: First, this is not perspective-correct, meaning that it looks distorted, however in this example the 3d is so shallow the distortion isn't very visible. More importantly, this uses /image objects that update every time someone moves, which incurs a performance penalty if you use too many of them, which makes this infeasable on things like walls.

The math for something like this should be pretty trivial - simply add a third row to /matrix objects.

The result would look like this:
new_x = a*x + b*y + c
new_y = d*x + e*y + f
new_w = g*x + h*y + i


Obviously, the third row would default to 0, 0, 1.

Then, you simply divide the x and y by w. This is what OpenGL does. (Make sure whatever shader you are *actually setting the w instead of dividing manually* or the thing will not be perspective-correct). The only caveat here is that you'd have to re-center the coordinate system so that 0,0 is the center of the screen when you do the division and then put the coordinate system back afterwards, otherwise this would do nothing to solve the problem of needing to update image objects per-client.

Here's an example matrix that would make something vertical:
transform = matrix(
1, 0, 0,
0, 0, -16,
0, -1/32, 1
)


Another thing that would be important for this is a new appearance flag to hide the back of a face. I don't expect you to go all in and use a Z-buffer or anything, but doing this should help make it so that convex shapes can be displayed sanely.

This isn't rocket science, this is *very* basic math.
3D transforms are not in fact possible with current features because perspective scaling with distance is not taken into account.

I'm open to adding full 3D transforms at some point, but before that can happen the software renderer needs to be retired.