|
|
|
|
|
|
InitializeMainShadowLightIndex(lights, out lightData.shadowLightIndex); |
|
|
|
} |
|
|
|
|
|
|
|
private void SetupShaderLightConstants(VisibleLight[] lights, ref LightData lightData, ref CullResults cullResults, ref ScriptableRenderContext context) |
|
|
|
{ |
|
|
|
if (lightData.isSingleLight) |
|
|
|
SetupShaderSingleLightConstants(lights, (lightData.pixelLightsCount > 0) ? 0 : -1, ref context); |
|
|
|
else |
|
|
|
SetupShaderLightListConstants(lights, ref lightData, ref context); |
|
|
|
} |
|
|
|
|
|
|
|
private void InitializeLightConstants(VisibleLight[] lights, int lightIndex, out Vector4 lightPos, out Vector4 lightColor, out Vector4 lightSpotDir, |
|
|
|
out Vector4 lightAttenuationParams) |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void SetupShaderSingleLightConstants(VisibleLight[] lights, int lightIndex, ref ScriptableRenderContext context) |
|
|
|
private void SetupShaderLightConstants(VisibleLight[] lights, ref LightData lightData, ref CullResults cullResults, ref ScriptableRenderContext context) |
|
|
|
{ |
|
|
|
CommandBuffer cmd = CommandBufferPool.Get("SetupSingleLightConstants"); |
|
|
|
Vector4 glossyEnvColor = RenderSettings.ambientSkyColor.gamma * RenderSettings.reflectionIntensity; |
|
|
|
|
|
|
|
cmd.SetGlobalVector("_GlossyEnvironmentColor", glossyEnvColor); |
|
|
|
if (m_Asset.AttenuationTexture != null) cmd.SetGlobalTexture("_AttenuationTexture", m_Asset.AttenuationTexture); |
|
|
|
|
|
|
|
if (lightData.isSingleLight) |
|
|
|
SetupShaderSingleLightConstants(cmd, lights, (lightData.pixelLightsCount > 0) ? 0 : -1, ref context); |
|
|
|
else |
|
|
|
SetupShaderLightListConstants(cmd, lights, ref lightData, ref context); |
|
|
|
|
|
|
|
context.ExecuteCommandBuffer(cmd); |
|
|
|
CommandBufferPool.Release(cmd); |
|
|
|
} |
|
|
|
|
|
|
|
private void SetupShaderSingleLightConstants(CommandBuffer cmd, VisibleLight[] lights, int lightIndex, ref ScriptableRenderContext context) |
|
|
|
CommandBuffer cmd = new CommandBuffer() { name = "SetupSingleLightConstants" }; |
|
|
|
if (m_Asset.AttenuationTexture != null) cmd.SetGlobalTexture("_AttenuationTexture", m_Asset.AttenuationTexture); |
|
|
|
context.ExecuteCommandBuffer(cmd); |
|
|
|
cmd.Dispose(); |
|
|
|
private void SetupShaderLightListConstants(VisibleLight[] lights, ref LightData lightData, ref ScriptableRenderContext context) |
|
|
|
private void SetupShaderLightListConstants(CommandBuffer cmd, VisibleLight[] lights, ref LightData lightData, ref ScriptableRenderContext context) |
|
|
|
{ |
|
|
|
int maxLights = Math.Min(kMaxVisibleLights, lights.Length); |
|
|
|
|
|
|
|
|
|
|
lightIndexMap[i] = -1; |
|
|
|
m_CullResults.SetLightIndexMap(lightIndexMap); |
|
|
|
|
|
|
|
CommandBuffer cmd = CommandBufferPool.Get("SetupLightShaderConstants"); |
|
|
|
if (m_Asset.AttenuationTexture != null) cmd.SetGlobalTexture("_AttenuationTexture", m_Asset.AttenuationTexture); |
|
|
|
context.ExecuteCommandBuffer(cmd); |
|
|
|
CommandBufferPool.Release(cmd); |
|
|
|
} |
|
|
|
|
|
|
|
private void SetShaderKeywords(ref LightData lightData, ref ScriptableRenderContext context) |
|
|
|