using System.Diagnostics ;
using UnityEngine.Experimental.GlobalIllumination ;
using UnityEngine.Rendering ;
using UnityEngine.Rendering.PostProcessing ;
using UnityEngine.XR ;
namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{
{
int vertexLightsCount = lightData . totalAdditionalLightsCount - lightData . pixelAdditionalLightsCount ;
CoreUtils . SetKeyword ( cmd , LightweightKeywords . AdditionalLightsText , lightData . totalAdditionalLightsCount > 0 ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywords . MixedLightingSubtractiveText , m_MixedLightingSetup = = MixedLightingSetup . Subtractive ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywords . VertexLightsText , vertexLightsCount > 0 ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywordString s . AdditionalLights , lightData . totalAdditionalLightsCount > 0 ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywordString s . MixedLightingSubtractive , m_MixedLightingSetup = = MixedLightingSetup . Subtractive ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywordString s . VertexLights , vertexLightsCount > 0 ) ;
// CoreUtils.SetKeyword(cmd, LightweightKeywords.MainLightCookieText, mainLightIndex != -1 && LightweightUtils.IsSupportedCookieType(visibleLights[mainLightIndex].lightType) && visibleLights[mainLightIndex].light.cookie != null);
// CoreUtils.SetKeyword(cmd, LightweightKeywordString s.MainLightCookieText, mainLightIndex != -1 && LightweightUtils.IsSupportedCookieType(visibleLights[mainLightIndex].lightType) && visibleLights[mainLightIndex].light.cookie != null);
LightShadows directionalShadowQuality = shadowData . renderedDirectionalShadowQuality ;
LightShadows localShadowQuality = shadowData . renderedLocalShadowQuality ;
shadowData . supportsSoftShadows ;
CoreUtils . SetKeyword ( cmd , LightweightKeywords . DirectionalShadowsText , directionalShadowQuality ! = LightShadows . None ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywords . LocalShadowsText , localShadowQuality ! = LightShadows . None ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywords . SoftShadowsText , hasSoftShadows ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywordString s . DirectionalShadows , directionalShadowQuality ! = LightShadows . None ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywordString s . LocalShadows , localShadowQuality ! = LightShadows . None ) ;
CoreUtils . SetKeyword ( cmd , LightweightKeywordString s . SoftShadows , hasSoftShadows ) ;
// TODO: Remove this. legacy particles support will be removed from Unity in 2018.3. This should be a shader_feature instead with prop exposed in the Standard particles shader.
CoreUtils . SetKeyword ( cmd , "SOFTPARTICLES_ON" , cameraData . requiresSoftParticles ) ;
ClearFlag clearFlag = GetCameraClearFlag ( camera ) ;
SetRenderTarget ( cmd , RenderBufferLoadAction . DontCare , RenderBufferStoreAction . Store , clearFlag , CoreUtils . ConvertSRGBToActiveColorSpace ( camera . backgroundColor ) ) ;
// If rendering to an intermediate RT we resolve viewport on blit due to offset not being supported
// while rendering to a RT.
if ( colorAttachmentHandle = = - 1 & & cameraData . isDefaultViewport )
cmd . SetViewport ( camera . pixelRect ) ;
// TODO: We need a proper way to handle multiple camera/ camera stack. Issue is: multiple cameras can share a same RT
// (e.g, split screen games). However devs have to be dilligent with it and know when to clear/preserve color.
// For now we make it consistent by resolving viewport with a RT until we can have a proper camera management system
//if (colorAttachmentHandle == -1 && !cameraData.isDefaultViewport)
// cmd.SetViewport(camera.pixelRect);
context . ExecuteCommandBuffer ( cmd ) ;
cmd . Clear ( ) ;
CommandBuffer cmd = CommandBufferPool . Get ( "Final Blit Pass" ) ;
cmd . SetGlobalTexture ( "_BlitTex" , sourceRT ) ;
// We need to handle viewport on a RT. We do it by rendering a fullscreen quad + viewport
SetRenderTarget ( cmd , BuiltinRenderTextureType . CameraTarget , RenderBufferLoadAction . DontCare , RenderBufferStoreAction . Store , ClearFlag . All , Color . black ) ;
SetRenderTarget ( cmd , BuiltinRenderTextureType . CameraTarget , RenderBufferLoadAction . DontCare , RenderBufferStoreAction . Store , ClearFlag . None , Color . black ) ;
cmd . SetViewProjectionMatrices ( Matrix4x4 . identity , Matrix4x4 . identity ) ;
cmd . SetViewport ( cameraData . camera . pixelRect ) ;
LightweightPipeline . DrawFullScreen ( cmd , material ) ;
if ( cameraData . msaaSamples > 1 )
{
cmd . DisableShaderKeyword ( LightweightKeywords . DepthNoMsaa ) ;
cmd . DisableShaderKeyword ( LightweightKeywordString s . DepthNoMsaa ) ;
cmd . DisableShaderKeyword ( LightweightKeywords . DepthMsaa2 ) ;
cmd . EnableShaderKeyword ( LightweightKeywords . DepthMsaa4 ) ;
cmd . DisableShaderKeyword ( LightweightKeywordString s . DepthMsaa2 ) ;
cmd . EnableShaderKeyword ( LightweightKeywordString s . DepthMsaa4 ) ;
cmd . EnableShaderKeyword ( LightweightKeywords . DepthMsaa2 ) ;
cmd . DisableShaderKeyword ( LightweightKeywords . DepthMsaa4 ) ;
cmd . EnableShaderKeyword ( LightweightKeywordString s . DepthMsaa2 ) ;
cmd . DisableShaderKeyword ( LightweightKeywordString s . DepthMsaa4 ) ;
cmd . EnableShaderKeyword ( LightweightKeywords . DepthNoMsaa ) ;
cmd . DisableShaderKeyword ( LightweightKeywords . DepthMsaa2 ) ;
cmd . DisableShaderKeyword ( LightweightKeywords . DepthMsaa4 ) ;
cmd . EnableShaderKeyword ( LightweightKeywordString s . DepthNoMsaa ) ;
cmd . DisableShaderKeyword ( LightweightKeywordString s . DepthMsaa2 ) ;
cmd . DisableShaderKeyword ( LightweightKeywordString s . DepthMsaa4 ) ;
LightweightPipeline . CopyTexture ( cmd , depthSurface , copyDepthSurface , m_DepthCopyMaterial ) ;
}
context . ExecuteCommandBuffer ( cmd ) ;