浏览代码

Add innerAngle for spotlight

/main
sebastienlagarde 8 年前
当前提交
2aba5fc9
共有 2 个文件被更改,包括 7 次插入3 次删除
  1. 8
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  2. 2
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl

8
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


if (light.lightType == LightType.Spot)
{
// TODO: Add support of cosine inner and outer for spot light to get nicer spotlight...
float cosSpotOuterHalfAngle = 1.0f / light.invCosHalfSpotAngle;
float cosSpotInnerHalfAngle = cosSpotOuterHalfAngle;
float spotAngle = light.light.spotAngle;
AdditionalLightData additionalLightData = light.light.GetComponent<AdditionalLightData>();
float innerConePercent = AdditionalLightData.GetInnerSpotPercent01(additionalLightData);
float cosSpotOuterHalfAngle = Mathf.Clamp(Mathf.Cos(spotAngle * 0.5f * Mathf.Deg2Rad), 0.0f, 1.0f);
float cosSpotInnerHalfAngle = Mathf.Clamp(Mathf.Cos(spotAngle * 0.5f * innerConePercent * Mathf.Deg2Rad), 0.0f, 1.0f); // inner cone
float val = Mathf.Max(0.001f, (cosSpotInnerHalfAngle - cosSpotOuterHalfAngle));
l.angleScale = 1.0f / val;

2
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


// Do not use "in", only "out" or "inout" as califier, not "inline" keyword either, useless.
// The lighting code assume that 1 Unity unit (1uu) == 1 meters. This is very important regarding physically based light unit and inverse square attenuation
// Include language header
#if defined(SHADER_API_D3D11)

正在加载...
取消
保存