Sprite material which works right with transparency in 3d view (SOLVED)

At some angles sprite transparency doesn’t work

2017-10-13 03_12_01-Defold Standard Geometry

Others it does work

2017-10-13 03_12_09-Defold Standard Geometry

Why? Only happens in engine not in editor.

Another issue is how would sprites which are arranged like the follow be made to render properly? This also looks right in the editor but not in engine.

2017-10-13 03_14_07-Defold Standard Geometry

2017-10-13 03_13_45-Defold Standard Geometry

This kind of asset pattern is useful for imposters, grass, projectile particles, explosions.

1 Like

I have the first issue solved by setting the correct blend function before rendering sprites. Although I don’t yet understand why it works sometimes with the wrong function set.

The second issue I think is caused by the depth test, but it’s needed to place the sprites properly behind regular geometry.

2017-10-13 12_38_27-Defold Standard Geometry

With depth testing disabled it renders how I want but then sprites behind geometry draw on top of geometry.

2017-10-13 12_39_51-Defold Standard Geometry

2017-10-13 12_40_28-Defold Standard Geometry

What do?

I think this is the kind of solution that is needed but not sure if it’s possible to do.

Got it all working now. What had to be done was simple - keep depth testing enabled for the sprites, but disable writing to the depth mask temporarily.

2017-10-13 23_08_20-Defold Standard Geometry

Parts of regular meshes with transparency might be a problem still though. Although possibly you could attach sprites to models where these effects are needed. Or have a separate predicate like sprites have and have separate mesh parts with transparent textures drawn on that.

2017-10-14 01_18_41-Defold Standard Geometry

6 Likes

I seem to be running into this issue too. I’ve got a perspective camera from a near-2D point of view, just rotated 20 degrees on the X axis. I have one big sprite as the background grid, and a smaller sprite just above it (the white X). If I move the camera along the Y axis, at a certain point the white X sprite starts drawing behind the grid. That’s with STATE_DEPTH_TEST enabled, and set_depth_mask(false). If I change it to set_depth_mask(true), they draw in the right order, but the transparency of the white X gets messed up. If I raise the X up on the Z axis it moves the tipping point up in Y. Any ideas?

3 Likes

Same problem for me

1 Like