@@ -36,20 +36,32 @@ public sealed class NoiseGenerator
3636 /// </summary>
3737 /// <param name="width">The width of the noise map.</param>
3838 /// <param name="height">The height of the noise map.</param>
39- public NoiseGenerator ( int width , int height )
39+ public NoiseGenerator ( int width , int height ) : this ( width , height , null )
40+ {
41+ }
42+
43+ /// <summary>
44+ /// Initializes a new instance of the <see cref="NoiseGenerator" /> class with a deterministic seed.
45+ /// The same seed and size always produce the same noise map, which is what texture variants rely on.
46+ /// </summary>
47+ /// <param name="width">The width of the noise map.</param>
48+ /// <param name="height">The height of the noise map.</param>
49+ /// <param name="seed">Seed for the random source. <c>null</c> keeps the legacy non-deterministic behavior.</param>
50+ public NoiseGenerator ( int width , int height , int ? seed )
4051 {
4152 _width = width ;
4253 _height = height ;
43- _noise = GenerateNoise ( ) ;
54+ _noise = GenerateNoise ( seed ) ;
4455 }
4556
4657 /// <summary>
4758 /// Generates a 2D array filled with random noise values between 0 and 1.
4859 /// </summary>
4960 /// <returns>A 2D array representing the noise map.</returns>
50- private double [ , ] GenerateNoise ( )
61+ /// <param name="seed">Optional deterministic seed.</param>
62+ private double [ , ] GenerateNoise ( int ? seed )
5163 {
52- var rand = new Random ( ) ;
64+ var rand = seed . HasValue ? new Random ( seed . Value ) : new Random ( ) ;
5365 var noiseData = new double [ _height , _width ] ;
5466
5567 for ( var y = 0 ; y < _height ; y ++ )
0 commit comments