protected void UpdateParams() { this.position = base.transform.position.y; this.scaleSum = VectorHelpers.Sum(this.waveScales); Vector4 vector = (Vector4.one * this.windAngle + this.waveAngles) * 0.0174532924f; this.waveDirection01 = VectorHelpers.GetV4(Mathf.Cos(vector.x), Mathf.Sin(vector.x), Mathf.Cos(vector.y), Mathf.Sin(vector.y)); this.waveDirection23 = VectorHelpers.GetV4(Mathf.Cos(vector.z), Mathf.Sin(vector.z), Mathf.Cos(vector.w), Mathf.Sin(vector.w)); this.waveOffsets += this.waveSpeeds * Time.deltaTime; this.waveConstants = VectorHelpers.Div(Vector4.one * 6.28318548f, this.waveLengths); this.waveDerivativeConstants = 0.5f * VectorHelpers.Mul(VectorHelpers.Mul(this.waveScales, this.waveConstants), this.waveExponents); float f = (this.windAngle + this.normalMapAngle0) * 0.0174532924f; float f2 = (this.windAngle + this.normalMapAngle1) * 0.0174532924f; this.normalMapOffset0 += VectorHelpers.GetV2(Mathf.Cos(f), Mathf.Sin(f)) * this.normalMapSpeed0 * Time.deltaTime; this.normalMapOffset1 += VectorHelpers.GetV2(Mathf.Cos(f2), Mathf.Sin(f2)) * this.normalMapSpeed1 * Time.deltaTime; }
protected void SendParamsToShader() { if (this.mat == null || !this.mat.HasProperty("ot_NormalMap0")) { return; } Shader.SetGlobalFloat("ot_OceanPosition", this.position); Shader.SetGlobalVector("ot_WaveScales", this.waveScales); Shader.SetGlobalVector("ot_WaveLengths", this.waveLengths); Shader.SetGlobalVector("ot_WaveExponents", this.waveExponents); Shader.SetGlobalVector("ot_WaveOffsets", this.waveOffsets); Shader.SetGlobalVector("ot_WaveDirection01", this.waveDirection01); Shader.SetGlobalVector("ot_WaveDirection23", this.waveDirection23); Shader.SetGlobalVector("ot_WaveConstants", this.waveConstants); Shader.SetGlobalVector("ot_WaveDerivativeConstants", this.waveDerivativeConstants); Vector2 textureScale = this.mat.GetTextureScale("ot_NormalMap0"); Vector2 textureScale2 = this.mat.GetTextureScale("ot_NormalMap1"); this.mat.SetTextureOffset("ot_NormalMap0", VectorHelpers.Mul(this.normalMapOffset0, textureScale)); this.mat.SetTextureOffset("ot_NormalMap1", VectorHelpers.Mul(this.normalMapOffset1, textureScale2)); Vector3 v = Vector3.up; if (this.sun != null) { v = -this.sun.transform.forward; } Shader.SetGlobalVector("ot_LightDir", v); Vector4 a = this.mat.GetColor("ot_DeepWaterColorUnlit"); float @float = this.mat.GetFloat("ot_DeepWaterIntensityZenith"); float float2 = this.mat.GetFloat("ot_DeepWaterIntensityHorizon"); float float3 = this.mat.GetFloat("ot_DeepWaterIntensityDark"); float d; if (v.y >= 0f) { d = Mathf.Lerp(float2, @float, v.y); } else { d = Mathf.Lerp(float2, float3, -v.y); } Shader.SetGlobalVector("ot_DeepWaterColor", a * d); }