Suggestion for fixing numerous z-fighting issues

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Suslik
Spiderkin
Posts: 481
Joined: Wed Aug 22, 2012 4:41 pm

Suggestion for fixing numerous z-fighting issues

#1 Post by Suslik »

Well probably everyone who played tome even a little notices that some effects(particles primarily) are rendered behind or above objects they should not be. Like doors and posters, mountains and such.

Reason is that currently t-engine renders sprites as follows: first it sorts them along global z-axis, then those which have equal z-component are sorted for screenspace y-axis.

No wonder it has artifacts because it's mathematically incorrect. I have not tested it yet, but common sense tells me that the only way to make them sort in a proper way is to sort the sprites along (z + y) component. Note that in such case z-component should be in range(0..1) for normal objects such as walls, doors, characters, on-character effects and such. For example if you want a door to be rendered above a wall and a character who stands in front of it should appear above both of them, then the wall should have z-coordinate 0.5, the door should have it for example 0.75, character z = 0.5, character effect under him z = 0.25 and above him are z = 0.75. Particles like explosion and fireball should have z = +inf.

In my case y is aligned from top to down and z is facing on the viewer. If you have differently oriented axes, just switch sorting formula for something like (y - z)

Post Reply