浏览代码

HDRenderPipeline: Fix issue with accumate light not accumulating correctly

/Add-support-for-light-specular-color-tint
sebastienlagarde 7 年前
当前提交
c0b5b529
共有 2 个文件被更改,包括 12 次插入12 次删除
  1. 20
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl
  2. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl

20
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl


for (i = 0; i < _DirectionalLightCount; ++i)
{
DirectLighting lighting = EvaluateBSDF_Directional(context, V, posInput, preLightData, _DirectionalLightDatas[i], bsdfData);
AccumulateDirectLighting(aggregateLighting, lighting);
AccumulateDirectLighting(lighting, aggregateLighting);
}
}

{
int punctualIndex = FetchIndex(punctualLightStart, i);
DirectLighting lighting = EvaluateBSDF_Punctual(context, V, posInput, preLightData, _LightDatas[punctualIndex], bsdfData, _LightDatas[punctualIndex].lightType);
AccumulateDirectLighting(aggregateLighting, lighting);
AccumulateDirectLighting(lighting, aggregateLighting);
}
#else

DirectLighting lighting = EvaluateBSDF_Punctual(context, V, posInput, preLightData, _LightDatas[i], bsdfData, _LightDatas[i].lightType);
AccumulateDirectLighting(aggregateLighting, lighting);
AccumulateDirectLighting(lighting, aggregateLighting);
}
#endif

while (i < areaLightCount && lightType == GPULIGHTTYPE_LINE)
{
DirectLighting lighting = EvaluateBSDF_Area(context, V, posInput, preLightData, _LightDatas[areaIndex], bsdfData, GPULIGHTTYPE_LINE);
AccumulateDirectLighting(aggregateLighting, lighting);
AccumulateDirectLighting(lighting, aggregateLighting);
i++;
areaIndex = i < areaLightCount ? FetchIndex(areaLightStart, i) : 0;

while (i < areaLightCount && lightType == GPULIGHTTYPE_RECTANGLE)
{
DirectLighting lighting = EvaluateBSDF_Area(context, V, posInput, preLightData, _LightDatas[areaIndex], bsdfData, GPULIGHTTYPE_RECTANGLE);
AccumulateDirectLighting(aggregateLighting, lighting);
AccumulateDirectLighting(lighting, aggregateLighting);
i++;
areaIndex = i < areaLightCount ? FetchIndex(areaLightStart, i) : 0;

for (i = _PunctualLightCount; i < _PunctualLightCount + _AreaLightCount; ++i)
{
DirectLighting lighting = EvaluateBSDF_Area(context, V, posInput, preLightData, _LightDatas[i], bsdfData, _LightDatas[i].lightType);
AccumulateDirectLighting(aggregateLighting, lighting);
AccumulateDirectLighting(lighting, aggregateLighting);
}
#endif

if (featureFlags & LIGHTFEATUREFLAGS_SSREFRACTION)
{
IndirectLighting lighting = EvaluateBSDF_SSRefraction(context, V, posInput, preLightData, bsdfData, refractionHierarchyWeight);
AccumulateIndirectLighting(aggregateLighting, lighting);
AccumulateIndirectLighting(lighting, aggregateLighting);
AccumulateIndirectLighting(aggregateLighting, lighting);
AccumulateIndirectLighting(lighting, aggregateLighting);
}
if (featureFlags & LIGHTFEATUREFLAGS_ENV || featureFlags & LIGHTFEATUREFLAGS_SKY)

#endif
IndirectLighting lighting = EvaluateBSDF_Env(context, V, posInput, preLightData, _EnvLightDatas[envLightIndex], bsdfData, _EnvLightDatas[envLightIndex].envShapeType,
reflectionHierarchyWeight);
AccumulateIndirectLighting(aggregateLighting, lighting);
AccumulateIndirectLighting(lighting, aggregateLighting);
}
}

context.sampleReflection = SINGLE_PASS_CONTEXT_SAMPLE_SKY;
EnvLightData envLightSky = InitSkyEnvLightData(0); // The sky data are generated on the fly so the compiler can optimize the code
IndirectLighting lighting = EvaluateBSDF_Env(context, V, posInput, preLightData, envLightSky, bsdfData, ENVSHAPETYPE_SKY, reflectionHierarchyWeight);
AccumulateIndirectLighting(aggregateLighting, lighting);
AccumulateIndirectLighting(lighting, aggregateLighting);
}
}
}

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


IndirectLighting indirect;
};
void AccumulateDirectLighting(AggregateLighting dst, DirectLighting src)
void AccumulateDirectLighting(DirectLighting src, inout AggregateLighting dst)
void AccumulateIndirectLighting(AggregateLighting dst, IndirectLighting src)
void AccumulateIndirectLighting(IndirectLighting src, inout AggregateLighting dst)
{
dst.indirect.specularReflected += src.specularReflected;
dst.indirect.specularTransmitted += src.specularTransmitted;

正在加载...
取消
保存