Example #1
0
        /// <summary>
        /// If a custom command has been provided use that one.
        /// The custom command must copy the screen and depth buffer
        /// into the correct textures but other than that its is free
        /// to post process the grab in anyway.
        /// </summary>
        IRefractionCommand GetRefractionCommand()
        {
            IRefractionCommand cmd = null;

            if (CustomRefractionCommand != null)
            {
                cmd = CustomRefractionCommand;
                //not using default cmd.
                //make sure it has been removed from cameras.
                m_refractionCommand.RemoveAll();
            }
            else
            {
                cmd = m_refractionCommand;
            }

            return(cmd);
        }
Example #2
0
        void Start()
        {
            try
            {
                m_refractionCommand = new RefractionCommand(copyDepthSdr);

                Mesh mesh = CreateBottomMesh(32, 512);

                //The bottom used to render the masks.
                m_bottomMask = new GameObject("Ceto Bottom Mask Gameobject");

                MeshFilter         filter     = m_bottomMask.AddComponent <MeshFilter>();
                MeshRenderer       renderer   = m_bottomMask.AddComponent <MeshRenderer>();
                NotifyOnWillRender willRender = m_bottomMask.AddComponent <NotifyOnWillRender>();

                filter.sharedMesh             = mesh;
                renderer.receiveShadows       = false;
                renderer.shadowCastingMode    = ShadowCastingMode.Off;
                renderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
                renderer.material             = new Material(oceanBottomSdr);

                willRender.AddAction(m_ocean.RenderWaveOverlays);
                willRender.AddAction(m_ocean.RenderOceanMask);
                willRender.AddAction(m_ocean.RenderOceanDepth);

                m_bottomMask.layer     = LayerMask.NameToLayer(Ocean.OCEAN_LAYER);
                m_bottomMask.hideFlags = HideFlags.HideAndDontSave;

                UpdateBottomBounds();

                Destroy(mesh);
            }
            catch (Exception e)
            {
                Ocean.LogError(e.ToString());
                WasError = true;
                enabled  = false;
            }
        }
Example #3
0
        /// <summary>
        /// Create the refraction command buffer.
        /// </summary>
        void CreateRefractionGrab(Camera cam, DepthData data)
        {
            IRefractionCommand cmd      = GetRefractionCommand();
            CameraEvent        cmdEvent = GetCommandEvent(cam);

            //The command has already been created.
            if (data.grabCmd != null)
            {
                if (depthMode != DEPTH_MODE.USE_DEPTH_BUFFER ||
                    refractionResolution != cmd.Resolution ||
                    cmdEvent != data.cmdEvent ||
                    !cmd.Matches(cam))
                {
                    //The current cmd settings no longer match camera
                    //or the depth mode is no longer DEPTH_BUFFER
                    //Remove command and release.
                    cmd.Remove(cam);
                    data.grabCmd = null;
                }
                else
                {
                    //The settings have not changed.
                    return;
                }
            }

            //If the depth mode is USE_DEPTH_BUFFER or useCmdBufferForGrab
            //is true then a command buffer is needed.
            if (depthMode == DEPTH_MODE.USE_DEPTH_BUFFER)
            {
                cmd.Resolution = refractionResolution;
                cmd.Event      = cmdEvent;

                data.grabCmd  = cmd.Create(cam);
                data.cmdEvent = cmdEvent;
            }
        }
Example #4
0
		void Start () 
		{

			try
			{

                m_refractionCommand = new RefractionCommand(copyDepthSdr);

                Mesh mesh = CreateBottomMesh(32, 512);

				//The bottom used to render the masks.
				m_bottomMask = new GameObject("Ceto Bottom Mask Gameobject");

				MeshFilter filter = m_bottomMask.AddComponent<MeshFilter>();
				MeshRenderer renderer = m_bottomMask.AddComponent<MeshRenderer>();
				NotifyOnWillRender willRender = m_bottomMask.AddComponent<NotifyOnWillRender>();

				filter.sharedMesh = mesh;
				renderer.receiveShadows = false;
				renderer.shadowCastingMode = ShadowCastingMode.Off;
				renderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
				renderer.material = new Material(oceanBottomSdr);

                willRender.AddAction(m_ocean.RenderWaveOverlays);
                willRender.AddAction(m_ocean.RenderOceanMask);
				willRender.AddAction(m_ocean.RenderOceanDepth);

				m_bottomMask.layer = LayerMask.NameToLayer(Ocean.OCEAN_LAYER);
				m_bottomMask.hideFlags = HideFlags.HideAndDontSave;
            
				UpdateBottomBounds();

                Destroy(mesh);

			}
			catch(Exception e)
			{
				Ocean.LogError(e.ToString());
				WasError = true;
				enabled = false;
			}

		
		}