Advertisement
Malzar

BurnShader

Dec 27th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Malzar/BurnEffect"
  2. {
  3.     Properties
  4.     {
  5.         [Header(Glow)]
  6.         [HDR]_GlowColor ("Glow Color", Color) = (1,1,1,1)
  7.         _GlowRange("Range", Range(0, 0.5)) = 0.1
  8.         _GlowFalloff("Falloff", Range(0.0001, 1)) = 0.1
  9.         [Header(Incandescent)]
  10.         [HDR]_IncandescentColor ("Incandescent color", Color) = (1,1,1,1)
  11.         _Amplitude("Speed", Range (0,1))= 0.5
  12.         //_DisplacementX("Dissplacement x", Range (0,1))= 1        
  13.         //_DisplacementY("Disslacement y", Range (0,1))= 1
  14.         [Header(Dissolved)]
  15.         _DissolvedTex("Dissolved texture (B/W)", 2D)="wite" {}
  16.         _DissolveAmount("Dissolve amount", Range(0,1)) = 1
  17.         [Header(Standar)]
  18.         _Color ("Color", Color) = (1,1,1,1)
  19.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
  20.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
  21.         _Metallic ("Metallic", Range(0,1)) = 0.0
  22.     }
  23.     SubShader
  24.     {
  25.         Tags { "RenderType"="Opaque" }
  26.         LOD 200
  27.         Cull Off
  28.         CGPROGRAM
  29.         // Physically based Standard lighting model, and enable shadows on all light types
  30.         #pragma surface surf Standard fullforwardshadows
  31.  
  32.         // Use shader model 3.0 target, to get nicer looking lighting
  33.         #pragma target 3.0
  34.  
  35.  
  36.         struct Input
  37.         {
  38.             float2 uv_MainTex;
  39.             float2 uv_DissolvedTex;
  40.             float3 worldPos;
  41.         };
  42.         sampler2D _MainTex;
  43.         sampler2D _DissolvedTex;
  44.  
  45.         fixed3 _GlowColor;
  46.         fixed3 _IncandescentColor;
  47.         half _DissolveAmount;
  48.         float _GlowRange;
  49.         float _GlowFalloff;
  50.         float _Amplitude;
  51.        // half _DisplacementX;
  52.         //half _DisplacementY;
  53.        
  54.         fixed4 _Color;
  55.         half _Glossiness;
  56.         half _Metallic;
  57.  
  58.  
  59.         void surf (Input IN, inout SurfaceOutputStandard o)
  60.         {
  61.             // Albedo comes from a texture tinted by color
  62.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
  63.             //Dissolver
  64.             fixed4 dissolve = tex2D(_DissolvedTex,IN.uv_DissolvedTex);
  65.             dissolve *=0.9999;
  66.             float invisible = dissolve.x - _DissolveAmount;            
  67.             clip(invisible);
  68.             o.Albedo = c.rgb;
  69.             // Metallic and smoothness come from slider variables
  70.             o.Metallic = _Metallic;
  71.             o.Smoothness = _Glossiness;
  72.             o.Alpha = c.a;
  73.             //incandescent      
  74.             float glow = smoothstep(_GlowRange+_GlowFalloff,_GlowRange,invisible);
  75.             // float IglowV = (cos((IN.worldPos.x*_Amplitude)+_SinTime.w*_DisplacementX)+1)*0.5;
  76.             // float IglowH = (sin((IN.worldPos.x*_Amplitude)+_CosTime.w*_DisplacementY)+1)*0.5;            
  77.             //float Incandescent = max((IglowV-IglowH)*glow,0);
  78.  
  79.             float IglowV = _Time.y*_Amplitude;
  80.             float IglowH = _SinTime.w*_Amplitude;
  81.             float Ivalue = tex2D(_DissolvedTex,float2(IN.uv_DissolvedTex.x+IglowH,IN.uv_DissolvedTex.y+IglowV)).x;
  82.             float Incandescent = max((Ivalue)*glow,0);
  83.  
  84.             o.Emission = Incandescent*_IncandescentColor+glow*_GlowColor;
  85.         }
  86.         ENDCG
  87.     }
  88.     FallBack "Diffuse"
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement