浏览代码

More fix

/main
Sebastien Lagarde 6 年前
当前提交
e5417732
共有 3 个文件被更改,包括 11 次插入5 次删除
  1. 5
      com.unity.render-pipelines.core/CoreRP/ShaderLibrary/CommonMaterial.hlsl
  2. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl
  3. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/NormalBuffer.hlsl

5
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/CommonMaterial.hlsl


return sqrt(roughness);
}
real RoughnessToPerceptualSmoothness(real roughness)
{
return 1.0 - sqrt(roughness);
}
real PerceptualSmoothnessToRoughness(real perceptualSmoothness)
{
return (1.0 - perceptualSmoothness) * (1.0 - perceptualSmoothness);

9
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl


#define CLEAR_COAT_IETA (1.0 / CLEAR_COAT_IOR) // IETA is the inverse eta which is the ratio of IOR of two interface
#define CLEAR_COAT_F0 0.04 // IORToFresnel0(CLEAR_COAT_IOR)
#define CLEAR_COAT_ROUGHNESS 0.001
#define CLEAR_COAT_PERCEPTUAL_SMOOTHNESS RoughnessToPerceptualSmoothness(CLEAR_COAT_ROUGHNESS)
#define CLEAR_COAT_PERCEPTUAL_ROUGHNESS RoughnessToPerceptualRoughness(CLEAR_COAT_ROUGHNESS)
//-----------------------------------------------------------------------------

// as it is the most dominant one
if (HasFeatureFlag(surfaceData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
{
normalData.perceptualSmoothness = CLEAR_COAT_ROUGHNESS;
normalData.perceptualSmoothness = CLEAR_COAT_PERCEPTUAL_SMOOTHNESS;
}
else
{

// Reading normal will suffer from compression, thus using following code depends on tradeoff between performance and quality.
// Test it for your project
// #define READ_FORWARD_NORMAL_FROM_TEXTURE
#define READ_FORWARD_NORMAL_FROM_TEXTURE
#if SHADERPASS == SHADERPASS_FORWARD
#if (SHADERPASS == SHADERPASS_FORWARD) && !defined(_SURFACE_TYPE_TRANSPARENT)
UpdateSurfaceDataFromNormalData(positionSS, surfaceData);
#endif
#endif

NormalData normalData;
DecodeFromNormalBuffer(inGBuffer1, positionSS, normalData);
bsdfData.normalWS = normalData.normalWS;
bsdfData.perceptualRoughness = normalData.perceptualSmoothness;
bsdfData.perceptualRoughness = PerceptualSmoothnessToPerceptualRoughness(normalData.perceptualSmoothness);
bakeDiffuseLighting = inGBuffer3.rgb;

2
com.unity.render-pipelines.high-definition/HDRP/Material/NormalBuffer.hlsl


float2 octNormalWS = PackNormalOctQuadEncode(normalData.normalWS);
float3 packNormalWS = PackFloat2To888(saturate(octNormalWS * 0.5 + 0.5));
// We store perceptualRoughness instead of roughness because it is perceptually linear.
outNormalBuffer0 = float4(packNormalWS, PerceptualSmoothnessToPerceptualRoughness(normalData.perceptualSmoothness));
outNormalBuffer0 = float4(packNormalWS, normalData.perceptualSmoothness);
}
void DecodeFromNormalBuffer(float4 normalBuffer, uint2 positionSS, out NormalData normalData)

正在加载...
取消
保存