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 xEnOnn · Mar 30, 2013 at 09:45 PM · modelfadeout

How can I fade out a model?

I have a fbx model in my scene. How can I fade out the model? I tried using renderer.material.color and reduce its alpha channel, but this doesn't work.

Comment
Add comment · Show 4
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 robertbu · Mar 30, 2013 at 09:57 PM 0
Share

renderer.material.color will only work with a shader that supports transparency. Experiment with different shaders...especially if they have 'transparency' in their names ;).

avatar image xEnOnn · Mar 30, 2013 at 10:04 PM 0
Share

The fbx model comes in different parts, and they are grouped into a parent gameobject. This gameobject itself has no shaders. The individual parts have shaders but changing them also changes their appearance. There are also many parts and changing every single one of their shaders is difficult. Is there any other ways to fade out a model?

avatar image robertbu · Mar 30, 2013 at 10:12 PM 0
Share

Not directly that I know of, but you might take a look at $$anonymous$$aterial.Lerp(). I've not had occasion to use it, but it might work for you. That is you leave your materials alone when fully visible, but you could then Lerp to one that supports alpha (perhaps one that is already invisible). It is only a theory. $$anonymous$$aybe someone else on the list can give you a better idea if it would work.

avatar image whydoidoit · Mar 31, 2013 at 12:03 AM 0
Share

$$anonymous$$aterial.Lerp just changes color values and floats on a material.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by whydoidoit · Mar 31, 2013 at 12:05 AM

The only thing I can think of doing that doesn't involve complicated specialised shaders is to render the object to a render texture and then fade the alpha of a shader that renders the texture over the main cameras view.

Comment
Add comment · Show 6 · 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 whydoidoit · Mar 31, 2013 at 10:58 AM 0
Share

If you render the object to the RenderTexture in OnPostRender of the main camera and don't clear the depth of the object's camera then it will also appear correctly behind other scene objects.

avatar image xEnOnn · Mar 31, 2013 at 01:57 PM 0
Share

Sounds like an interesting technique. But I'm still quite confused with how I should go about doing it. I tried creating a RenderTexture, got my main camera to render texture on it. Since my main camera captures all layers, everything in the scene is displayed on the RenderTexture. If I don't clear the depth, it will affect my main scene.

avatar image whydoidoit · Mar 31, 2013 at 11:30 PM 0
Share

Yeah you'd need a few stages:

  • Render the main camera to a texture not displaying the fading model

  • Render the main camera to a different texture with a replacement shader to write the depth (would write nothing else)

  • Render a second camera not clearing anything to the second texture, just displaying the model to fade

  • Have a third camera which rendered the two textures in order to the actual display surface. This one would have a shader to modify the alpha value of the second texture to fade in and out your model.

avatar image xEnOnn · Apr 01, 2013 at 05:13 PM 0
Share

Cool! But wouldn't this be very expensive for just fading a model? I'm thinking if it would still worth to do a fade. I'm not very familiar with shaders. What kind of shader do I have to use to allow me to modify the alpha value and yet doesn't affect its appearance? The transparency shaders will change the way the materials on the model look.

avatar image whydoidoit · Apr 01, 2013 at 05:32 PM 0
Share

Well it's pretty expensive - it's not much worse than an iOS depth of field or something - the shaders are all lightweight. But yes, fading a model isn't particularly cheap I'm afraid - not without doing as Eric says and fading all of the parts - though that clearly has unintended effects of seeing the model through itself.

Show more comments
avatar image
1

Answer by Eric5h5 · Apr 01, 2013 at 05:21 PM

Changing renderer.material.color.a does work, but you need to use a transparent shader. If the model is in many parts, just put them in an array and iterate through the array.

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 xEnOnn · Apr 01, 2013 at 07:26 PM 0
Share

Thanks! But changing to a transparent shader, for some reason, changes the way the model looks. The model looks "brighter" and the colours are somewhat off from the original one too. The original shader is diffuse. I changed it to transparent diffuse and a few others but they all affect the model's appearance.

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

12 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

Related Questions

MMD How to export model and animations to Unity as 3rd person controller? 2 Answers

Make model fade out. Transparency help. 1 Answer

Imported model gives error: "Transform.rotation is no longer valid" 2 Answers

Mesh Collidor Faster 1 Answer

how to rotate 3d model in touch using guy texture object 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