示例#1
0
 void OnDisable()
 {
     if (_instance == this)
     {
         _instance = null;
     }
     RenderTexture.ReleaseTemporary(mTmpRT);
     if (Indirect)
     {
         for (int i = 0; i < IMs.Length; i++)
         {
             IMs[i].Destroy();
         }
     }
 }
示例#2
0
    void OnEnable()
    {
        // 添加强制关闭,以便于模块化测试
        if (GlobalGameDefine.mIsForceCloseGPUGrass)
        {
            this.enabled = false;
            return;
        }

        if (AutoMethodSelection)
        {
            Indirect = UnityUtils.FindShader("SAO_TJia_V3/Grass/TjiaInstancedGrassShader").isSupported;
        }

        //Indirect = false;
        Debug.Log("TJiaGrassGenerator.OnEnable: " + UnityEngine.SystemInfo.deviceModel);
        if (UnityEngine.SystemInfo.deviceModel.Contains("HUAWEI"))
        {
            Indirect = false;
            Debug.Log("TJiaGrassGenerator.OnEnable: " + Indirect);
        }

        mTmpRT = RenderTexture.GetTemporary(InteractiveGrassTexture.descriptor);

        _instance = this;

        mTmpRT.name = "TJia_Grass_Interactive";
        Shader.SetGlobalTexture("_InteractiveGrass", InteractiveGrassTexture);

        if (GameObject.Find("TJiaGrassFX"))
        {
            GrassFXTr = GameObject.Find("TJiaGrassFX").transform;
            GrassFX   = GrassFXTr.GetComponent <ParticleSystem>();
        }

        for (int i = 0; i < IMs.Length; i++)
        {
            IMs[i].Indirect = Indirect;
            IMs[i].Initialization();
            IMs[i].RepeatRate = 0.7f + 1.5f * (float)i;
        }
    }
示例#3
0
    void Start()
    {
        Shader.SetGlobalInt("_CrossfadeOn", 1);

        PlayerPos      = null;
        OpenShadow     = true;
        OverdrawShader = UnityUtils.FindShader("SAO_TJia_V3/Debugger/Overdraw");

#if BUILD_SINGLESCNE_MODE
        singleCamera = GameObject.Find("客户端测试节点_请勿删除/saoUIJoyPadCom/Camera").GetComponent <Camera>();
#endif
        mSun = RenderSettings.sun;

#if BUILD_SINGLESCNE_MODE
        mCam = singleCamera;
        mCam = singleCamera;
#else
        _mCam = GetComponent <Camera>();
#endif
        OpenDepth();

        if (GetComponent <DBP_Controler>())
        {
#if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                DestroyImmediate(GetComponent <DBP_Controler>());
            }
            else
            {
                Destroy(GetComponent <DBP_Controler>());
            }
#else
            Destroy(GetComponent <DBP_Controler>());
#endif
        }
        if (!GetComponent <QuadtreeManager>() && GetComponent <CameraController>())
        {
            QuadtreeManager qtm = gameObject.AddComponent <QuadtreeManager>();
            //qtm.HideAngle = 30;
        }
        else if (GetComponent <QuadtreeManager>())
        {
            GetComponent <QuadtreeManager>().enabled = true;
        }

        mTGG = GetComponent <TJiaGrassGenerator>();

        foreach (GameObject go in FindObjectsOfType <GameObject>())
        {
            if (go.tag == "MainPlayer")
            {
                PlayerPos = go.transform;
                if (mTGG != null)
                {
                    mTGG.PlayerPos = PlayerPos;
                }
                break;
            }
        }

        //------------------------------------------------------------
        //Add by Zzc
        //------------------------------------------------------------
        PlayerAddRipple();

        int pSize = 8;
        for (int i = 0; i < mAutoExplosureRTs.Length; i++)
        {
            mAutoExplosureRTs[i] = new RenderTexture(pSize, pSize, 0);
            pSize /= 2;
        }
        mAERTMemo  = new RenderTexture(1, 1, 0);
        mAERTMemo1 = new RenderTexture(1, 1, 0);
    }
