SupercyanShaderLighting.cginc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef SUPERCYAN_SHADING_LIGHTING_INCLUDED
  2. #define SUPERCYAN_SHADING_LIGHTING_INCLUDED
  3. static const half LightingSupercyanShadingSmoothMin = 0.3;
  4. static const half LightingSupercyanShadingSmoothMax = 0.5;
  5. static const half LightingSupercyanShadingSmoothPow = 0.5;
  6. static const half LightingSupercyanShadingRimStrength = 0.25;
  7. inline half GetMax(half3 color) {
  8. return max(color.g, max(color.r, color.b));
  9. }
  10. inline void LightingSupercyanShadingForward_GI(inout SurfaceOutput s, UnityGIInput data, inout UnityGI gi)
  11. {
  12. gi = UnityGlobalIllumination(data, 1.0, s.Normal);
  13. }
  14. inline half4 LightingSupercyanShadingForward(SurfaceOutput s, half3 viewDir, UnityGI gi) {
  15. UnityLight light = gi.light;
  16. half diffuse = max(0, min(dot(s.Normal, light.dir), GetMax(light.color)));
  17. half rim = (1 - dot(s.Normal, viewDir)) * diffuse;
  18. diffuse = pow(smoothstep(LightingSupercyanShadingSmoothMin, LightingSupercyanShadingSmoothMax, diffuse), LightingSupercyanShadingSmoothPow);
  19. rim = (pow(smoothstep(LightingSupercyanShadingSmoothMin, LightingSupercyanShadingSmoothMax, rim), LightingSupercyanShadingSmoothPow)) * LightingSupercyanShadingRimStrength;
  20. half4 c;
  21. c.rgb = s.Albedo * light.color * diffuse + rim * light.color;
  22. #ifdef UNITY_LIGHT_FUNCTION_APPLY_INDIRECT
  23. c.rgb += s.Albedo * gi.indirect.diffuse.rgb;
  24. #endif
  25. c.a = s.Alpha;
  26. return c;
  27. }
  28. #endif