Ejemplo n.º 1
0
 public void Setup(RenderTexture dst, ref LookingGlassRenderingInfo dinfo,
                   ref LookingGlassRenderInfoPerCamera perCamInfo)
 {
     dstTiledTexture    = dst;
     this.drawInfo      = dinfo;
     this.perCameraInfo = perCamInfo;
 }
Ejemplo n.º 2
0
 public bool HaveToRemakeRenderTexture(ref LookingGlassRenderingInfo obj)
 {
     return((this.renderMethod != obj.renderMethod) ||
            (this.renderTargetW != obj.renderTargetW) ||
            (this.renderTargetH != obj.renderTargetH) ||
            (this.tileSizeX != obj.tileSizeX) ||
            (this.tileSizeY != obj.tileSizeY));
 }
Ejemplo n.º 3
0
 public void SetUp(RenderTargetHandle colorHandle, RenderTexture texture,
                   ref LookingGlassRenderingInfo dinfo, ref LookingGlassDeviceConfig dconfig)
 {
     this.colorAttachmentHandle = colorHandle;
     tiledTexture = texture;
     drawInfo     = dinfo;
     deviceConfig = dconfig;
 }
Ejemplo n.º 4
0
        public void Setup(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            Init();

            Camera camera = renderingData.cameraData.camera;

            renderer.SetupPerObjectLightIndices(ref renderingData.cullResults, ref renderingData.lightData);
            RenderTextureDescriptor baseDescriptor   = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData);
            RenderTextureDescriptor shadowDescriptor = baseDescriptor;
            ClearFlag clearFlag = ScriptableRenderer.GetCameraClearFlag(renderingData.cameraData.camera);

            shadowDescriptor.dimension = TextureDimension.Tex2D;

            bool requiresRenderToTexture = ScriptableRenderer.RequiresIntermediateColorTexture(ref renderingData.cameraData, baseDescriptor);

            RenderTargetHandle colorHandle = RenderTargetHandle.CameraTarget;
            RenderTargetHandle depthHandle = RenderTargetHandle.CameraTarget;

            if (requiresRenderToTexture)
            {
                colorHandle = ColorAttachment;
                depthHandle = DepthAttachment;

                var sampleCount = (SampleCount)renderingData.cameraData.msaaSamples;
                m_CreateLightweightRenderTexturesPass.Setup(baseDescriptor, colorHandle, depthHandle, sampleCount);
                renderer.EnqueuePass(m_CreateLightweightRenderTexturesPass);
            }


            bool mainLightShadows = false;

            if (renderingData.shadowData.supportsMainLightShadows)
            {
                mainLightShadows = m_MainLightShadowCasterPass.Setup(MainLightShadowmap, ref renderingData);
                if (mainLightShadows)
                {
                    renderer.EnqueuePass(m_MainLightShadowCasterPass);
                }
            }



            renderer.EnqueuePass(m_SetupForwardRenderingPass);


            RendererConfiguration rendererConfiguration = ScriptableRenderer.GetRendererConfiguration(renderingData.lightData.additionalLightsCount);

            m_SetupLightweightConstants.Setup(renderer.maxVisibleAdditionalLights, renderer.perObjectLightIndices);
            renderer.EnqueuePass(m_SetupLightweightConstants);
            // GameView at LGRP
            if (!renderingData.cameraData.isSceneViewCamera)
            {
                LookingGlassRenderingInfo       info = renderingData.cameraData.lookingGlassInfo;
                LookingGlassDeviceConfig        config;
                LookingGlassRenderInfoPerCamera perCameraInfo;

                var cameraDeviceInfo = camera.GetComponent <LookingGlassCameraInfo>();
                if (cameraDeviceInfo != null)
                {
                    config        = cameraDeviceInfo.config;
                    perCameraInfo = cameraDeviceInfo.renderInfo;
                }
                else
                {
                    config = new LookingGlassDeviceConfig();
                    config.SetUpDefault();
                    perCameraInfo = new LookingGlassRenderInfoPerCamera();
                    perCameraInfo.SetupDefault();
                }

                int depthValue = (info.renderMethod == LookingGlassRenderingInfo.RenderingMethod.RenderMultiPass) ? 0 : 32;
                if (tileTexture != null && oldLookingRenderInfo.HaveToRemakeRenderTexture(ref info))
                {
                    tileTexture.Release();
                    tileTexture = null;
                    Debug.Log("Recreate RenderTexture");
                }

                if (tileTexture == null || !tileTexture)
                {
                    tileTexture      = new RenderTexture(info.renderTargetW, info.renderTargetH, depthValue);
                    tileTexture.name = "LookingGlassQuiltTexture";
                }

                // tile texture draw( changed by method)
                switch (info.renderMethod)
                {
                case LookingGlassRenderingInfo.RenderingMethod.RenderMultiPass:
                    m_LookingMultiTexturePass.Setup(tileTexture, ref info, ref perCameraInfo);
                    renderer.EnqueuePass(m_LookingMultiTexturePass);
                    break;

                case LookingGlassRenderingInfo.RenderingMethod.RenderSinglePassInstancing:
                    m_LookingInstancingRenderPass.Setup(tileTexture, ref info, ref perCameraInfo);
                    renderer.EnqueuePass(m_LookingInstancingRenderPass);
                    break;
                }

                m_LookingFinalPass.SetUp(colorHandle, tileTexture, ref info, ref config);
                renderer.EnqueuePass(m_LookingFinalPass);
                // info setup
                oldLookingRenderInfo = info;
            }
            // SceneView
            else
            {
                m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, clearFlag, camera.backgroundColor, rendererConfiguration);
                renderer.EnqueuePass(m_RenderOpaqueForwardPass);
                if (camera.clearFlags == CameraClearFlags.Skybox && RenderSettings.skybox != null)
                {
                    m_DrawSkyboxPass.Setup(colorHandle, depthHandle);
                    renderer.EnqueuePass(m_DrawSkyboxPass);
                }
                m_RenderTransparentForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, rendererConfiguration);
                renderer.EnqueuePass(m_RenderTransparentForwardPass);
                if (!renderingData.cameraData.isOffscreenRender && colorHandle != RenderTargetHandle.CameraTarget)
                {
                    m_FinalBlitPass.Setup(baseDescriptor, colorHandle);
                    renderer.EnqueuePass(m_FinalBlitPass);
                }
            }

#if UNITY_EDITOR
            if (renderingData.cameraData.isSceneViewCamera)
            {
                m_SceneViewDepthCopyPass.Setup(DepthTexture);
                renderer.EnqueuePass(m_SceneViewDepthCopyPass);
            }
#endif
        }