Exemplo n.º 1
0
        // Use this for initialization
        public virtual void Start()
        {
            m_cameraToWorldMatrix = Matrix4x4d.Identity();

            //using different materials for both the far and near cameras because they have different projection matrixes
            //the projection matrix in the shader has to match that of the camera or the projection will be wrong and the ocean will
            //appear to "shift around"
            m_oceanMaterialNear = new Material(ShaderTool.GetMatFromShader2("CompiledOceanWhiteCaps.shader"));
            m_oceanMaterialFar  = new Material(ShaderTool.GetMatFromShader2("CompiledOceanWhiteCaps.shader"));

            m_manager.GetSkyNode().InitUniforms(m_oceanMaterialNear);
            m_manager.GetSkyNode().InitUniforms(m_oceanMaterialFar);

            m_oldlocalToOcean = Matrix4x4d.Identity();
            m_oldworldToOcean = Matrix4x4d.Identity();
            m_offset          = Vector3d2.Zero();

            //Create the projected grid. The resolution is the size in pixels
            //of each square in the grid. If the squares are small the size of
            //the mesh will exceed the max verts for a mesh in Unity. In this case
            //split the mesh up into smaller meshes.

            m_resolution = Mathf.Max(1, m_resolution);
            //The number of squares in the grid on the x and y axis
            int NX = Screen.width / m_resolution;
            int NY = Screen.height / m_resolution;

            numGrids = 1;

            //			const int MAX_VERTS = 65000;
            //The number of meshes need to make a grid of this resolution
            if (NX * NY > MAX_VERTS)
            {
                numGrids += (NX * NY) / MAX_VERTS;
            }

            m_screenGrids = new Mesh[numGrids];

//			waterGameObjectsNear = new GameObject[numGrids];
//			waterMeshRenderersNear = new MeshRenderer[numGrids];
//			waterMeshFiltersNear = new MeshFilter[numGrids];
//
//			waterGameObjectsFar = new GameObject[numGrids];
//			waterMeshRenderersFar = new MeshRenderer[numGrids];
//			waterMeshFiltersFar = new MeshFilter[numGrids];

            //Make the meshes. The end product will be a grid of verts that cover
            //the screen on the x and y axis with the z depth at 0. This grid is then
            //projected as the ocean by the shader
            for (int i = 0; i < numGrids; i++)
            {
                NY = Screen.height / numGrids / m_resolution;

                m_screenGrids [i]        = MakePlane(NX, NY, (float)i / (float)numGrids, 1.0f / (float)numGrids);
                m_screenGrids [i].bounds = new Bounds(Vector3.zero, new Vector3(1e8f, 1e8f, 1e8f));


                //bad idea, the meshes still render arbitrarily to the near and far camera and end up drawing over everything
                //to get around this I use drawmesh further down
                //seems to have better performance also

//								waterGameObjectsNear[i] = new GameObject();
//								waterGameObjectsNear[i].transform.parent=m_manager.parentCelestialBody.transform;
//								waterMeshFiltersNear[i] = waterGameObjectsNear[i].AddComponent<MeshFilter>();
//								waterMeshFiltersNear[i].mesh.Clear ();
//								waterMeshFiltersNear[i].mesh = m_screenGrids[i];
//								waterGameObjectsNear[i].layer = 15;
//
//								waterMeshRenderersNear[i] = waterGameObjectsNear[i].AddComponent<MeshRenderer>();
//
//								waterMeshRenderersNear[i].sharedMaterial = m_oceanMaterialNear;
//								waterMeshRenderersNear[i].material =m_oceanMaterialNear;
//
//								waterMeshRenderersNear[i].castShadows = false;
//								waterMeshRenderersNear[i].receiveShadows = false;
//
//								waterMeshRenderersNear[i].enabled=true;
//
//
//				waterGameObjectsFar[i] = new GameObject();
//				waterGameObjectsFar[i].transform.parent=m_manager.parentCelestialBody.transform;
//				waterMeshFiltersFar[i] = waterGameObjectsFar[i].AddComponent<MeshFilter>();
//				waterMeshFiltersFar[i].mesh.Clear ();
//				waterMeshFiltersFar[i].mesh = m_screenGrids[i];
//				waterGameObjectsFar[i].layer = 15;
//
//				waterMeshRenderersFar[i] = waterGameObjectsFar[i].AddComponent<MeshRenderer>();
//
//				waterMeshRenderersFar[i].sharedMaterial = m_oceanMaterialFar;
//				waterMeshRenderersFar[i].material =m_oceanMaterialFar;
//
//				waterMeshRenderersFar[i].castShadows = false;
//				waterMeshRenderersFar[i].receiveShadows = false;
//
//				waterMeshRenderersFar[i].enabled=true;
            }

//			PQS pqs = m_manager.parentCelestialBody.pqsController;
//
//			if (pqs.ChildSpheres[0])
//				UnityEngine.Object.Destroy (pqs.ChildSpheres [0]);

//			if (ocean)
//			{
//				UnityEngine.Object.Destroy (ocean);
//			}



            //				Debug.Log("PQS.childspheres count"+pqs.ChildSpheres.Length);

//			PQS pqs = m_manager.parentCelestialBody.pqsController;
//			if (pqs.ChildSpheres [0]) {
//				ocean = pqs.ChildSpheres [0];
//				//					ocean.surfaceMaterial = new Material (ShaderTool.GetMatFromShader2 ("EmptyShader.shader"));
//
//				///Thanks to rbray89 for this snippet that disables the stock ocean in a clean way
//				GameObject container = ocean.gameObject;
//
//				FakeOceanPQS fakeOcean1 = new GameObject ().AddComponent<FakeOceanPQS> ();
//
//				fakeOcean1.CloneFrom (ocean);
//				Destroy (ocean);
//
//				FakeOceanPQS fakeOcean = container.AddComponent<FakeOceanPQS> ();
//				fakeOcean.CloneFrom (fakeOcean1);
//
//				Destroy (fakeOcean1);
//
//				FieldInfo field = typeof(PQS).GetFields (BindingFlags.Instance | BindingFlags.NonPublic).First (
//					f => f.FieldType == typeof(PQS[]));
//				field.SetValue (pqs, new PQS[] {fakeOcean });
//
//				PQSMod_CelestialBodyTransform cbt = pqs.GetComponentsInChildren<PQSMod_CelestialBodyTransform> () [0];
//				cbt.secondaryFades = new PQSMod_CelestialBodyTransform.AltitudeFade[] { };
//			}


//			fakeOceanMesh = isosphere.Create (m_manager.GetRadius());
//
//
//			fakeOcean = new GameObject ();
//			fakeOceanMF = fakeOcean.AddComponent<MeshFilter>();
//			fakeOceanMF.mesh = fakeOceanMesh;
//			fakeOcean.layer = 15;
//
//
//			fakeOcean.transform.parent = m_manager.parentCelestialBody.transform;
//
//			fakeOceanMR = fakeOcean.AddComponent<MeshRenderer>();
//
//			newMat = new Material (ShaderTool.GetMatFromShader2 ("BlackShader.shader"));
//			fakeOceanMR.sharedMaterial = newMat;
//			fakeOceanMR.material =newMat;
//
//			fakeOceanMR.castShadows = false;
//			fakeOceanMR.receiveShadows = false;
        }
