浏览代码

Added missing env BRDF surface reduction. Now BRDF matches reference image.

/RenderPassXR_Sandbox
Felipe Lira 7 年前
当前提交
ef02bc3e
共有 4 个文件被更改,包括 8 次插入12 次删除
  1. 5
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineBRDF.cginc
  2. 7
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandardShader.shader
  3. 4
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/024_Shader_PBRvalidation/Adam/Materials/Crowd_LOD0_Mat_Limbs.mat
  4. 4
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/024_Shader_PBRvalidation/Adam/Materials/Crowd_LOD0_Mat_Torso.mat

5
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineBRDF.cginc


#endif
}
half3 LightweightBRDFIndirect(half3 diffColor, half3 specColor, UnityIndirect indirect, half grazingTerm, half fresnelTerm)
half3 LightweightBRDFIndirect(half3 diffColor, half3 specColor, UnityIndirect indirect, float roughness, half grazingTerm, half fresnelTerm)
c += indirect.specular * lerp(specColor, grazingTerm, fresnelTerm);
float surfaceReduction = 1.0 / (roughness * roughness + 1.0);
c += surfaceReduction * indirect.specular * lerp(specColor, grazingTerm, fresnelTerm);
return c;
}

7
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandardShader.shader


half3 viewDir = normalize(_WorldSpaceCameraPos - worldPos);
o.viewDir.xyz = viewDir;
#ifndef _METALLICGLOSSMAP
o.viewDir.w = saturate(_Glossiness + MetallicSetup_Reflectivity()); // grazing term
#endif
half3 normal = normalize(UnityObjectToWorldNormal(v.normal));

#else
o.normal = normal;
#endif
o.posWS.w = Pow4(1 - saturate(dot(normal, viewDir))); // fresnel term
#if defined(_LIGHT_PROBES_ON) && !defined(LIGHTMAP_ON)
o.fogCoord.yzw += max(half3(0, 0, 0), ShadeSH9(half4(normal, 1)));

// grazingTerm = F90
half grazingTerm = saturate(smoothness + (1 - oneMinusReflectivity));
half fresnelTerm = Pow4(1.0 - saturate(dot(normal, i.viewDir.xyz)));
half3 color = LightweightBRDFIndirect(diffColor, specColor, indirectLight, grazingTerm, fresnelTerm);
half3 color = LightweightBRDFIndirect(diffColor, specColor, indirectLight, perceptualRoughness * perceptualRoughness, grazingTerm, fresnelTerm);
half3 lightDirection;
#ifndef _MULTIPLE_LIGHTS

4
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/024_Shader_PBRvalidation/Adam/Materials/Crowd_LOD0_Mat_Limbs.mat


m_PrefabInternal: {fileID: 0}
m_Name: Crowd_LOD0_Mat_Limbs
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_ON _METALLICSPECGLOSSMAP _METALLIC_SETUP _NORMALMAP
_SPECULARHIGHLIGHTS_ON
m_ShaderKeywords: _GLOSSYREFLECTIONS_ON _METALLICSPECGLOSSMAP _NORMALMAP _SPECULARHIGHLIGHTS_ON
_SPECULAR_SETUP
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

4
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/024_Shader_PBRvalidation/Adam/Materials/Crowd_LOD0_Mat_Torso.mat


m_PrefabInternal: {fileID: 0}
m_Name: Crowd_LOD0_Mat_Torso
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _EMISSION _GLOSSYREFLECTIONS_ON _METALLICSPECGLOSSMAP _METALLIC_SETUP
_NORMALMAP _SPECULARHIGHLIGHTS_ON
m_ShaderKeywords: _EMISSION _GLOSSYREFLECTIONS_ON _METALLICSPECGLOSSMAP _NORMALMAP
_SPECULARHIGHLIGHTS_ON _SPECULAR_SETUP
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

正在加载...
取消
保存