Nerites 6 年前
当前提交
ec2d7882
共有 5 个文件被更改,包括 29 次插入14 次删除
  1. 2
      com.unity.render-pipelines.core/CoreRP/Shadow/AdditionalShadowData.cs
  2. 7
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Preview.cs
  3. 1
      com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipelineResources/ReflectionProbesPreview.shader
  4. 11
      com.unity.render-pipelines.high-definition/HDRP/Material/NormalBuffer.hlsl
  5. 22
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl

2
com.unity.render-pipelines.core/CoreRP/Shadow/AdditionalShadowData.cs


[Range(0.0F, 10.0F)]
public float normalBiasScale = 1.0f;
public bool sampleBiasScale = true;
public bool edgeLeakFixup = true;
public bool edgeLeakFixup = false; // Causes large banding artifacts
public bool edgeToleranceNormal = true;
[Range(0.0F, 1.0F)]
public float edgeTolerance = 1.0f;

7
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Preview.cs


return false; // We only handle one preview for reflection probes
// Ensure valid cube map editor (if possible)
if (ValidPreviewSetup())
if (ValidPreviewSetup() && m_CubemapEditor == null)
{
Editor editor = m_CubemapEditor;
CreateCachedEditor(((ReflectionProbe)target).texture, typeof(HDCubemapInspector), ref editor);

{
var p = target as ReflectionProbe;
return p != null && p.texture != null;
}
private void OnDestroy()
{
DestroyImmediate(m_CubemapEditor);
}
}
}

1
com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipelineResources/ReflectionProbesPreview.shader


v2f o;
// Transform local to world before custom vertex code
o.positionWS = TransformObjectToWorld(v.positionOS.xyz);
o.positionWS = GetCameraRelativePositionWS(o.positionWS);
o.positionCS = TransformWorldToHClip(o.positionWS);
o.normalWS = TransformObjectToWorldNormal(v.normalOS);

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


// RT1 - 8:8:8:8
// Our tangent encoding is based on our normal.
float2 octNormalWS = PackNormalOctQuadEncode(normalData.normalWS);
#if defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN)
// With octahedral quad packing we get an artifact for reconstructed tangent at the center of this quad. We use rect packing instead to avoid it.
float2 octNormalWS = PackNormalOctRectEncode(normalData.normalWS);
#else
float2 octNormalWS = PackNormalOctQuadEncode(normalData.normalWS);
#endif
float3 packNormalWS = PackFloat2To888(saturate(octNormalWS * 0.5 + 0.5));
// We store perceptualRoughness instead of roughness because it is perceptually linear.
outNormalBuffer0 = float4(packNormalWS, normalData.perceptualRoughness);

{
float3 packNormalWS = normalBuffer.rgb;
float2 octNormalWS = Unpack888ToFloat2(packNormalWS);
#if defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN)
normalData.normalWS = UnpackNormalOctRectEncode(octNormalWS * 2.0 - 1.0);
#else
#endif
normalData.perceptualRoughness = normalBuffer.a;
}

22
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl


float _s_r0m, s_r12, m_rr; // we will need these outside the loop for further calculations
// HACK: If we don't use a local table and write the result directly in preLightData.vLayerEnergyCoeff
// we get a warning 'array reference cannot be used as an l-value; not natively addressable, forcing loop to unroll'
// Caution: be sure NB_VLAYERS == 3 and complete the code after
float3 localvLayerEnergyCoeff[NB_VLAYERS];
// Iterate over the layers
for(int i = 0; i < NB_VLAYERS; ++i)
{

_s_ri0 = (e_ri0 > 0.0) ? _s_ri0/e_ri0 : 0.0;
// Store the coefficient and variance
if(m_r0i > 0.0)
{
preLightData.vLayerEnergyCoeff[i] = m_R0i;
//preLightData.vLayerPerceptualRoughness[i] = LinearVarianceToPerceptualRoughness(_s_r0m);
}
else
{
preLightData.vLayerEnergyCoeff[i] = float3(0.0, 0.0, 0.0);
//preLightData.vLayerPerceptualRoughness[i] = 0.0;
}
localvLayerEnergyCoeff[i] = (m_r0i > 0.0) ? m_R0i : float3(0.0, 0.0, 0.0);
//preLightData.vLayerPerceptualRoughness[i] = (m_r0i > 0.0) ? LinearVarianceToPerceptualRoughness(_s_r0m) : 0.0;
// Update energy
R0i = e_R0i;

ji0 *= j21;
}
}
// HACK: See note above why we need to do this
preLightData.vLayerEnergyCoeff[0] = localvLayerEnergyCoeff[0];
preLightData.vLayerEnergyCoeff[1] = localvLayerEnergyCoeff[1];
preLightData.vLayerEnergyCoeff[2] = localvLayerEnergyCoeff[2];
//-------------------------------------------------------------
// Post compute:

正在加载...
取消
保存