public Layer(string name, int size, float damping, ErosionSim link, float overwriteFluidity, float fluidity) { main = new DoubleDataTexture(name, size, RenderTextureFormat.ARGBFloat, FilterMode.Point); // was RFloat main.ClearColor(); outFlow = new DoubleDataTexture(name, size, RenderTextureFormat.ARGBFloat, FilterMode.Point); //was ARGBHalf outFlow.ClearColor(); this.damping = damping; this.link = link; this.size = size; this.overwriteFluidity = overwriteFluidity; this.fluidity = fluidity; }
public LayerWithErosion(string name, int size, float viscosity, ErosionSim link) : base(name, size, viscosity, link) { //waterField = new DoubleDataTexture("Water Field", TEX_SIZE, RenderTextureFormat.RFloat, FilterMode.Point); //waterOutFlow = new DoubleDataTexture("Water outflow", TEX_SIZE, RenderTextureFormat.ARGBHalf, FilterMode.Point); sedimentField = new DoubleDataTexture("Sediment Field", size, RenderTextureFormat.ARGBFloat, FilterMode.Bilinear); // was RHalf sedimentField.ClearColor(); advectSediment = new DoubleDataTexture("Sediment Advection", size, RenderTextureFormat.RHalf, FilterMode.Bilinear); // was RHalf advectSediment.ClearColor(); sedimentDeposition = new DoubleDataTexture("Sediment Deposition", size, RenderTextureFormat.ARGBFloat, FilterMode.Point); // was RHalf sedimentDeposition.ClearColor(); tiltAngle = DoubleDataTexture.Create("Tilt Angle", size, RenderTextureFormat.RHalf, FilterMode.Point);// was RHalf //sedimentOutFlow = DoubleDataTexture.Create("sedimentOutFlow", size, RenderTextureFormat.ARGBHalf, FilterMode.Point);// was ARGBHalf //sedimentOutFlow.ClearColor(); }
private void InitMaps() { terrainField.ClearColor(); //waterOutFlow.ClearColor(); //waterVelocity.ClearColor(); //advectSediment.ClearColor(); //waterField.ClearColor(); //sedimentField.ClearColor(); regolithField.ClearColor(); regolithOutFlow.ClearColor(); //sedimentDeposition.ClearColor(); magmaVelocity.ClearColor(); DoubleDataTexture noiseTex; noiseTex = new DoubleDataTexture("", TEX_SIZE, RenderTextureFormat.RFloat, FilterMode.Bilinear); GPUPerlinNoise perlin = new GPUPerlinNoise(m_seed); perlin.LoadResourcesFor2DNoise(); m_noiseMat.SetTexture("_PermTable1D", perlin.PermutationTable1D); m_noiseMat.SetTexture("_Gradient2D", perlin.Gradient2D); for (int j = 0; j < TERRAIN_LAYERS; j++) { m_noiseMat.SetFloat("_Offset", m_offset[j]); float amp = 0.5f; float freq = m_frequency[j]; //Must clear noise from last pass noiseTex.ClearColor(); //write noise into texture with the settings for this layer for (int i = 0; i < m_octaves[j]; i++) { m_noiseMat.SetFloat("_Frequency", freq); m_noiseMat.SetFloat("_Amp", amp); m_noiseMat.SetFloat("_Pass", (float)i); Graphics.Blit(noiseTex.READ, noiseTex.WRITE, m_noiseMat, (int)m_layerStyle[j]); noiseTex.Swap(); freq *= m_lacunarity[j]; amp *= m_gain[j]; } float useAbs = 0.0f; if (m_finalNosieIsAbs[j]) { useAbs = 1.0f; } //Mask the layers that we dont want to write into Vector4 mask = new Vector4(0.0f, 0.0f, 0.0f, 0.0f); mask[j] = 1.0f; m_initTerrainMat.SetFloat("_Amp", m_amp[j]); m_initTerrainMat.SetFloat("_UseAbs", useAbs); m_initTerrainMat.SetVector("_Mask", mask); m_initTerrainMat.SetTexture("_NoiseTex", noiseTex.READ); m_initTerrainMat.SetFloat("_Height", TERRAIN_HEIGHT); //Apply the noise for this layer to the terrain field Graphics.Blit(terrainField.READ, terrainField.WRITE, m_initTerrainMat); terrainField.Swap(); } //dont need this tex anymore noiseTex.Destroy(); }
public LayerWithVelocity(string name, int size, float viscosity, ErosionSim link) : base(name, size, viscosity, link, 0.96f, 4181f, 1f, 1f) { velocity = new DoubleDataTexture("Water Velocity", size, RenderTextureFormat.ARGBFloat, FilterMode.Bilinear);// was RGHalf velocity.ClearColor(); }