csinkers / ualbion

A remake of the 1995 RPG Albion (requires data from an install of the original game)
MIT License
133 stars 12 forks source link

Draw billboarded sprites on top of walls and floors #9

Closed IS4Code closed 4 years ago

IS4Code commented 4 years ago

This method computes for every sprite its "front depth" by rotating it towards the camera and getting the final depth of the closest vertex. All pixels of the sprite are then assumed to be part of a vertical cyllinder and their depth is recalculated based on their position, moving them closer to the camera near the y axis.

This simulates the original behaviour quite well without resorting to sorting, but it is not perfect. Sprites can intersect with the floor or ceiling, but only when viewed from distance and only when it would be physically impossible for them to be visible there (so it is better in a sense). It can also be further improved by setting or creating a sort of bump map for every individual sprite, as this for example makes large trees appear over smaller ones in front of them (since the size of the cyllinder is assumed to be the size of the whole bitmap).

csinkers commented 4 years ago

Hmm, these changes do introduce a fair bit of complexity to the vertex shader, and introduce a couple of new graphical artifacts, but the floor clipping does seem to be improved quite a bit. I'll bring them in for now but will be looking for ways to simplify things.

Would you be able to revert the changes to DungeonScene.cs first though? There don't appear to be any significant changes there, most likely just some differing whitespace.

csinkers commented 4 years ago

Actually, don't worry about DungeonScene, changes merged.