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); } }
// 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(); } }
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; } }
public void AddPG(NeoNormalGrid PGrid) { if (PGrid && !grids.Contains(PGrid)) { UpdateMaterial(PGrid.oceanMaterial); grids.Add(PGrid); } }
public void AddPG(NeoNormalGrid PGrid) { if (!grids.Contains(PGrid)) { Material mat = PGrid.oceanMaterial; UpdateMaterial(PGrid, mat, true); grids.Add(PGrid); } }
private NeoNormalGrid FindMainPGrid() { var _e = grids.GetEnumerator(); NeoNormalGrid closestPG = null; while (_e.MoveNext()) { return(_e.Current); } return(closestPG); }
// 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(); } }
void OnDestroy() { gTime = 0; DestroyAllMaterial(); //if (Application.isPlaying) // GerstnerWavesJobs.Cleanup(); mainPGrid = null; if (instance == this) { instance = null; } }
public void RemovePG(NeoNormalGrid PGrid) { grids.Remove(PGrid); }
public float UpdateCameraPlane(NeoNormalGrid pgrid, float fAdd) { Camera cam = Camera.main; return(Mathf.Max(cam.nearClipPlane, cam.farClipPlane + fAdd)); }