Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
- // Alpha of color - intensity of mask
- Shader "Custom/Neon_height_hard_color2" {
- Properties {
- _MainTex ("Main texture", 2D) = "white" {}
- _SkinTex ("Mask texture", 2D) = "white" {}
- [Space]
- _EmissionMap("Emission map", 2D) = "black"{}
- [Space]
- _MainColor ("Main color (red)", Color) = (1,1,1,1)
- _AddColor ("Additional color (green)", Color) = (1,1,1,1)
- _ExtColor ("Extra color (blue)", Color) = (1,1,1,1)
- [Space]
- [Toggle] _Emission("Emission", Float) = 0
- [Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 //"Back"
- [Space]
- [HDR]_MinColor("Min color", Color) = (0,0,0,1)
- [Space]
- _MinY1("Min Y", Float) = 0.0
- _MaxY1("Max Y", Float) = 0.95
- [HDR]_MaxColor1("Max color 1", Color) = (0,1,1,1)
- [Space]
- _MinY2("Min Y", Float) = 0.0
- _MaxY2("Max Y", Float) = 0.95
- [HDR]_MaxColor2("Max color 2", Color) = (0,1,1,1)
- }
- SubShader {
- Cull [_Cull]
- Blend SrcAlpha OneMinusSrcAlpha
- Pass {
- CGPROGRAM
- #pragma fragment frag
- #pragma vertex vert
- #pragma multi_compile_fog
- #include "UnityCG.cginc"
- #include "UnityLightingCommon.cginc"
- sampler2D _MainTex;
- sampler2D _SkinTex;
- float4 _MainTex_ST;
- float4 _MainColor;
- float4 _AddColor;
- float4 _ExtColor;
- float _Emission;
- sampler2D _EmissionMap;
- float4 _MinColor;
- float _MinY1;
- float _MaxY1;
- float4 _MaxColor1;
- float _MinY2;
- float _MaxY2;
- float4 _MaxColor2;
- struct Interpolators {
- float4 position : SV_POSITION;
- float2 uv : TEXCOORD0;
- float2 uvSplat : TEXCOORD1;
- float3 normal : NORMAL;
- fixed4 diff : COLOR0; // diffuse lighting color
- fixed4 world : TEXCOORD2;
- UNITY_FOG_COORDS(3)
- };
- struct VertexData {
- float4 position : POSITION;
- float2 uv : TEXCOORD0;
- float3 normal : NORMAL;
- };
- Interpolators vert (VertexData v) {
- Interpolators i;
- i.position = UnityObjectToClipPos(v.position);
- i.uv = TRANSFORM_TEX(v.uv, _MainTex);
- i.uvSplat = v.uv;
- i.normal = UnityObjectToWorldNormal(v.normal);
- half nl = max(0, dot(i.normal, _WorldSpaceLightPos0.xyz));
- nl = clamp(nl, 0, 1);
- i.diff = lerp(unity_AmbientSky, _LightColor0 * nl, nl);
- //i.world = mul(unity_ObjectToWorld, v.position);
- i.world = mul(unity_ObjectToWorld, float4(0.0,0.0,0.0,1.0) );
- UNITY_TRANSFER_FOG(i, i.position);
- return i;
- }
- float4 frag(Interpolators i) : SV_TARGET{
- float4 splat = tex2D(_SkinTex, i.uvSplat);
- float3 tex = tex2D(_MainTex, i.uv);
- float4 color = float4(tex.rgb * (1 - splat.r - splat.g - splat.b) +
- lerp (tex.rgb, _MainColor.rgb, _MainColor.a) * splat.r +
- lerp (tex.rgb, _AddColor.rgb, _AddColor.a) * splat.g +
- lerp (tex.rgb, _ExtColor.rgb, _ExtColor.a) * splat.b, splat.a);
- color.rgb *= i.diff.rgb;
- fixed c1 = step(i.world.y, _MaxY1) * step(_MinY1, i.world.y);
- float h1 = step((i.world.y - _MinY1) / (_MaxY1 - _MinY1), 1.0);
- float3 emisColor1 = lerp(_MinColor, _MaxColor1, h1);
- fixed c2 = step(i.world.y, _MaxY2) * step(_MinY2, i.world.y);
- float h2 = step((i.world.y - _MinY2) / (_MaxY2 - _MinY2), 1.0);
- float3 emisColor2 = lerp(_MaxColor1, _MaxColor2, h2);
- float3 emisColor = emisColor1 * c1 + emisColor2 * c2 + _MaxColor2 * step(_MaxY2, i.world.y) + _MinColor * step(i.world.y, _MinY1);
- float h = step(i.world.y, _MinY1);
- float emisPower = lerp(0, _Emission, h);
- float3 emisG = tex2D(_EmissionMap, i.uv).g * emisPower;
- float3 emis = tex2D(_EmissionMap, i.uv).r;
- color.rgb = lerp(color.rgb, emisG * emisColor, emisG * _Emission);
- color.rgb = lerp(color.rgb, emis * emisColor, emis * _Emission);
- UNITY_APPLY_FOG(i.fogCoord, color);
- return color;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement