public void Tsunami() { RTUtility.SetToPoint(m_waterField); float line = 0f; m_tsunamiMat.SetFloat("_Z", line); m_tsunamiMat.SetFloat("_Amount", m_tsunamiAmount); Graphics.Blit(m_waterField[READ], m_waterField[WRITE], m_tsunamiMat); RTUtility.SetToBilinear(m_waterField); RTUtility.Swap(m_waterField); }
public void addLava(float x, float y) { RTUtility.SetToPoint(m_lavaField); Vector2 m_lavaOutputPoint = new Vector2(x, y); m_lavaInputMat.SetVector("_Point", m_lavaOutputPoint); m_lavaInputMat.SetFloat("_Radius", m_terrainOutputRadius); m_lavaInputMat.SetFloat("_Amount", m_terrainOutputAmount); Graphics.Blit(m_lavaField[READ], m_lavaField[WRITE], m_lavaInputMat); RTUtility.SetToBilinear(m_lavaField); RTUtility.Swap(m_lavaField); }
public void grabWater(float x, float y) { RTUtility.SetToPoint(m_waterField); float amnt = -m_terrainOutputAmount; Vector2 m_waterOutputPoint = new Vector2(x, y); m_waterInputMat.SetVector("_Point", m_waterOutputPoint); m_waterInputMat.SetFloat("_Radius", m_terrainOutputRadius); m_waterInputMat.SetFloat("_Amount", amnt); Graphics.Blit(m_waterField[READ], m_waterField[WRITE], m_waterInputMat); RTUtility.SetToBilinear(m_waterField); RTUtility.Swap(m_waterField); }
public void grabElement(float x, float y, int layer) { RTUtility.SetToPoint(m_terrainField); Vector2 m_terrainOutputPoint = new Vector2(x, y); m_terrainOutputMat.SetVector("_Point", m_terrainOutputPoint); m_terrainOutputMat.SetFloat("_Radius", m_terrainOutputRadius); m_terrainOutputMat.SetFloat("_Amount", m_terrainOutputAmount); m_terrainOutputMat.SetFloat("_Layer", layer); Graphics.Blit(m_terrainField[READ], m_terrainField[WRITE], m_terrainOutputMat); RTUtility.SetToBilinear(m_terrainField); RTUtility.Swap(m_terrainField); }
void Update() { //You cant call the graphics blit function on the first frame in Unity for a dx9 build //Wait to second frame then init maps. You only need to do this if you want to make a dx9 build if (m_frameCount == 1) { InitMaps(); //initMeshCollider(); } /*if( m_frameCount>1800 && count >0 && m_frameCount%100 == 0){ * Tsunami(); * count--; * }*/ m_frameCount++; RTUtility.SetToPoint(m_terrainField); RTUtility.SetToPoint(m_waterField); RTUtility.SetToPoint(m_lavaField); WaterInput(); LavaInput(); ApplyFreeSlip(m_terrainField); ApplyFreeSlip(m_sedimentField); ApplyFreeSlip(m_waterField); ApplyFreeSlip(m_regolithField); ApplyFreeSlip(m_lavaField); OutFlow(m_waterField, m_waterOutFlow, m_waterDamping); OutFlow(m_lavaField, m_lavaOutFlow, m_lavaDamping); WaterVelocity(); LavaVelocity(); ErosionAndDeposition(); ApplyFreeSlip(m_terrainField); ApplyFreeSlip(m_sedimentField); //AdvectSediment(); //DisintegrateAndDeposit(); ApplyFreeSlip(m_terrainField); ApplyFreeSlip(m_regolithField); OutFlow(m_regolithField, m_regolithOutFlow, m_regolithDamping); ApplySlippage(); RTUtility.SetToBilinear(m_terrainField); RTUtility.SetToBilinear(m_waterField); RTUtility.SetToBilinear(m_lavaField); //if the size of the mesh does not match the size of the teture //the y axis needs to be scaled float scaleY = (float)TOTAL_GRID_SIZE / (float)TEX_SIZE; m_landMat.SetFloat("_ScaleY", scaleY); m_landMat.SetFloat("_TexSize", (float)TEX_SIZE); m_landMat.SetTexture("_MainTex", m_terrainField[READ]); m_landMat.SetFloat("_Layers", (float)TERRAIN_LAYERS); /*m_terrainLandMat.SetFloat("_ScaleY", scaleY); * m_terrainLandMat.SetFloat("_TexSize", (float)TEX_SIZE); * m_terrainLandMat.SetTexture("_LandTex", m_terrainField[READ]); * m_terrainLandMat.SetFloat("_Layers", (float)TERRAIN_LAYERS);*/ m_waterMat.SetTexture("_SedimentField", m_sedimentField[READ]); m_waterMat.SetTexture("_VelocityField", m_waterVelocity[READ]); m_waterMat.SetFloat("_ScaleY", scaleY); m_waterMat.SetFloat("_TexSize", (float)TEX_SIZE); m_waterMat.SetTexture("_WaterField", m_waterField[READ]); m_waterMat.SetTexture("_MainTex", m_terrainField[READ]); m_waterMat.SetFloat("_Layers", (float)TERRAIN_LAYERS); m_waterMat.SetVector("_SunDir", m_sun.transform.forward * -1.0f); m_lavaMat.SetTexture("_VelocityField", m_lavaVelocity[READ]); m_lavaMat.SetFloat("_ScaleY", scaleY); m_lavaMat.SetFloat("_TexSize", (float)TEX_SIZE); m_lavaMat.SetTexture("_LavaField", m_lavaField[READ]); m_lavaMat.SetTexture("_MainTex", m_terrainField[READ]); m_lavaMat.SetFloat("_Layers", (float)TERRAIN_LAYERS); m_wireframeMat.SetFloat("_ScaleY", scaleY); m_wireframeMat.SetFloat("_TexSize", (float)TEX_SIZE); m_wireframeMat.SetTexture("_MainTex", m_terrainField[READ]); m_wireframeMat.SetFloat("_Layers", (float)TERRAIN_LAYERS); //updateTerrainHeight(); }