浏览代码

Fix projector light dimensions

/fptl_cleanup
Evgenii Golubev 8 年前
当前提交
c4ee2251
共有 3 个文件被更改,包括 17 次插入16 次删除
  1. 23
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  2. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  3. 6
      Assets/TestScenes/HDTest/HDRenderLoopTest.unity

23
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


Vector3 zAxisVS = worldToView.MultiplyVector(lightData.forward);
// Projector lights point forwards (along Z). The projection window is aligned with the XY plane.
Vector3 boxDims = new Vector3(lightData.size.x, lightData.size.y, 1000000.0f);
Vector3 boxDims = new Vector3(lightData.size.x, lightData.size.y, 1000000.0f);
Vector3 halfDims = 0.5f * boxDims;
bound.boxAxisX = boxDims.x * xAxisVS; // Should this be halved or not?
bound.boxAxisY = boxDims.y * yAxisVS; // Should this be halved or not?
bound.boxAxisZ = boxDims.z * zAxisVS; // Should this be halved or not?
bound.radius = 0.5f * boxDims.magnitude; // Radius of a circumscribed sphere?
bound.boxAxisX = halfDims.x * xAxisVS; // Should this be halved or not?
bound.boxAxisY = halfDims.y * yAxisVS; // Should this be halved or not?
bound.boxAxisZ = halfDims.z * zAxisVS; // Should this be halved or not?
bound.radius = halfDims.magnitude; // Radius of a circumscribed sphere?
lightVolumeData.lightPos = posVS; // Is this the center of the volume?
lightVolumeData.lightAxisX = xAxisVS;
lightVolumeData.lightAxisY = yAxisVS;
lightVolumeData.lightAxisZ = zAxisVS;
lightVolumeData.boxInnerDist = boxDims * 0.5f; // No idea what this is. Document your code
lightVolumeData.boxInvRange.Set(1.0f / boxDims.x, 1.0f / boxDims.y, 1.0f / boxDims.z); // No idea what this is. Document your code
lightVolumeData.lightPos = posVS; // Is this the center of the volume?
lightVolumeData.lightAxisX = xAxisVS;
lightVolumeData.lightAxisY = yAxisVS;
lightVolumeData.lightAxisZ = zAxisVS;
lightVolumeData.boxInnerDist = halfDims; // No idea what this is. Document your code
lightVolumeData.boxInvRange.Set(1.0f / halfDims.x, 1.0f / halfDims.y, 1.0f / halfDims.z); // No idea what this is. Document your code
lightVolumeData.featureFlags = LightFeatureFlags.FEATURE_FLAG_LIGHT_PROJECTOR;
}
else

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


float distY = dot(unL, lightData.up);
// Compute windowing factors using the dimensions of the light's "viewport".
float windowX = (abs(distX) <= lightData.size.x) ? 1 : 0;
float windowY = (abs(distY) <= lightData.size.y) ? 1 : 0;
float windowX = (abs(distX) <= 0.5 * lightData.size.x) ? 1 : 0;
float windowY = (abs(distY) <= 0.5 * lightData.size.y) ? 1 : 0;
float illuminance = saturate(dot(bsdfData.normalWS, L) * (windowX * windowY));

6
Assets/TestScenes/HDTest/HDRenderLoopTest.unity


m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1085128921}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.3, y: 0, z: -2.0000005}
m_LocalPosition: {x: -0.0514, y: 0.39, z: -2}
m_LocalScale: {x: 1, y: 1, z: 1.0000005}
m_Children: []
m_Father: {fileID: 2026378394}

affectDiffuse: 1
affectSpecular: 1
archetype: 2
isDoubleSided: 1
isDoubleSided: 0
lightLength: 3
lightWidth: 2
--- !u!108 &1879857774

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1879857772}
m_LocalRotation: {x: 0.000000059604645, y: 0, z: -0, w: 1}
m_LocalPosition: {x: -0.31449968, y: -0.34166676, z: -2.5199997}
m_LocalPosition: {x: -0.3023, y: -0.2512, z: -2.904}
m_LocalScale: {x: 0.05, y: 0.08333334, z: 1}
m_Children: []
m_Father: {fileID: 2026378394}

正在加载...
取消
保存