• 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
Question by Malygon · Jan 03, 2013 at 01:02 PM · renderingtexturesperspective

Textures are being displayed in the wrong order - How can I fix this?

Hello, we are currently working on a 2D Platformer. The Objects in the game are represented as textures on a plane with invisible bounding meshes as platforms.

We use the normal perspective camera instead of the orthographic one so we can have background objects at different z-coordinates to simulate parallax scrolling.

However there seems to be a problem with this method. In the inspector, in the game and also in the build game some objects are shown as being in front of other objects even though they are technically behind them.

Example:

alt text

The mushroom is actually 5 units behind the tree but still shown in front of it. If I move the character however:

alt text

If I'm above the mushroom it is shown correctly. Even if I place the mushroom about 20 units behind the tree it is still shown to be in front of the tree, it only gets smaller. This problem doesn't exist in orthographic projection but we would loose the parallax scrolling if we were to use that. I don't know what's causing the problem or how to fix it. Anyone got an idea?

mushroomwrong.png (189.0 kB)
mushroomright.png (105.6 kB)
Comment

People who like this

0 Show 0
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

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by Piflik · Jan 03, 2013 at 01:45 PM

It is usually quite hard for an engine to get the correct render order with transparent materials, especially Alpha Blended materials. Alpha Tested materials don't have this problem AFAIK. Try a cutout shader. If that doesn't work, you can also change the render order per script.

http://docs.unity3d.com/Documentation/ScriptReference/Material-renderQueue.html

Comment

People who like this

0 Show 1 · 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 Malygon · Jan 03, 2013 at 02:21 PM 0
Share

Thanks, the cutout shader seems to do the job. At least with the one mushroom. Should other problems arise I will try out the render order.

Edit: Since the cutout shader negatively impacted the quality of our textures I used the renderer order. I wrote a simple script that sorts every GameObject by its Z axis and then applies a number to the renderQueue variable.

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Aligning planes thin gap? c# 0 Answers

Object shown on top of another, rendering priorities? 2 Answers

Planes clipping through each other. 0 Answers

2d PNG on Plane Texture padding 1 Answer

How to Render a Sliced Sprite to a Mesh? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges