TeardownPreviewLightingAndFx() private static méthode

private static TeardownPreviewLightingAndFx ( bool oldFog ) : void
oldFog bool
Résultat void
Exemple #1
0
        public Texture DoRenderPreview(Rect previewRect, GUIStyle background)
        {
            this.m_PreviewUtility.BeginPreview(previewRect, background);
            Vector3    bodyPosition = this.bodyPosition;
            Quaternion quaternion;
            Vector3    vector;
            Quaternion quaternion2;
            Vector3    pivotPos;

            if (this.Animator && this.Animator.isHuman)
            {
                quaternion  = this.Animator.rootRotation;
                vector      = this.Animator.rootPosition;
                quaternion2 = this.Animator.bodyRotation;
                pivotPos    = this.Animator.pivotPosition;
            }
            else
            {
                if (this.Animator && this.Animator.hasRootMotion)
                {
                    quaternion  = this.Animator.rootRotation;
                    vector      = this.Animator.rootPosition;
                    quaternion2 = Quaternion.identity;
                    pivotPos    = Vector3.zero;
                }
                else
                {
                    quaternion  = Quaternion.identity;
                    vector      = Vector3.zero;
                    quaternion2 = Quaternion.identity;
                    pivotPos    = Vector3.zero;
                }
            }
            bool    oldFog  = this.SetupPreviewLightingAndFx();
            Vector3 forward = quaternion2 * Vector3.forward;

            forward[1] = 0f;
            Quaternion directionRot = Quaternion.LookRotation(forward);
            Vector3    directionPos = vector;
            Quaternion pivotRot     = quaternion;

            this.PositionPreviewObjects(pivotRot, pivotPos, quaternion2, bodyPosition, directionRot, quaternion, vector, directionPos, this.m_AvatarScale);
            bool  flag = Mathf.Abs(this.m_NextFloorHeight - this.m_PrevFloorHeight) > this.m_ZoomFactor * 0.01f;
            float num2;
            float num3;

            if (flag)
            {
                float num = (this.m_NextFloorHeight >= this.m_PrevFloorHeight) ? 0.8f : 0.2f;
                num2 = ((this.timeControl.normalizedTime >= num) ? this.m_NextFloorHeight : this.m_PrevFloorHeight);
                num3 = Mathf.Clamp01(Mathf.Abs(this.timeControl.normalizedTime - num) / 0.2f);
            }
            else
            {
                num2 = this.m_PrevFloorHeight;
                num3 = 1f;
            }
            Quaternion identity = Quaternion.identity;
            Vector3    position = new Vector3(0f, 0f, 0f);

            position   = this.m_ReferenceInstance.transform.position;
            position.y = num2;
            Matrix4x4     matrix;
            RenderTexture renderTexture = this.RenderPreviewShadowmap(this.m_PreviewUtility.m_Light[0], this.m_BoundingVolumeScale / 2f, bodyPosition, position, out matrix);

            this.m_PreviewUtility.m_Camera.nearClipPlane = 0.5f * this.m_ZoomFactor;
            this.m_PreviewUtility.m_Camera.farClipPlane  = 100f * this.m_AvatarScale;
            Quaternion rotation  = Quaternion.Euler(-this.m_PreviewDir.y, -this.m_PreviewDir.x, 0f);
            Vector3    position2 = rotation * (Vector3.forward * -5.5f * this.m_ZoomFactor) + bodyPosition + this.m_PivotPositionOffset;

            this.m_PreviewUtility.m_Camera.transform.position = position2;
            this.m_PreviewUtility.m_Camera.transform.rotation = rotation;
            position.y = num2;
            Material  floorMaterial = this.m_FloorMaterial;
            Matrix4x4 matrix2       = Matrix4x4.TRS(position, identity, Vector3.one * 5f * this.m_AvatarScale);

            floorMaterial.mainTextureOffset = -new Vector2(position.x, position.z) * 5f * 0.08f * (1f / this.m_AvatarScale);
            floorMaterial.SetTexture("_ShadowTexture", renderTexture);
            floorMaterial.SetMatrix("_ShadowTextureMatrix", matrix);
            floorMaterial.SetVector("_Alphas", new Vector4(0.5f * num3, 0.3f * num3, 0f, 0f));
            Graphics.DrawMesh(this.m_FloorPlane, matrix2, floorMaterial, Camera.PreviewCullingLayer, this.m_PreviewUtility.m_Camera, 0);
            if (flag)
            {
                bool  flag2 = this.m_NextFloorHeight > this.m_PrevFloorHeight;
                float num4  = (!flag2) ? this.m_PrevFloorHeight : this.m_NextFloorHeight;
                float from  = (!flag2) ? this.m_NextFloorHeight : this.m_PrevFloorHeight;
                float num5  = ((num4 != num2) ? 1f : (1f - num3)) * Mathf.InverseLerp(from, num4, vector.y);
                position.y = num4;
                Material floorMaterialSmall = this.m_FloorMaterialSmall;
                floorMaterialSmall.mainTextureOffset = -new Vector2(position.x, position.z) * 0.2f * 0.08f;
                floorMaterialSmall.SetTexture("_ShadowTexture", renderTexture);
                floorMaterialSmall.SetMatrix("_ShadowTextureMatrix", matrix);
                floorMaterialSmall.SetVector("_Alphas", new Vector4(0.5f * num5, 0f, 0f, 0f));
                Matrix4x4 matrix3 = Matrix4x4.TRS(position, identity, Vector3.one * 0.2f * this.m_AvatarScale);
                Graphics.DrawMesh(this.m_FloorPlane, matrix3, floorMaterialSmall, Camera.PreviewCullingLayer, this.m_PreviewUtility.m_Camera, 0);
            }
            this.SetPreviewCharacterEnabled(true, this.m_ShowReference);
            this.m_PreviewUtility.m_Camera.Render();
            this.SetPreviewCharacterEnabled(false, false);
            AvatarPreview.TeardownPreviewLightingAndFx(oldFog);
            RenderTexture.ReleaseTemporary(renderTexture);
            return(this.m_PreviewUtility.EndPreview());
        }
