浏览代码

Fixed GI in unlit shader. Removed SampleGI function overloads as it's error prone due to implicit truncation.

/tag-1.1.4-preview
Felipe Lira 6 年前
当前提交
59a13656
共有 2 个文件被更改,包括 6 次插入15 次删除
  1. 13
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl
  2. 8
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardUnlit.shader

13
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl


// If lightmap: sampleData.xy = lightmapUV
// If probe: sampleData.xyz = L2 SH terms
#ifdef LIGHTMAP_ON
#define SAMPLE_GI(lmName, shName, normalWSName) SampleGI(lmName, normalWSName)
half3 SampleGI(float2 sampleData, half3 normalWS)
{
return SampleLightmap(sampleData, normalWS);
}
#define SAMPLE_GI(lmName, shName, normalWSName) SampleLightmap(lmName, normalWSName)
#define SAMPLE_GI(lmName, shName, normalWSName) SampleGI(shName, normalWSName)
half3 SampleGI(half3 sampleData, half3 normalWS)
{
// If lightmap is not enabled we sample GI from SH
return SampleSHPixel(sampleData, normalWS);
}
#define SAMPLE_GI(lmName, shName, normalWSName) SampleSHPixel(shName, normalWSName)
#endif
half3 GlossyEnvironmentReflection(half3 reflectVector, half perceptualRoughness, half occlusion)

8
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardUnlit.shader


{
float3 uv0AndFogCoord : TEXCOORD0; // xy: uv0, z: fogCoord
#if _SAMPLE_GI
float4 lightmapOrVertexSH : TEXCOORD1;
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 1);
half3 normal : TEXCOORD2;
#if _NORMALMAP
half3 tangent : TEXCOORD3;

#if _SAMPLE_GI
OUTPUT_NORMAL(v, o);
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapOrVertexSH.xy);
OUTPUT_SH(o.normal, o.lightmapOrVertexSH);
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapUV);
OUTPUT_SH(o.normal, o.vertexSH);
#endif
return o;
}

#else
half3 normalWS = normalize(IN.normal);
#endif
color *= SampleGI(IN.lightmapOrVertexSH, normalWS);
color += SAMPLE_GI(IN.lightmapUV, IN.vertexSH, normalWS);
#endif
ApplyFog(color, IN.uv0AndFogCoord.z);

正在加载...
取消
保存