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; } }
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; } }
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(); } }
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; } }
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; } }
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; } }
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; } }
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; } }
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(); } }
public void CreateAndCacheCondition(int fourierSize, float windSpeed, float windDir, float waveAge) { if (this.m_conditionCache == null) { return; } if (this.m_conditionCache.Count >= this.m_maxConditionCacheSize) { Ocean.LogWarning("Condition cache full. Condition not cached."); return; } if (!Mathf.IsPowerOfTwo(fourierSize) || fourierSize < 32 || fourierSize > 512) { Ocean.LogWarning("Fourier size must be a pow2 number from 32 to 512. Condition not cached."); return; } WaveSpectrumCondition waveSpectrumCondition = this.NewSpectrumCondition(fourierSize, windSpeed, windDir, waveAge); if (this.m_conditionCache.ContainsKey(waveSpectrumCondition.Key)) { return; } IThreadedTask createSpectrumConditionTask = waveSpectrumCondition.GetCreateSpectrumConditionTask(); createSpectrumConditionTask.Start(); createSpectrumConditionTask.Run(); createSpectrumConditionTask.End(); this.m_conditionCache.AddFirst(waveSpectrumCondition.Key, waveSpectrumCondition); }
/// <summary> /// For textures that require their contents to be /// sampled check to see if read/write is enabled. /// </summary> protected void CheckCanSampleTex(Texture tex, string name) { if (tex == null) { return; } if (!(tex is Texture2D))//OYM: 新技巧get { Ocean.LogWarning("Can not query overlays " + name + " if texture is not Texture2D"); return; } Texture2D t = tex as Texture2D; //Is there a better way to do this? try { Color c = t.GetPixel(0, 0); } catch { Ocean.LogWarning("Can not query overlays " + name + " if read/write is not enabled"); } }
private void GetFourierSize(out int size, out bool isCpu) { switch (this.fourierSize) { case FOURIER_SIZE.LOW_32_CPU: size = 32; isCpu = true; break; case FOURIER_SIZE.LOW_32_GPU: size = 32; isCpu = false; break; case FOURIER_SIZE.MEDIUM_64_CPU: size = 64; isCpu = true; break; case FOURIER_SIZE.MEDIUM_64_GPU: size = 64; isCpu = false; break; case FOURIER_SIZE.HIGH_128_CPU: size = 128; isCpu = true; break; case FOURIER_SIZE.HIGH_128_GPU: size = 128; isCpu = false; break; case FOURIER_SIZE.ULTRA_256_GPU: size = 256; isCpu = false; break; case FOURIER_SIZE.EXTREME_512_GPU: size = 512; isCpu = false; break; default: size = 64; isCpu = true; break; } bool flag = SystemInfo.graphicsShaderLevel >= 50 && SystemInfo.supportsComputeShaders; if (!isCpu && !this.disableReadBack && !flag) { Ocean.LogWarning("You card does not support dx11. Fourier can not be GPU. Changing to CPU. Disable read backs to use GPU but with no height querys."); this.fourierSize = FOURIER_SIZE.MEDIUM_64_CPU; size = 64; isCpu = true; } }
void ExportMask(float[] data, int size, int resolution, string name, DateTime stamp, float spread, bool isClip, bool isReadable) { //Create interpolated array from data so the mask resolution does not need to match the terrain height map size. InterpolatedArray2f heightMap = new InterpolatedArray2f(data, size, size, 1, false); //Create the path name to save mask. string fileName = string.Format("{0}-{1:yyyyMMdd-HHmmss}.png", name, stamp); string path = System.IO.Path.Combine(Application.dataPath, fileName); path = path.Replace('\\', '/'); Texture2D mask = null; //Create the mask texture. Clip masks are created slightly different. if (isClip) { mask = ShoreMaskGenerator.CreateClipMask(heightMap, resolution, resolution, m_oceanLevel + spread, TextureFormat.ARGB32); } else { mask = ShoreMaskGenerator.CreateMask(heightMap, resolution, resolution, m_oceanLevel, spread, TextureFormat.ARGB32); } //Save the texture. byte[] bytes = mask.EncodeToPNG(); System.IO.File.WriteAllBytes(path, bytes); DestroyImmediate(mask); string relativePath = "Assets/" + fileName; //Update asset data base with new mask texture. AssetDatabase.ImportAsset(relativePath, ImportAssetOptions.ForceUpdate); //Create a importer from the texture so some of its settings can be changed. AssetImporter tmp = TextureImporter.GetAtPath(relativePath); TextureImporter importer = tmp as TextureImporter; if (importer != null) { //Change some of the settings of textures. //Should always be bilinear clamped with no mipmaps. //Height and clip masks should also be readable. importer.wrapMode = TextureWrapMode.Clamp; importer.filterMode = FilterMode.Bilinear; importer.textureType = TextureImporterType.Default; importer.mipmapEnabled = false; importer.isReadable = isReadable; AssetDatabase.ImportAsset(relativePath, ImportAssetOptions.ForceUpdate); } else { string msg = string.Format("{0:MM/dd/yy H:mm:ss zzz} - Failed to modify texture settings after creation. You will need to manually adjust texture settings.", DateTime.Now); Ocean.LogInfo(msg); } }
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(); } }
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; } }
public Projection3f(Ocean ocean) { this.m_ocean = ocean; this.m_projectorP = default(Matrix4x4); this.m_projectorV = default(Matrix4x4); this.m_projectorR = Matrix4x4.identity; this.m_projectorI = default(Matrix4x4); this.m_pointList = new List <Vector3>(12); this.m_frustumCorners = new Vector3[8]; }
private void GenerateFoam(float time) { Vector4 vector = this.Choppyness; if (!this.disableFoam && SystemInfo.graphicsShaderLevel < 30) { Ocean.LogWarning("Spectrum foam needs at least SM3 to run. Disabling foam."); this.disableFoam = true; } float sqrMagnitude = vector.sqrMagnitude; this.m_jacobianBuffer.EnableBuffer(-1); if (this.disableFoam || this.foamAmount == 0f || sqrMagnitude == 0f || !this.m_conditions[0].SupportsJacobians) { this.m_jacobianBuffer.DisableBuffer(-1); } if (this.m_jacobianBuffer.EnabledBuffers() == 0) { Shader.SetGlobalTexture("Ceto_FoamMap0", Texture2D.blackTexture); } else { int numGrids = this.m_conditions[0].Key.NumGrids; if (numGrids == 1) { this.m_jacobianBuffer.DisableBuffer(1); this.m_jacobianBuffer.DisableBuffer(2); } else if (numGrids == 2) { this.m_jacobianBuffer.DisableBuffer(2); } if (!this.m_jacobianBuffer.HasRun || this.m_jacobianBuffer.TimeValue != time) { this.m_foamInitMat.SetFloat("Ceto_FoamAmount", this.foamAmount); this.m_jacobianBuffer.InitMaterial = this.m_foamInitMat; this.m_jacobianBuffer.InitPass = numGrids - 1; this.m_jacobianBuffer.Run(this.m_conditions[0], time); } if (!this.m_jacobianBuffer.BeenSampled) { this.m_jacobianBuffer.EnableSampling(); this.m_foamCopyMat.SetTexture("Ceto_JacobianBuffer0", this.m_jacobianBuffer.GetTexture(0)); this.m_foamCopyMat.SetTexture("Ceto_JacobianBuffer1", this.m_jacobianBuffer.GetTexture(1)); this.m_foamCopyMat.SetTexture("Ceto_JacobianBuffer2", this.m_jacobianBuffer.GetTexture(2)); this.m_foamCopyMat.SetTexture("Ceto_HeightBuffer", this.m_displacementBuffer.GetTexture(0)); this.m_foamCopyMat.SetVector("Ceto_FoamChoppyness", vector); this.m_foamCopyMat.SetFloat("Ceto_FoamCoverage", this.foamCoverage); Graphics.Blit(null, this.m_foamMaps[0], this.m_foamCopyMat, numGrids - 1); Shader.SetGlobalTexture("Ceto_FoamMap0", this.m_foamMaps[0]); this.m_jacobianBuffer.DisableSampling(); this.m_jacobianBuffer.BeenSampled = true; } } }
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; } }
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(); } }
protected virtual void OnDestroy() { try { m_ocean.Deregister(this); } catch (Exception e) { Ocean.LogError(e.ToString()); WasError = true; enabled = false; } }
private void Start() { try { this.m_imageBlur = new ImageBlur(this.blurShader); } catch (Exception ex) { Ocean.LogError(ex.ToString()); base.WasError = true; base.enabled = false; } }
void Start() { try { m_imageBlur = new ImageBlur(blurShader); } catch (Exception e) { Ocean.LogError(e.ToString()); WasError = true; enabled = false; } }
protected virtual void OnDestroy() { try { this.m_ocean.Deregister(this); } catch (Exception ex) { Ocean.LogError(ex.ToString()); this.WasError = true; base.enabled = false; } }
/// <summary> /// /// </summary> public Projection3f(Ocean ocean) { m_ocean = ocean; m_projectorP = new Matrix4x4(); m_projectorV = new Matrix4x4(); m_projectorR = Matrix4x4.identity; m_projectorI = new Matrix4x4(); m_pointList = new List <Vector3>(12); m_frustumCorners = new Vector3[8]; }
/// <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; } }
/// <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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
/// <summary> /// /// </summary> public Projection3f(Ocean ocean) { m_ocean = ocean; m_projectorP = new Matrix4x4(); m_projectorV = new Matrix4x4(); m_projectorR = Matrix4x4.identity; m_projectorI = new Matrix4x4(); m_pointList = new List<Vector3>(12); m_frustumCorners = new Vector3[8]; }
/// <summary> /// /// </summary> public Projection3d(Ocean ocean) { m_ocean = ocean; m_projectorP = new double[16]; m_projectorV = new double[16]; m_projectorVP = new double[16]; m_projectorIVP = new double[16]; m_projectorR = new double[16]; m_projectorI = new double[16]; MATRIX_BUFFER0 = new double[16]; MATRIX_BUFFER1 = new double[16]; VECTOR_BUFFER = new double[4]; m_up = new double[]{0,1,0}; m_xaxis = new double[3]; m_yaxis = new double[3]; m_zaxis = new double[3]; m_a = new double[4]; m_b = new double[4]; m_ab = new double[4]; m_pos = new double[3]; m_dir = new double[3]; m_lookAt = new double[3]; m_p = new double[4]; m_q = new double[4]; m_p0 = new double[4]; m_p1 = new double[4]; Identity(m_projectorR); m_pointList = new List<double[]>(32); for(int i = 0; i < 32; i++) m_pointList.Add(new double[3]); m_frustumCorners = new List<double[]>(8); for(int i = 0; i < 8; i++) m_frustumCorners.Add(new double[3]); m_quad = new List<double[]>(4); m_quad.Add(new double[]{0, 0, 0, 1}); m_quad.Add(new double[]{1, 0, 0, 1}); m_quad.Add(new double[]{1, 1, 0, 1}); m_quad.Add(new double[]{0, 1, 0, 1}); m_corners = new List<double[]>(8); // near m_corners.Add(new double[]{-1, -1, -1, 1}); m_corners.Add(new double[]{ 1, -1, -1, 1}); m_corners.Add(new double[]{ 1, 1, -1, 1}); m_corners.Add(new double[]{-1, 1, -1, 1}); // far m_corners.Add(new double[]{-1, -1, 1, 1}); m_corners.Add(new double[]{ 1, -1, 1, 1}); m_corners.Add(new double[]{ 1, 1, 1, 1}); m_corners.Add(new double[]{-1, 1, 1, 1}); }