浏览代码

Fixed issue that was causing the attenuation to be applied to direcitonal lights when using attenuation texture.

/RenderPassXR_Sandbox
Felipe Lira 7 年前
当前提交
5f72f0d9
共有 2 个文件被更改,包括 6 次插入2 次删除
  1. 4
      ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs
  2. 4
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineLighting.cginc

4
ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs


lightColor = light.finalColor;
float rangeSq = light.range * light.range;
float quadAtten = (light.lightType == LightType.Directional) ? 0.0f : 25.0f / rangeSq;
float quadAtten = 0.0f;
if (light.lightType != LightType.Directional)
quadAtten = (m_Asset.AttenuationTexture != null) ? 1.0f : 25.0f / rangeSq;
if (light.lightType == LightType.Spot)
{

4
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineLighting.cginc


float3 posToLightVec = lightInput.pos.xyz - worldPos * lightInput.pos.w;
float distanceSqr = max(dot(posToLightVec, posToLightVec), 0.001);
// TODO: Test separating dir lights into diff loop by sorting on the pipe and setting -1 on LightIndexMap.
float lightAtten = tex2D(_AttenuationTexture, float2(distanceSqr / attenuationParams.w, 0.0)).a;
float u = (distanceSqr * attenuationParams.z) / attenuationParams.w;
float lightAtten = tex2D(_AttenuationTexture, float2(u, 0.0)).a;
#else
//// attenuationParams.z = kQuadFallOff = (25.0) / (lightRange * lightRange)
//// attenuationParams.w = lightRange * lightRange

正在加载...
取消
保存