浏览代码

removed spot falloff scatter support

/projects-TheLastStand
John Parsaie 7 年前
当前提交
7ad6f02f
共有 1 个文件被更改,包括 5 次插入11 次删除
  1. 16
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/Subsurface/Lighting.hlsl

16
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/Subsurface/Lighting.hlsl


half3 color;
half3 attenuation; //NOTE: RGB attenuation for shadow scatter.
half subtractiveModeAttenuation;
int isSpot;
};
///////////////////////////////////////////////////////////////////////////////

light.attenuation = directionAndRealtimeAttenuation.w;
light.subtractiveModeAttenuation = lightInput.distanceAttenuation.w;
light.color = lightInput.color;
light.isSpot = lightInput.spotAttenuation.w;
return light;
}

light.attenuation = directionAndRealtimeAttenuation.w;
light.subtractiveModeAttenuation = lightInput.distanceAttenuation.w;
light.color = lightInput.color;
light.isSpot = lightInput.spotAttenuation.w;
return light;
}

return volumeAlbedo * (exp(-t2 * halfRcpVariance1) * lerpWeight1 + exp(-t2 * halfRcpVariance2) * lerpWeight2);
}
half3 DiffuseScattering(BRDFData brdfData, half3 normalHighWS, half3 lightDirectionWS, half Attenuation, int isSpot)
half3 DiffuseScattering(BRDFData brdfData, half3 normalHighWS, half3 lightDirectionWS, half Attenuation)
//NOTE: We need to account for spot light attenuation here.
float lookup = (0.5 * NdotL + 0.5) * lerp(1, 0.5 * Attenuation + 0.5, isSpot); //Scale lookup to 0..1
float lookup = (0.5 * NdotL + 0.5); //Scale lookup to 0..1
//Sample the preintegrated subsurface scattering.
//NOTE: We only do broad-form scattering, too expensive on mobile to sample 3x for high detail normals.

return lightColor * specularReflection;
}
half3 LightingPhysicallyBased(BRDFData brdfData, half3 lightColor, half3 lightDirectionWS, half3 lightAttenuation, int isSpot, half3 normalWS, half3 viewDirectionWS)
half3 LightingPhysicallyBased(BRDFData brdfData, half3 lightColor, half3 lightDirectionWS, half3 lightAttenuation, half3 normalWS, half3 viewDirectionWS)
half3 NdotL = DiffuseScattering(brdfData, normalWS, lightDirectionWS, lightAttenuation, isSpot);
half3 NdotL = DiffuseScattering(brdfData, normalWS, lightDirectionWS, lightAttenuation);
half3 radiance = lightColor * (lightAttenuation * NdotL);
return DirectBDRF(brdfData, normalWS, lightDirectionWS, viewDirectionWS) * radiance;
}

return LightingPhysicallyBased(brdfData, light.color, light.direction, light.attenuation, light.isSpot, normalWS, viewDirectionWS);
return LightingPhysicallyBased(brdfData, light.color, light.direction, light.attenuation, normalWS, viewDirectionWS);
}
half3 VertexLighting(float3 positionWS, half3 normalWS)

int pixelLightCount = GetPixelLightCount();
for (int i = 0; i < pixelLightCount; ++i)
{
//TODO: DICE Approximation
Light light = GetLight(i, inputData.positionWS);
color += LightingPhysicallyBased(brdfData, light, inputData.normalWS, inputData.viewDirectionWS);
}

正在加载...
取消
保存