Exemplo n.º 2
0
        // Use this for initialization
        public virtual void Init()
        {
            if (Core.Instance.oceanPixelLights)
            {
                m_oceanMaterial = new Material(ShaderReplacer.Instance.LoadedShaders[("Scatterer/OceanWhiteCapsPixelLights")]);
            }
            else
            {
                m_oceanMaterial = new Material(ShaderReplacer.Instance.LoadedShaders[("Scatterer/OceanWhiteCaps")]);
            }

            if (Core.Instance.oceanSkyReflections)
            {
                m_oceanMaterial.EnableKeyword("SKY_REFLECTIONS_ON");
                m_oceanMaterial.DisableKeyword("SKY_REFLECTIONS_OFF");
            }
            else
            {
                m_oceanMaterial.EnableKeyword("SKY_REFLECTIONS_OFF");
                m_oceanMaterial.DisableKeyword("SKY_REFLECTIONS_ON");
            }

            if (Core.Instance.usePlanetShine)
            {
                m_oceanMaterial.EnableKeyword("PLANETSHINE_ON");
                m_oceanMaterial.DisableKeyword("PLANETSHINE_OFF");
            }
            else
            {
                m_oceanMaterial.DisableKeyword("PLANETSHINE_ON");
                m_oceanMaterial.EnableKeyword("PLANETSHINE_OFF");
            }

            if (Core.Instance.oceanRefraction)
            {
                m_oceanMaterial.EnableKeyword("REFRACTION_ON");
                m_oceanMaterial.DisableKeyword("REFRACTION_OFF");
            }
            else
            {
                m_oceanMaterial.EnableKeyword("REFRACTION_OFF");
                m_oceanMaterial.DisableKeyword("REFRACTION_ON");
            }

            if (Core.Instance.shadowsOnOcean && (QualitySettings.shadows != ShadowQuality.Disable))
            {
                if (QualitySettings.shadows == ShadowQuality.HardOnly)
                {
                    m_oceanMaterial.EnableKeyword("OCEAN_SHADOWS_HARD");
                    m_oceanMaterial.DisableKeyword("OCEAN_SHADOWS_SOFT");
                }
                else
                {
                    m_oceanMaterial.EnableKeyword("OCEAN_SHADOWS_SOFT");
                    m_oceanMaterial.DisableKeyword("OCEAN_SHADOWS_HARD");
                }
                m_oceanMaterial.DisableKeyword("OCEAN_SHADOWS_OFF");
            }
            else
            {
                m_oceanMaterial.EnableKeyword("OCEAN_SHADOWS_OFF");
                m_oceanMaterial.DisableKeyword("OCEAN_SHADOWS_HARD");
                m_oceanMaterial.DisableKeyword("OCEAN_SHADOWS_SOFT");
            }

            m_oceanMaterial.SetOverrideTag("IgnoreProjector", "True");

            m_manager.GetSkyNode().InitUniforms(m_oceanMaterial);

            m_oceanMaterial.SetTexture(ShaderProperties._customDepthTexture_PROPERTY, Core.Instance.bufferRenderingManager.depthTexture);

            //if (Core.Instance.oceanRefraction)
            m_oceanMaterial.SetTexture("_BackgroundTexture", Core.Instance.bufferRenderingManager.refractionTexture);
            m_oceanMaterial.renderQueue = 2501;

            m_oldlocalToOcean = Matrix4x4d.Identity();

            m_offset = Vector3d2.Zero();

            //Create the projected grid. The resolution is the size in pixels
            //of each square in the grid. If the squares are small the size of
            //the mesh will exceed the max verts for a mesh in Unity. In this case
            //split the mesh up into smaller meshes.

            m_resolution = Mathf.Max(1, m_resolution);
            //The number of squares in the grid on the x and y axis
            int NX = Screen.width / m_resolution;
            int NY = Screen.height / m_resolution;

            numGrids = 1;

            //			const int MAX_VERTS = 65000;
            //The number of meshes need to make a grid of this resolution
            if (NX * NY > MAX_VERTS)
            {
                numGrids += (NX * NY) / MAX_VERTS;
            }

            m_screenGrids = new Mesh[numGrids];

            waterGameObjects   = new GameObject[numGrids];
            waterMeshRenderers = new MeshRenderer[numGrids];
            waterMeshFilters   = new MeshFilter[numGrids];

            //Make the meshes. The end product will be a grid of verts that cover
            //the screen on the x and y axis with the z depth at 0. This grid is then
            //projected as the ocean by the shader
            for (int i = 0; i < numGrids; i++)
            {
                NY = Screen.height / numGrids / m_resolution;

                m_screenGrids [i]        = MakePlane(NX, NY, (float)i / (float)numGrids, 1.0f / (float)numGrids);
                m_screenGrids [i].bounds = new Bounds(Vector3.zero, new Vector3(1e8f, 1e8f, 1e8f));


                waterGameObjects[i] = new GameObject();
                waterGameObjects[i].transform.parent = m_manager.parentCelestialBody.transform;               //might be redundant
                waterMeshFilters[i] = waterGameObjects[i].AddComponent <MeshFilter>();
                waterMeshFilters[i].mesh.Clear();
                waterMeshFilters[i].mesh = m_screenGrids[i];

                waterGameObjects[i].layer = 15;
                waterMeshRenderers[i]     = waterGameObjects[i].AddComponent <MeshRenderer>();

                waterMeshRenderers[i].sharedMaterial = m_oceanMaterial;
                waterMeshRenderers[i].material       = m_oceanMaterial;

                waterMeshRenderers[i].receiveShadows    = false;
                waterMeshRenderers[i].shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;

                waterMeshRenderers[i].enabled = true;
            }

            oceanCameraProjectionMatModifier           = waterGameObjects[0].AddComponent <OceanCameraUpdateHook>();
            oceanCameraProjectionMatModifier.oceanNode = this;

            underwaterMaterial = new Material(ShaderReplacer.Instance.LoadedShaders[("Scatterer/UnderwaterScatterProjector")]);
            m_manager.GetSkyNode().InitPostprocessMaterial(underwaterMaterial);
            m_manager.GetSkyNode().InitPostprocessMaterial(m_oceanMaterial);

            underwaterMaterial.renderQueue = 2502;           //draw over fairings which is 2450 and over ocean which is 2501

            underwaterProjector = new AtmosphereProjector(underwaterMaterial, m_manager.parentLocalTransform, (float)m_manager.m_radius);
            underwaterProjector.setActivated(false);

            initUniforms();

            //move this to separate class and make it work on every camera

            //refraction command buffer
            oceanRefractionCommandBuffer      = new CommandBuffer();
            oceanRefractionCommandBuffer.name = "ScattererOceanGrabScreen";

            // copy screen
            oceanRefractionCommandBuffer.Blit(BuiltinRenderTextureType.CurrentActive, Core.Instance.bufferRenderingManager.refractionTexture);

            Core.Instance.farCamera.AddCommandBuffer(CameraEvent.AfterForwardOpaque, oceanRefractionCommandBuffer);
            Core.Instance.nearCamera.AddCommandBuffer(CameraEvent.AfterForwardOpaque, oceanRefractionCommandBuffer);

            //dimming
            if (Core.Instance.underwaterLightDimming && (HighLogic.LoadedScene != GameScenes.MAINMENU))
            {
                underwaterDimmingHook           = (UnderwaterDimmingHook)Core.Instance.scaledSpaceCamera.gameObject.AddComponent(typeof(UnderwaterDimmingHook));
                underwaterDimmingHook.oceanNode = this;
            }
        }
