|
|
|
|
|
|
else |
|
|
|
m_IntermediateTextureArray = false; |
|
|
|
|
|
|
|
bool hdrEnabled = m_Asset.SupportsHDR && m_CurrCamera.allowHDR; |
|
|
|
m_Asset.RenderScale < 1.0f || m_CurrCamera.allowHDR; |
|
|
|
m_Asset.RenderScale < 1.0f || hdrEnabled; |
|
|
|
m_ColorFormat = m_CurrCamera.allowHDR ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32; |
|
|
|
m_ColorFormat = hdrEnabled ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default; |
|
|
|
m_RequiredDepth = false; |
|
|
|
m_CameraPostProcessLayer = m_CurrCamera.GetComponent<PostProcessLayer>(); |
|
|
|
|
|
|
|
|
|
|
bias = light.shadowBias * proj.m22 * 0.5f * sign; |
|
|
|
|
|
|
|
// Currently only square POT cascades resolutions are used.
|
|
|
|
// We scale normalBias
|
|
|
|
// We scale normalBias
|
|
|
|
double frustumWidth = 2.0 / (double)proj.m00; |
|
|
|
double frustumHeight = 2.0 / (double)proj.m11; |
|
|
|
float texelSizeX = (float)(frustumWidth / (double)cascadeResolution); |
|
|
|
|
|
|
CoreUtils.SetKeyword(cmd, "_MIXED_LIGHTING_SUBTRACTIVE", m_MixedLightingSetup == MixedLightingSetup.Subtractive); |
|
|
|
CoreUtils.SetKeyword(cmd, "_VERTEX_LIGHTS", vertexLightsCount > 0); |
|
|
|
CoreUtils.SetKeyword(cmd, "SOFTPARTICLES_ON", m_Asset.RequireCameraDepthTexture); |
|
|
|
|
|
|
|
bool linearFogModeEnabled = false; |
|
|
|
bool exponentialFogModeEnabled = false; |
|
|
|
if (RenderSettings.fog) |
|
|
|
{ |
|
|
|
if (RenderSettings.fogMode == FogMode.Linear) |
|
|
|
linearFogModeEnabled = true; |
|
|
|
else |
|
|
|
exponentialFogModeEnabled = true; |
|
|
|
} |
|
|
|
|
|
|
|
CoreUtils.SetKeyword(cmd, "FOG_LINEAR", linearFogModeEnabled); |
|
|
|
CoreUtils.SetKeyword(cmd, "FOG_EXP2", exponentialFogModeEnabled); |
|
|
|
} |
|
|
|
|
|
|
|
private bool RenderShadows(ref CullResults cullResults, ref VisibleLight shadowLight, int shadowLightIndex, ref ScriptableRenderContext context) |
|
|
|
|
|
|
worldToShadow = cascadeAtlas * worldToShadow; |
|
|
|
|
|
|
|
m_ShadowSlices[cascadeIndex].atlasX = atlasX; |
|
|
|
m_ShadowSlices[cascadeIndex].atlasY = atlasY; |
|
|
|
m_ShadowSlices[cascadeIndex].atlasY = atlasY; |
|
|
|
m_ShadowSlices[cascadeIndex].shadowResolution = shadowResolution; |
|
|
|
m_ShadowSlices[cascadeIndex].shadowTransform = worldToShadow; |
|
|
|
} |
|
|
|
|
|
|
{ |
|
|
|
// If PostProcessing is enabled, it is already blit to CameraTarget.
|
|
|
|
if (!LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.PostProcess)) |
|
|
|
Blit(cmd, renderingConfig, BuiltinRenderTextureType.CurrentActive, BuiltinRenderTextureType.CameraTarget); |
|
|
|
Blit(cmd, renderingConfig, BuiltinRenderTextureType.CurrentActive, BuiltinRenderTextureType.CameraTarget, m_BlitMaterial); |
|
|
|
} |
|
|
|
|
|
|
|
SetRenderTarget(cmd, BuiltinRenderTextureType.CameraTarget); |
|
|
|
|
|
|
|
|
|
|
private void Blit(CommandBuffer cmd, FrameRenderingConfiguration renderingConfig, RenderTargetIdentifier sourceRT, RenderTargetIdentifier destRT, Material material = null) |
|
|
|
{ |
|
|
|
cmd.SetGlobalTexture(m_BlitTexID, sourceRT); |
|
|
|
if (LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.DefaultViewport)) |
|
|
|
{ |
|
|
|
cmd.Blit(sourceRT, destRT, material); |
|
|
|
|
|
|
if (m_BlitQuad == null) |
|
|
|
m_BlitQuad = LightweightUtils.CreateQuadMesh(false); |
|
|
|
|
|
|
|
cmd.SetGlobalTexture(m_BlitTexID, sourceRT); |
|
|
|
cmd.DrawMesh(m_BlitQuad, Matrix4x4.identity, m_BlitMaterial); |
|
|
|
cmd.DrawMesh(m_BlitQuad, Matrix4x4.identity, material); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|