Exemple #2
0
        public void DoRenderPreview(Rect previewRect, GUIStyle background)
        {
            this.m_PreviewUtility.BeginPreview(previewRect, background);
            Vector3    bodyPosition = this.bodyPosition;
            Quaternion quaternion1;
            Vector3    rootPos;
            Quaternion bodyRot;
            Vector3    pivotPos;

            if ((bool)((Object)this.Animator) && this.Animator.isHuman)
            {
                quaternion1 = this.Animator.rootRotation;
                rootPos     = this.Animator.rootPosition;
                bodyRot     = this.Animator.bodyRotation;
                pivotPos    = this.Animator.pivotPosition;
            }
            else if ((bool)((Object)this.Animator) && this.Animator.hasRootMotion)
            {
                quaternion1 = this.Animator.rootRotation;
                rootPos     = this.Animator.rootPosition;
                bodyRot     = Quaternion.identity;
                pivotPos    = Vector3.zero;
            }
            else
            {
                quaternion1 = Quaternion.identity;
                rootPos     = Vector3.zero;
                bodyRot     = Quaternion.identity;
                pivotPos    = Vector3.zero;
            }
            bool    oldFog  = this.SetupPreviewLightingAndFx();
            Vector3 forward = bodyRot * Vector3.forward;

            forward[1] = 0.0f;
            Quaternion directionRot = Quaternion.LookRotation(forward);
            Vector3    directionPos = rootPos;

            this.PositionPreviewObjects(quaternion1, pivotPos, bodyRot, bodyPosition, directionRot, quaternion1, rootPos, directionPos, this.m_AvatarScale);
            bool  flag1 = (double)Mathf.Abs(this.m_NextFloorHeight - this.m_PrevFloorHeight) > (double)this.m_ZoomFactor * 0.00999999977648258;
            float num1;
            float num2;

            if (flag1)
            {
                float num3 = (double)this.m_NextFloorHeight >= (double)this.m_PrevFloorHeight ? 0.8f : 0.2f;
                num1 = (double)this.timeControl.normalizedTime >= (double)num3 ? this.m_NextFloorHeight : this.m_PrevFloorHeight;
                num2 = Mathf.Clamp01(Mathf.Abs(this.timeControl.normalizedTime - num3) / 0.2f);
            }
            else
            {
                num1 = this.m_PrevFloorHeight;
                num2 = 1f;
            }
            Quaternion identity = Quaternion.identity;
            Vector3    vector3  = new Vector3(0.0f, 0.0f, 0.0f);
            Vector3    position = this.m_ReferenceInstance.transform.position;

            position.y = num1;
            Matrix4x4     outShadowMatrix;
            RenderTexture temp = this.RenderPreviewShadowmap(this.m_PreviewUtility.m_Light[0], this.m_BoundingVolumeScale / 2f, bodyPosition, position, out outShadowMatrix);

            this.m_PreviewUtility.m_Camera.nearClipPlane = 0.5f * this.m_ZoomFactor;
            this.m_PreviewUtility.m_Camera.farClipPlane  = 100f * this.m_AvatarScale;
            Quaternion quaternion2 = Quaternion.Euler(-this.m_PreviewDir.y, -this.m_PreviewDir.x, 0.0f);

            this.m_PreviewUtility.m_Camera.transform.position = quaternion2 * Vector3.forward * -5.5f * this.m_ZoomFactor + bodyPosition + this.m_PivotPositionOffset;
            this.m_PreviewUtility.m_Camera.transform.rotation = quaternion2;
            position.y = num1;
            Material  floorMaterial = this.m_FloorMaterial;
            Matrix4x4 matrix        = Matrix4x4.TRS(position, identity, Vector3.one * 5f * this.m_AvatarScale);

            floorMaterial.mainTextureOffset = -new Vector2(position.x, position.z) * 5f * 0.08f * (1f / this.m_AvatarScale);
            floorMaterial.SetTexture("_ShadowTexture", (Texture)temp);
            floorMaterial.SetMatrix("_ShadowTextureMatrix", outShadowMatrix);
            floorMaterial.SetVector("_Alphas", new Vector4(0.5f * num2, 0.3f * num2, 0.0f, 0.0f));
            Graphics.DrawMesh(this.m_FloorPlane, matrix, floorMaterial, Camera.PreviewCullingLayer, this.m_PreviewUtility.m_Camera, 0);
            if (flag1)
            {
                bool  flag2 = (double)this.m_NextFloorHeight > (double)this.m_PrevFloorHeight;
                float b     = !flag2 ? this.m_PrevFloorHeight : this.m_NextFloorHeight;
                float a     = !flag2 ? this.m_NextFloorHeight : this.m_PrevFloorHeight;
                float num3  = ((double)b != (double)num1 ? 1f : 1f - num2) * Mathf.InverseLerp(a, b, rootPos.y);
                position.y = b;
                Material floorMaterialSmall = this.m_FloorMaterialSmall;
                floorMaterialSmall.mainTextureOffset = -new Vector2(position.x, position.z) * 0.2f * 0.08f;
                floorMaterialSmall.SetTexture("_ShadowTexture", (Texture)temp);
                floorMaterialSmall.SetMatrix("_ShadowTextureMatrix", outShadowMatrix);
                floorMaterialSmall.SetVector("_Alphas", new Vector4(0.5f * num3, 0.0f, 0.0f, 0.0f));
                Graphics.DrawMesh(this.m_FloorPlane, Matrix4x4.TRS(position, identity, Vector3.one * 0.2f * this.m_AvatarScale), floorMaterialSmall, Camera.PreviewCullingLayer, this.m_PreviewUtility.m_Camera, 0);
            }
            this.SetPreviewCharacterEnabled(true, this.m_ShowReference);
            this.m_PreviewUtility.m_Camera.Render();
            this.SetPreviewCharacterEnabled(false, false);
            AvatarPreview.TeardownPreviewLightingAndFx(oldFog);
            RenderTexture.ReleaseTemporary(temp);
        }