Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strided generators #151

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

nolankramer
Copy link

This PR adds strided generators, for generating noise corresponding to pre-made spatial points.

@nolankramer
Copy link
Author

nolankramer commented Mar 21, 2025

I modified FastNoiseCpp11Include test temporarily, and tested with a 4x4 position grid:

0,0: 0 vs 0
1,0: -0.209467 vs 0.125916
2,0: 0.424659 vs -0.209467
3,0: -0.15126 vs -0.220221
0,1: 0.125916 vs 0.424659
1,1: 0.327784 vs 0.000303611
2,1: 0.019688 vs -0.15126
3,1: -0.0671406 vs 0
0,2: -0.220221 vs -0.220221
1,2: 0.22565 vs 0.019688
2,2: 0.305475 vs 0.22565
3,2: 0.0472323 vs 0.305475
0,3: 0.000303611 vs 0.305475
1,3: 0.0469043 vs -0.091646
2,3: -0.091646 vs 0.0472323
3,3: 0.0466066 vs 0.424659

where the left column values are generated with GenUniformGrid2D and the right with GenStridedArray2D. They are indeed different at some indices, and I'm not sure why. Here are the calls:

FastNoise::Generator::Vector2 posArray[size * size];
    for( int y = 0; y < size; y++ )
    {
        for( int x = 0; x < size; x++ )
        {
            posArray[y * size + x].x = (float)x;
            posArray[y * size + x].y = (float)y;
        }
    } 

node->GenUniformGrid2D( noise, 0, 0, size, size, 1.0f, 1337 );
node->GenStridedArray2D( noise2, size * size, posArray, 1337 );

@nolankramer
Copy link
Author

Oh, I see the issue now. Load_f32 is assuming contiguous values, and we need to gather instead of load

@nolankramer
Copy link
Author

nolankramer commented Mar 22, 2025

I've updated the code to add a FS_Gather_f32, and it is now producing expected results:

256
0,0: 0 vs 0
1,0: -0.209467 vs -0.209467
2,0: 0.424659 vs 0.424659
3,0: -0.15126 vs -0.15126
0,1: 0.125916 vs 0.125916
1,1: 0.327784 vs 0.327784
2,1: 0.019688 vs 0.019688
3,1: -0.0671406 vs -0.0671406
0,2: -0.220221 vs -0.220221
1,2: 0.22565 vs 0.22565
2,2: 0.305475 vs 0.305475
3,2: 0.0472323 vs 0.0472323
0,3: 0.000303611 vs 0.000303611
1,3: 0.0469043 vs 0.0469043
2,3: -0.091646 vs -0.091646
3,3: 0.0466066 vs 0.0466066

I can only test on Win32 with AVX2, and this likely needs to be tested elsewhere

@Auburn
Copy link
Owner

Auburn commented Mar 26, 2025

Thanks, I don't think I will pull this into the current main branch. I'm working on the 1.0 release in the NewFastSIMD branch which hopefully can be released soon. So I will look to integrate it into there

@nolankramer
Copy link
Author

Thanks, I don't think I will pull this into the current main branch. I'm working on the 1.0 release in the NewFastSIMD branch which hopefully can be released soon. So I will look to integrate it into there

SGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants