Esempio n. 1
0
 void UpdateMatricesPropertiesForGPUInstancingSRP()
 {
     if (SRPHelper.IsUsingCustomRenderPipeline() && Config.Instance.actualRenderingMode == RenderingMode.GPUInstancing)
     {
         SetMaterialProp(ShaderProperties.LocalToWorldMatrix, transform.localToWorldMatrix);
         SetMaterialProp(ShaderProperties.WorldToLocalMatrix, transform.worldToLocalMatrix);
     }
 }
Esempio n. 2
0
        void OnEnable()
        {
            // When a GAO is disabled, all its coroutines are killed, so renable them on OnEnable.
            RestartFadeOutCoroutine();

#if VLB_SRP_SUPPORT
            SRPHelper.RegisterOnBeginCameraRendering(OnBeginCameraRenderingSRP);
#endif
        }
Esempio n. 3
0
        protected override bool OnProcessOcclusion(ProcessOcclusionSource source)
        {
            Debug.Assert(m_Master && m_DepthCamera);

            if (source == ProcessOcclusionSource.RenderLoop && SRPHelper.IsUsingCustomRenderPipeline()) // Recursive rendering is not supported on SRP
            {
                m_NeedToUpdateOcclusionNextFrame = true;
            }
            else
            {
                ProcessOcclusionInternal();
            }

            return(true);
        }
Esempio n. 4
0
        void OnWillRenderObject()
        {
            Camera currentCam = null;

#if VLB_SRP_SUPPORT
            if (SRPHelper.IsUsingCustomRenderPipeline())
            {
                currentCam = m_CurrentCameraRenderingSRP;
            }
            else
#endif
            {
                currentCam = Camera.current;
            }

            OnWillCameraRenderThisBeam(currentCam);
        }
Esempio n. 5
0
        void UpdateCameraRelatedProperties(Camera cam)
        {
            if (cam && m_Master)
            {
                MaterialChangeStart();
                {
                    var camPosOS = m_Master.transform.InverseTransformPoint(cam.transform.position);

                    var   camForwardVectorOSN   = transform.InverseTransformDirection(cam.transform.forward).normalized;
                    float camIsInsideBeamFactor = cam.orthographic ? -1f : m_Master.GetInsideBeamFactorFromObjectSpacePos(camPosOS);
                    SetMaterialProp(ShaderProperties.CameraParams, new Vector4(camForwardVectorOSN.x, camForwardVectorOSN.y, camForwardVectorOSN.z, camIsInsideBeamFactor));

#if VLB_SRP_SUPPORT
                    // This update is to be able to move beams without trackChangesDuringPlaytime enabled with SRP & GPU Instancing
                    UpdateMatricesPropertiesForGPUInstancingSRP();

                #if UNITY_2017_3_OR_NEWER // ScalableBufferManager introduced in Unity 2017.3
                    if (SRPHelper.IsUsingCustomRenderPipeline())
                    {
                        var bufferSize = cam.allowDynamicResolution ? new Vector2(ScalableBufferManager.widthScaleFactor, ScalableBufferManager.heightScaleFactor) : Vector2.one;
                        SetMaterialProp(ShaderProperties.CameraBufferSizeSRP, bufferSize);
                    }
                #endif
#endif

                    if (m_Master.colorMode == ColorMode.Gradient)
                    {
                        // Send the gradient matrix every frame since it's not a shader's property
                        SetMaterialProp(ShaderProperties.ColorGradientMatrix, m_ColorGradientMatrix);
                    }
                }
                MaterialChangeStop();

#if FORCE_CURRENT_CAMERA_DEPTH_TEXTURE_MODE
                if (m_Master.depthBlendDistance > 0f)
                {
                    cam.depthTextureMode |= DepthTextureMode.Depth;
                }
#endif
            }
        }
Esempio n. 6
0
 void OnDisable()
 {
     SRPHelper.UnregisterOnBeginCameraRendering(OnBeginCameraRenderingSRP);
     m_CurrentCameraRenderingSRP = null;
 }