• 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
2
Question by Caiuse · Jan 06, 2010 at 09:20 PM · guigraphicsblackwhitegreyscale

Fade A Whole Scene From Black & White to Colour

For anyone whos played the New Call of Duty, Modern Warfare 2, this will be very fimilar, I would like to fade a whole scene from black & white to colour and I do not have a clue where to start, Can anyone help me achive this?

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
15
Best Answer

Answer by duck · Jan 06, 2010 at 10:11 PM

This can be done by following these steps. First, you'll need Unity Pro, because modifying the scene with a full screen image effect is a Pro-only feature.

Now, Unity Pro comes with a fullscreen Greyscale image effect, but it's all-or-nothing, you can't fade it in or out, you can only switch it on or off. So what I'm going to do is give you the instructions to tweak these files to add fading functionality to it. Specifically, I will add a variable which controls the fade amount, which you can then modify yourself at runtime. Here's what you have to do:

  • Make sure the Pro Standard Assets are imported into your project. You'll be editing a couple of files in here, but these are only copies of your Pro Standard Assets - if you start another project and include Pro Standard Assets, you'll get the original unmodified versions again.

  • In your project view, look in the "Pro Standard Assets / Image Based" folder. Inside are two files named "Grayscale Effect". One is a C# script, and one is a .shader file. Open the .shader file to edit the source (it's the one with the "S" icon).

  • Add this line inside the "Properties" section (at line 5):

    _EffectAmount ("Effect Amount", Range (0,1)) = 1.0
    

    Add this line under the "uniform" declarations (at line 22):

    uniform float _EffectAmount;
    

    Modify the 'return' line to look like this (which is now at line 31):

    return lerp(original, output, _EffectAmount);
    
  • Now save and close GreyscaleEffect.shader, and open the other "GreyscaleEffect" file, which is a C# file called "GreyscaleEffect.cs"

  • Under the Public variable declarations, add this line (at line 8):

    public float effectAmount = 1;
    

    Just before the 'Graphics.Blit' line, add this line (at line 13):

    material.SetFloat("_EffectAmount", effectAmount);
    

    You now have an extra variable in the Greyscale script which you can modify to control the fading. You can modify this value either in the animation editor, or via another script.

    Just add this image effect script to your camera, then create a reference to the GreyscaleEffect script instance at runtime. You can then modify the "effectAmount" variable anywhere from 0.0 to 1.0 to fade the effect in and out. Note: there's no error checking for whether that value goes beyond 1.0, or lower than 0.0 so you'll have to manage that yourself (weird colourful effects ensue if you don't!).

    Comment
    Add comment · Show 8 · 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 Caiuse · Jan 06, 2010 at 11:39 PM 0
    Share

    Thankyou SO $$anonymous$$UCH! very detailed response AWESO$$anonymous$$E!

    Got a question though, Don't supose you could tell me how to fade the "effectAmount" variable, over time, on Runtime (assu$$anonymous$$g that does mean when I run the game).

    Cheeky of me to ask but you obviously have a very clear idea of what your doing! :D

    avatar image dreasgrech · Jul 10, 2013 at 08:22 PM 0
    Share

    @duck: Thanks a lot for this solution. It works perfectly.

    avatar image dreasgrech · Jul 10, 2013 at 08:24 PM 0
    Share

    @Caiuse: what you need to do is to interpolate the new effectAmount variable from 0 to 1 to fade from colour to grayscale and 1 to 0 for vice versa. Take a look at $$anonymous$$athf.Lerp

    avatar image Neeko · Jun 02, 2015 at 11:32 PM 0
    Share

    You sir, are a gentleman and a scholar. Thank you!

    avatar image Michael-Glen-Montague · Jun 03, 2015 at 02:16 AM 0
    Share

    Is this still a pro-only feature in Unity 5?

    Show more comments

    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.

    Welcome to Unity Answers

    The best place to ask and answer questions about development with Unity.

    To help users navigate the site we have posted a site navigation guide.

    If you are a new user to Unity Answers, check out our FAQ for more information.

    Make sure to check out our Knowledge Base for commonly asked Unity questions.

    If you are a moderator, see our Moderator Guidelines page.

    We are making improvements to UA, see the list of changes.



    Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Aditive Greyscale Shader (Turns any texture a solid color) 1 Answer

    iphone album art how? 0 Answers

    Low level text writing 1 Answer

    GUI elements sometimes flicker or flash, briefly showing incorrect sprite images 1 Answer

    Best way to draw an ECG trace. 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