Exemplo n.º 3
0
        // Use this for initialization
        public virtual void Start()
        {
//			m_cameraToWorldMatrix = Matrix4x4d.Identity ();
//
            //using different materials for both the far and near cameras because they have different projection matrixes
            //the projection matrix in the shader has to match that of the camera or the projection will be wrong and the ocean will
            //appear to "shift around"

            if (Core.Instance.oceanPixelLights)
            {
                m_oceanMaterial = new Material(ShaderReplacer.Instance.LoadedShaders[("Scatterer/OceanWhiteCapsPixelLights")]);
            }
            else
            {
                m_oceanMaterial = new Material(ShaderReplacer.Instance.LoadedShaders[("Scatterer/OceanWhiteCaps")]);
            }

            if (Core.Instance.oceanSkyReflections)
            {
                m_oceanMaterial.EnableKeyword("SKY_REFLECTIONS_ON");
                m_oceanMaterial.DisableKeyword("SKY_REFLECTIONS_OFF");
            }
            else
            {
                m_oceanMaterial.EnableKeyword("SKY_REFLECTIONS_OFF");
                m_oceanMaterial.DisableKeyword("SKY_REFLECTIONS_ON");
            }

            if (Core.Instance.usePlanetShine)
            {
                m_oceanMaterial.EnableKeyword("PLANETSHINE_ON");
                m_oceanMaterial.DisableKeyword("PLANETSHINE_OFF");
            }
            else
            {
                m_oceanMaterial.DisableKeyword("PLANETSHINE_ON");
                m_oceanMaterial.EnableKeyword("PLANETSHINE_OFF");
            }

            if (Core.Instance.oceanRefraction)
            {
                m_oceanMaterial.EnableKeyword("REFRACTION_ON");
                m_oceanMaterial.DisableKeyword("REFRACTION_OFF");
            }
            else
            {
                m_oceanMaterial.EnableKeyword("REFRACTION_OFF");
                m_oceanMaterial.DisableKeyword("REFRACTION_ON");
            }


//			m_manager.GetSkyNode ().InitUniforms (m_oceanMaterialNear);


            m_manager.GetSkyNode().InitUniforms(m_oceanMaterial);

            m_oceanMaterial.SetTexture(ShaderProperties._customDepthTexture_PROPERTY, Core.Instance.customDepthBufferTexture);

            m_oceanMaterial.SetTexture("_BackgroundTexture", Core.Instance.refractionTexture);

            m_oceanMaterial.renderQueue = 2050;

            m_oldlocalToOcean = Matrix4x4d.Identity();
//			m_oldworldToOcean = Matrix4x4d.Identity ();
            m_offset = Vector3d2.Zero();

            //Create the projected grid. The resolution is the size in pixels
            //of each square in the grid. If the squares are small the size of
            //the mesh will exceed the max verts for a mesh in Unity. In this case
            //split the mesh up into smaller meshes.

            m_resolution = Mathf.Max(1, m_resolution);
            //The number of squares in the grid on the x and y axis
            int NX = Screen.width / m_resolution;
            int NY = Screen.height / m_resolution;

            numGrids = 1;

            //			const int MAX_VERTS = 65000;
            //The number of meshes need to make a grid of this resolution
            if (NX * NY > MAX_VERTS)
            {
                numGrids += (NX * NY) / MAX_VERTS;
            }

            m_screenGrids = new Mesh[numGrids];

            waterGameObjects   = new GameObject[numGrids];
            waterMeshRenderers = new MeshRenderer[numGrids];
            waterMeshFilters   = new MeshFilter[numGrids];

            //Make the meshes. The end product will be a grid of verts that cover
            //the screen on the x and y axis with the z depth at 0. This grid is then
            //projected as the ocean by the shader
            for (int i = 0; i < numGrids; i++)
            {
                NY = Screen.height / numGrids / m_resolution;

                m_screenGrids [i]        = MakePlane(NX, NY, (float)i / (float)numGrids, 1.0f / (float)numGrids);
                m_screenGrids [i].bounds = new Bounds(Vector3.zero, new Vector3(1e8f, 1e8f, 1e8f));


                waterGameObjects[i] = new GameObject();
                waterGameObjects[i].transform.parent = m_manager.parentCelestialBody.transform;               //might be redundant
                waterMeshFilters[i] = waterGameObjects[i].AddComponent <MeshFilter>();
                waterMeshFilters[i].mesh.Clear();
                waterMeshFilters[i].mesh = m_screenGrids[i];

                //waterGameObjects[i].layer = 15;
                waterGameObjects[i].layer = 23;
                waterMeshRenderers[i]     = waterGameObjects[i].AddComponent <MeshRenderer>();


                waterMeshRenderers[i].sharedMaterial = m_oceanMaterial;
                waterMeshRenderers[i].material       = m_oceanMaterial;


                waterMeshRenderers[i].receiveShadows    = false;
                waterMeshRenderers[i].shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;


//				CommandBufferModifiedProjectionMatrix tmp = waterGameObjects[i].AddComponent<CommandBufferModifiedProjectionMatrix>();
//				tmp.Core.Instance=Core.Instance;

                waterMeshRenderers[i].enabled = true;
            }

            cbProjectionMat           = waterGameObjects[0].AddComponent <CommandBufferModifiedProjectionMatrix>();
            cbProjectionMat.oceanNode = this;

            underwaterGameObject = new GameObject();

            if (underwaterGameObject.GetComponent <MeshFilter> ())
            {
                underwaterMeshFilter = underwaterGameObject.GetComponent <MeshFilter> ();
            }
            else
            {
                underwaterMeshFilter = underwaterGameObject.AddComponent <MeshFilter>();
            }

            underwaterMeshFilter.mesh.Clear();
            underwaterMeshFilter.mesh        = MeshFactory.MakePlaneWithFrustumIndexes();
            underwaterMeshFilter.mesh.bounds = new Bounds(Vector3.zero, new Vector3(1e8f, 1e8f, 1e8f));

            if (underwaterGameObject.GetComponent <MeshRenderer> ())
            {
                underwaterMeshrenderer = underwaterGameObject.GetComponent <MeshRenderer> ();
            }
            else
            {
                underwaterMeshrenderer = underwaterGameObject.AddComponent <MeshRenderer>();
            }

            underwaterPostProcessingMaterial = new Material(ShaderReplacer.Instance.LoadedShaders[("Scatterer/UnderwaterScatter")]);
            underwaterPostProcessingMaterial.SetOverrideTag("IgnoreProjector", "True");
            m_manager.GetSkyNode().InitPostprocessMaterial(underwaterPostProcessingMaterial);
            underwaterPostProcessingMaterial.renderQueue = 2049;

            if (Core.Instance.oceanRefraction && (HighLogic.LoadedScene != GameScenes.TRACKSTATION))
            {
                Core.Instance.refractionCam.underwaterPostProcessing = underwaterMeshrenderer;
            }
            underwaterMeshrenderer.sharedMaterial = underwaterPostProcessingMaterial;
            underwaterMeshrenderer.material       = underwaterPostProcessingMaterial;

            underwaterMeshrenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            underwaterMeshrenderer.receiveShadows    = false;
            underwaterMeshrenderer.enabled           = false;

            //underwaterGameObject.layer = 15;
            underwaterGameObject.layer = 23;
        }
