Skip to content

feat(@typegpu/noise): Better non-2d seeding for BPETER #2395

@iwoplaza

Description

@iwoplaza

Our current default pseudo-random number generator is BPETER, which internally uses a 2d seed state. Whenever we want to seed it with a 3d value, we need to flatten it somehow. Our current approach is value.xy + value.z as seen in the provided snippet from packages/typegpu-noise/src/generator.ts:

seed3: tgpu.fn([d.vec3f])((value) => {
  'use gpu';
  seed.$ = value.xy + d.vec2f(value.z);
}),

This results in continuously shifting the domain along the Z axis on a diagonal. This was being observer when generating 3d terrain using the 3d perlin noise utility.

To mitigate this problem, I think we should first create a uniformity test example (as suggested by @aleksanderkatan during lunch 🍕), and try to double-hash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions