浏览代码

Checked compiled shaders and updated code for simplicity and consistency.

/main
Felipe Lira 6 年前
当前提交
53d049a2
共有 1 个文件被更改,包括 5 次插入7 次删除
  1. 12
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl

12
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl


// We use a shared distance attenuation for additional directional and puctual lights
// for directional lights attenuation will be 1
half quadFalloff = distanceAttenuation.x;
half denom = distanceSqr * quadFalloff + 1.0;
half lightAtten = 1.0 / denom;
half denom = distanceSqr * quadFalloff + 1.0h;
half lightAtten = 1.0h / denom;
// We need to smoothly fade attenuation to light range. We start fading linearly at 80% of light range
// Therefore:

#else
// The following code is more optimal than indexing unity_4LightIndices0.
// Conditional moves are branch free even on mali-400
half i_rem = (i < 2.0h) ? i : i - 2;
half i_rem = (i < 2.0h) ? i : i - 2.0h;
half2 lightIndex2 = (i < 2.0h) ? unity_4LightIndices0.xy : unity_4LightIndices0.zw;
int lightIndex = (i_rem < 1.0h) ? lightIndex2.x : lightIndex2.y;
#endif

int pixelLightCount = GetPixelLightCount();
for (int i = 0; i < pixelLightCount; ++i)
{
half index = half(i);
Light light = GetLight(index, inputData.positionWS);
Light light = GetLight(i, inputData.positionWS);
light.attenuation *= LocalLightRealtimeShadowAttenuation(light.index, inputData.positionWS);
color += LightingPhysicallyBased(brdfData, light, inputData.normalWS, inputData.viewDirectionWS);
}

int pixelLightCount = GetPixelLightCount();
for (int i = 0; i < pixelLightCount; ++i)
{
half index = half(i);
Light light = GetLight(index, inputData.positionWS);
Light light = GetLight(i, inputData.positionWS);
light.attenuation *= LocalLightRealtimeShadowAttenuation(light.index, inputData.positionWS);
half3 attenuatedLightColor = light.color * light.attenuation;
diffuseColor += LightingLambert(attenuatedLightColor, light.direction, inputData.normalWS);

正在加载...
取消
保存