コード例 #1
0
		private float sample( Vector3 pos, PlanetNoise noiseParams, PlanetNoisePerlin perlinNoise )
		{
			float result	= 0f;
			float offset	= 0f;

			if( noiseParams.smearOctaves > 0 )
			{
				offset = perlinNoise.getOctave( pos / noiseParams.smearScale, noiseParams.smearOctaves );
				offset = Mathf.Pow( offset, noiseParams.smearFalloff );
				offset *= noiseParams.smearIntensity;
			}

			result = perlinNoise.getNormalisedOctave( ( pos / noiseParams.scale ) + ( Vector3.one * offset ), noiseParams.octaves );

			if( noiseParams.ridginess > 0f )
			{
				float ridge	= perlinNoise.getNormalisedOctave( ( pos / noiseParams.scale ) + new Vector3( offset, offset, offset + 11f ), noiseParams.octaves );
				result		= ( noiseParams.ridginess * ( 1f - ( Mathf.Abs( ridge - 0.5f ) * 2f ) ) ) + ( ( 1f - noiseParams.ridginess ) * result );
			}

			result = Mathf.Pow( result, noiseParams.falloff );
			result = Mathf.Clamp01( result * noiseParams.intensity );

			return result;
		}
コード例 #2
0
		public void createNoise( int seedSurface, int seedLand, int seedLandColour01, int seedLandColour23, int seedCity, int seedCloud )
		{
			perlinNoiseSurface		= new PlanetNoisePerlin( seedSurface );
			perlinNoiseLand			= new PlanetNoisePerlin( seedLand );
			perlinNoiseLandColour01	= new PlanetNoisePerlin( seedLandColour01 );
			perlinNoiseLandColour23	= new PlanetNoisePerlin( seedLandColour23 );

			_cityRnd				= new System.Random( seedCity );

			perlinNoiseCloud		= new PlanetNoisePerlin( seedCloud );
			
			worleyNoiseCloud		= new PlanetNoiseWorley( seedCloud );

			isDoingCityWork			= false;

#if USE_GPU
			if( noiseComputeShader == null )
			{
				useComputerShader = false;

				if( SystemInfo.supportsComputeShaders )
				{
					useComputerShader	= true;

					noiseComputeShader	= ( ComputeShader ) AssetDatabase.LoadAssetAtPath( computeShaderPath, typeof( ComputeShader ) );

					if( noiseComputeShader )
					{
						_diffuseKernel	= noiseComputeShader.FindKernel( "diffuseNoiseKernel" );
						_cloudKernel	= noiseComputeShader.FindKernel( "cloudNoiseKernel" );
					}
					else
					{
						Debug.LogError( "couldn't load " + computeShaderPath );
						useComputerShader = false;
					}
				}
			}
#endif
		}
コード例 #3
0
		public void createNoise( int seedSurface, int seedLand, int seedLandColour01, int seedLandColour23, int seedCity, int seedCloud )
		{
			perlinNoiseSurface		= new PlanetNoisePerlin( seedSurface );
			perlinNoiseLand			= new PlanetNoisePerlin( seedLand );
			perlinNoiseLandColour01	= new PlanetNoisePerlin( seedLandColour01 );
			perlinNoiseLandColour23	= new PlanetNoisePerlin( seedLandColour23 );

			_cityRnd				= new System.Random( seedCity );

			perlinNoiseCloud		= new PlanetNoisePerlin( seedCloud );
			
			worleyNoiseCloud		= new PlanetNoiseWorley( seedCloud );

			isDoingCityWork			= false;

#if USE_GPU
			if( noiseComputeShader == null )
			{
				useComputerShader = false;

				if( SystemInfo.supportsComputeShaders )
				{
					useComputerShader	= true;

					noiseComputeShader	= ( ComputeShader ) AssetDatabase.LoadAssetAtPath( computeShaderPath, typeof( ComputeShader ) );

					if( noiseComputeShader )
					{
						_diffuseKernel	= noiseComputeShader.FindKernel( "diffuseNoiseKernel" );
						_cloudKernel	= noiseComputeShader.FindKernel( "cloudNoiseKernel" );
					}
					else
					{
						//Debug.LogError( "couldn't load " + computeShaderPath );
						useComputerShader = false;
					}
				}
			}
#endif
		}
コード例 #4
0
		private float sample( Vector3 pos, PlanetNoise noiseParams, PlanetNoisePerlin perlinNoise )
		{
			float result	= 0f;
			float offset	= 0f;

			if( noiseParams.smearOctaves > 0 )
			{
				offset = perlinNoise.getOctave( pos / noiseParams.smearScale, noiseParams.smearOctaves );
				offset = Mathf.Pow( offset, noiseParams.smearFalloff );
				offset *= noiseParams.smearIntensity;
			}

			result = perlinNoise.getNormalisedOctave( ( pos / noiseParams.scale ) + ( Vector3.one * offset ), noiseParams.octaves );

			if( noiseParams.ridginess > 0f )
			{
				float ridge	= perlinNoise.getNormalisedOctave( ( pos / noiseParams.scale ) + new Vector3( offset, offset, offset + 11f ), noiseParams.octaves );
				result		= ( noiseParams.ridginess * ( 1f - ( Mathf.Abs( ridge - 0.5f ) * 2f ) ) ) + ( ( 1f - noiseParams.ridginess ) * result );
			}

			result = Mathf.Pow( result, noiseParams.falloff );
			result = Mathf.Clamp01( result * noiseParams.intensity );

			return result;
		}
コード例 #5
0
		private Color getSurfaceColour( Vector3 pos, PlanetNoise noiseParams, Color colour0, Color colour1, PlanetNoisePerlin perlinNoise )
		{
			float c			= sample( pos, noiseParams, perlinNoise );
			Color result	= Color.Lerp( colour0, colour1, 1f - c );
			return result;
		}
コード例 #6
0
		private float getSurfaceHeight( Vector3 pos, PlanetNoise noiseParams, PlanetNoisePerlin perlinNoise )
		{
			float result = sample( pos, noiseParams, perlinNoise );
			return result;
		}
コード例 #7
0
		private Color getSurfaceColour( Vector3 pos, PlanetNoise noiseParams, Color colour0, Color colour1, PlanetNoisePerlin perlinNoise )
		{
			float c			= sample( pos, noiseParams, perlinNoise );
			Color result	= Color.Lerp( colour0, colour1, 1f - c );
			return result;
		}
コード例 #8
0
		private float getSurfaceHeight( Vector3 pos, PlanetNoise noiseParams, PlanetNoisePerlin perlinNoise )
		{
			float result = sample( pos, noiseParams, perlinNoise );
			return result;
		}