x


How does Unity handle alpha sorting?

We've written an MOV material that plays a PNG compressed MOV file with alpha on a poly. It's pretty cool though a little memory intensive. Not a problem for this application.

Here's the problem/question:

Problem: I'm seeing alpha flutter between two polygons that overlap each other in the game camera. The distance between them is way more than it needs to be to avoid Z-Buffer artifacts so nope, it's not that.

Question: How does Unity decide which pixels of an alpha texture to display? Is it by object center or object bounding volume?

Here's what we're trying for: http://www.lindsaydigital.com/clients/MBAQ/webPlayer/test_006.html

more ▼

asked Dec 14 '09 at 09:11 PM

spencer lindsay gravatar image

spencer lindsay
207 8 9 22

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

One thing which may be helpful here is to use non-standart render queues in your shaders. If you replace

Tags {"Queue" = "Transparent" }

with

Tags {"Queue" = "Transparent+1" },

that material will be rendered after all normal transparent materials.

more ▼

answered Dec 14 '09 at 09:30 PM

jonas echterhoff gravatar image

jonas echterhoff ♦♦
9.8k 7 23 104

Cool. As in the skybox shader, right?

Thanks Jonas.

Dec 15 '09 at 09:13 PM spencer lindsay

well, the skybox shader uses "Queue"="Background" to make it render before all others. But, yeah - this is how you can manually change render order.

Dec 16 '09 at 08:56 AM jonas echterhoff ♦♦

You can also set material.renderQueue, which avoids having to create multiple copies of the shader when you need multiple sort orders.

Jan 06 '11 at 07:35 PM yoyo
(comments are locked)
10|3000 characters needed characters left

The answer seems to be: "Bounding Volume".

I added a triangle to the object I wanted to be in front and moved it out towards the camera, making the bounding volume of the smaller, "front" object larger than the background object. It's a hack, but it works.

Spence.

more ▼

answered Dec 14 '09 at 09:22 PM

spencer lindsay gravatar image

spencer lindsay
207 8 9 22

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3004
x815
x491

asked: Dec 14 '09 at 09:11 PM

Seen: 4138 times

Last Updated: Dec 14 '09 at 09:11 PM