Exemplo n.º 4
0
        // Use this for initialization
        public virtual void Start()
        {
//			m_cameraToWorldMatrix = Matrix4x4d.Identity ();
//
            //using different materials for both the far and near cameras because they have different projection matrixes
            //the projection matrix in the shader has to match that of the camera or the projection will be wrong and the ocean will
            //appear to "shift around"
//			m_oceanMaterialNear = new Material (ShaderTool.GetMatFromShader2 ("CompiledOceanWhiteCaps.shader"));

            if (m_core.oceanPixelLights)
            {
                m_oceanMaterialFar = new Material(ShaderTool.GetMatFromShader2("CompiledOceanWhiteCapsPixelLights.shader"));
            }
            else
            {
                m_oceanMaterialFar = new Material(ShaderTool.GetMatFromShader2("CompiledOceanWhiteCaps.shader"));
            }

            if (m_core.oceanSkyReflections)
            {
                m_oceanMaterialFar.EnableKeyword("SKY_REFLECTIONS_ON");
                m_oceanMaterialFar.DisableKeyword("SKY_REFLECTIONS_OFF");
            }
            else
            {
                m_oceanMaterialFar.EnableKeyword("SKY_REFLECTIONS_OFF");
                m_oceanMaterialFar.DisableKeyword("SKY_REFLECTIONS_ON");
            }


//			m_manager.GetSkyNode ().InitUniforms (m_oceanMaterialNear);
            m_manager.GetSkyNode().InitUniforms(m_oceanMaterialFar);

            m_oldlocalToOcean = Matrix4x4d.Identity();
//			m_oldworldToOcean = Matrix4x4d.Identity ();
            m_offset = Vector3d2.Zero();

            //Create the projected grid. The resolution is the size in pixels
            //of each square in the grid. If the squares are small the size of
            //the mesh will exceed the max verts for a mesh in Unity. In this case
            //split the mesh up into smaller meshes.

            m_resolution = Mathf.Max(1, m_resolution);
            //The number of squares in the grid on the x and y axis
            int NX = Screen.width / m_resolution;
            int NY = Screen.height / m_resolution;

            numGrids = 1;

            //			const int MAX_VERTS = 65000;
            //The number of meshes need to make a grid of this resolution
            if (NX * NY > MAX_VERTS)
            {
                numGrids += (NX * NY) / MAX_VERTS;
            }

            m_screenGrids = new Mesh[numGrids];

            waterGameObjects   = new GameObject[numGrids];
            waterMeshRenderers = new MeshRenderer[numGrids];
            waterMeshFilters   = new MeshFilter[numGrids];

            //Make the meshes. The end product will be a grid of verts that cover
            //the screen on the x and y axis with the z depth at 0. This grid is then
            //projected as the ocean by the shader
            for (int i = 0; i < numGrids; i++)
            {
                NY = Screen.height / numGrids / m_resolution;

                m_screenGrids [i]        = MakePlane(NX, NY, (float)i / (float)numGrids, 1.0f / (float)numGrids);
                m_screenGrids [i].bounds = new Bounds(Vector3.zero, new Vector3(1e8f, 1e8f, 1e8f));


                waterGameObjects[i] = new GameObject();
                waterGameObjects[i].transform.parent = m_manager.parentCelestialBody.transform;               //might be redundant
                waterMeshFilters[i] = waterGameObjects[i].AddComponent <MeshFilter>();
                waterMeshFilters[i].mesh.Clear();
                waterMeshFilters[i].mesh = m_screenGrids[i];

                waterGameObjects[i].layer = 15;
                waterMeshRenderers[i]     = waterGameObjects[i].AddComponent <MeshRenderer>();


                waterMeshRenderers[i].sharedMaterial = m_oceanMaterialFar;
                waterMeshRenderers[i].material       = m_oceanMaterialFar;

                waterMeshRenderers[i].shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                waterMeshRenderers[i].receiveShadows    = false;

//				CommandBufferModifiedProjectionMatrix tmp = waterGameObjects[i].AddComponent<CommandBufferModifiedProjectionMatrix>();
//				tmp.m_core=m_core;

                waterMeshRenderers[i].enabled = true;
            }

            cbProjectionMat        = waterGameObjects[0].AddComponent <CommandBufferModifiedProjectionMatrix>();
            cbProjectionMat.m_core = m_core;
        }