89 lines
2.3 KiB
Plaintext
89 lines
2.3 KiB
Plaintext
![]() |
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||
|
|
||
|
Shader "MY/Mount Specular Alpha" {
|
||
|
Properties{
|
||
|
_Color("Main Color", Color) = (1,1,1,1)
|
||
|
[PowerSlider(5.0)] _Shininess("Shininess", Range(0.01, 1)) = 0.078125
|
||
|
_ReflectColor("Reflection Color", Color) = (1,1,1,0.5)
|
||
|
_MainTex("Base (RGB) RefStrGloss (A)", 2D) = "white" {}
|
||
|
_Cube("Reflection Cubemap", Cube) = "" {}
|
||
|
_SpecTex("SpecTex", 2D) = "white" {}
|
||
|
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
|
||
|
}
|
||
|
|
||
|
SubShader{
|
||
|
Tags { "RenderType" = "Opaque" }
|
||
|
LOD 400
|
||
|
CGPROGRAM
|
||
|
#pragma surface surf SimpleSpecular alphatest:_Cutoff finalcolor:mycolor exclude_path:deferred exclude_path:prepass nometa nolightmap nofog keepalpha noforwardadd
|
||
|
#pragma target 3.0
|
||
|
|
||
|
sampler2D _MainTex;
|
||
|
sampler2D _SpecTex;
|
||
|
samplerCUBE _Cube;
|
||
|
|
||
|
fixed4 _Color;
|
||
|
fixed4 _ReflectColor;
|
||
|
half _Shininess;
|
||
|
|
||
|
struct Input {
|
||
|
float2 uv_MainTex;
|
||
|
float2 uv_SpecTex;
|
||
|
float3 worldRefl;
|
||
|
INTERNAL_DATA
|
||
|
};
|
||
|
|
||
|
struct SurfaceOutput1
|
||
|
{
|
||
|
fixed3 Albedo; // diffuse color
|
||
|
fixed3 Normal; // tangent space normal, if written
|
||
|
fixed3 Emission; //
|
||
|
half3 Specular; // specular power in 0..1 range
|
||
|
fixed Gloss; // specular intensity
|
||
|
fixed Unlit;
|
||
|
fixed Alpha; // alpha for transparencies
|
||
|
};
|
||
|
|
||
|
half4 LightingSimpleSpecular(SurfaceOutput1 s, half3 lightDir, half3 viewDir, half atten)
|
||
|
{
|
||
|
half3 h = normalize(lightDir + viewDir);
|
||
|
|
||
|
half diff = max(0, dot(s.Normal, lightDir));
|
||
|
|
||
|
float nh = max(0, dot(s.Normal, h));
|
||
|
float spec = pow(nh, s.Specular*128.0) * s.Gloss;
|
||
|
|
||
|
half4 c;
|
||
|
c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec)* atten;
|
||
|
|
||
|
c.rgb = lerp(c.rgb, s.Albedo, s.Unlit);
|
||
|
c.a = s.Alpha;
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
void mycolor(Input IN, SurfaceOutput1 o, inout fixed4 color)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
void surf(Input IN, inout SurfaceOutput1 o) {
|
||
|
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
|
||
|
fixed4 c = tex * _Color;
|
||
|
o.Albedo = c.rgb;
|
||
|
|
||
|
o.Gloss = tex.a;
|
||
|
o.Specular = _Shininess;
|
||
|
fixed4 spec = tex2D(_SpecTex, IN.uv_SpecTex);
|
||
|
o.Unlit = 1 - spec.r;
|
||
|
|
||
|
fixed4 reflcol = texCUBE(_Cube, IN.worldRefl);
|
||
|
reflcol *= spec.r;
|
||
|
o.Emission = reflcol.rgb * _ReflectColor.rgb * _ReflectColor.a * 5.0;
|
||
|
o.Alpha = tex.a;
|
||
|
}
|
||
|
ENDCG
|
||
|
}
|
||
|
|
||
|
FallBack "Transparent/Cutout/Diffuse"
|
||
|
}
|