Posts

Post not yet marked as solved
5 Replies
Thanks for looking into this! Here's a demo method that demonstartes the issue:- (void) testNoiseMap{ GKNoiseSource *theSource; float freq = 1; NSInteger octaves = 3; float pers = 0.75; float lacu = 4.2; int32_t seed = 0; theSource = [GKPerlinNoiseSource perlinNoiseSourceWithFrequency:freq octaveCount:octaves persistence:pers lacunarity:lacu seed:seed]; NSDictionary *theGrads; theGrads = @{ @-1 : [[self color0] color], // black @1 : [[self color1] color], // white }; GKNoise *theNoise = [GKNoise noiseWithNoiseSource:theSource gradientColors:theGrads]; vector_double2 vSize; vSize.x = 256; vSize.y = 256; vector_double2 vSizeFixed = {1.0, 1.0}; vector_int2 sampleSize = {vSize.x, vSize.y}; vector_double2 orig = {0, 0}; GKNoiseMap *theMap = [GKNoiseMap noiseMapWithNoise:theNoise size:vSizeFixed origin:orig sampleCount:sampleSize seamless:NO]; // this works: returns perlin values -1..+1 int x = 0; while (x < 20) { vector_int2 pos = {x, 0}; NSLog(@"sample val is %f", [theMap valueAtPosition:pos]); x++; } // does NOT work // always returns -1 x = 0; while (x < 20) { vector_float2 fpos = {x / 256.0, 0}; NSLog(@"sample val is %f", [theMap interpolatedValueAtPosition:fpos]); x++; } }When you run it, you'll see that the valueAtPosition works flawlessly, but sampling via interpolated always returns -1020-04-06 19:54:15.658556+0200 noiseexplorer[1994:711977] sample val is 0.0000002020-04-06 19:54:19.946082+0200 noiseexplorer[1994:711977] sample val is -0.0317272020-04-06 19:54:21.450169+0200 noiseexplorer[1994:711977] sample val is -0.0595782020-04-06 19:54:22.360135+0200 noiseexplorer[1994:711977] sample val is -0.083551etc.2020-04-06 19:54:46.453443+0200 noiseexplorer[1994:711977] sample val is -1.0000002020-04-06 19:54:47.783488+0200 noiseexplorer[1994:711977] sample val is -1.0000002020-04-06 19:54:48.541423+0200 noiseexplorer[1994:711977] sample val is -1.0000002020-04-06 19:54:49.337322+0200 noiseexplorer[1994:711977] sample val is -1.000000Thanks for any hints on what I'm doing wrong.-ch