summaryrefslogtreecommitdiff
path: root/Assets/ProFlares/Shaders/ProFlaresBumpSpecShader.shader
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/ProFlares/Shaders/ProFlaresBumpSpecShader.shader')
-rw-r--r--Assets/ProFlares/Shaders/ProFlaresBumpSpecShader.shader95
1 files changed, 95 insertions, 0 deletions
diff --git a/Assets/ProFlares/Shaders/ProFlaresBumpSpecShader.shader b/Assets/ProFlares/Shaders/ProFlaresBumpSpecShader.shader
new file mode 100644
index 0000000..53e61f1
--- /dev/null
+++ b/Assets/ProFlares/Shaders/ProFlaresBumpSpecShader.shader
@@ -0,0 +1,95 @@
+Shader "ProFlares/Demo/Bumped Specular" {
+
+Properties {
+ _Color ("Main Color", Color) = (1,1,1,1)
+ _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
+ _SpecPower ("SpecPower", Range (0.03, 2)) = 0.078125
+ _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
+ _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
+ _SpecTex ("Spec ", 2D) = "white" {}
+ _BumpMap ("Normalmap", 2D) = "bump" {}
+}
+SubShader {
+ Tags { "RenderType"="Opaque" }
+ LOD 400
+
+CGPROGRAM
+#pragma surface surf BlinnPhongExtra addshadow
+
+
+sampler2D _MainTex;
+sampler2D _SpecTex;
+sampler2D _BumpMap;
+fixed4 _Color;
+half _SpecPower;
+half _Shininess;
+
+struct Input {
+ float2 uv_MainTex;
+ float2 uv_BumpMap;
+ fixed4 color : COLOR;
+};
+
+half4 LightingBlinnPhongExtra (SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
+{
+ half3 h = normalize (lightDir + viewDir);
+
+ fixed 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;
+
+ fixed4 c;
+ c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * _SpecColor.rgb * spec) * (atten * 2);
+ c.a = s.Alpha + _LightColor0.a * _SpecColor.a * spec * atten;
+ return c;
+}
+
+
+inline fixed4 LightingBlinnPhongExtra_PrePass (SurfaceOutput s, half4 light)
+{
+ fixed spec = light.a * s.Gloss;
+
+ fixed4 c;
+ c.rgb = (s.Albedo * light.rgb + light.rgb * _SpecColor.rgb * spec);
+ c.a = s.Alpha + spec * _SpecColor.a;
+ return c;
+}
+
+inline half4 LightingBlinnPhongExtra_DirLightmap (SurfaceOutput s, fixed4 color, fixed4 scale, half3 viewDir, bool surfFuncWritesNormal, out half3 specColor)
+{
+ UNITY_DIRBASIS
+ half3 scalePerBasisVector;
+
+ half3 lm = DirLightmapDiffuse (unity_DirBasis, color, scale, s.Normal, surfFuncWritesNormal, scalePerBasisVector);
+
+ half3 lightDir = normalize (scalePerBasisVector.x * unity_DirBasis[0] + scalePerBasisVector.y * unity_DirBasis[1] + scalePerBasisVector.z * unity_DirBasis[2]);
+ half3 h = normalize (lightDir + viewDir);
+
+ float nh = max (0, dot (s.Normal, h));
+ float spec = pow (nh, s.Specular * 128.0);
+
+ // specColor used outside in the forward path, compiled out in prepass
+ specColor = lm * _SpecColor.rgb * s.Gloss * spec;
+
+ // spec from the alpha component is used to calculate specular
+ // in the Lighting*_Prepass function, it's not used in forward
+ return half4(lm, spec);
+}
+
+
+
+void surf (Input IN, inout SurfaceOutput o) {
+ fixed4 tex = tex2D(_MainTex, IN.uv_MainTex)*IN.color;
+ fixed4 spec = tex2D(_SpecTex, IN.uv_MainTex)*IN.color;
+ o.Albedo = tex.rgb * _Color.rgb;
+ o.Gloss = spec.r;
+ o.Alpha = tex.a * _Color.a;
+ o.Specular = tex.a;//_Shininess*_SpecPower;
+ o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
+}
+ENDCG
+}
+
+FallBack "Specular"
+} \ No newline at end of file