|
|
|
|
|
|
#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); |
|
|
|