Object sprite color turned white, sometimes (SOLVED)

I am using Defold 1.2.118.

This test app contains one collection.

The collection contains two atlases (1.atlas, 2.atlas).
1.atlas contains one png (blue).
2.atlas contains one png (red).

The blue.png is used as the background color.

The collection contains one object (red.go).

The background sprite (blue)
Material: /builtins/materials/sprite.material
Blend mode: Add

The red object sprite
Material: /builtins/materials/sprite.material
Blend mode: Alpha

Just to display the red (object) on top of the blue background.

Problem:
Attachment 1 (displayed correctly)
Attachment 2 (sometimes the red color became white)

What could be wrong?

zip of this defold project attached in below message. Thanks

It would be easier to upload a zip of a test project!

i found out how to generate zip of a defold project.

zip of this test defold project attachedtcolors.zip (305.8 KB)

Try changing the Z-index for your position of red.go’s sprite to 1. I think this might be happening because your main.collection’s sprite has ‘Add’ blend mode and they’re on the same z-index.

Tested it locally:

  • with 0 Z index, 3/10 times circle was red
  • with 1 Z index, 10/10 times circle was red

Hope that helps :slight_smile:

2 Likes

You are Super! I followed your instruction and it worked. Thanks!

1 Like

Yeah, sounds like they were on same z-value. The order isn’t guaranteed then.

Also, unless you have changed your render script, your objects will only be drawn from -1 to 1 z. You have high precision in that range though. If you have multiple objects that need to be drawn in a specific order, you will want to change their z-positions by very small numbers. 0.01, 0.02, 0.03, or something like that.

1 Like