Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by Ross_S · Aug 16, 2012 at 10:48 AM · camerarenderorthographicorderrender order

Orthographic camera rendering order not always working

Hey if anybody could shed some light on this I'd be grateful... Basically I'm determining the render order of all my on-screen gameobjects each frame by setting their vertices each frame - and setting the z value to determine which should be down in front of which... The objects are all flat planes with just 4 verts .... This all works fine most of the time - but in some places where I'm sure that the z verts are being correctly assigned, some objects which should be in front of others are being drawn under them... And I really can't see why... FYI - this is a conversion from an iPhone game so that's why I'm doing it like this - in the original code the objects were rendered in the precise order they should be drAwn so each time I draw something I increase a global var that contains the z-depth for the next drawn object... Camera is orthographic... Any clues? Thanks, Ross

Comment
Add comment · Show 1
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 Kryptos · Aug 16, 2012 at 12:14 PM 0
Share
  1. Not all shader perform a ZTest. $$anonymous$$ake sure yours do.

  2. In Unity the forward direction is along the z-axis, so make sure you're not mistaken with it. The z coordinate and the z of the z-buffer are two different thing.

2 Replies

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

Answer by ScroodgeM · Aug 16, 2012 at 12:01 PM

first. check this

second. check shaders. shaders also have a render queue value that is more important that z position. shader with lower queue value will render first.

third. for transparent objects they are sorted using it's pivots. so be sure not vertices but pivots are sorted in right order

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
avatar image
0

Answer by Ross_S · Aug 25, 2012 at 04:26 PM

Thanks for your answers here - The problem did seem to have something to do with using the transparent shader - when i turned it off - everything was rendered right - the solution that finally worked for me was to set the 'render queue' value for each GameObject's mesh renderer material - like so...

so each frame for each GO it's ... ...

meshRenderer.material.renderQueue = Globals.renderQueueCounter; Globals.renderQueueCounter += 1; ...

basically... thanks

Comment
Add comment · Show 4 · 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 ScroodgeM · Aug 25, 2012 at 09:18 PM 0
Share

methinks you should fix object's pivots. check any two objects that are renders in incorrect order - what is the distance from camera to that objects pivots?

avatar image Ross_S · Aug 26, 2012 at 11:57 AM 0
Share

i admit i didn't put too much effort into it but i couldn't really see where the pivots were - as the objects are all simple planes i presumed the pivot would just be in the middle of that plane. I'm repositioning them by changing the 4 verts - that doesn't also change the pivot?

it's an orthographic camera - my first attempt to get render order working was by using the z - axis... but that wasn't working...

avatar image ScroodgeM · Aug 26, 2012 at 12:04 PM 0
Share

repositioning verts always leave pivot in place, cause vert has coordinate relative to pivot. so you should use verts position so that one dimension is 0. for example (1,1,0) (-1,1,0) (-1,-1,0) (1,-1,0) and move along z axis using pivot (gameObject.transform.position)

I'm repositioning them by changing the 4 verts - that's an answer to your issue 8)

avatar image Ross_S · Aug 27, 2012 at 03:45 PM 0
Share

Hey thanks Scroodge - you are totally right - i fixed it as you recommended and it's working perfectly...

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.

Follow this Question

Answers Answers and Comments

10 People are following this question.

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

Related Questions

How to resize a camera's orthoSize for an object to fit inside its rect viewport? 1 Answer

Why is part of object outside camera frustum visible? 1 Answer

is it possible to set the view port rect at both ends 1 Answer

Set renderable objects on camera without Layers 2 Answers

Orthographic camera "cutting off" part of the frame 2 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