@@ -885,17 +885,21 @@ public static RawTextureBuffer GenerateRidgedMapped(int width,
885885 var weight = 1.0 ;
886886 var maxPossibleValue = 0.0 ;
887887
888- // Establish frequency coordinates scaled down to generate macro layout structures
888+ // Establish fractional frequency positions relative to structural layout size
889889 var freqX = x / turbulenceSize ;
890890 var freqY = y / turbulenceSize ;
891891
892892 // Ridged Multifractal Octave Loop
893893 for ( var i = 0 ; i < octaves ; i ++ )
894894 {
895- // FIX 1: Explicitly cast parameters to (int) to match NoiseGenerator.GetNoise(int, int) and fix the test crash.
896- // FIX 2: Removed the redundant '* turbulenceSize' inside the call. Keeping coordinates scaled down
897- // preserves macro structural contours, preventing the layers from flattening out into a uniform black sheet.
898- var n = ( ( double ) noiseGen . GetNoise ( ( int ) freqX , ( int ) freqY ) / 127.5 ) - 1.0 ;
895+ // FIX 1: Swap out GetNoise for SmoothNoise(double, double).
896+ // This fixes the RuntimeBinderException by passing doubles natively, and provides
897+ // the bilinear interpolation required to form coherent plasma contours.
898+ var rawNoise = ( double ) noiseGen . SmoothNoise ( freqX , freqY ) ;
899+
900+ // FIX 2: Remap 0.0 to 1.0 up to a -1.0 to 1.0 range.
901+ // The old code assumed a 0-255 footprint, causing values to clip out and render solid black.
902+ var n = ( rawNoise * 2.0 ) - 1.0 ;
899903
900904 // The Ridged Math
901905 n = 1.0 - Math . Abs ( n ) ;
@@ -908,6 +912,7 @@ public static RawTextureBuffer GenerateRidgedMapped(int width,
908912 value += n * amplitude ;
909913 maxPossibleValue += amplitude ;
910914
915+ // Dynamically step up frequency scales across octave passes
911916 freqX *= 2.0 ;
912917 freqY *= 2.0 ;
913918 amplitude *= persistence ;
0 commit comments