示例#4
0
    //
    // 当场景重新加载的时候,我们希望能再次刷新那些与品质相关的设置
    //
    public static void ReSettingRelativeQualityWhenSceneLoad(int intQuality)
    {
        //Jia
        switch (intQuality)
        {
        case 0:
            foreach (CameraFX cfx in GameObject.FindObjectsOfType <CameraFX>())
            {
                TJiaGrassGenerator TGG = cfx.GetComponent <TJiaGrassGenerator>();
                //TJiaBloom TB = cfx.GetComponent<TJiaBloom>();
                if (TGG != null)
                {
                    if (TGG.IMs.Length == 3)
                    {
                        TGG.IMs[0].Density     = GlobalGameDefine.intGrassDensityLevel0;
                        TGG.IMs[1].Density     = GlobalGameDefine.intGrassDensityLevel1;
                        TGG.IMs[2].Density     = GlobalGameDefine.intGrassDensityLevel2;
                        TGG.IMs[0].StartRadias = 0;
                        TGG.IMs[0].Thickness   = 45;
                        TGG.IMs[1].StartRadias = 35;
                        TGG.IMs[1].Thickness   = 25;
                        TGG.IMs[2].StartRadias = 55;
                        TGG.IMs[2].Thickness   = 88;
                    }
                }
                //if (TB != null)
                //{
                //    TB.enabled = false;
                //}

                // hw special setting
                //if (GlobalGameDefine.mIsHWMate30BossDevice)
                //{
                //    cfx.enabled = true;
                //    cfx.OpenShadow = true;
                //    cfx.AA = false;
                //}
                //else
                //{
                //    cfx.OpenShadow = false;
                //    cfx.DisableCFX();
                //}
            }
            break;

        case 1:
            foreach (CameraFX cfx in GameObject.FindObjectsOfType <CameraFX>())
            {
                TJiaGrassGenerator TGG = cfx.GetComponent <TJiaGrassGenerator>();
                TJiaBloom          TB  = cfx.GetComponent <TJiaBloom>();
                if (TGG != null)
                {
                    if (TGG.IMs.Length == 3)
                    {
                        //TGG.IMs[0].Density = 2;
                        //TGG.IMs[1].Density = 2;
                        //TGG.IMs[2].Density = 1;
                        //TGG.IMs[0].StartRadias = 0;
                        //TGG.IMs[0].Thickness = 50;
                        //TGG.IMs[1].StartRadias = 40;
                        //TGG.IMs[1].Thickness = 40;
                        //TGG.IMs[2].StartRadias = 70;
                        //TGG.IMs[2].Thickness = 88;
                        TGG.IMs[0].Density     = GlobalGameDefine.intGrassDensityLevel0;
                        TGG.IMs[1].Density     = GlobalGameDefine.intGrassDensityLevel1;
                        TGG.IMs[2].Density     = GlobalGameDefine.intGrassDensityLevel2;
                        TGG.IMs[0].StartRadias = 0;
                        TGG.IMs[0].Thickness   = 59;
                        TGG.IMs[1].StartRadias = 46;
                        TGG.IMs[1].Thickness   = 40;
                        TGG.IMs[2].StartRadias = 78;
                        TGG.IMs[2].Thickness   = 88;
                    }
                }
                //if (TB != null)
                //{
                //    if(GlobalGameDefine.mIsForceDisableAnyBloom)
                //    {
                //        TB.enabled = false;
                //    }
                //    else
                //    {
                //        if (GlobalGameDefine.mIsHWDevice)
                //        {
                //            TB.enabled = !GlobalGameDefine.mIsForceCloseBloomForHW;
                //        }
                //        else
                //        {
                //            TB.enabled = true;
                //        }
                //    }
                //}
                //cfx.enabled = true;
                //cfx.OpenShadow = true;
                //cfx.AA = false;
            }
            break;

        case 2:
            foreach (CameraFX cfx in GameObject.FindObjectsOfType <CameraFX>())
            {
                TJiaGrassGenerator TGG = cfx.GetComponent <TJiaGrassGenerator>();
                TJiaBloom          TB  = cfx.GetComponent <TJiaBloom>();
                if (TGG != null)
                {
                    if (TGG.IMs.Length == 3)
                    {
                        TGG.IMs[0].Density     = GlobalGameDefine.intGrassDensityLevel0;
                        TGG.IMs[1].Density     = GlobalGameDefine.intGrassDensityLevel1;
                        TGG.IMs[2].Density     = GlobalGameDefine.intGrassDensityLevel2;
                        TGG.IMs[0].StartRadias = 0;
                        TGG.IMs[0].Thickness   = 59;
                        TGG.IMs[1].StartRadias = 46;
                        TGG.IMs[1].Thickness   = 40;
                        TGG.IMs[2].StartRadias = 78;
                        TGG.IMs[2].Thickness   = 88;
                    }
                }
                //if (TB != null)
                //{
                //    if(GlobalGameDefine.mIsForceDisableAnyBloom)
                //    {
                //        TB.enabled = false;
                //    }
                //    else
                //    {
                //        if (GlobalGameDefine.mIsHWDevice)
                //        {
                //            TB.enabled = !GlobalGameDefine.mIsForceCloseBloomForHW;
                //        }
                //        else
                //        {
                //            TB.enabled = true;
                //        }
                //    }
                //}
                //cfx.enabled = true;
                //cfx.OpenShadow = true;
                //cfx.AA = true;
            }
            break;
        }

        LsyBlur.SetQualityAll(intQuality);
    }
