浏览代码

[PlanarReflection] projection fixes

/main
Frédéric Vauchelles 7 年前
当前提交
726cdc40
共有 4 个文件被更改,包括 18 次插入11 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  2. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
  3. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  4. 21
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _EnvLightDatas = Shader.PropertyToID("_EnvLightDatas");
public static readonly int _EnvProxyDatas = Shader.PropertyToID("_EnvProxyDatas");
public static readonly int _EnvLightCount = Shader.PropertyToID("_EnvLightCount");
public static readonly int _EnvProjCount = Shader.PropertyToID("_EnvProjCount");
public static readonly int _EnvProxyCount = Shader.PropertyToID("_EnvProxyCount");
public static readonly int _ShadowDatas = Shader.PropertyToID("_ShadowDatas");
public static readonly int _NumTileFtplX = Shader.PropertyToID("_NumTileFtplX");
public static readonly int _NumTileFtplY = Shader.PropertyToID("_NumTileFtplY");

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs


int n = m_lightList.envLights.Count;
EnvLightData envLightData = m_lightList.envLights[n - 1];
envLightData.capturePositionWS -= camPosWS;
envLightData.positionWS -= camPosWS;
m_lightList.envLights[n - 1] = envLightData;
var envProjData = m_lightList.envProxies[n - 1];

cmd.SetGlobalBuffer(HDShaderIDs._EnvLightDatas, s_EnvLightDatas);
cmd.SetGlobalBuffer(HDShaderIDs._EnvProxyDatas, s_EnvProxyDatas);
cmd.SetGlobalInt(HDShaderIDs._EnvLightCount, m_lightList.envLights.Count);
cmd.SetGlobalInt(HDShaderIDs._EnvProjCount, m_lightList.envProxies.Count);
cmd.SetGlobalInt(HDShaderIDs._EnvProxyCount, m_lightList.envProxies.Count);
cmd.SetGlobalBuffer(HDShaderIDs._ShadowDatas, s_shadowDatas);
cmd.SetGlobalInt(HDShaderIDs._NumTileFtplX, GetNumTileFtplX(camera));

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


CBUFFER_START(UnityPerLightLoop)
uint _DirectionalLightCount;
uint _PunctualLightCount;
uint _AreaLightCount;
uint _AreaLightCount;
uint _EnvProxyCount;
int _EnvLightSkyEnabled; // TODO: make it a bool
CBUFFER_END

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


#include "CoreRP/ShaderLibrary/VolumeRendering.hlsl"
#include "../../Lighting/VolumeProjection.hlsl"
//#define ENV_PROJECTION_USE_LIGHTSPACE
//-----------------------------------------------------------------------------
// Texture and constant buffer declaration
//-----------------------------------------------------------------------------

float3x3 worldToLS = WorldToLightSpace(lightData);
float3 positionLS = WorldToLightPosition(lightData, worldToLS, positionWS);
float3 dirLS = mul(R, worldToLS); // Projection and influence share the space
float3 dirLS = mul(R, worldToLS);
#if defined(ENV_PROJECTION_USE_LIGHTSPACE)
/*float3x3 worldToPS = worldToLS;
float3x3 worldToPS = worldToLS;
float3 dirPS = dirLS;*/
float3 dirPS = dirLS;
#else
#endif
float projectionDistance = 0;
float projectionDistance = IntersectSphereProxy(proxyData, dirPS, positionPS);
projectionDistance = IntersectSphereProxy(proxyData, dirPS, positionPS);
// We can reuse dist calculate in LS directly in WS as there is no scaling. Also the offset is already include in lightData.capturePositionWS
R = (positionWS + projectionDistance * R) - lightData.capturePositionWS;

}
else if (projectionShapeType == ENVSHAPETYPE_BOX)
{
float projectionDistance = IntersectBoxProxy(proxyData, dirPS, positionPS);
projectionDistance = IntersectBoxProxy(proxyData, dirPS, positionPS);
// No need to normalize for fetching cubemap
// We can reuse dist calculate in LS directly in WS as there is no scaling. Also the offset is already include in lightData.capturePositionWS
R = (positionWS + projectionDistance * R) - lightData.capturePositionWS;

}
// 2. Process the influence
/*if (influenceShapeType == ENVSHAPETYPE_SPHERE)
if (influenceShapeType == ENVSHAPETYPE_SPHERE)
weight = InfluenceBoxWeight(lightData, bsdfData, positionWS, positionLS, dirLS);*/
weight = 1;
weight = InfluenceBoxWeight(lightData, bsdfData, positionWS, positionLS, dirLS);
// Smooth weighting
weight = Smoothstep01(weight);

正在加载...
取消
保存