Ejemplo n.º 1
0
    public void Update()
    {
        if (this.actor == null || !this.actor.Visible)
        {
            return;
        }
        float scalar = this.actor.groundY.get_scalar();

        if (this.lastUpdateGroundY != scalar)
        {
            if (this.shadowMesh != null && this.shadowMesh.activeInHierarchy)
            {
                Transform transform = this.shadowMesh.transform;
                Vector3   position  = transform.position;
                position.y         = scalar;
                transform.position = position;
            }
            this.lastUpdateGroundY = scalar;
        }
        if (this.mats != null && this.mats.get_Count() > 0)
        {
            Vector4 vector = new Vector4(0f, 1f, 0f, 0f);
            vector.w  = scalar;
            vector.w += 0.05f;
            float value = Mathf.Abs(PlaneShadowSettings.shadowProjDir.y / Mathf.Max(0.001f, this.height));
            for (int i = 0; i < this.mats.get_Count(); i++)
            {
                Material material = this.mats.get_Item(i);
                material.SetVector("_ShadowPlane", vector);
                material.SetFloat("_ShadowInvLen", value);
                material.SetVector("_WorldPos", MMGame_Math.toVec4(base.gameObject.transform.position, 1f));
            }
        }
    }
Ejemplo n.º 2
0
    private void LateUpdate()
    {
        if (this.depthCam_ == null || this.depthTextures_ == null || !this.supportShadow)
        {
            return;
        }
        Matrix4x4 matrix4x = GL.GetGPUProjectionMatrix(this.depthCam_.projectionMatrix, false);

        matrix4x *= this.depthCam_.worldToCameraMatrix;
        Vector4 vec = MMGame_Math.toVec4(base.transform.forward.normalized, this.ShadowIntensity);

        Shader.SetGlobalMatrix("_SGameShadowMatrix", matrix4x);
        Shader.SetGlobalVector("_SGameShadowParams", vec);
    }
Ejemplo n.º 3
0
 public static void Apply()
 {
     Shader.SetGlobalVector("_ShadowProjDir", MMGame_Math.toVec4(PlaneShadowSettings.shadowProjDir, 1f));
     Shader.SetGlobalVector("_ShadowFadeParams", PlaneShadowSettings.shadowParams);
 }