浏览代码

Merge pull request #223 from EvgeniiG/master

Fix the orientation of area lights
/Branch_Batching2
GitHub 8 年前
当前提交
7c8771b2
共有 3 个文件被更改,包括 17 次插入16 次删除
  1. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  2. 23
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  3. 8
      Assets/TestScenes/HDTest/HDRenderLoopTest.unity

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


if (!lightData.twoSided)
{
centerVS -= zAxisVS * radius * 0.5f;
centerVS += zAxisVS * radius * 0.5f;
dimensions.z *= 0.5f;
}

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


[branch] if (lightData.cookieIndex >= 0 && illuminance > 0.0)
{
float3 unL = positionWS - lightData.positionWS;
float3 lightToSurface = positionWS - lightData.positionWS;
// Project 'unL' onto the light's axes.
float2 coord = float2(dot(unL, lightData.right), dot(unL, lightData.up));
// Project 'lightToSurface' onto the light's axes.
float2 coord = float2(dot(lightToSurface, lightData.right), dot(lightToSurface, lightData.up));
// Compute the NDC coordinates (in [-1, 1]^2).
coord.x *= lightData.invScaleX;

float len = lightData.size.x;
float3 T = lightData.right;
float3 unL = positionWS - lightData.positionWS;
float3 unL = lightData.positionWS - positionWS;
// Pick the major axis of the ellipsoid.
float3 axis = lightData.right;

float2 u = Hammersley2d(i, sampleCount);
u = frac(u + randNum);
float4x4 localToWorld = float4x4(float4(lightData.right, 0.0), float4(lightData.up, 0.0), float4(lightData.forward, 0.0), float4(lightData.positionWS, 1.0));
// Lights in Unity point backward.
float4x4 localToWorld = float4x4(float4(lightData.right, 0.0), float4(lightData.up, 0.0), float4(-lightData.forward, 0.0), float4(lightData.positionWS, 1.0));
switch (lightData.lightType)
{

float halfWidth = lightData.size.x * 0.5;
float halfHeight = lightData.size.y * 0.5;
float3 unL = positionWS - lightData.positionWS;
float3 unL = lightData.positionWS - positionWS;
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, lightData.forward);
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, -lightData.forward);
unL = mul(unL, transpose(lightToWorld));
// Define the dimensions of the attenuation volume.

lightData.specularScale *= intensity;
// TODO: store 4 points and save 12 cycles (24x MADs - 12x MOVs).
float3 p0 = lightData.positionWS + lightData.right * -halfWidth + lightData.up * halfHeight;
float3 p1 = lightData.positionWS + lightData.right * -halfWidth + lightData.up * -halfHeight;
float3 p2 = lightData.positionWS + lightData.right * halfWidth + lightData.up * -halfHeight;
float3 p3 = lightData.positionWS + lightData.right * halfWidth + lightData.up * halfHeight;
float3 p0 = lightData.positionWS + lightData.right * halfWidth + lightData.up * halfHeight;
float3 p1 = lightData.positionWS + lightData.right * halfWidth + lightData.up * -halfHeight;
float3 p2 = lightData.positionWS + lightData.right * -halfWidth + lightData.up * -halfHeight;
float3 p3 = lightData.positionWS + lightData.right * -halfWidth + lightData.up * halfHeight;
float4x3 matL = float4x3(p0, p1, p2, p3) - float4x3(positionWS, positionWS, positionWS, positionWS);

8
Assets/TestScenes/HDTest/HDRenderLoopTest.unity


affectDiffuse: 1
affectSpecular: 1
archetype: 1
isDoubleSided: 1
isDoubleSided: 0
lightLength: 16
lightWidth: 2
--- !u!108 &827169275

m_GameObject: {fileID: 827169273}
m_Enabled: 1
serializedVersion: 8
m_Type: 2
m_Type: 1
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 1
m_Range: 12

affectDiffuse: 1
affectSpecular: 1
archetype: 1
isDoubleSided: 1
isDoubleSided: 0
lightLength: 4
lightWidth: 2
--- !u!108 &1640077385

m_GameObject: {fileID: 1640077383}
m_Enabled: 1
serializedVersion: 8
m_Type: 2
m_Type: 1
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 1
m_Range: 6

正在加载...
取消
保存