void Start() { m_waves = new WaveSpectrumCPU(m_fourierGridSize, m_windSpeed, m_waveAmp, m_inverseWaveAge, m_ansio, m_gridSizes); CreateFresnelLookUp(); if (m_resolution * m_resolution >= 65000) { m_resolution = (int)Mathf.Sqrt(65000); Debug.Log("Grid resolution set to high. Setting resolution to the maximum allowed(" + m_resolution.ToString() + ")"); } if (m_bias < 1.0f) { m_bias = 1.0f; Debug.Log("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.GetComponent <Renderer>().material = m_oceanMat; m_grid.GetComponent <MeshFilter>().mesh = mesh; //Make radial grid have a radius equal to far plane m_grid.transform.localScale = new Vector3(far, 1, far); m_oceanMat.SetTexture("_FresnelLookUp", m_fresnelLookUp); m_oceanMat.SetVector("_GridSizes", m_waves.gridSizes); m_oceanMat.SetFloat("_MaxLod", m_waves.mipMapLevels); m_oceanMat.SetTexture("_Map0", m_waves.map0); m_oceanMat.SetTexture("_Map1", m_waves.map1); m_oceanMat.SetTexture("_Map2", m_waves.map2); }
void Start() { m_waves = new WaveSpectrumCPU(m_fourierGridSize, m_windSpeed, m_waveAmp, m_inverseWaveAge, m_ansio, m_gridSizes); CreateFresnelLookUp(); if (m_resolution * m_resolution >= 65000) { m_resolution = (int)Mathf.Sqrt(65000); Debug.Log("Grid resolution set to high. Setting resolution to the maximum allowed(" + m_resolution.ToString() + ")"); } if (m_bias < 1.0f) { m_bias = 1.0f; Debug.Log("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.GetComponent<Renderer>().material = m_oceanMat; m_grid.GetComponent<MeshFilter>().mesh = mesh; //Make radial grid have a radius equal to far plane m_grid.transform.localScale = new Vector3(far, 1, far); m_oceanMat.SetTexture("_FresnelLookUp", m_fresnelLookUp); m_oceanMat.SetVector("_GridSizes", m_waves.gridSizes); m_oceanMat.SetFloat("_MaxLod", m_waves.mipMapLevels); m_oceanMat.SetTexture("_Map0", m_waves.map0); m_oceanMat.SetTexture("_Map1", m_waves.map1); m_oceanMat.SetTexture("_Map2", m_waves.map2); }