Синтаксис:
Используется glsl
Shader "hair_last"
{
Properties
{
_Color1("_Color1", Color) = (0,0,0,1)
_Color2("_Color2", Color) = (0,0,0,1)
_Diffuse("_Diffuse", 2D) = "black" {}
_Specular("_Specular", 2D) = "black" {}
_SpecularPow("_SpecularPow", Range(0,5) ) = 5
_Glossy("_Glossy", Range(0,1) ) = 0.135
_NormalBump("_NormalBump", 2D) = "black" {}
_Reflection("_Reflection", Cube) = "black" {}
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="False"
"RenderType"="Transparent"
}
Cull Back
ZWrite On
ZTest LEqual
ColorMask RGBA
Blend SrcAlpha OneMinusSrcAlpha
Fog{
}
CGPROGRAM
#pragma surface surf BlinnPhongEditor alpha decal:blend vertex:vert
#pragma target 3.0
float4 _Color1;
float4 _Color2;
sampler2D _Diffuse;
sampler2D _Specular;
float _SpecularPow;
float _Glossy;
sampler2D _NormalBump;
samplerCUBE _Reflection;
struct EditorSurfaceOutput {
half3 Albedo;
half3 Normal;
half3 Emission;
half3 Gloss;
half Specular;
half Alpha;
half4 Custom;
};
inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
{
half3 spec = light.a * s.Gloss;
half4 c;
c.rgb = (s.Albedo * light.rgb + light.rgb * spec);
c.a = s.Alpha;
return c;
}
inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
{
half3 h = normalize (lightDir + viewDir);
half diff = max (0, dot ( lightDir, s.Normal ));
float nh = max (0, dot (s.Normal, h));
float spec = pow (nh, s.Specular*128.0);
half4 res;
res.rgb = _LightColor0.rgb * diff;
res.w = spec * Luminance (_LightColor0.rgb);
res *= atten * 2.0;
return LightingBlinnPhongEditor_PrePass( s, res );
}
struct Input {
float2 uv_Diffuse;
float3 simpleWorldRefl;
float3 viewDir;
float2 uv_NormalBump;
float2 uv_Specular;
};
void vert (inout appdata_full v, out Input o) {
float4 VertexOutputMaster0_0_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
o.simpleWorldRefl = -reflect( normalize(WorldSpaceViewDir(v.vertex)), normalize(mul((float3x3)_Object2World, SCALED_NORMAL)));
}
void surf (Input IN, inout EditorSurfaceOutput o) {
o.Normal = float3(0.0,0.0,1.0);
o.Alpha = 1.0;
o.Albedo = 0.0;
o.Emission = 0.0;
o.Gloss = 0.0;
o.Specular = 0.0;
o.Custom = 0.0;
float4 Sampled2D0=tex2D(_Diffuse,IN.uv_Diffuse.xy);
float4 Lerp0=lerp(_Color1,_Color2,Sampled2D0);
float4 TexCUBE0=texCUBE(_Reflection,float4( IN.simpleWorldRefl.x, IN.simpleWorldRefl.y,IN.simpleWorldRefl.z,1.0 ));
float4 Tex2DNormal0=float4(UnpackNormal( tex2D(_NormalBump,(IN.uv_NormalBump.xyxy).xy)).xyz, 1.0 );
float4 Fresnel0=(1.0 - dot( normalize( float4( IN.viewDir.x, IN.viewDir.y,IN.viewDir.z,1.0 ).xyz), normalize( Tex2DNormal0.xyz ) )).xxxx;
float4 Multiply4=Fresnel0 * float4( 3,3,3,3 );
float4 Multiply2=TexCUBE0 * Multiply4;
float4 Multiply3=Multiply2 * float4( 1,1,1,1 );
float4 Sampled2D1=tex2D(_Specular,IN.uv_Specular.xy);
float4 Multiply6=Sampled2D1 * float4( 1.5,1.5,1.5,1.5 );
float4 Multiply5=Multiply3 * Multiply6;
float4 Add0=Lerp0 + Multiply5;
float4 Multiply1=Sampled2D1 * _Glossy.xxxx;
float4 Multiply0=Sampled2D1 * _SpecularPow.xxxx;
float4 Master0_2_NoInput = float4(0,0,0,0);
float4 Master0_7_NoInput = float4(0,0,0,0);
float4 Master0_6_NoInput = float4(1,1,1,1);
o.Albedo = Add0;
o.Normal = Tex2DNormal0;
o.Specular = Multiply1;
o.Gloss = Multiply0;
o.Alpha = Sampled2D0.aaaa;
o.Normal = normalize(o.Normal);
}
ENDCG
}
Fallback "Diffuse"
}
{
Properties
{
_Color1("_Color1", Color) = (0,0,0,1)
_Color2("_Color2", Color) = (0,0,0,1)
_Diffuse("_Diffuse", 2D) = "black" {}
_Specular("_Specular", 2D) = "black" {}
_SpecularPow("_SpecularPow", Range(0,5) ) = 5
_Glossy("_Glossy", Range(0,1) ) = 0.135
_NormalBump("_NormalBump", 2D) = "black" {}
_Reflection("_Reflection", Cube) = "black" {}
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="False"
"RenderType"="Transparent"
}
Cull Back
ZWrite On
ZTest LEqual
ColorMask RGBA
Blend SrcAlpha OneMinusSrcAlpha
Fog{
}
CGPROGRAM
#pragma surface surf BlinnPhongEditor alpha decal:blend vertex:vert
#pragma target 3.0
float4 _Color1;
float4 _Color2;
sampler2D _Diffuse;
sampler2D _Specular;
float _SpecularPow;
float _Glossy;
sampler2D _NormalBump;
samplerCUBE _Reflection;
struct EditorSurfaceOutput {
half3 Albedo;
half3 Normal;
half3 Emission;
half3 Gloss;
half Specular;
half Alpha;
half4 Custom;
};
inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
{
half3 spec = light.a * s.Gloss;
half4 c;
c.rgb = (s.Albedo * light.rgb + light.rgb * spec);
c.a = s.Alpha;
return c;
}
inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
{
half3 h = normalize (lightDir + viewDir);
half diff = max (0, dot ( lightDir, s.Normal ));
float nh = max (0, dot (s.Normal, h));
float spec = pow (nh, s.Specular*128.0);
half4 res;
res.rgb = _LightColor0.rgb * diff;
res.w = spec * Luminance (_LightColor0.rgb);
res *= atten * 2.0;
return LightingBlinnPhongEditor_PrePass( s, res );
}
struct Input {
float2 uv_Diffuse;
float3 simpleWorldRefl;
float3 viewDir;
float2 uv_NormalBump;
float2 uv_Specular;
};
void vert (inout appdata_full v, out Input o) {
float4 VertexOutputMaster0_0_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
o.simpleWorldRefl = -reflect( normalize(WorldSpaceViewDir(v.vertex)), normalize(mul((float3x3)_Object2World, SCALED_NORMAL)));
}
void surf (Input IN, inout EditorSurfaceOutput o) {
o.Normal = float3(0.0,0.0,1.0);
o.Alpha = 1.0;
o.Albedo = 0.0;
o.Emission = 0.0;
o.Gloss = 0.0;
o.Specular = 0.0;
o.Custom = 0.0;
float4 Sampled2D0=tex2D(_Diffuse,IN.uv_Diffuse.xy);
float4 Lerp0=lerp(_Color1,_Color2,Sampled2D0);
float4 TexCUBE0=texCUBE(_Reflection,float4( IN.simpleWorldRefl.x, IN.simpleWorldRefl.y,IN.simpleWorldRefl.z,1.0 ));
float4 Tex2DNormal0=float4(UnpackNormal( tex2D(_NormalBump,(IN.uv_NormalBump.xyxy).xy)).xyz, 1.0 );
float4 Fresnel0=(1.0 - dot( normalize( float4( IN.viewDir.x, IN.viewDir.y,IN.viewDir.z,1.0 ).xyz), normalize( Tex2DNormal0.xyz ) )).xxxx;
float4 Multiply4=Fresnel0 * float4( 3,3,3,3 );
float4 Multiply2=TexCUBE0 * Multiply4;
float4 Multiply3=Multiply2 * float4( 1,1,1,1 );
float4 Sampled2D1=tex2D(_Specular,IN.uv_Specular.xy);
float4 Multiply6=Sampled2D1 * float4( 1.5,1.5,1.5,1.5 );
float4 Multiply5=Multiply3 * Multiply6;
float4 Add0=Lerp0 + Multiply5;
float4 Multiply1=Sampled2D1 * _Glossy.xxxx;
float4 Multiply0=Sampled2D1 * _SpecularPow.xxxx;
float4 Master0_2_NoInput = float4(0,0,0,0);
float4 Master0_7_NoInput = float4(0,0,0,0);
float4 Master0_6_NoInput = float4(1,1,1,1);
o.Albedo = Add0;
o.Normal = Tex2DNormal0;
o.Specular = Multiply1;
o.Gloss = Multiply0;
o.Alpha = Sampled2D0.aaaa;
o.Normal = normalize(o.Normal);
}
ENDCG
}
Fallback "Diffuse"
}