Created
January 25, 2019 14:42
-
-
Save sansuke05/574307be39ca73b553c232923a6f2afb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/Rainbow" { | |
Properties { | |
_BaseColor("Base Color", Color) = (0, 0, 0, 1) | |
_MaskTex("Mask Texture", 2D) = "white" {} | |
_Speed("Speed", Range( 0 , 3)) = 0.2 | |
_Value("Value", Range( 0 , 1)) = 0.5 | |
_Saturation("Saturation", Range( 0 , 1)) = 0.5 | |
} | |
SubShader { | |
Tags { | |
"RenderType" = "Opaque" | |
} | |
LOD 200 | |
CGPROGRAM | |
#pragma surface surf Standard fullforwardshadows | |
#pragma target 3.0 | |
struct Input { | |
float2 uv_MainTex; | |
}; | |
fixed4 _BaseColor; | |
sampler2D _MaskTex; | |
float _Speed; | |
float _Saturation; | |
float _Value; | |
float3 HSVToRGB( float3 c ) { | |
float4 K = float4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 ); | |
float3 p = abs( frac( c.xxx + K.xyz ) * 6.0 - K.www ); | |
return c.z * lerp( K.xxx, saturate( p - K.xxx ), c.y ); | |
} | |
void surf(Input IN, inout SurfaceOutputStandard o) { | |
float mulTime = _Time.y * _Speed; | |
float4 mask = tex2D(_MaskTex, IN.uv_MainTex); | |
//clip(mask.r - 0.5); // do not draw if mask.r is less than 0.5 | |
float3 col = HSVToRGB( float3(mulTime, _Saturation, _Value) ); | |
//o.Albedo = mask; | |
o.Albedo = _BaseColor; //* mask; | |
o.Emission = col * mask.rgb; | |
o.Alpha = 1; | |
} | |
ENDCG | |
} | |
Fallback "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment