Shader "UTK/StandardSample" { Properties { _TintColor("TintColor", Color) = (1,1,1,1) _MainTex("Albedo(RGB)", 2D) = "white" {} [Normal][NoScaleOffset]_BumpMap("Normal Texture", 2D) = "Bump" {} _NormalInten("Noraml Intensity", Range(0,2)) = 0
_Metallic("Metallic", Range(0,1)) = 0 _Smoothness("Smoothness", Range(0,1)) = 0.5
_Occlusion("Occlusion", 2D) = "white" {} _OcInten("Occlusion Intensity", Range(0,1)) = 1 [Space(15)][Enum(UnityEngine.Rendering.CullMode)]_CullMode("CullMode", Float) = 0
[KeywordEnum(BRDF1, BRDF2, BRDF3)] _BRDF("Unity BRDF select", Float) = 0 }
SubShader {
Tags{"IgnoreProjector" = "True" "Render Type" = "Opaque" "Queue" = "Geometry"} Blend off Cull[_CullMode] CGPROGRAM
#pragma surface surf StandardCustom fullforwardshadows #pragma target 3.0
#pragma shader_feature _BRDF_BRDF1 _BRDF_BRDF2 _BRDF_BRDF3 #include "UnityPBSLighting.cginc" #include "AutoLight.cginc"
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _Occlusion;
half _NormalInten;
half _Metallic, _Smoothness, _OcInten;
fixed4 _TintColor;
struct Input { float2 uv_MainTex; };
void surf(Input IN, inout SurfaceOutputStandard o) { fixed4 c = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = c.rgb * _TintColor; o.Normal = UnpackScaleNormal(tex2D(_BumpMap, IN.uv_MainTex), _NormalInten); o.Metallic = _Metallic; o.Smoothness = _Metallic; o.Occlusion = tex2D(_Occlusion, IN.uv_MainTex).r * _OcInten; o.Alpha = 1; }
inline half4 LightingStandardCustom(SurfaceOutputStandard s, half3 viewDir, UnityGI gi) { s.Normal = normalize(s.Normal);
half oneMinusReflectivity; half3 specColor; s.Albedo = DiffuseAndSpecularFromMetallic (s.Albedo, s.Metallic, /*out*/ specColor, /*out*/ oneMinusReflectivity); // shader relies on pre-multiply alpha-blend (_SrcBlend = One, _DstBlend = OneMinusSrcAlpha) // this is necessary to handle transparency in physically correct way - only diffuse component gets affected by alpha half outputAlpha;
s.Albedo = PreMultiplyAlpha (s.Albedo, s.Alpha, oneMinusReflectivity, /*out*/ outputAlpha);
// half3 lightData = half3(0, 0, 0); #if _BRDF_BRDF1 half4 c = BRDF1_Unity_PBS(s.Albedo, specColor, oneMinusReflectivity, s.Smoothness, s.Normal, viewDir, gi.light, gi.indirect); #elif _BRDF_BRDF2 half4 c = BRDF2_Unity_PBS(s.Albedo, specColor, oneMinusReflectivity, s.Smoothness, s.Normal, viewDir, gi.light, gi.indirect); #elif _BRDF_BRDF3 half4 c = BRDF3_Unity_PBS(s.Albedo, specColor, oneMinusReflectivity, s.Smoothness, s.Normal, viewDir, gi.light, gi.indirect); #endif
// half3 lighting = saturate(lightData); // c.rgb = c.rgb + gi.light.color * lighting; c.a = outputAlpha; return c; }
inline void LightingStandardCustom_GI(SurfaceOutputStandard s, UnityGIInput data, inout UnityGI gi) { gi = UnityGlobalIllumination(data, s.Occlusion, s.Normal); }
ENDCG }
Fallback "Standard"
}
|