|
|
|
|
|
|
#define SAMPLE_METALLICSPECULAR(uv) tex2D(_MetallicGlossMap, uv) |
|
|
|
#endif |
|
|
|
|
|
|
|
CBUFFER_START(MaterialProperties) |
|
|
|
half4 _MainTex_ST; |
|
|
|
sampler2D _MainTex; half4 _MainTex_ST; |
|
|
|
sampler2D _MetallicGlossMap; |
|
|
|
sampler2D _SpecGlossMap; |
|
|
|
sampler2D _BumpMap; |
|
|
|
sampler2D _OcclusionMap; |
|
|
|
sampler2D _EmissionMap; |
|
|
|
CBUFFER_END |
|
|
|
|
|
|
|
sampler2D _MainTex; |
|
|
|
sampler2D _MetallicGlossMap; |
|
|
|
sampler2D _SpecGlossMap; |
|
|
|
sampler2D _BumpMap; |
|
|
|
sampler2D _OcclusionMap; |
|
|
|
sampler2D _EmissionMap; |
|
|
|
|
|
|
|
struct LightweightVertexInput |
|
|
|
{ |
|
|
|
|
|
|
#endif |
|
|
|
half3 viewDir : TEXCOORD5; |
|
|
|
half4 fogFactorAndVertexLight : TEXCOORD6; // x: fogFactor, yzw: vertex light |
|
|
|
#if defined(EVALUATE_SH_VERTEX) || defined(EVALUATE_SH_MIXED) |
|
|
|
|
|
|
|
#ifndef LIGHTMAP_ON |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
|
|
|
// Material Property Helpers // |
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
|
|
|
inline half Alpha(half albedoAlpha) |
|
|
|
{ |
|
|
|
#if defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A) |
|
|
|
|
|
|
outSurfaceData.alpha = Alpha(albedoAlpha.a); |
|
|
|
} |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
|
|
|
// Vertex and Fragment functions // |
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
|
// Vertex: Used for Standard and StandardSimpleLighting shaders |
|
|
|
LightweightVertexOutput LitPassVertex(LightweightVertexInput v) |
|
|
|
{ |
|
|
|
LightweightVertexOutput o = (LightweightVertexOutput)0; |
|
|
|
|
|
|
o.uv01.zw = v.lightmapUV * unity_LightmapST.xy + unity_LightmapST.zw; |
|
|
|
#endif |
|
|
|
|
|
|
|
float3 positionWS = mul(unity_ObjectToWorld, v.vertex).xyz; |
|
|
|
half3 viewDirectionWS = SafeNormalize(_WorldSpaceCameraPos - positionWS); |
|
|
|
float4 positionWS = mul(unity_ObjectToWorld, v.vertex); |
|
|
|
half3 viewDirectionWS = SafeNormalize(_WorldSpaceCameraPos - positionWS.xyz); |
|
|
|
|
|
|
|
#if _NORMALMAP |
|
|
|
OutputTangentToWorld(v.tangent, v.normal, o.tangent, o.binormal, o.normal); |
|
|
|
|
|
|
|
|
|
|
float4 clipPos = UnityObjectToClipPos(v.vertex); |
|
|
|
float4 clipPos = mul(UNITY_MATRIX_VP, positionWS); |
|
|
|
#if defined(EVALUATE_SH_VERTEX) || defined(EVALUATE_SH_MIXED) |
|
|
|
#ifndef LIGHTMAP_ON |
|
|
|
o.fogFactorAndVertexLight.yzw = VertexLighting(positionWS, o.normal); |
|
|
|
o.fogFactorAndVertexLight.yzw = VertexLighting(positionWS.xyz, o.normal); |
|
|
|
o.fogFactorAndVertexLight.x = ComputeFogFactor(clipPos.z); |
|
|
|
o.clipPos = clipPos; |
|
|
|
|
|
|
|
|
|
|
// Used for Standard shader |
|
|
|
half4 LitPassFragment(LightweightVertexOutput IN) : SV_Target |
|
|
|
{ |
|
|
|
SurfaceData surfaceData; |
|
|
|
|
|
|
return OUTPUT_COLOR(color); |
|
|
|
} |
|
|
|
|
|
|
|
// Used for StandardSimpleLighting shader |
|
|
|
half4 LitPassFragmentSimple(LightweightVertexOutput IN) : SV_Target |
|
|
|
{ |
|
|
|
float2 uv = IN.uv01.xy; |
|
|
|