Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Reverend-Speed · Jun 28, 2016 at 07:01 PM · performance optimizationfadebatchingfadeoutrenderer.material.color

Is it possible to fade individual game objects while maintaining material batching?

Hey there - idle question, which may or may not be dumb...

If I wanted an individual instance of a game object to fade out (examples: dead body, object exiting visibility range, scenery between camera and player avatar, floor and contents of building level above level with current focus) I would probably grab the object's materials in question (renderer.material, assuming it has alpha) and repeatedly assign a colour which I lerp the alpha on over the course of a third of a second or whatever. I could do this with a coroutine or an animation clip. (Description's a bit rough because I haven't done this in a while - as I say, it's an idle question)

However - if I want to maintain static and dynamic batching, I should in general avoid modifying renderer.material as this creates a new copy of the material, messing with the batching (and adding to memory usage). So there's a conflict there.

Obviously creating an object pool can help a little for enemies, etc, but as I say, sometimes you just want to fade out an arbitrary wall or other scenery if a player's behind it (again, ignoring solutions like having the player show x-ray like through the walls, or having the walls shrink in Y to show the player behind).

Does anybody have any best practice suggestions for having individual game objects fade out while maintaining material batching?

--Rev

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

1 Reply

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

Answer by tanoshimi · Jun 28, 2016 at 08:23 PM

Batched objects must share the same material. So, the only way I can think to adjust the alpha of a single gameobject with a shared material is to assign its opacity based on a vertex colour applied to the mesh. But, depending on how complex your mesh is, the cost of looping through and assigning a colour to each vertex might outweight the benefit saved from maintaining batching.

Comment
Add comment · 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 Reverend-Speed · Jun 29, 2016 at 02:41 PM 0
Share

Yeah. Pretty much what I thought - if you want this effect, at some point you just have to go 'feck it' and eat the performance drop.

I did think that - given the fade time - it might make sense to store an array of materials at various alpha levels and on fade event iterate through 'em, but again, are you doing to do this for everything? No.

Wouldn't $$anonymous$$d hearing more about your vertex opacity scheme, but basically I think I have my answer. Thanks!

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

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

Related Questions

Fading out GUITexture - I need help with timer function that will control the speed of fading out 1 Answer

Multiple Meshes VS Armature 1 Answer

Fading from my splash screen 1 Answer

A question about draw call performance when it comes to unique texture use. 0 Answers

Fade in/out a GameObject 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