void AcquireComponents() { if (!reflection) { if (transform.parent) { reflection = transform.parent.GetComponent<PlanarReflection>(); } else { reflection = transform.GetComponent<PlanarReflection>(); } } if (!waterBase) { if (transform.parent) { waterBase = transform.parent.GetComponent<WaterBase>(); } else { waterBase = transform.GetComponent<WaterBase>(); } } }
private void AcquireComponents() { if (!reflection) { if ((bool)base.transform.parent) { reflection = base.transform.parent.GetComponent <PlanarReflection>(); } else { reflection = base.transform.GetComponent <PlanarReflection>(); } } if (!waterBase) { if ((bool)base.transform.parent) { waterBase = base.transform.parent.GetComponent <WaterBase>(); } else { waterBase = base.transform.GetComponent <WaterBase>(); } } }
private static Matrix4x4 CalculateObliqueMatrix(Matrix4x4 projection, Vector4 clipPlane) { Vector4 b = projection.inverse * new Vector4(PlanarReflection.Sgn(clipPlane.x), PlanarReflection.Sgn(clipPlane.y), 1f, 1f); Vector4 vector = clipPlane * (2f / Vector4.Dot(clipPlane, b)); projection[2] = vector.x - projection[3]; projection[6] = vector.y - projection[7]; projection[10] = vector.z - projection[11]; projection[14] = vector.w - projection[15]; return(projection); }
private void RenderReflectionFor(Camera cam, Camera reflectCamera) { if (!reflectCamera) { return; } if (this.m_SharedMaterial && !this.m_SharedMaterial.HasProperty(this.reflectionSampler)) { return; } reflectCamera.cullingMask = (this.reflectionMask & ~(1 << LayerMask.NameToLayer("Water"))); this.SaneCameraSettings(reflectCamera); reflectCamera.backgroundColor = this.clearColor; reflectCamera.clearFlags = ((!this.reflectSkybox) ? CameraClearFlags.Color : CameraClearFlags.Skybox); if (this.reflectSkybox && cam.gameObject.GetComponent(typeof(Skybox))) { Skybox skybox = (Skybox)reflectCamera.gameObject.GetComponent(typeof(Skybox)); if (!skybox) { skybox = (Skybox)reflectCamera.gameObject.AddComponent(typeof(Skybox)); } skybox.material = ((Skybox)cam.GetComponent(typeof(Skybox))).material; } GL.invertCulling = true; Transform transform = base.transform; Vector3 eulerAngles = cam.transform.eulerAngles; reflectCamera.transform.eulerAngles = new Vector3(-eulerAngles.x, eulerAngles.y, eulerAngles.z); reflectCamera.transform.position = cam.transform.position; Vector3 position = transform.transform.position; position.y = transform.position.y; Vector3 up = transform.transform.up; float w = -Vector3.Dot(up, position) - this.clipPlaneOffset; Vector4 plane = new Vector4(up.x, up.y, up.z, w); Matrix4x4 matrix4x = Matrix4x4.zero; matrix4x = PlanarReflection.CalculateReflectionMatrix(matrix4x, plane); this.m_Oldpos = cam.transform.position; Vector3 position2 = matrix4x.MultiplyPoint(this.m_Oldpos); reflectCamera.worldToCameraMatrix = cam.worldToCameraMatrix * matrix4x; Vector4 clipPlane = this.CameraSpacePlane(reflectCamera, position, up, 1f); Matrix4x4 matrix4x2 = cam.projectionMatrix; matrix4x2 = PlanarReflection.CalculateObliqueMatrix(matrix4x2, clipPlane); reflectCamera.projectionMatrix = matrix4x2; reflectCamera.transform.position = position2; Vector3 eulerAngles2 = cam.transform.eulerAngles; reflectCamera.transform.eulerAngles = new Vector3(-eulerAngles2.x, eulerAngles2.y, eulerAngles2.z); reflectCamera.Render(); GL.invertCulling = false; }
private void AcquireComponents() { if (!this.reflection) { this.reflection = !base.transform.parent ? base.transform.GetComponent <PlanarReflection>() : base.transform.parent.GetComponent <PlanarReflection>(); } if (!this.waterBase) { this.waterBase = !base.transform.parent ? base.transform.GetComponent <WaterBase>() : base.transform.parent.GetComponent <WaterBase>(); } }
private void AcquireComponents() { if (!this.reflection) { if (base.transform.parent) { this.reflection = base.transform.parent.GetComponent <PlanarReflection>(); } else { this.reflection = base.transform.GetComponent <PlanarReflection>(); } } }
private void Start() { if (this.sharedMaterialList != null && this.sharedMaterialList.Length > 0) { this.sharedMaterial = this.sharedMaterialList[0]; } this.waterTileRender = base.gameObject.GetComponentInChildren <Renderer>(); this.reflectionCtrl = base.gameObject.GetComponent <PlanarReflection>(); if (this.waterTileRender) { this.waterTileRender.sharedMaterial = this.sharedMaterial; } if (this.reflectionCtrl) { this.reflectionCtrl.m_SharedMaterial = this.sharedMaterial; } }