示例#5
0
 private void Start()
 {
     gg = Camera.main.GetComponent <TJiaGrassGenerator>();
     Shader.SetGlobalVector("_CullDis", Vector4.zero);
     Shader.SetGlobalVector("_CamPos1", Vector4.zero);
 }
示例#6
0
    protected override void OnGUI_Mission4()
    {
        base.OnGUI_Mission4();
        TesterGroup("LOD距离",
                    "0", delegate() { QualitySettings.lodBias = 0f; },
                    "0.3", delegate() { QualitySettings.lodBias = 0.3f; },
                    "1", delegate() { QualitySettings.lodBias = 1f; }
                    );

        var g = GrassRenderer.Instance;

        if (rootGrass != null)
        {
            TesterGroup("草",
                        "关闭", delegate() {
                rootGrass.SetActive(false);
            },
                        "40", delegate() {
                rootGrass.SetActive(true);
                g.settings.SetDis(40);
                g.settings.lodDis = new float[] { 10, 20, 30 };
                DitherCrossFadeManager._FadeNear = 22;
                DitherCrossFadeManager._FadeFar  = 27;
            },
                        "50", delegate() {
                rootGrass.SetActive(true);
                g.settings.SetDis(50);
                g.settings.lodDis = new float[] { 15, 25, 35 };
                DitherCrossFadeManager._FadeNear = 35;
                DitherCrossFadeManager._FadeFar  = 40;
            },
                        "60", delegate() {
                rootGrass.SetActive(true);
                g.settings.SetDis(60);
                g.settings.lodDis = new float[] { 20, 30, 40 };
                DitherCrossFadeManager._FadeNear = 40;
                DitherCrossFadeManager._FadeFar  = 45;
            }
                        );
        }

        if (rootWater != null)
        {
            TesterGroup("水",
                        "关闭", delegate() {
                rootWater.SetActive(false);
            },
                        "打开", delegate() {
                rootWater.SetActive(true);
            }
                        );
        }


        if (rootFX != null)
        {
            TesterGroup("特效",
                        "关闭", delegate() {
                rootFX.SetActive(false);
            },
                        "打开", delegate() {
                rootFX.SetActive(true);
            }
                        );
        }
        TesterGroup("粒子系统",
                    "关闭", delegate() { SetParticleSystem(false); },
                    "打开", delegate() { SetParticleSystem(true); }
                    );


        if (charRoot != null)
        {
            TesterGroup("角色",
                        "创建", delegate() {
                Char_Create();
            }
                        );
            TesterGroup("角色 Outline",
                        "0.015", delegate() {
                Char_SetOutline(0.015f);
            },
                        "0.03", delegate() {
                Char_SetOutline(0.03f);
            },
                        "0.04", delegate() {
                Char_SetOutline(0.04f);
            },
                        "0.05", delegate() {
                Char_SetOutline(0.05f);
            }
                        );
        }

        GUILayout.BeginHorizontal();
        GUILayout.Space(UIWidth + 7);
        if (GUILayout.Button("^", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
        {
            Camera.main.transform.localEulerAngles += new Vector3(-5, 0, 0);
            Camera.main.transform.localPosition    += new Vector3(0, 0, 30f);
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("<", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
        {
            Camera.main.transform.localEulerAngles += new Vector3(0, -5, 0);
            Camera.main.transform.localPosition    += new Vector3(-30f, 0, 0);
        }
        if (GUILayout.Button("v", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
        {
            Camera.main.transform.localEulerAngles += new Vector3(5, 0, 0);
            Camera.main.transform.localPosition    += new Vector3(0, 0f, 30f);
        }
        if (GUILayout.Button(">", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
        {
            Camera.main.transform.localEulerAngles += new Vector3(0, 5, 0);
            Camera.main.transform.localPosition    += new Vector3(30f, 0, 0f);
        }
        GUILayout.EndHorizontal();

        if (!Camera.main.GetComponent <TJiaGrassGenerator>())
        {
            TJiaGrassGenerator tgg = Camera.main.gameObject.AddComponent <TJiaGrassGenerator>();
            tgg.InteractiveGrassTexture = InteractiveGrassTexture;
            tgg.InteractiveGrassMat     = InteractiveGrassMat;
            tgg.IMs                     = new TJiaGrassGenerator.InstanceModule[3];
            tgg.IMs[0].Density          = 3;
            tgg.IMs[0].StartRadias      = 0;
            tgg.IMs[0].Thickness        = 60;
            tgg.IMs[0].InstanceMesh     = instanceMesh;
            tgg.IMs[0].InstanceMaterial = IMLOD0;
            //tgg.IMs[0].Dither = TJiaGrassGenerator.InstanceModule.DitherMode.Off;

            tgg.IMs[0].Density          = 3;
            tgg.IMs[0].StartRadias      = 60;
            tgg.IMs[0].Thickness        = 70;
            tgg.IMs[0].InstanceMesh     = instanceMesh;
            tgg.IMs[0].InstanceMaterial = IMLOD1;
            //tgg.IMs[0].Dither = TJiaGrassGenerator.InstanceModule.DitherMode.Off;

            tgg.IMs[0].Density          = 2;
            tgg.IMs[0].StartRadias      = 130;
            tgg.IMs[0].Thickness        = 160;
            tgg.IMs[0].InstanceMesh     = instanceMesh;
            tgg.IMs[0].InstanceMaterial = IMLOD2;
            //tgg.IMs[0].Dither = TJiaGrassGenerator.InstanceModule.DitherMode.OneToZero;
        }


        if (Camera.main.GetComponent <TJiaGrassGenerator>())
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(UIWidth + 7);
            if (GUILayout.Button("^", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
            {
                Camera.main.transform.localPosition += new Vector3(0, 0, 20f);
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("<", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
            {
                Camera.main.transform.localPosition += new Vector3(-20f, 0, 0);
            }
            if (GUILayout.Button("v", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
            {
                Camera.main.transform.localPosition += new Vector3(0, 0f, 20f);
            }
            if (GUILayout.Button(">", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
            {
                Camera.main.transform.localPosition += new Vector3(20f, 0, 0f);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("TGG关", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
            {
                Camera.main.GetComponent <TJiaGrassGenerator>().enabled = false;
            }
            if (GUILayout.Button("TGG开", GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
            {
                Camera.main.GetComponent <TJiaGrassGenerator>().enabled = true;
            }
            GUILayout.EndHorizontal();
        }

        if (Camera.main.GetComponent <TJiaGrassGenerator>())
        {
            if (GUILayout.Button("TGG:" + Camera.main.GetComponent <TJiaGrassGenerator>().enabled.ToString(), GUILayout.Width(UIWidth), GUILayout.Height(UIHeight)))
            {
            }
        }


        //if (target!=null)
        //	Camera.main.transform.position = target.position - target.forward * followH + Vector3.up*followV;

        var c = Camera.main.GetComponentInChildren <GameCamera> ();

        if (c != null)
        {
            Destroy(c);
        }
        Camera.main.allowMSAA = true;
    }