浏览代码

Merge pull request #405 from EvgeniiG/refl_probe_fix

Fix light culling while rendering reflection probes
/main
GitHub 7 年前
当前提交
0682a517
共有 4 个文件被更改,包括 22 次插入28 次删除
  1. 9
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/LightingConvexHullUtils.hlsl
  2. 17
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  3. 15
      TestbedPipelines/Fptl/FptlLighting.cs
  4. 9
      TestbedPipelines/Fptl/LightingConvexHullUtils.hlsl

9
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/LightingConvexHullUtils.hlsl


if (bIsSideQuad) { vA2 *= (iAbsSide == 0 ? scaleXY.x : scaleXY.y); vB2 *= (iAbsSide == 0 ? scaleXY.y : scaleXY.x); }
p0 = center + (vA + vB - vC); // center + vA is center of face when scaleXY is 1.0
float3 vNout = cross( vB2, 0.5*(vA-vA2) - vC );
float3 v0 = vA + vB - vC; // vector from center to p0
p0 = center + v0; // center + vA is center of face when scaleXY is 1.0
#if USE_LEFT_HAND_CAMERA_SPACE
vNout = -vNout;
#endif
float3 n0 = cross(vB2, 0.5 * (vA - vA2) - vC);
float3 vNout = dot(n0,v0) < 0.0 ? (-n0) : n0;
vN = vNout;
}

17
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


}
else if (gpuLightType == GPULightType.Point)
{
bool isNegDeterminant = Vector3.Dot(worldToView.GetColumn(0), Vector3.Cross(worldToView.GetColumn(1), worldToView.GetColumn(2))) < 0.0f; // 3x3 Determinant.
Vector3 vx = xAxisVS;
Vector3 vy = yAxisVS;
Vector3 vz = zAxisVS;
bound.center = positionVS;
bound.boxAxisX.Set(range, 0, 0);
bound.boxAxisY.Set(0, range, 0);
bound.boxAxisZ.Set(0, 0, isNegDeterminant ? (-range) : range); // transform to camera space (becomes a left hand coordinate frame in Unity since Determinant(worldToView)<0)
bound.center = positionVS;
bound.boxAxisX = vx * range;
bound.boxAxisY = vy * range;
bound.boxAxisZ = vz * range;
// represents a left hand coordinate system in world space since det(worldToView)<0
Vector3 vx = xAxisVS;
Vector3 vy = yAxisVS;
Vector3 vz = zAxisVS;
// fill up ldata
lightVolumeData.lightAxisX = vx;

15
TestbedPipelines/Fptl/FptlLighting.cs


light.sliceIndex = m_CubeCookieTexArray.FetchSlice(cl.light.cookie);
}
bound.center = worldToView.MultiplyPoint(lightPos);
bound.boxAxisX.Set(range, 0, 0);
bound.boxAxisY.Set(0, range, 0);
bound.boxAxisZ.Set(0, 0, isNegDeterminant ? (-range) : range); // transform to camera space (becomes a left hand coordinate frame in Unity since Determinant(worldToView)<0)
bound.scaleXY.Set(1.0f, 1.0f);
bound.radius = range;
// represents a left hand coordinate system in world space since det(worldToView)<0
bound.center = worldToView.MultiplyPoint(lightPos);
bound.boxAxisX = vx * range;
bound.boxAxisY = vy * range;
bound.boxAxisZ = vz * range;
bound.scaleXY.Set(1.0f, 1.0f);
bound.radius = range;
// fill up ldata
light.lightType = (uint)LightDefinitions.SPHERE_LIGHT;

9
TestbedPipelines/Fptl/LightingConvexHullUtils.hlsl


if (bIsSideQuad) { vA2 *= (iAbsSide == 0 ? scaleXY.x : scaleXY.y); vB2 *= (iAbsSide == 0 ? scaleXY.y : scaleXY.x); }
p0 = center + (vA + vB - vC); // center + vA is center of face when scaleXY is 1.0
float3 vNout = cross( vB2, 0.5*(vA-vA2) - vC );
float3 v0 = vA + vB - vC; // vector from center to p0
p0 = center + v0; // center + vA is center of face when scaleXY is 1.0
#if USE_LEFTHAND_CAMERASPACE
vNout = -vNout;
#endif
float3 n0 = cross(vB2, 0.5 * (vA - vA2) - vC);
float3 vNout = dot(n0,v0) < 0.0 ? (-n0) : n0;
vN = vNout;
}

正在加载...
取消
保存