public void OnWillRenderObject() { if (!base.get_enabled() || !base.get_renderer() || !base.get_renderer().get_sharedMaterial() || !base.get_renderer().get_enabled()) { return; } Camera current = Camera.get_current(); if (!current) { return; } if (Water.s_InsideWater) { return; } Water.s_InsideWater = true; this.m_HardwareWaterSupport = this.FindHardwareWaterSupport(); Water.WaterMode waterMode = this.GetWaterMode(); Camera camera; Camera camera2; this.CreateWaterObjects(current, out camera, out camera2); Vector3 position = base.get_transform().get_position(); Vector3 up = base.get_transform().get_up(); int pixelLightCount = QualitySettings.get_pixelLightCount(); if (this.m_DisablePixelLights) { QualitySettings.set_pixelLightCount(0); } this.UpdateCameraModes(current, camera); this.UpdateCameraModes(current, camera2); if (waterMode >= Water.WaterMode.Reflective) { float num = -Vector3.Dot(up, position) - this.m_ClipPlaneOffset; Vector4 plane = new Vector4(up.x, up.y, up.z, num); Matrix4x4 zero = Matrix4x4.get_zero(); Water.CalculateReflectionMatrix(ref zero, plane); Vector3 position2 = current.get_transform().get_position(); Vector3 position3 = zero.MultiplyPoint(position2); camera.set_worldToCameraMatrix(current.get_worldToCameraMatrix() * zero); Vector4 clipPlane = this.CameraSpacePlane(camera, position, up, 1f); Matrix4x4 projectionMatrix = current.get_projectionMatrix(); Water.CalculateObliqueMatrix(ref projectionMatrix, clipPlane); camera.set_projectionMatrix(projectionMatrix); camera.set_cullingMask(-17 & this.m_ReflectLayers.get_value()); camera.set_targetTexture(this.m_ReflectionTexture); GL.SetRevertBackfacing(true); camera.get_transform().set_position(position3); Vector3 eulerAngles = current.get_transform().get_eulerAngles(); camera.get_transform().set_eulerAngles(new Vector3(0f, eulerAngles.y, eulerAngles.z)); camera.Render(); camera.get_transform().set_position(position2); GL.SetRevertBackfacing(false); base.get_renderer().get_sharedMaterial().SetTexture("_ReflectionTex", this.m_ReflectionTexture); } if (waterMode >= Water.WaterMode.Refractive) { camera2.set_worldToCameraMatrix(current.get_worldToCameraMatrix()); Vector4 clipPlane2 = this.CameraSpacePlane(camera2, position, up, -1f); Matrix4x4 projectionMatrix2 = current.get_projectionMatrix(); Water.CalculateObliqueMatrix(ref projectionMatrix2, clipPlane2); camera2.set_projectionMatrix(projectionMatrix2); camera2.set_cullingMask(-17 & this.m_RefractLayers.get_value()); camera2.set_targetTexture(this.m_RefractionTexture); camera2.get_transform().set_position(current.get_transform().get_position()); camera2.get_transform().set_rotation(current.get_transform().get_rotation()); camera2.Render(); base.get_renderer().get_sharedMaterial().SetTexture("_RefractionTex", this.m_RefractionTexture); } if (this.m_DisablePixelLights) { QualitySettings.set_pixelLightCount(pixelLightCount); } switch (waterMode) { case Water.WaterMode.Simple: Shader.EnableKeyword("WATER_SIMPLE"); Shader.DisableKeyword("WATER_REFLECTIVE"); Shader.DisableKeyword("WATER_REFRACTIVE"); break; case Water.WaterMode.Reflective: Shader.DisableKeyword("WATER_SIMPLE"); Shader.EnableKeyword("WATER_REFLECTIVE"); Shader.DisableKeyword("WATER_REFRACTIVE"); break; case Water.WaterMode.Refractive: Shader.DisableKeyword("WATER_SIMPLE"); Shader.DisableKeyword("WATER_REFLECTIVE"); Shader.EnableKeyword("WATER_REFRACTIVE"); break; } Water.s_InsideWater = false; }
// Token: 0x06001473 RID: 5235 RVA: 0x000259BC File Offset: 0x00023BBC public void OnWillRenderObject() { if (!base.enabled || !base.renderer || !base.renderer.sharedMaterial || !base.renderer.enabled) { return; } Camera current = Camera.current; if (!current) { return; } if (Water.s_InsideWater) { return; } Water.s_InsideWater = true; this.m_HardwareWaterSupport = this.FindHardwareWaterSupport(); Water.WaterMode waterMode = this.GetWaterMode(); Camera camera; Camera camera2; this.CreateWaterObjects(current, out camera, out camera2); Vector3 position = base.transform.position; Vector3 up = base.transform.up; int pixelLightCount = QualitySettings.pixelLightCount; if (this.m_DisablePixelLights) { QualitySettings.pixelLightCount = 0; } this.UpdateCameraModes(current, camera); this.UpdateCameraModes(current, camera2); if (waterMode >= Water.WaterMode.Reflective) { float w = -Vector3.Dot(up, position) - this.m_ClipPlaneOffset; Vector4 plane = new Vector4(up.x, up.y, up.z, w); Matrix4x4 zero = Matrix4x4.zero; Water.CalculateReflectionMatrix(ref zero, plane); Vector3 position2 = current.transform.position; Vector3 position3 = zero.MultiplyPoint(position2); camera.worldToCameraMatrix = current.worldToCameraMatrix * zero; Vector4 clipPlane = this.CameraSpacePlane(camera, position, up, 1f); Matrix4x4 projectionMatrix = current.projectionMatrix; Water.CalculateObliqueMatrix(ref projectionMatrix, clipPlane); camera.projectionMatrix = projectionMatrix; camera.cullingMask = (-17 & this.m_ReflectLayers.value); camera.targetTexture = this.m_ReflectionTexture; GL.SetRevertBackfacing(true); camera.transform.position = position3; Vector3 eulerAngles = current.transform.eulerAngles; camera.transform.eulerAngles = new Vector3(-eulerAngles.x, eulerAngles.y, eulerAngles.z); camera.Render(); camera.transform.position = position2; GL.SetRevertBackfacing(false); base.renderer.sharedMaterial.SetTexture("_ReflectionTex", this.m_ReflectionTexture); } if (waterMode >= Water.WaterMode.Refractive) { camera2.worldToCameraMatrix = current.worldToCameraMatrix; Vector4 clipPlane2 = this.CameraSpacePlane(camera2, position, up, -1f); Matrix4x4 projectionMatrix2 = current.projectionMatrix; Water.CalculateObliqueMatrix(ref projectionMatrix2, clipPlane2); camera2.projectionMatrix = projectionMatrix2; camera2.cullingMask = (-17 & this.m_RefractLayers.value); camera2.targetTexture = this.m_RefractionTexture; camera2.transform.position = current.transform.position; camera2.transform.rotation = current.transform.rotation; camera2.Render(); base.renderer.sharedMaterial.SetTexture("_RefractionTex", this.m_RefractionTexture); } if (this.m_DisablePixelLights) { QualitySettings.pixelLightCount = pixelLightCount; } switch (waterMode) { case Water.WaterMode.Simple: Shader.EnableKeyword("WATER_SIMPLE"); Shader.DisableKeyword("WATER_REFLECTIVE"); Shader.DisableKeyword("WATER_REFRACTIVE"); break; case Water.WaterMode.Reflective: Shader.DisableKeyword("WATER_SIMPLE"); Shader.EnableKeyword("WATER_REFLECTIVE"); Shader.DisableKeyword("WATER_REFRACTIVE"); break; case Water.WaterMode.Refractive: Shader.DisableKeyword("WATER_SIMPLE"); Shader.DisableKeyword("WATER_REFLECTIVE"); Shader.EnableKeyword("WATER_REFRACTIVE"); break; } Water.s_InsideWater = false; }