Inheritance: MonoBehaviour
 private void AcquireComponents()
 {
     if (!this.reflection)
     {
         if (base.transform.parent)
         {
             this.reflection = base.transform.parent.GetComponent <PlanarReflection>();
         }
         else
         {
             this.reflection = base.transform.GetComponent <PlanarReflection>();
         }
     }
     if (!this.waterBase)
     {
         if (base.transform.parent)
         {
             this.waterBase = base.transform.parent.GetComponent <WaterBase>();
         }
         else
         {
             this.waterBase = base.transform.GetComponent <WaterBase>();
         }
     }
 }
    private void AcquireComponents()
    {
        if (!reflection)
        {
            if (transform.parent)
            {
                reflection = (PlanarReflection)transform.parent.GetComponent <PlanarReflection>();
            }
            else
            {
                reflection = (PlanarReflection)transform.GetComponent <PlanarReflection>();
            }
        }

        if (!waterBase)
        {
            if (transform.parent)
            {
                waterBase = (WaterBase)transform.parent.GetComponent <WaterBase>();
            }
            else
            {
                waterBase = (WaterBase)transform.GetComponent <WaterBase>();
            }
        }
    }
    // Token: 0x06001491 RID: 5265 RVA: 0x00026BF4 File Offset: 0x00024DF4
    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);
    }
    // Token: 0x0600148F RID: 5263 RVA: 0x00026968 File Offset: 0x00024B68
    private void RenderReflectionFor(Camera cam, Camera reflectCamera)
    {
        if (!reflectCamera)
        {
            return;
        }
        if (this.sharedMaterial && !this.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.SetRevertBackfacing(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.oldpos = cam.transform.position;
        Vector3 position2 = matrix4x.MultiplyPoint(this.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.SetRevertBackfacing(false);
    }
Beispiel #5
0
    private 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>();
    }
Beispiel #6
0
    private void AcquireComponents()
    {
        Transform parent = transform.parent;

        if (parent == null)
        {
            Debug.Log("No parent specified to this target! Disabling...", this);
            this.enabled = false;
            return;
        }

        reflection = parent.GetComponent <PlanarReflection>();
        waterBase  = parent.GetComponent <WaterBase>();
        GetComponent <Renderer>().castShadows = false;
    }
Beispiel #7
0
    protected void RefreshSettings()
    {
        WaterBase        component        = base.GetComponent <WaterBase>();
        PlanarReflection planarReflection = base.GetComponent <PlanarReflection>();

        if (!component)
        {
            return;
        }
        if (render.level > 0.8f)
        {
            component.waterQuality = WaterQuality.High;
            component.edgeBlend    = true;
        }
        else if (render.level <= 0.5f)
        {
            component.waterQuality = WaterQuality.Low;
            component.edgeBlend    = false;
        }
        else
        {
            component.waterQuality = WaterQuality.Medium;
            component.edgeBlend    = false;
        }
        if (water.level != -1)
        {
            component.waterQuality = (WaterQuality)Mathf.Clamp(water.level - 1, 0, 2);
            component.edgeBlend    = water.level == 2;
        }
        if (planarReflection)
        {
            planarReflection.reflectionMask = 13111296;
            if (!water.reflection)
            {
                planarReflection.reflectionMask = 8388608;
            }
        }
    }
Beispiel #8
0
    // Token: 0x06002B2C RID: 11052 RVA: 0x000A0A24 File Offset: 0x0009EC24
    protected void RefreshSettings()
    {
        WaterBase        component  = base.GetComponent <WaterBase>();
        PlanarReflection component2 = base.GetComponent <PlanarReflection>();

        if (!component)
        {
            return;
        }
        if (global::render.level > 0.8f)
        {
            component.waterQuality = 2;
            component.edgeBlend    = true;
        }
        else if (global::render.level > 0.5f)
        {
            component.waterQuality = 1;
            component.edgeBlend    = false;
        }
        else
        {
            component.waterQuality = 0;
            component.edgeBlend    = false;
        }
        if (global::water.level != -1)
        {
            component.waterQuality = Mathf.Clamp(global::water.level - 1, 0, 2);
            component.edgeBlend    = (global::water.level == 2);
        }
        if (component2)
        {
            component2.reflectionMask = 13111296;
            if (!global::water.reflection)
            {
                component2.reflectionMask = 8388608;
            }
        }
    }
Beispiel #9
0
    protected void RefreshSettings()
    {
        WaterBase        component  = base.GetComponent <WaterBase>();
        PlanarReflection reflection = base.GetComponent <PlanarReflection>();

        if (component != null)
        {
            if (render.level > 0.8f)
            {
                component.waterQuality = WaterQuality.High;
                component.edgeBlend    = true;
            }
            else if (render.level > 0.5f)
            {
                component.waterQuality = WaterQuality.Medium;
                component.edgeBlend    = false;
            }
            else
            {
                component.waterQuality = WaterQuality.Low;
                component.edgeBlend    = false;
            }
            if (water.level != -1)
            {
                component.waterQuality = (WaterQuality)Mathf.Clamp(water.level - 1, 0, 2);
                component.edgeBlend    = water.level == 2;
            }
            if (reflection != null)
            {
                reflection.reflectionMask = 0xc81000;
                if (!water.reflection)
                {
                    reflection.reflectionMask = 0x800000;
                }
            }
        }
    }
Beispiel #10
0
    private void RenderReflectionFor(Camera cam, Camera reflectCamera)
    {
        if (!reflectCamera)
        {
            return;
        }
        if (this.sharedMaterial && !this.sharedMaterial.HasProperty(this.reflectionSampler))
        {
            return;
        }
        if (GraphicsSettings.planarReflectionNeedsUpdate)
        {
            GraphicsSettings.planarReflectionNeedsUpdate = false;
            switch (GraphicsSettings.planarReflectionQuality)
            {
            case EGraphicQuality.LOW:
                reflectCamera.cullingMask = PlanarReflection.CULLING_MASK_LOW;
                break;

            case EGraphicQuality.MEDIUM:
                reflectCamera.cullingMask = PlanarReflection.CULLING_MASK_MEDIUM;
                break;

            case EGraphicQuality.HIGH:
                reflectCamera.cullingMask = PlanarReflection.CULLING_MASK_HIGH;
                break;

            case EGraphicQuality.ULTRA:
                reflectCamera.cullingMask = PlanarReflection.CULLING_MASK_ULTRA;
                break;
            }
            reflectCamera.layerCullDistances = cam.layerCullDistances;
            reflectCamera.layerCullSpherical = cam.layerCullSpherical;
        }
        this.SaneCameraSettings(reflectCamera);
        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   num = -Vector3.Dot(up, position) - this.clipPlaneOffset;
        Vector4 plane;

        plane..ctor(up.x, up.y, up.z, num);
        Matrix4x4 matrix4x = Matrix4x4.zero;

        matrix4x    = PlanarReflection.CalculateReflectionMatrix(matrix4x, plane);
        this.oldpos = cam.transform.position;
        Vector3 position2 = matrix4x.MultiplyPoint(this.oldpos);

        reflectCamera.worldToCameraMatrix = cam.worldToCameraMatrix * matrix4x;
        Vector4 vector = this.CameraSpacePlane(reflectCamera, position, up, 1f);

        reflectCamera.projectionMatrix   = cam.CalculateObliqueMatrix(vector);
        reflectCamera.transform.position = position2;
        Vector3 eulerAngles2 = cam.transform.eulerAngles;

        reflectCamera.transform.eulerAngles = new Vector3(-eulerAngles2.x, eulerAngles2.y, eulerAngles2.z);
        float lodBias = QualitySettings.lodBias;

        QualitySettings.lodBias = 1f;
        if (PlanarReflection.preRender != null)
        {
            PlanarReflection.preRender();
        }
        reflectCamera.Render();
        if (PlanarReflection.postRender != null)
        {
            PlanarReflection.postRender();
        }
        QualitySettings.lodBias = lodBias;
        GL.invertCulling        = false;
    }
Beispiel #11
0
 void Start()
 {
     pr        = GetComponent <PlanarReflection>();
     gSettings = GameSettings.settingsController;
 }