Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 MauiMauo · Jun 13, 2016 at 12:44 PM · renderingtransparentmobileoptimizationopaque

Renderer using wrong rendering mode (Transparent instead of Opaque)

Hi! I'm working on a project using very basic 3D shapes and a point light:

alt text

No matter which shader I use for those objects (Standard shader with Opaque mode selected, Simply Lit shader with only lighting and one color property selectable), profiler tells me they're being rendered using the transparent rendering mode. This results in very bad performance on mobile devices, getting worse with every "step" the objects get bigger and cover more area behind them.

alt text

Am I missing something? I'm currently on Unity 5.1.5, tested on other versions as well with the same problem.

Thanks in advance, Maui

EDIT:

Okay I think I got one step further. As the game proceeds, the floor-meshes get assigned materials that are reused so that the color can change gradually from one floor element to the next. To get this working, I set up an array which gets filled with 30 materials at the beginning of runtime. They are then reused everytime a new floor element gets spawned at the end of the path.

I'm already trying to set the material's shaders to Opaque like this: (found inside the Unity docs)

 materialArray[i].SetFloat("_Mode", 0);
 materialArray[i].SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
 materialArray[i].SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
 materialArray[i].SetInt("_ZWrite", 1);
 materialArray[i].DisableKeyword("_ALPHATEST_ON");
 materialArray[i].DisableKeyword("_ALPHABLEND_ON");
 materialArray[i].DisableKeyword("_ALPHAPREMULTIPLY_ON");
 materialArray[i].renderQueue = -1;

But this doesn't seem to really set the shaders to opaque, they are still rendered as transparent.

Maybe someone has a suggestion to even improve the whole thing so that I don't need to create/use so many different materials and still have multiple colors for the floor elements at the same time.

Thx!

bildschirmfoto-2016-06-13-um-122058.png (89.3 kB)
bildschirmfoto-2016-06-13-um-122949.png (23.7 kB)
Comment
Add comment · Show 3
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 JatsArts · Jun 13, 2016 at 06:27 PM 0
Share

Change your material?

avatar image MauiMauo JatsArts · Jun 13, 2016 at 07:59 PM 0
Share

Could you elaborate? Thx!

avatar image JatsArts JatsArts · Jun 14, 2016 at 08:40 AM 0
Share

It's difficult to give an answer without knowing more about your setup, like: What's your camera setting's

  • Camera settings

  • Player settings

  • $$anonymous$$aterial settings

  • Object renderer component settings

  • Layers

  • What layers the objects are on

  • What layers the camera culling mask can see

  • more... But mostly I'm just guessing.

2 Replies

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

Answer by MauiMauo · Jun 15, 2016 at 06:15 AM

Okay so the problem was not using the correct renderQueue. Setting it to 2000 is putting it into the Geometry queue which fixed the problem and made the meshes render in opaque mode.

A longer explanation can be found here

For special uses in-between queues can be used. Internally each queue is represented by integer index; Background is 1000, Geometry is 2000, AlphaTest is 2450, Transparent is 3000 and Overlay is 4000.

Thank you tanoshimi!

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
2

Answer by tanoshimi · Jun 13, 2016 at 06:29 PM

Why are you assigning a renderqueue of -1? Should you not be using:

 materialArray[i].renderQueue = RenderQueue.Geometry;

?

Comment
Add comment · Show 5 · 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 MauiMauo · Jun 13, 2016 at 07:57 PM 0
Share

What do I need to import to use this line of code? RenderQueue.Geometry can't be found, "using UnityEngine.Rendering" doesn't help. I'm a noob regarding shaders etc. :/

avatar image Dave-Carlile MauiMauo · Jun 13, 2016 at 08:06 PM 0
Share

Looks like this might be a 5.4 thing.

https://docs.unity3d.com/540/Documentation/ScriptReference/Rendering.RenderQueue.html

Don't see it in the 5.3 docs.

avatar image MauiMauo Dave-Carlile · Jun 13, 2016 at 08:08 PM 0
Share

Ah okay. So what would I have to do to use that with 5.1.5? Project is in it's final stage and I can't update to another version of Unity now. EDIT: Looks like setting the renderQueue to 2000 is the way to go as described here. I'll test that!

avatar image Dave-Carlile MauiMauo · Jun 13, 2016 at 08:22 PM 0
Share

From the docs, -1 means use whatever render queue is defined in the shader, otherwise it should be positive. I'm not sure what the other values might be that correspond with the queue specified in the shader.

avatar image tanoshimi MauiMauo · Jun 13, 2016 at 09:27 PM 0
Share

@$$anonymous$$aui$$anonymous$$auo Ah, yes, it's a new feature, but it's basically just an enum in which "Geometry" corresponds to 2000, as you've noted. So that should work fine too.

@Dave-Carlile - yes, precisely, -1 means use the renderqueue defined in the shader. But the whole point is that the OP wants not to use the queue in the shader, but to override it!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to change Render mode in URP at runtime? 1 Answer

how to remove texture show-through? 0 Answers

How to reduce draw calls for efficient 3D model rendering 1 Answer

Don't render objects behind other objects, or use transparency flags? (Like Source engine) 1 Answer

Custom shader renders back objects only in certain angles 1 Answer


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