浏览代码

Merge pull request #869 from Unity-Technologies/feature/PlanarReflection2

Planar reflection - fixes
/main
GitHub 7 年前
当前提交
aa6acaea
共有 5 个文件被更改,包括 29 次插入18 次删除
  1. 19
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs
  2. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs
  3. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/Volume/ReflectionProxyVolumeComponentUI.cs
  4. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  5. 14
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

19
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs


{
var objs = new List<Object>();
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
objs.Add(((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolumeReference);
reflectionProxyVolume = new SerializedReflectionProxyVolumeComponent(new SerializedObject(objs.ToArray()));
{
var p = ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolumeReference;
if (p != null)
objs.Add(p);
}
reflectionProxyVolume = objs.Count > 0
? new SerializedReflectionProxyVolumeComponent(new SerializedObject(objs.ToArray()))
: null;
}
public void Update()

var updateProxyVolume = serializedObject.targetObjects.Length != reflectionProxyVolume.serializedObject.targetObjects.Length;
if (!updateProxyVolume)
var updateProxyVolume = reflectionProxyVolume != null
&& serializedObject.targetObjects.Length != reflectionProxyVolume.serializedObject.targetObjects.Length;
if (!updateProxyVolume && reflectionProxyVolume != null)
{
var proxyVolumeTargets = reflectionProxyVolume.serializedObject.targetObjects;
for (var i = 0; i < serializedObject.targetObjects.Length; i++)

public void Apply()
{
serializedObject.ApplyModifiedProperties();
reflectionProxyVolume.Apply();
if (reflectionProxyVolume != null)
reflectionProxyVolume.Apply();
}
}
}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs


public override void Update()
{
base.Update();
SetIsSectionExpanded_Shape((ShapeType)data.shapeType.intValue);
if (data != null)
SetIsSectionExpanded_Shape((ShapeType)data.shapeType.intValue);
}
void SetIsSectionExpanded_Shape(ShapeType shape)

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/Volume/ReflectionProxyVolumeComponentUI.cs


public override void Reset(SerializedReflectionProxyVolumeComponent data, UnityAction repaint)
{
proxyVolume.Reset(data.proxyVolume, repaint);
if (data != null)
proxyVolume.Reset(data.proxyVolume, repaint);
base.Reset(data, repaint);
}

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl


#define SINGLE_PASS_CONTEXT_SAMPLE_SKY 1
#ifdef DEBUG_DISPLAY
float4 ApplyDebugProjectionVolume(float4 color, float3 texCoord, float scale)
float4 ApplyDebugProjectionVolume(float4 color, float3 radiusToProxy, float scale)
float l = length(texCoord);
float l = length(radiusToProxy);
l = pow(l / (1 + l), scale);
return float4(l.xxx * 0.7 + color.rgb * 0.3, color.a);
}

float4 color = SAMPLE_TEXTURE2D_ARRAY_LOD(_Env2DTextures, s_trilinear_clamp_sampler, ndc.xy, index, 0);
color.a = any(ndc.xyz < 0) || any(ndc.xyz > 1) ? 0 : 1;
#ifdef DEBUG_DISPLAY
if (_DebugLightingMode == DEBUGLIGHTINGMODE_ENVIRONMENT_PROXY_VOLUME)
return ApplyDebugProjectionVolume(color, texCoord, _DebugEnvironmentProxyDepthScale);
#endif
return color;
}
else if (cacheType == ENVCACHETYPE_CUBEMAP)

14
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


weight = InfluenceBoxWeight(lightData, bsdfData, positionWS, positionIS, dirIS);
}
// 2. Process the influence
//if (influenceShapeType == ENVSHAPETYPE_SPHERE)
// weight = InfluenceSphereWeight(lightData, bsdfData, positionWS, positionIS, dirIS);
//else if (influenceShapeType == ENVSHAPETYPE_BOX)
// weight = InfluenceBoxWeight(lightData, bsdfData, positionWS, positionIS, dirIS);
#ifdef DEBUG_DISPLAY
float3 radiusToProxy = R;
#endif
// When we are rough, we tend to see outward shifting of the reflection when at the boundary of the projection volume
// Also it appear like more sharp. To avoid these artifact and at the same time get better match to reference we lerp to original unmodified reflection.

float3 F = preLightData.specularFGD;
float iblMipLevel = PerceptualRoughnessToMipmapLevel(preLightData.iblPerceptualRoughness);
#ifdef DEBUG_DISPLAY
if (_DebugLightingMode == DEBUGLIGHTINGMODE_ENVIRONMENT_PROXY_VOLUME)
preLD = ApplyDebugProjectionVolume(preLD, radiusToProxy, _DebugEnvironmentProxyDepthScale);
#endif
// Smooth weighting
weight = Smoothstep01(weight);

正在加载...
取消
保存