Quantcast
Channel: Latest Questions by PokeJoe
Viewing all articles
Browse latest Browse all 20

Trying to implement specularity in my shader, but getting apparent type mismatches

$
0
0
I am brand new to writing shaders, so I am mostly copy+pasting from examples at this point. But I successfully implemented a rim lighting shader, and a rim lighting shader that takes into account a bump map. However, I am getting unexpected type-mismatch errors when I try to implement specularity. Material doesn't have a color property '_SpecColor' UnityEditor.MaterialEditor:OnSelectedShaderPopup(String, Shader) Material doesn't have a float or range property '_Shininess' UnityEditor.MaterialEditor:OnSelectedShaderPopup(String, Shader) Material doesn't have a color property '_RimColor' UnityEditor.MaterialEditor:OnSelectedShaderPopup(String, Shader) Material doesn't have a float or range property '_RimPower' UnityEditor.MaterialEditor:OnSelectedShaderPopup(String, Shader) Here is the (incomplete) code. Shader "Falloff/FalloffSpecular" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0) _RimPower ("Rim Power", Range(0.5,8.0)) = 3.0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf BlinnPhong sampler2D _MainTex; float4 _SpecColor; half _Shininess; float4 _RimColor; float _RimPower; struct Input { float2 uv_MainTex; float3 viewDir; }; void surf (Input IN, inout SurfaceOutput o) { half4 c = tex2D (_MainTex, IN.uv_MainTex); o.Albedo = c.rgb; o.Alpha = c.a; half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal)); o.Emission = _RimColor.rgb * pow (rim, _RimPower); } ENDCG } FallBack "Specular" }

Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>