void Start() { m_lastStaged = m_staged; m_waves = new WaveSpectrumCPU(m_fourierGridSize, m_windSpeed, m_waveAmp, m_inverseWaveAge, m_ansio, m_gridSizes); m_waves.SimulateWaves(Time.realtimeSinceStartup); CreateFresnelLookUp(); if (m_resolution * m_resolution >= 65000 || m_useMaxResolution) { m_resolution = (int)Mathf.Sqrt(65000); if (!m_useMaxResolution) { Debug.Log("Ocean::Start - Grid resolution set to high. Setting resolution to the maxium allowed(" + m_resolution.ToString() + ")"); } } if (m_bias < 1.0f) { m_bias = 1.0f; Debug.Log("Ocean::Start - bias must not be less than 1, changing to 1"); } Mesh mesh = CreateRadialGrid(m_resolution, m_resolution); float far = Camera.main.farClipPlane; m_grid = new GameObject("Ocean Grid"); m_grid.AddComponent <MeshFilter>(); m_grid.AddComponent <MeshRenderer>(); m_grid.renderer.material = m_oceanMat; m_grid.GetComponent <MeshFilter>().mesh = mesh; m_grid.transform.localScale = new Vector3(far, 1, far); //Make radial grid have a radius equal to far plane m_gridWireframe = new GameObject("Ocean Grid Wireframe"); m_gridWireframe.AddComponent <MeshFilter>(); m_gridWireframe.AddComponent <MeshRenderer>(); m_gridWireframe.renderer.material = m_wireframeMat; m_gridWireframe.GetComponent <MeshFilter>().mesh = mesh; m_gridWireframe.transform.localScale = new Vector3(far, 1, far); m_gridWireframe.layer = 8; m_oceanMat.SetTexture("_FresnelLookUp", m_fresnelLookUp); m_oceanMat.SetVector("_GridSizes", m_waves.GetGridSizes()); m_oceanMat.SetFloat("_MaxLod", m_waves.GetMipMapLevels()); m_wireframeMat.SetVector("_GridSizes", m_waves.GetGridSizes()); m_wireframeMat.SetFloat("_MaxLod", m_waves.GetMipMapLevels()); }
void Start() { m_lastStaged = m_staged; m_waves = new WaveSpectrumCPU(m_fourierGridSize, m_windSpeed, m_waveAmp, m_inverseWaveAge, m_ansio, m_gridSizes); m_waves.SimulateWaves(Time.realtimeSinceStartup); CreateFresnelLookUp(); if(m_resolution*m_resolution >= 65000 || m_useMaxResolution) { m_resolution = (int)Mathf.Sqrt(65000); if(!m_useMaxResolution) Debug.Log("Ocean::Start - Grid resolution set to high. Setting resolution to the maxium allowed(" + m_resolution.ToString() + ")" ); } if(m_bias < 1.0f) { m_bias = 1.0f; Debug.Log("Ocean::Start - bias must not be less than 1, changing to 1"); } Mesh mesh = CreateRadialGrid(m_resolution, m_resolution); float far = Camera.main.farClipPlane; m_grid = new GameObject("Ocean Grid"); m_grid.AddComponent<MeshFilter>(); m_grid.AddComponent<MeshRenderer>(); m_grid.renderer.material = m_oceanMat; m_grid.GetComponent<MeshFilter>().mesh = mesh; m_grid.transform.localScale = new Vector3(far,1,far); //Make radial grid have a radius equal to far plane m_gridWireframe = new GameObject("Ocean Grid Wireframe"); m_gridWireframe.AddComponent<MeshFilter>(); m_gridWireframe.AddComponent<MeshRenderer>(); m_gridWireframe.renderer.material = m_wireframeMat; m_gridWireframe.GetComponent<MeshFilter>().mesh = mesh; m_gridWireframe.transform.localScale = new Vector3(far,1,far); m_gridWireframe.layer = 8; m_oceanMat.SetTexture("_FresnelLookUp", m_fresnelLookUp); m_oceanMat.SetVector("_GridSizes", m_waves.GetGridSizes()); m_oceanMat.SetFloat("_MaxLod", m_waves.GetMipMapLevels()); m_wireframeMat.SetVector("_GridSizes", m_waves.GetGridSizes()); m_wireframeMat.SetFloat("_MaxLod", m_waves.GetMipMapLevels()); }