- Home /
How can I use a "Specular" property with surface shaders using the Standard lighting model?
This thread suggests using "#define UNITY_SETUP_BRDF_INPUT SpecularSetup" to allow the use of SurfaceOutputStandard.Specular. However, when I uncomment the line that begins "o.Specular" in this shader:
 Shader "Custom/KarShaderHi" {
     Properties {
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _BumpMap ("Bumpmap", 2D) = "bump" {}
         _Colour1 ("Colour 1", Color) = ( 1, 1, 1, 1 )
         _Colour2 ("Colour 2", Color) = ( 1, 1, 1, 1 )
     }
     CGINCLUDE
         #define _GLOSSYENV 1
         #define UNITY_SETUP_BRDF_INPUT SpecularSetup
     ENDCG
     SubShader {
         Tags { "RenderType"="Opaque" }
         LOD 200
         
         CGPROGRAM
         #pragma target 3.0
         #include "UnityPBSLighting.cginc"
         #pragma surface surf Standard
 
         sampler2D _MainTex;
         sampler2D _BumpMap;
         float4 _Colour1;
         float4 _Colour2;
 
         struct Input {
             float2 uv_MainTex;
         };
 
         void surf (Input IN, inout SurfaceOutputStandard o) {
             half4 c = tex2D (_MainTex, IN.uv_MainTex);
             o.Albedo = c.a * (_Colour1.rgb * c.r + _Colour2.rgb * c.b);
             o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_MainTex));
             float shiny = 1.0 - c.a;
             o.Smoothness = 0.95;
             //o.Specular = _Colour1.rgb;
         }
         ENDCG
     } 
     FallBack "Diffuse"
 }
 
The material using it in Unity goes magenta (as is typical of shaders that cannot compile) and I get the error: "Shader error in 'Custom/KarShaderHi': expression left of ."Specular" is not a struct or array at line 36 (on d3d9)".
I've looked all over the place and can't find an answer. Can anyone tell me how I can change the specular colour in a surface shader using physically based shading?
Your answer
 
 
             Follow this Question
Related Questions
Sharp reflections despite material smoothness? 0 Answers
Light color in a fragment shader? 0 Answers
Metallic/Specular map broke fading in build 0 Answers
Simple Blinn Phong Surface Shader 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                