Example #1
0
        void OnWillRenderObject()
        {
            if (m_Master)
            {
                var cam = Camera.current;
                if (material)
                {
                    var   camForwardVectorOSN   = transform.InverseTransformDirection(cam.transform.forward).normalized;
                    float camIsInsideBeamFactor = cam.orthographic ? -1f : m_Master.GetInsideBeamFactor(cam.transform.position);
                    material.SetVector("_CameraParams", new Vector4(camForwardVectorOSN.x, camForwardVectorOSN.y, camForwardVectorOSN.z, camIsInsideBeamFactor));

                    if (m_Master.colorMode == ColorMode.Gradient)
                    {
                        // Send the gradient matrix every frame since it's not a shader's property
                        material.SetMatrix("_ColorGradientMatrix", m_ColorGradientMatrix);
                    }
                }

#if FORCE_CURRENT_CAMERA_DEPTH_TEXTURE_MODE
                if (m_Master.depthBlendDistance > 0f)
                {
                    cam.depthTextureMode |= DepthTextureMode.Depth;
                }
#endif
            }
        }
Example #2
0
        void OnWillRenderObject()
        {
            if (m_Master)
            {
                var cam = Camera.current;
                if (material)
                {
                    var   camForwardVectorOSN   = transform.InverseTransformDirection(cam.transform.forward).normalized;
                    float camIsInsideBeamFactor = cam.orthographic ? -1f : m_Master.GetInsideBeamFactor(cam.transform.position);
                    material.SetVector("_CameraParams", new Vector4(camForwardVectorOSN.x, camForwardVectorOSN.y, camForwardVectorOSN.z, camIsInsideBeamFactor));
                }

#if FORCE_CURRENT_CAMERA_DEPTH_TEXTURE_MODE
                if (m_Master.depthBlendDistance > 0f)
                {
                    cam.depthTextureMode |= DepthTextureMode.Depth;
                }
#endif
            }
        }