Exemple #1
0
        public void UpdateMaterial(NeoNormalGrid pgrid, Material mat, bool main)
        {
            if (mat == null)
            {
                return;
            }

            if (envParam.sunLight != null)
            {
                if (mat.IsKeywordEnabled("_PIXELFORCES_ON"))
                {
                    mat.SetVector("_WorldLightPos", envParam.sunLight.transform.position);
                }
                else
                {
                    mat.SetVector("_WorldLightDir", envParam.sunLight.transform.forward);
                }

                mat.SetColor("_SpecularColor", envParam.sunLight.color);

                //envParam.sunLight.cullingMask = 0;
                //envParam.sunLight.shadows = LightShadows.None;
                //envParam.sunLight.renderMode = LightRenderMode.ForceVertex;
            }
            else
            {
                mat.SetColor("_SpecularColor", Color.black);
            }
        }
Exemple #2
0
        // Update is called once per frame
        void Update()
        {
            var _e = grids.GetEnumerator();

            if (!CheckInstance(false))
            {
                while (_e.MoveNext())
                {
                    _e.Current.enabled = false;
                }

                return;
            }

            while (_e.MoveNext())
            {
                if (_e.Current != null)
                {
                    _e.Current.enabled = _e.Current.gameObject.activeSelf;
                }
            }

            gTime += Mathf.Min(Time.smoothDeltaTime, 1f) * uniWaveSpeed;
            gTime  = Mathf.PingPong(gTime, 1e4f);

            CheckParams();

            //find main grid
            mainPGrid = FindMainPGrid();

            if (mainPGrid != null)
            {
                UpdateMainGrid();
            }
        }
Exemple #3
0
 public void CheckDepth(NeoNormalGrid grid)
 {
     if (UnityEngine.Rendering.Universal.UniversalRenderPipeline.asset != null)
     {
         UnityEngine.Rendering.Universal.UniversalRenderPipeline.asset.supportsCameraOpaqueTexture = true;
         UnityEngine.Rendering.Universal.UniversalRenderPipeline.asset.supportsCameraDepthTexture  = true;
     }
 }
Exemple #4
0
 public void AddPG(NeoNormalGrid PGrid)
 {
     if (PGrid && !grids.Contains(PGrid))
     {
         UpdateMaterial(PGrid.oceanMaterial);
         grids.Add(PGrid);
     }
 }
Exemple #5
0
 public void AddPG(NeoNormalGrid PGrid)
 {
     if (!grids.Contains(PGrid))
     {
         Material mat = PGrid.oceanMaterial;
         UpdateMaterial(PGrid, mat, true);
         grids.Add(PGrid);
     }
 }
Exemple #6
0
        private NeoNormalGrid FindMainPGrid()
        {
            var           _e        = grids.GetEnumerator();
            NeoNormalGrid closestPG = null;

            while (_e.MoveNext())
            {
                return(_e.Current);
            }

            return(closestPG);
        }
Exemple #7
0
        // Update is called once per frame
        void Update()
        {
            var _e = grids.GetEnumerator();

            if (!CheckInstance(false))
            {
                while (_e.MoveNext())
                {
                    _e.Current.enabled = false;
                }

                return;
            }

            while (_e.MoveNext())
            {
                if (_e.Current != null)
                {
                    _e.Current.enabled = _e.Current.gameObject.activeSelf;
                }
            }

            Camera cam = Camera.main;

            if (cam == null)
            {
                return;
            }

            if (!cam.gameObject.activeSelf)
            {
                return;
            }

            gTime += Mathf.Min(Time.smoothDeltaTime, 1f);
            float rTime = (float)(gTime / 20f);

            Shader.SetGlobalFloat("_NeoGlobalTime", rTime - 4f);

            CheckParams();

            //find main grid
            mainPGrid = FindMainPGrid();

            if (mainPGrid != null)
            {
                UpdateMainGrid();
            }
        }
Exemple #8
0
        void OnDestroy()
        {
            gTime = 0;

            DestroyAllMaterial();

            //if (Application.isPlaying)
            //    GerstnerWavesJobs.Cleanup();

            mainPGrid = null;

            if (instance == this)
            {
                instance = null;
            }
        }
Exemple #9
0
 public void RemovePG(NeoNormalGrid PGrid)
 {
     grids.Remove(PGrid);
 }
Exemple #10
0
        public float UpdateCameraPlane(NeoNormalGrid pgrid, float fAdd)
        {
            Camera cam = Camera.main;

            return(Mathf.Max(cam.nearClipPlane, cam.farClipPlane + fAdd));
        }