|
|
|
|
|
|
HLSLPROGRAM |
|
|
|
// Required to compile gles 2.0 with standard srp library |
|
|
|
#pragma prefer_hlslcc gles |
|
|
|
#pragma target 3.0 |
|
|
|
#pragma target 2.0 |
|
|
|
|
|
|
|
// ------------------------------------- |
|
|
|
// Lightweight Pipeline keywords |
|
|
|
|
|
|
struct GraphVertexOutput |
|
|
|
{ |
|
|
|
float4 clipPos : SV_POSITION; |
|
|
|
float4 lightmapUVOrVertexSH : TEXCOORD0; |
|
|
|
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 0); |
|
|
|
half4 fogFactorAndVertexLight : TEXCOORD1; // x: fogFactor, yzw: vertex light |
|
|
|
float4 shadowCoord : TEXCOORD2; |
|
|
|
${Interpolators} |
|
|
|
|
|
|
// We either sample GI from lightmap or SH. lightmap UV and vertex SH coefficients |
|
|
|
// are packed in lightmapUVOrVertexSH to save interpolator. |
|
|
|
// The following funcions initialize |
|
|
|
OUTPUT_LIGHTMAP_UV(v.texcoord1, unity_LightmapST, o.lightmapUVOrVertexSH); |
|
|
|
OUTPUT_SH(lwWNormal, o.lightmapUVOrVertexSH); |
|
|
|
OUTPUT_LIGHTMAP_UV(v.texcoord1, unity_LightmapST, o.lightmapUV); |
|
|
|
OUTPUT_SH(lwWNormal, o.vertexSH); |
|
|
|
|
|
|
|
half3 vertexLight = VertexLighting(lwWorldPos, lwWNormal); |
|
|
|
half fogFactor = ComputeFogFactor(clipPos.z); |
|
|
|
|
|
|
#ifdef _NORMALMAP |
|
|
|
inputData.normalWS = TangentToWorldNormal(Normal, WorldSpaceTangent, WorldSpaceBiTangent, WorldSpaceNormal); |
|
|
|
#else |
|
|
|
#if !SHADER_HINT_NICE_QUALITY |
|
|
|
inputData.normalWS = WorldSpaceNormal; |
|
|
|
#else |
|
|
|
#endif |
|
|
|
#ifdef SHADER_API_MOBILE |
|
|
|
#if !SHADER_HINT_NICE_QUALITY |
|
|
|
// viewDirection should be normalized here, but we avoid doing it as it's close enough and we save some ALU. |
|
|
|
inputData.viewDirectionWS = WorldSpaceViewDirection; |
|
|
|
#else |
|
|
|
|
|
|
|
|
|
|
inputData.fogCoord = IN.fogFactorAndVertexLight.x; |
|
|
|
inputData.vertexLighting = IN.fogFactorAndVertexLight.yzw; |
|
|
|
inputData.bakedGI = SampleGI(IN.lightmapUVOrVertexSH, inputData.normalWS); |
|
|
|
inputData.bakedGI = SAMPLE_GI(IN.lightmapUV, IN.vertexSH, inputData.normalWS); |
|
|
|
|
|
|
|
half4 color = LightweightFragmentPBR( |
|
|
|
inputData, |
|
|
|