• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by spencer lindsay · Dec 14, 2009 at 09:11 PM · cameramaterialgraphics

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by jonas-echterhoff · Dec 14, 2009 at 09:30 PM

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image spencer lindsay · Dec 15, 2009 at 09:13 PM 0
Share

Cool. As in the skybox shader, right?

Thanks Jonas.

avatar image jonas-echterhoff ♦♦ · Dec 16, 2009 at 08:56 AM 0
Share

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.

avatar image yoyo · Jan 06, 2011 at 07:35 PM 0
Share

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

avatar image
2

Answer by spencer lindsay · Dec 14, 2009 at 09:22 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Render Texture and antialiasing 3 Answers

Creating a Material from shader string 2 Answers

Unsmooth camera on sprite diffuse 0 Answers

Is it possible to align the cubemap axes with the camera? 0 Answers

Problem of using multiple scripts attached to camera containing OnPostRender() for VR projects 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges