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
4
Question by yeoldesnake 1 · Mar 04, 2012 at 11:33 AM · shadercolourgreyscaleselective

Modifying Greyscale Shader for selective Colouring.

I would like to achieve a selective colouring effect where everything is coloured in greyscale besides the colour red, preferrably by editing the greyscale effect default unity pro shader. However i have no idea how to do such a thing, how would i go about it?

A reference example: alt text

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

2 Replies

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

Answer by Tim-Michels · Jun 27, 2012 at 10:04 AM

Ok, since you ment post-processing, I tried to change the greyscale post-processing shader and it worked pretty fine.

Here's the shader: link text

Just change the extension to .shader

Here's the script:

link text

Change the extension to .cs

I had to change the extensions in order to upload these files, so correct them. Put the first attachement (shader) inside Standard Assets / Image Effects (Pro Only) / _Sources / Shaders, and put the cs script in Standard Assets / Image Effects (Pro Only)

Altough the shader isn't optimized, this still deserves a thumbs up ;)


GrayscaleEffect.txt (621 B)
GrayscaleEffect.txt (1.2 kB)
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 yeoldesnake 1 · Jun 27, 2012 at 04:05 PM 0
Share

This appears to be quite what i was looking for! The greyscaled image might not be as dark as it was with the default greyscale shader but that is a $$anonymous$$or issue. $$anonymous$$uch appreciated.

avatar image
1

Answer by Tim-Michels · Jun 25, 2012 at 10:32 AM

Here's the code for something I tried to get the effect you want. It's far from perfect, but I would really want you to try it out and let me know if its what you need.

When you create a material with this shader, you will have two sliders to tweak tresholds.

Cheers ;)

Shader

Shader "Custom/GreyRedScale" {

 Properties {
     _MainTex ("Base (RGB)", 2D) = "white" {}
     _RedPower ("Red Power", Range(0.001,1.0)) = 1.0
     _RedDelta ("Red Delta", Range(0.001,1.0)) = 1.0
 }
 SubShader {
     Tags { "RenderType"="Opaque" }
     LOD 200
     
     CGPROGRAM
     #pragma surface surf Lambert

     sampler2D _MainTex;
     float _RedPower;
     float _RedDelta;

     struct Input {
         float2 uv_MainTex;
     };

     void surf (Input IN, inout SurfaceOutput o) {
         half4 c = tex2D (_MainTex, IN.uv_MainTex);
         
         half avg = c.r + c.g + c.b;
         avg *= 0.333;
         half4 nC = half4(avg,avg,avg,c.a);
         
         half avg2 = c.g+c.b;
         avg2 *= 0.5;
         
         if(c.r > _RedPower && (c.r - avg2) > _RedDelta)
         {                
             nC.rgb = half3(c.r,avg2,avg2);
         }
         
         o.Albedo = nC.rgb;
         o.Alpha = c.a;
     }
     ENDCG
 } 
 FallBack "Diffuse"

}

Comment
Add comment · Show 2 · 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 yeoldesnake 1 · Jun 27, 2012 at 09:14 AM 0
Share

This appears to be quite a lovely material shader. However i was talking about a Post-Proccessing effect shader.

avatar image Deoxyz · Jun 27, 2012 at 10:18 AM 1
Share

I think it isn't that hard to create it from this shader.

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

Desaturating scene while leaving selected object fully saturated 0 Answers

Change specific vertex colours in a shader 0 Answers

Unlit greyscale shader 1 Answer

Shader for mesh that turns sprites behind it greyscale 0 Answers

Overlay that creates only black and white underneath. 3 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