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 Angelorpheus · Jun 03, 2013 at 07:02 PM · shadercolorblend

how can i add color blend to Madfingers shader (making character flashing red when damaged)

hi :) i would like to add color blend with main texture to create the typical red flash when get damaged, using the free to use Madfinger shader ...i tried with no luck :/

this is my attempt..any suggestion?


 Shader "Mobile/BRDFLit (Supports Backlight, Shadowgun style Light Probes)" {
 Properties {
     _MainTex ("Base (RGB) Gloss (A)", 2D) = "grey" {}
     _BumpMap ("Normalmap", 2D) = "bump" {}
     _BRDFTex ("NdotL NdotH (RGBA)", 2D) = "white" {}
     _Color ("Main Color", Color) = (1,1,1,1)
     }    
 SubShader { 
     Tags { "RenderType"="Opaque" "LightMode"="ForwardBase" }
     LOD 400
     
     Pass{
             
             Material{
                 Diffuse [_Color]
             }
             
             
             SetTexture [_MainTex] { combine texture * primary Double, texture * primary}
             SetTexture [_Detail] { combine previous * texture Double, previous}
         }
     
     
     
     
     
     
 CGPROGRAM
 #pragma surface surf PseudoBRDF exclude_path:prepass vertex:separateSH nolightmap noforwardadd noambient approxview
 
 
 
 struct MySurfaceOutput {
     fixed3 Albedo;
     fixed3 Normal;
     fixed3 Emission;
     half Specular;
     fixed Gloss;
     fixed Alpha;
     fixed3 OcclusionAndAmbientLight;
 };
 
 sampler2D _BRDFTex;
 
 inline fixed4 LightingPseudoBRDF (MySurfaceOutput s, fixed3 lightDir, fixed3 viewDir, fixed atten)
 {
     // Half vector
     fixed3 halfDir = normalize (lightDir + viewDir);
     
     // N.L
     fixed NdotL = dot (s.Normal, lightDir);
     // N.H
     fixed NdotH = dot (s.Normal, halfDir);
     
     // remap N.L from [-1..1] to [0..1]
     // this way we can shade pixels facing away from the light - helps to simulate bounce lights
     fixed biasNdotL = NdotL * 0.5 + 0.5;
     
     // lookup light texture
     //  rgb = diffuse term
     //    a = specular term
     fixed4 l = tex2D (_BRDFTex, fixed2(biasNdotL, NdotH));
 
     fixed4 c;
     // mask specular term by Gloss factor
     // modulate specular with Albedo to allow metalic-ish look
     //
     // Shadowgun style: instead of adding LightProbes, treat them as both occlusion for MainLight and Ambient bounce
     // that is not physically correct, but it
     // 1) provides way to occlude MainLight without using runtime shadows
     // 2) allows bounce light to be affected by per-pixel normals
     // note that bounce lights becomes much weaker!
     c.rgb = s.OcclusionAndAmbientLight * s.Albedo * (l.rgb + s.Gloss * l.a) * 2;
     c.a = 0;
     
     return c;
 }
 
 
 sampler2D _MainTex;
 sampler2D _BumpMap;
 
 struct Input {
     float2 uv_MainTex;
     float2 uv_BumpMap;
     fixed3 shOcclusionAndAmbient;
 };
 
 void separateSH (inout appdata_full v, out Input o)
 {
     float3 worldN = mul ((float3x3)_Object2World, SCALED_NORMAL);
     o.shOcclusionAndAmbient = ShadeSH9 (float4(worldN,1.0));
 }
 
 void surf (Input IN, inout MySurfaceOutput o) {
     fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
     o.Albedo = tex.rgb;
     o.Gloss = tex.a;
     o.Alpha = tex.a;
     o.Normal = tex2D(_BumpMap, IN.uv_BumpMap).rgb * 2.0 - 1.0;
     o.OcclusionAndAmbientLight = IN.shOcclusionAndAmbient;
 }
 ENDCG
 
     }
 
 FallBack "Mobile/Diffuse"
 }
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

0 Replies

· Add your reply
  • Sort: 

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

14 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

Related Questions

Shader: Normal Angle 1 Answer

Material doesn't have a color property '_Color' 4 Answers

How do I invert the color of ui text to make it more readable, on a messy background? 4 Answers

UI Triangle Color picker 0 Answers

What is the correct way to mix colours in a surface shader? 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