Esempio n. 1
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     try
     {
         if (this.m_scheduler != null)
         {
             this.m_scheduler.ShutingDown = true;
             this.m_scheduler.CancelAllTasks();
         }
         if (this.m_conditionCache != null)
         {
             foreach (WaveSpectrumCondition current in this.m_conditionCache)
             {
                 current.Release();
             }
             this.m_conditionCache.Clear();
             this.m_conditionCache = null;
         }
         this.Release();
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 2
0
        protected override void OnEnable()
        {
            base.OnEnable();

            if (WasError)
            {
                return;
            }

            try
            {
                // If enabled activate all meshes.
                var e = m_grids.GetEnumerator();
                while (e.MoveNext())
                {
                    Grid grid = e.Current.Value;
                    Activate(grid.top, true);
                    Activate(grid.under, true);
                }
            }
            catch (Exception e)
            {
                Ocean.LogError(e.ToString());
                WasError = true;
                enabled  = false;
            }
        }
Esempio n. 3
0
 private void ApplyProjection(GameObject go)
 {
     try
     {
         if (base.enabled)
         {
             Camera current = Camera.current;
             if (!(current == null))
             {
                 CameraData cameraData = this.m_ocean.FindCameraData(current);
                 if (cameraData.projection == null)
                 {
                     cameraData.projection = new ProjectionData();
                 }
                 if (!cameraData.projection.updated)
                 {
                     this.m_ocean.Projection.UpdateProjection(current, cameraData, this.m_ocean.ProjectSceneView);
                     Shader.SetGlobalMatrix("Ceto_Interpolation", cameraData.projection.interpolation);
                     Shader.SetGlobalMatrix("Ceto_ProjectorVP", cameraData.projection.projectorVP);
                 }
                 if (!cameraData.projection.checkedForFlipping)
                 {
                     int num  = 2;
                     int num2 = 1;
                     if (!Ocean.DISABLE_PROJECTION_FLIPPING)
                     {
                         bool isFlipped = this.m_ocean.Projection.IsFlipped;
                         if (this.oceanTopSideMat != null)
                         {
                             this.oceanTopSideMat.SetInt("_CullFace", (!isFlipped) ? num : num2);
                         }
                         if (this.oceanUnderSideMat != null)
                         {
                             this.oceanUnderSideMat.SetInt("_CullFace", (!isFlipped) ? num2 : num);
                         }
                     }
                     else
                     {
                         if (this.oceanTopSideMat != null)
                         {
                             this.oceanTopSideMat.SetInt("_CullFace", num);
                         }
                         if (this.oceanUnderSideMat != null)
                         {
                             this.oceanUnderSideMat.SetInt("_CullFace", num2);
                         }
                     }
                     cameraData.projection.checkedForFlipping = true;
                 }
                 this.UpdateBounds(go, current);
             }
         }
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 4
0
        void Start()
        {
            try
            {
                //Needs at least SM3 for vertex texture fetches.
                if (SystemInfo.graphicsShaderLevel < 30)
                {
                    throw new InvalidOperationException("The projected grids needs at least SM3 to render.");
                }

                if (oceanTopSideMat == null)
                {
                    Ocean.LogWarning("Top side material is null. There will be no top ocean mesh rendered");
                }

                if (oceanUnderSideMat == null)
                {
                    Ocean.LogWarning("Under side material is null. There will be no under ocean mesh rendered");
                }
            }
            catch (Exception e)
            {
                Ocean.LogError(e.ToString());
                WasError = true;
                enabled  = false;
            }
        }
Esempio n. 5
0
 protected override void OnEnable()
 {
     base.OnEnable();
     if (base.WasError)
     {
         return;
     }
     try
     {
         Dictionary <MESH_RESOLUTION, ProjectedGrid.Grid> .Enumerator enumerator = this.m_grids.GetEnumerator();
         while (enumerator.MoveNext())
         {
             KeyValuePair <MESH_RESOLUTION, ProjectedGrid.Grid> current = enumerator.Current;
             ProjectedGrid.Grid value = current.Value;
             this.Activate(value.top, true);
             this.Activate(value.under, true);
         }
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 6
0
 private void Start()
 {
     try
     {
         Mesh mesh = this.CreateBottomMesh(32, 512);
         this.m_bottomMask = new GameObject("Ceto Bottom Mask Gameobject");
         MeshFilter         meshFilter         = this.m_bottomMask.AddComponent <MeshFilter>();
         MeshRenderer       meshRenderer       = this.m_bottomMask.AddComponent <MeshRenderer>();
         NotifyOnWillRender notifyOnWillRender = this.m_bottomMask.AddComponent <NotifyOnWillRender>();
         meshFilter.sharedMesh             = mesh;
         meshRenderer.receiveShadows       = false;
         meshRenderer.shadowCastingMode    = ShadowCastingMode.Off;
         meshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
         meshRenderer.material             = new Material(this.oceanBottomSdr);
         notifyOnWillRender.AddAction(new Action <GameObject>(this.m_ocean.RenderWaveOverlays));
         notifyOnWillRender.AddAction(new Action <GameObject>(this.m_ocean.RenderOceanMask));
         notifyOnWillRender.AddAction(new Action <GameObject>(this.m_ocean.RenderOceanDepth));
         this.m_bottomMask.layer     = LayerMask.NameToLayer(Ocean.OCEAN_LAYER);
         this.m_bottomMask.hideFlags = HideFlags.HideAndDontSave;
         this.UpdateBottomBounds();
         UnityEngine.Object.Destroy(mesh);
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 7
0
 private void OnDestroy()
 {
     try
     {
         Ocean.Instance = null;
         if (this.OverlayManager != null)
         {
             this.OverlayManager.Release();
         }
         if (this.m_scheduler != null)
         {
             this.m_scheduler.ShutingDown = true;
             this.m_scheduler.CancelAllTasks();
         }
         List <Camera> list = new List <Camera>(this.m_cameraData.Keys);
         foreach (Camera cam in list)
         {
             this.RemoveCameraData(cam);
         }
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         this.DisableOcean();
     }
 }
Esempio n. 8
0
 private void Awake()
 {
     try
     {
         if (Ocean.Instance != null)
         {
             throw new InvalidOperationException("There can only be one ocean instance.");
         }
         Ocean.Instance     = this;
         this.WindDirVector = this.CalculateWindDirVector();
         if (this.doublePrecisionProjection)
         {
             this.Projection = new Projection3d(this);
         }
         else
         {
             this.Projection = new Projection3f(this);
         }
         this.OceanTime        = new OceanTime();
         this.m_waveOverlayMat = new Material(this.waveOverlaySdr);
         this.OverlayManager   = new OverlayManager(this.m_waveOverlayMat);
         this.m_scheduler      = new Scheduler();
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         this.DisableOcean();
     }
 }
Esempio n. 9
0
 private void Start()
 {
     try
     {
         Shader.SetGlobalTexture("Ceto_SlopeMap0", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_SlopeMap1", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_DisplacementMap0", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_DisplacementMap1", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_DisplacementMap2", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_DisplacementMap3", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_FoamMap0", Texture2D.blackTexture);
         this.m_slopeCopyMat        = new Material(this.slopeCopySdr);
         this.m_displacementCopyMat = new Material(this.displacementCopySdr);
         this.m_foamCopyMat         = new Material(this.foamCopySdr);
         this.m_slopeInitMat        = new Material(this.initSlopeSdr);
         this.m_displacementInitMat = new Material(this.initDisplacementSdr);
         this.m_foamInitMat         = new Material(this.initJacobianSdr);
         this.m_conditionCache      = new DictionaryQueue <WaveSpectrumConditionKey, WaveSpectrumCondition>();
         this.m_scheduler           = new Scheduler();
         this.CreateBuffers();
         this.CreateRenderTextures();
         this.CreateConditions();
         this.UpdateQueryScaling();
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 10
0
 public override void RenderOceanMask(GameObject go)
 {
     try
     {
         if (base.enabled)
         {
             if (!(this.oceanMaskSdr == null))
             {
                 if (this.underwaterMode != UNDERWATER_MODE.ABOVE_ONLY)
                 {
                     Camera current = Camera.current;
                     if (!(current == null))
                     {
                         CameraData cameraData = this.m_ocean.FindCameraData(current);
                         if (cameraData.mask == null)
                         {
                             cameraData.mask = new MaskData();
                         }
                         if (!cameraData.mask.updated)
                         {
                             if (current.name == "SceneCamera" || current.GetComponent <UnderWaterPostEffect>() == null || SystemInfo.graphicsShaderLevel < 30 || this.GetDisableUnderwater(cameraData.settings))
                             {
                                 Shader.SetGlobalTexture(Ocean.OCEAN_MASK_TEXTURE_NAME, Texture2D.blackTexture);
                                 cameraData.mask.updated          = true;
                                 cameraData.mask.updatedLastFrame = true;
                             }
                             else
                             {
                                 this.CreateMaskCameraFor(current, cameraData.mask);
                                 this.FitBottomToCamera();
                                 NotifyOnEvent.Disable = true;
                                 if (this.m_ocean.Projection.IsFlipped)
                                 {
                                     cameraData.mask.cam.RenderWithShader(this.oceanMaskFlippedSdr, "OceanMask");
                                 }
                                 else
                                 {
                                     cameraData.mask.cam.RenderWithShader(this.oceanMaskSdr, "OceanMask");
                                 }
                                 NotifyOnEvent.Disable = false;
                                 Shader.SetGlobalTexture(Ocean.OCEAN_MASK_TEXTURE_NAME, cameraData.mask.cam.targetTexture);
                                 cameraData.mask.updated          = true;
                                 cameraData.mask.updatedLastFrame = true;
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 11
0
 public void RenderWaveOverlays(GameObject go)
 {
     try
     {
         if (base.enabled)
         {
             Camera current = Camera.current;
             if (!this.m_cameraData.ContainsKey(current))
             {
                 this.m_cameraData.Add(current, new CameraData());
             }
             CameraData cameraData = this.m_cameraData[current];
             if (cameraData.overlay == null)
             {
                 cameraData.overlay = new WaveOverlayData();
             }
             if (cameraData.projection == null)
             {
                 cameraData.projection = new ProjectionData();
             }
             if (!cameraData.overlay.updated)
             {
                 if (!cameraData.projection.updated)
                 {
                     this.Projection.UpdateProjection(current, cameraData, this.ProjectSceneView);
                     Shader.SetGlobalMatrix("Ceto_Interpolation", cameraData.projection.interpolation);
                     Shader.SetGlobalMatrix("Ceto_ProjectorVP", cameraData.projection.projectorVP);
                 }
                 if (this.GetDisableAllOverlays(cameraData.settings))
                 {
                     this.OverlayManager.DestroyBuffers(cameraData.overlay);
                     Shader.SetGlobalTexture("Ceto_Overlay_NormalMap", Texture2D.blackTexture);
                     Shader.SetGlobalTexture("Ceto_Overlay_HeightMap", Texture2D.blackTexture);
                     Shader.SetGlobalTexture("Ceto_Overlay_FoamMap", Texture2D.blackTexture);
                     Shader.SetGlobalTexture("Ceto_Overlay_ClipMap", Texture2D.blackTexture);
                 }
                 else
                 {
                     OVERLAY_MAP_SIZE overlay_MAP_SIZE  = (!(cameraData.settings != null)) ? this.normalOverlaySize : cameraData.settings.normalOverlaySize;
                     OVERLAY_MAP_SIZE overlay_MAP_SIZE2 = (!(cameraData.settings != null)) ? this.heightOverlaySize : cameraData.settings.heightOverlaySize;
                     OVERLAY_MAP_SIZE overlay_MAP_SIZE3 = (!(cameraData.settings != null)) ? this.foamOverlaySize : cameraData.settings.foamOverlaySize;
                     OVERLAY_MAP_SIZE overlay_MAP_SIZE4 = (!(cameraData.settings != null)) ? this.clipOverlaySize : cameraData.settings.clipOverlaySize;
                     this.OverlayManager.CreateOverlays(current, cameraData.overlay, overlay_MAP_SIZE, overlay_MAP_SIZE2, overlay_MAP_SIZE3, overlay_MAP_SIZE4);
                     this.OverlayManager.HeightOverlayBlendMode = this.heightBlendMode;
                     this.OverlayManager.FoamOverlayBlendMode   = this.foamBlendMode;
                     this.OverlayManager.RenderWaveOverlays(current, cameraData.overlay);
                 }
                 cameraData.overlay.updated = true;
             }
         }
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         this.DisableOcean();
     }
 }
Esempio n. 12
0
 private void Update()
 {
     if (!LocalPlayer.Transform)
     {
         return;
     }
     if (Time.frameCount % 2 == 0 && (!LocalPlayer.Buoyancy.InWater || !LocalPlayer.Buoyancy.IsOcean))
     {
         return;
     }
     try
     {
         this.gridScale      = Mathf.Clamp(this.gridScale, 0.1f, 1f);
         this.windSpeed      = Mathf.Clamp(this.windSpeed, 0f, 30f);
         this.waveAge        = Mathf.Clamp(this.waveAge, 0.5f, 1f);
         this.waveSpeed      = Mathf.Clamp(this.waveSpeed, 0f, 10f);
         this.foamAmount     = Mathf.Clamp(this.foamAmount, 0f, 6f);
         this.foamCoverage   = Mathf.Clamp(this.foamCoverage, 0f, 0.5f);
         this.waveSmoothing  = Mathf.Clamp(this.waveSmoothing, 1f, 6f);
         this.slopeSmoothing = Mathf.Clamp(this.slopeSmoothing, 1f, 6f);
         this.foamSmoothing  = Mathf.Clamp(this.foamSmoothing, 1f, 6f);
         float time = this.m_ocean.OceanTime.Now * this.waveSpeed;
         this.CreateBuffers();
         this.CreateRenderTextures();
         this.CreateConditions();
         int numGrids = this.m_conditions[0].Key.NumGrids;
         if (numGrids > 2)
         {
             Shader.EnableKeyword("CETO_USE_4_SPECTRUM_GRIDS");
         }
         else
         {
             Shader.DisableKeyword("CETO_USE_4_SPECTRUM_GRIDS");
         }
         this.UpdateQueryScaling();
         Shader.SetGlobalVector("Ceto_GridSizes", this.GridSizes);
         Shader.SetGlobalVector("Ceto_GridScale", new Vector2(this.GridScale, this.GridScale));
         Shader.SetGlobalVector("Ceto_Choppyness", this.Choppyness);
         Shader.SetGlobalFloat("Ceto_MapSize", (float)this.m_bufferSettings.size);
         Shader.SetGlobalFloat("Ceto_WaveSmoothing", this.waveSmoothing);
         Shader.SetGlobalFloat("Ceto_SlopeSmoothing", this.slopeSmoothing);
         Shader.SetGlobalFloat("Ceto_FoamSmoothing", this.foamSmoothing);
         Shader.SetGlobalFloat("Ceto_TextureWaveFoam", (!this.textureFoam) ? 0f : 1f);
         this.UpdateSpectrumScheduler();
         this.GenerateDisplacement(time);
         this.GenerateSlopes(time);
         this.GenerateFoam(time);
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 13
0
 private void Start()
 {
     try
     {
         Matrix4x4 identity = Matrix4x4.identity;
         identity.m00 = 2f;
         identity.m03 = -1f;
         identity.m11 = 2f;
         identity.m13 = -1f;
         for (int i = 0; i < 4; i++)
         {
             identity[1, i] = -identity[1, i];
         }
         Shader.SetGlobalMatrix("Ceto_T2S", identity);
         Shader.SetGlobalTexture("Ceto_Overlay_NormalMap", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_Overlay_HeightMap", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_Overlay_FoamMap", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_Overlay_ClipMap", Texture2D.blackTexture);
         Shader.SetGlobalTexture(Ocean.REFRACTION_GRAB_TEXTURE_NAME, Texture2D.blackTexture);
         Shader.SetGlobalTexture(Ocean.DEPTH_GRAB_TEXTURE_NAME, Texture2D.whiteTexture);
         Shader.SetGlobalTexture(Ocean.OCEAN_MASK_TEXTURE_NAME, Texture2D.blackTexture);
         Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME, Texture2D.blackTexture);
         Shader.SetGlobalTexture(Ocean.NORMAL_FADE_TEXTURE_NAME, Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_SlopeMap0", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_SlopeMap1", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_DisplacementMap0", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_DisplacementMap1", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_DisplacementMap2", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_DisplacementMap3", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_FoamMap0", Texture2D.blackTexture);
         Shader.SetGlobalTexture("Ceto_FoamMap1", Texture2D.blackTexture);
         Shader.SetGlobalVector("Ceto_GridSizes", Vector4.one);
         Shader.SetGlobalVector("Ceto_GridScale", Vector4.one);
         Shader.SetGlobalVector("Ceto_Choppyness", Vector4.one);
         Shader.SetGlobalFloat("Ceto_MapSize", 1f);
         Shader.SetGlobalColor("Ceto_FoamTint", Color.white);
         Shader.SetGlobalTexture("Ceto_FoamTexture0", Texture2D.whiteTexture);
         Shader.SetGlobalTexture("Ceto_FoamTexture1", Texture2D.whiteTexture);
         Shader.SetGlobalVector("Ceto_FoamTextureScale0", Vector4.one);
         Shader.SetGlobalVector("Ceto_FoamTextureScale1", Vector4.one);
         Shader.SetGlobalFloat("Ceto_MaxWaveHeight", 40f);
         Shader.SetGlobalVector("Ceto_PosOffset", Vector3.zero);
         Shader.SetGlobalTexture("Ceto_CausticTexture", Texture2D.blackTexture);
         Shader.SetGlobalVector("Ceto_CausticTextureScale", new Vector4(1f, 1f, 0f, 0f));
         Shader.SetGlobalColor("Ceto_CausticTint", Color.white);
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         this.DisableOcean();
     }
 }
Esempio n. 14
0
 protected virtual void OnDestroy()
 {
     try
     {
         this.m_ocean.Deregister(this);
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         this.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 15
0
 void Start()
 {
     try
     {
         m_imageBlur = new ImageBlur(blurShader);
     }
     catch (Exception e)
     {
         Ocean.LogError(e.ToString());
         WasError = true;
         enabled  = false;
     }
 }
Esempio n. 16
0
 private void Start()
 {
     try
     {
         this.m_imageBlur = new ImageBlur(this.blurShader);
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
 protected virtual void OnDestroy()
 {
     try
     {
         m_ocean.Deregister(this);
     }
     catch (Exception e)
     {
         Ocean.LogError(e.ToString());
         WasError = true;
         enabled  = false;
     }
 }
 /// <summary>
 /// On awake find the ocean and store a reference to it.
 /// </summary>
 protected virtual void Awake()
 {
     try
     {
         m_ocean = GetComponent <Ocean>();
         m_ocean.Register(this);
     }
     catch (Exception e)
     {
         Ocean.LogError(e.ToString());
         WasError = true;
         enabled  = false;
     }
 }
Esempio n. 19
0
 protected virtual void Awake()
 {
     try
     {
         this.m_ocean = base.GetComponent <Ocean>();
         this.m_ocean.Register(this);
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         this.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 20
0
 private void Update()
 {
     try
     {
         Shader.SetGlobalFloat("Ceto_GridEdgeBorder", Mathf.Max(0f, this.borderLength));
         int     num = this.ResolutionToNumber(this.resolution);
         Vector2 v   = new Vector2((float)num / (float)this.ScreenWidth(), (float)num / (float)this.ScreenHeight());
         Shader.SetGlobalVector("Ceto_ScreenGridSize", v);
         this.CreateGrid(this.resolution);
         Dictionary <MESH_RESOLUTION, ProjectedGrid.Grid> .Enumerator enumerator = this.m_grids.GetEnumerator();
         while (enumerator.MoveNext())
         {
             KeyValuePair <MESH_RESOLUTION, ProjectedGrid.Grid> current = enumerator.Current;
             ProjectedGrid.Grid value = current.Value;
             KeyValuePair <MESH_RESOLUTION, ProjectedGrid.Grid> current2 = enumerator.Current;
             bool flag = current2.Key == this.resolution;
             if (flag)
             {
                 this.UpdateGrid(value);
                 this.Activate(value.top, true);
                 this.Activate(value.under, true);
             }
             else
             {
                 this.Activate(value.top, false);
                 this.Activate(value.under, false);
             }
         }
         if (this.m_ocean.UnderWater == null || this.m_ocean.UnderWater.Mode == UNDERWATER_MODE.ABOVE_ONLY)
         {
             enumerator = this.m_grids.GetEnumerator();
             while (enumerator.MoveNext())
             {
                 KeyValuePair <MESH_RESOLUTION, ProjectedGrid.Grid> current3 = enumerator.Current;
                 this.Activate(current3.Value.under, false);
             }
         }
         if (this.oceanTopSideMat != null && this.m_ocean.UnderWater != null && this.m_ocean.UnderWater.DepthMode == DEPTH_MODE.USE_DEPTH_BUFFER && this.oceanTopSideMat.shader.isSupported && this.oceanTopSideMat.renderQueue <= 2500)
         {
             Ocean.LogWarning("Underwater depth mode must be USE_OCEAN_DEPTH_PASS if using opaque material. Underwater effect will not look correct.");
         }
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 21
0
 protected override void OnDisable()
 {
     base.OnDisable();
     try
     {
         Shader.DisableKeyword("CETO_UNDERWATER_ON");
         this.SetBottomActive(this.m_bottomMask, false);
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 22
0
 private void UpdateSpectrumScheduler()
 {
     try
     {
         this.m_scheduler.DisableMultithreading = Ocean.DISABLE_ALL_MULTITHREADING;
         this.m_scheduler.CheckForException();
         this.m_scheduler.Update();
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 23
0
 private void UpdateOceanScheduler()
 {
     try
     {
         if (this.m_scheduler != null)
         {
             this.m_scheduler.DisableMultithreading = Ocean.DISABLE_ALL_MULTITHREADING;
             this.m_scheduler.CheckForException();
             this.m_scheduler.Update();
         }
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         this.DisableOcean();
     }
 }
Esempio n. 24
0
        protected override void OnEnable()
        {
            base.OnEnable();

            try
            {
                Shader.EnableKeyword("CETO_UNDERWATER_ON");

                SetBottomActive(m_bottomMask, true);
            }
            catch (Exception e)
            {
                Ocean.LogError(e.ToString());
                WasError = true;
                enabled  = false;
            }
        }
Esempio n. 25
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     try
     {
         if (this.m_dummy != null)
         {
             UnityEngine.Object.DestroyImmediate(this.m_dummy);
         }
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 26
0
 void Start()
 {
     try
     {
         //Needs at least SM3 for vertex texture fetches.
         if (SystemInfo.graphicsShaderLevel < 30)//OYM:  测试版本
         {
             throw new InvalidOperationException("The projected grids needs at least SM3 to render.");
         }
     }
     catch (Exception e)
     {
         Ocean.LogError(e.ToString());//OYM:  hmmm什么东西会爆bug吧
         WasError = true;
         enabled  = false;
     }
 }
Esempio n. 27
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            try
            {
                if (m_dummy != null)
                {
                    DestroyImmediate(m_dummy);
                }
            }
            catch (Exception e)
            {
                Ocean.LogError(e.ToString());
                WasError = true;
                enabled  = false;
            }
        }
Esempio n. 28
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     try
     {
         if (this.m_bottomMask != null)
         {
             Mesh mesh = this.m_bottomMask.GetComponent <MeshFilter>().mesh;
             UnityEngine.Object.Destroy(this.m_bottomMask);
             UnityEngine.Object.Destroy(mesh);
         }
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }
Esempio n. 29
0
        /// <summary>
        /// If called it means a grid is about to be rendered by the current camera.
        /// </summary>
        void ApplyProjection(GameObject go)
        {
            try
            {
                if (!enabled)
                {
                    return;
                }

                Camera cam = Camera.current;

                if (cam == null)
                {
                    return;
                }

                CameraData data = m_ocean.FindCameraData(cam);

                if (data.projection == null)
                {
                    data.projection = new ProjectionData();
                }

                //If the projection for this camera has
                //not been calculated yet do it now.
                if (!data.projection.updated)
                {
                    //Update set to true in this function call
                    m_ocean.Projection.UpdateProjection(cam, data, m_ocean.ProjectSceneView);

                    Shader.SetGlobalMatrix("Ceto_Interpolation", data.projection.interpolation);
                    Shader.SetGlobalMatrix("Ceto_ProjectorVP", data.projection.projectorVP);
                }

                UpdateBounds(go, cam);
            }
            catch (Exception e)
            {
                Ocean.LogError(e.ToString());
                WasError = true;
                enabled  = false;
            }
        }
Esempio n. 30
0
 protected override void OnDestroy()
 {
     try
     {
         foreach (KeyValuePair <MESH_RESOLUTION, ProjectedGrid.Grid> keyValuePair in this.m_grids)
         {
             ProjectedGrid.Grid value = keyValuePair.Value;
             this.ClearGrid(value);
         }
         this.m_grids.Clear();
         this.m_grids = null;
     }
     catch (Exception ex)
     {
         Ocean.LogError(ex.ToString());
         base.WasError = true;
         base.enabled  = false;
     }
 }