浏览代码

(wip) Fixed refraction with sky proxy

/main
Frédéric Vauchelles 6 年前
当前提交
c96eb98a
共有 7 个文件被更改,包括 39 次插入23 次删除
  1. 13
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs
  2. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs.hlsl
  3. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/ScreenSpaceRefractionVolumeEditor.cs
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.hlsl
  5. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceRefractionVolume.cs
  6. 15
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceTracing.hlsl
  7. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

13
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs


// 1x32 bits
public Lit.RefractionSSRayModel tracingModel;
// 7x32 bits
// 6x32 bits
public uint loopStartPositionSSX; // Proxy, HiZ
public uint loopStartPositionSSY; // Proxy, HiZ
public float loopStartLinearDepth; // Proxy, HiZ

// 10x32 bits
// 9x32 bits
public Vector3 iterationPositionSS; // HiZ
public uint iterationMipLevel; // HiZ
public uint iteration; // HiZ

public uint iterationCellSizeH; // HiZ
public EnvShapeType proxyShapeType; // Proxy
public float projectionDistance; // Proxy
// 4x32 bits
public bool endHitSuccess; // Proxy, HiZ

// 2x32 bits (padding)
public uint unused01;
public uint unused02;
// 0x32 bits (padding)
public Vector2 loopStartPositionSS { get { return new Vector2(loopStartPositionSSX, loopStartPositionSSY); } }
public Vector2 endPositionSS { get { return new Vector2(endPositionSSX, endPositionSSY); } }

children =
{
new DebugUI.Value { displayName = "Hit Success", getter = () => screenSpaceTracingDebugData.endHitSuccess },
new DebugUI.Value { displayName = "Proxy Shape", getter = () => screenSpaceTracingDebugData.proxyShapeType },
new DebugUI.Value { displayName = "Projection Distance", getter = () => screenSpaceTracingDebugData.projectionDistance },
new DebugUI.Value { displayName = "Start Position", getter = () => screenSpaceTracingDebugData.loopStartPositionSS },
new DebugUI.Value { displayName = "Start Linear Depth", getter = () => screenSpaceTracingDebugData.loopStartLinearDepth },
new DebugUI.Value { displayName = "End Linear Depth", getter = () => screenSpaceTracingDebugData.endLinearDepth },
new DebugUI.Value { displayName = "End Position", getter = () => screenSpaceTracingDebugData.endPositionSS },

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs.hlsl


int iterationIntersectionKind;
uint iterationCellSizeW;
uint iterationCellSizeH;
int proxyShapeType;
float projectionDistance;
uint unused01;
uint unused02;
};
//

{
return value.iterationCellSizeH;
}
int GetProxyShapeType(ScreenSpaceTracingDebug value)
{
return value.proxyShapeType;
}
float GetProjectionDistance(ScreenSpaceTracingDebug value)
{
return value.projectionDistance;
}
bool GetEndHitSuccess(ScreenSpaceTracingDebug value)
{
return value.endHitSuccess;

uint GetEndPositionSSY(ScreenSpaceTracingDebug value)
{
return value.endPositionSSY;
}
uint GetUnused01(ScreenSpaceTracingDebug value)
{
return value.unused01;
}
uint GetUnused02(ScreenSpaceTracingDebug value)
{
return value.unused02;
}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/ScreenSpaceRefractionVolumeEditor.cs


SerializedDataParameter m_RayMaxLevel;
SerializedDataParameter m_RayMaxIterations;
SerializedDataParameter m_RayDepthSuccessBias;
SerializedDataParameter m_ScreenWeightDistance;
public override void OnEnable()
{

m_RayMaxLevel = Unpack(o.Find(x => x.rayMaxLevel));
m_RayMaxIterations = Unpack(o.Find(x => x.rayMaxIterations));
m_RayDepthSuccessBias = Unpack(o.Find(x => x.rayDepthSuccessBias));
m_ScreenWeightDistance = Unpack(o.Find(x => x.screenWeightDistance));
}
public override void OnInspectorGUI()

PropertyField(m_RayMaxIterations, CoreEditorUtils.GetContent("Ray Max Iterations"));
PropertyField(m_RayDepthSuccessBias, CoreEditorUtils.GetContent("Ray Depth Success Bias"));
PropertyField(m_ScreenWeightDistance, CoreEditorUtils.GetContent("Screen Weight Distance"));
}
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.hlsl


#endif
firstEnvLight = _EnvLightDatas[envLightIndex];
}
else
firstEnvLight = InitSkyEnvLightData(0);
}
if (featureFlags & LIGHTFEATUREFLAGS_SSREFRACTION)

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceRefractionVolume.cs


{
public IntParameter rayMinLevel = new IntParameter(2);
public IntParameter rayMaxLevel = new IntParameter(6);
public IntParameter rayMaxIterations = new IntParameter(1024);
public IntParameter rayMaxIterations = new IntParameter(32);
public FloatParameter screenWeightDistance = new FloatParameter(0.1f);
public ClampedFloatParameter screenWeightDistance = new ClampedFloatParameter(0.1f, 0, 1);
public void PushShaderParameters(CommandBuffer cmd)
{

15
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceTracing.hlsl


switch(input.proxyData.influenceShapeType)
{
case ENVSHAPETYPE_SPHERE:
case ENVSHAPETYPE_SKY:
{
}
case ENVSHAPETYPE_BOX:
projectionDistance = IntersectBoxProxy(input.proxyData, rayDirPS, rayOriginPS);
break;

uint2 hitPositionSS = uint2(hitPositionNDC *_ScreenSize.xy);
float hitLinearDepth = hitPositionCS.w;
hit.positionNDC = hitPositionNDC;
hit.positionSS = hitPositionSS;
hit.linearDepth = hitLinearDepth;
hit.positionNDC = hitPositionNDC;
hit.positionSS = hitPositionSS;
hit.linearDepth = hitLinearDepth;
bool hitSuccessful = rayOriginCS.w <= hitLinearDepth;
bool hitSuccessful = true;
#ifdef DEBUG_DISPLAY
DebugComputeCommonOutput(input.rayDirWS, hitSuccessful, hit);

debug.endLinearDepth = hitLinearDepth;
debug.endPositionSSX = hitPositionSS.x;
debug.endPositionSSY = hitPositionSS.y;
debug.proxyShapeType = input.proxyData.influenceShapeType;
debug.projectionDistance = projectionDistance;
return false;
return hitSuccessful;
}
// -------------------------------------------------

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


weightNDC = weightNDC * weightNDC * (3 - 2 * weightNDC);
float weight = weightNDC.x * weightNDC.y;
float hitDeviceDepth = LOAD_TEXTURE2D_LOD(_DepthPyramidTexture, hit.positionSS, 0).r;
float hitLinearDepth = LinearEyeDepth(hitDeviceDepth, _ZBufferParams);
if (hit.linearDepth < posInput.linearDepth
if (hitLinearDepth < posInput.linearDepth
|| weight == 0)
{
// Do nothing and don't update the hierarchy weight so we can fall back on refraction probe

正在加载...
取消
保存