private void OnDestroy()
 {
     RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
     if (s_currentInstance == this)
     {
         s_renderPassList.Clear();
         s_currentInstance = null;
     }
 }
Example #2
0
 public ProjectorRendererFeature()
 {
     if (s_projectorPasses == null)
     {
         s_projectorPasses = new Dictionary <Camera, RenderProjectorPass>();
     }
     ++s_instanceCount;
     s_currentInstance = this;
 }
Example #3
0
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            s_currentInstance = this;
            RenderProjectorPass pass;

            if (s_projectorPasses.TryGetValue(renderingData.cameraData.camera, out pass))
            {
                renderer.EnqueuePass(pass);
            }
        }
Example #4
0
        public void AddCustomRenderer(Camera camera, ICustomRenderer customRenderer)
        {
            CustomRendererPass pass = m_cameraToPassMap[camera][customRenderer.renderPassEvent];

            if (pass.rendererCount == 0)
            {
                ProjectorRendererFeature.AddRenderPass(camera, pass);
            }
            pass.AddRenderer(customRenderer);
        }
Example #5
0
        private void OnBeginFrameRendering(ScriptableRenderContext context, Camera[] cameras)
        {
            if (ProjectorRendererFeature.checkUnityProjectorComponentEnabled && !m_projector.enabled)
            {
                return;
            }
            if (m_projector.material == null)
            {
                return;
            }
            if (m_cullingResults == null)
            {
                m_cullingResults = new Dictionary <Camera, CullingResults>();
            }
            m_cullingResults.Clear();
            for (int i = 0, count = cameras.Length; i < count; ++i)
            {
                bool   visible = false;
                Camera cam     = cameras[i];
#if UNITY_EDITOR
                if (cam.cameraType == CameraType.SceneView)
                {
                    visible = StartCullingIfVisible(context, cam);
                }
#endif
                if (m_cameras == null || m_cameras.Length == 0)
                {
#if DEBUG
                    if (Camera.main == null)
                    {
                        Debug.LogError("Camera.main is null! No projectors will be rendered. Please add a camera to Cameras property of Projector For LWRP component.", this);
                    }
#endif
                    if (cam == Camera.main)
                    {
                        visible = StartCullingIfVisible(context, cam);
                    }
                }
                else
                {
                    for (int j = 0, count2 = m_cameras.Length; j < count2; ++j)
                    {
                        if (cam == m_cameras[j])
                        {
                            visible = StartCullingIfVisible(context, cam);
                            break;
                        }
                    }
                }
                if (visible)
                {
                    ProjectorRendererFeature.AddProjector(this, cam);
                }
            }
        }
 public override void Create()
 {
     RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
     s_renderPassList.Clear();
     s_currentInstance = this;
 }
        private void OnBeginFrameRendering(ScriptableRenderContext context, Camera[] cameras)
        {
            if (ProjectorRendererFeature.checkUnityProjectorComponentEnabled && !m_projector.enabled)
            {
                return;
            }
            if (m_projector.material == null)
            {
                return;
            }
            if (m_cullingResults == null)
            {
                m_cullingResults = new Dictionary <Camera, CullingResults>();
            }
            m_cullingResults.Clear();
            if (m_isDynamic)
            {
                System.UInt64 hash = CalculateProjectorPropertyHash(m_projector);
                if (hash != m_projectorPropertyHash)
                {
                    UpdateFrustum();
                    m_projectorPropertyHash = hash;
                }
            }
            for (int i = 0, count = cameras.Length; i < count; ++i)
            {
                bool   visible = false;
                Camera cam     = cameras[i];
#if UNITY_EDITOR
                if (cam.cameraType == CameraType.SceneView)
                {
                    visible = StartCullingIfVisible(context, cam);
                }
#endif
                bool cameraFound = false;
                if (m_cameras != null)
                {
                    for (int j = 0, count2 = m_cameras.Length; j < count2; ++j)
                    {
                        if (cam == m_cameras[j])
                        {
                            cameraFound = true;
                            visible     = StartCullingIfVisible(context, cam);
                            break;
                        }
                    }
                }
                if (!cameraFound)
                {
                    string[] cameraTags = m_cameraTags;
                    if (cameraTags == null || cameraTags.Length == 0)
                    {
                        cameraTags = ProjectorRendererFeature.defaultCameraTags;
                    }
                    if (cameraTags != null)
                    {
                        for (int j = 0, count2 = cameraTags.Length; j < count2; ++j)
                        {
                            if (cam.tag == cameraTags[j])
                            {
                                visible = StartCullingIfVisible(context, cam);
                                break;
                            }
                        }
                    }
                }
                if (visible)
                {
                    ProjectorRendererFeature.AddProjector(this, cam);
                }
            }
        }
Example #8
0
 public ProjectorRendererFeature()
 {
     m_projectorPasses = new Dictionary <Camera, RenderProjectorPass>();
     s_instance        = this;
 }