Question by
zhenghzzz · Dec 01, 2015 at 03:58 AM ·
surface shadersurfaceshader
A strange problem when I wrote a simple surfaceshader using Occlusion
Here is my surf function:
void surf (Input IN, inout SurfaceOutputStandardSpecular o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Specular = tex2D (_SpecGlossMap, IN.uv_SpecGlossMap);
o.Smoothness = _Glossiness;
half occ = tex2D(_OcclusionMap, IN.uv2_OcclusionMap).g;
half oneMinusT = 1 - _OcclusionStrength;
o.Occlusion = saturate(oneMinusT + occ * _OcclusionStrength);
//Magic?????????
half noMatterWhat = 10000;
if (o.Occlusion == noMatterWhat)
{
o.Albedo = o.Albedo;
}
//End
o.Emission = _EmissionColor;
float4 packedNormal = tex2D(_BumpMap, IN.uv_BumpMap);
o.Normal = UnpackNormal(packedNormal);
o.Alpha = c.a;
}
If I delete the "Magic" part, the model becomes tatolly dark.The param "noMatterWhat" could be any number, it works. As you can see, the "Magic" part actually does not play any role. But why this happens?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612050941im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Surface shader, too many samplers workaround 1 Answer
Additive Blending Shader for Mobile - parse error 1 Answer
Procedural Terrain Generation: How can I make different terrain types? 1 Answer
Wrong normals when object is rotated and using custom world aligned shader? 4 Answers
Execute UnityObjectToClipPos() once in surface shader? 2 Answers