g3n / engine

Go 3D Game Engine (http://g3n.rocks)
https://discord.gg/NfaeVr8zDg
BSD 2-Clause "Simplified" License
2.79k stars 295 forks source link

Sprite with alpha glitching against textured floor plane #231

Closed harbdog closed 3 years ago

harbdog commented 3 years ago

I'm experiencing an issue where viewing a sprite, which has a texture image containing alpha, at certain angles has its alpha channel showing when against a textured background/floor.

G3N Version: github.com/g3n/engine v0.1.1-0.20210127232258-6d0136f3444c and v0.1.1-0.20200214161420-db7282a2ba23 from G3N Demo project

bad-transparency

Here's a gist with the G3ND tests/model.go code to reproduce the problem: Gist: https://gist.github.com/harbdog/6e32a467b45779126fe6a15cd007cd0a

danaugrs commented 3 years ago

Hi, and thanks for providing a GIF and reproduceable example! This happens because both the sprite and the plane have a transparent material, so their render order is computed by comparing the distance between their centers with the camera. You can manually modify the render order of the sprite to be drawn on top of the plane via s1.SetRenderOrder(1). Then it will always be rendered on top of the plane.

harbdog commented 3 years ago

Excellent thanks for the tip! Setting the floor plane render order to -1 also did the trick