浏览代码

Merge pull request #730 from Unity-Technologies/Add-GetHDAdditionalData-method

Add GetHDAdditionalLightData method
/feature-ReflectionProbeFit
GitHub 7 年前
当前提交
b05e292a
共有 1 个文件被更改,包括 17 次插入7 次删除
  1. 24
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs

24
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs


directionalLightData.up = light.light.transform.up * 2 / Mathf.Max(additionalData.shapeHeight, 0.001f);
directionalLightData.positionWS = light.light.transform.position;
directionalLightData.color = GetLightColor(light);
// Caution: This is bad but if additionalData == defaultHDAdditionalLightData it mean we are trying to promote legacy lights, which is the case for the preview for example, so we need to multiply by PI as legacy Unity do implicit divide by PI for direct intensity.
// So we expect that all light with additionalData == defaultHDAdditionalLightData are currently the one from the preview, light in scene MUST have additionalData
directionalLightData.color *= (defaultHDAdditionalLightData == additionalData) ? Mathf.PI : 1.0f;
directionalLightData.diffuseScale = additionalData.affectDiffuse ? diffuseDimmer : 0.0f;
directionalLightData.specularScale = additionalData.affectSpecular ? specularDimmer : 0.0f;
directionalLightData.shadowIndex = directionalLightData.cookieIndex = -1;

var light = cullResults.visibleLights[lightIndex];
// Light should always have additional data, however preview light right don't have, so we must handle the case by assigning defaultHDAdditionalLightData
var additionalData = light.light.GetComponent<HDAdditionalLightData>();
if (additionalData == null)
additionalData = defaultHDAdditionalLightData;
var additionalData = GetHDAdditionalLightData(light);
LightCategory lightCategory = LightCategory.Count;
GPULightType gpuLightType = GPULightType.Point;

m_enableBakeShadowMask = m_enableBakeShadowMask || IsBakedShadowMaskLight(light.light);
// Light should always have additional data, however preview light right don't have, so we must handle the case by assigning defaultHDAdditionalLightData
var additionalLightData = light.light.GetComponent<HDAdditionalLightData>();
if (additionalLightData == null)
additionalLightData = defaultHDAdditionalLightData;
var additionalLightData = GetHDAdditionalLightData(light);
var additionalShadowData = light.light.GetComponent<AdditionalShadowData>(); // Can be null
// Directional rendering side, it is separated as it is always visible so no volume to handle here

add.blendDistancePositive = Vector3.one * probe.blendDistance;
add.blendDistanceNegative = add.blendDistancePositive;
add.influenceShape = ReflectionInfluenceShape.Box;
}
return add;
}
HDAdditionalLightData GetHDAdditionalLightData(VisibleLight light)
{
var add = light.light.GetComponent<HDAdditionalLightData>();
if (add == null)
{
add = defaultHDAdditionalLightData;
}
return add;
}

正在加载...
取消
保存