summaryrefslogtreecommitdiff
path: root/src/procedural/generator.h
blob: 96d76514b1c77a73aab9d537033ae1e25e640a9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// This file is part of the 64k demo project.
// It defines the interface for procedural texture generation.
// Used to generate texture data at runtime.

#pragma once

#include <cstdint>

// Procedural generation function signature
// buffer: Pointer to RGBA8 buffer (size w * h * 4)
// w, h: Dimensions
// params: Arbitrary float parameters for the generator
// Returns true on success, false on failure.
typedef bool (*ProcGenFunc)(uint8_t* buffer, int w, int h, const float* params,
                            int num_params);

namespace procedural {

// Simple noise generator
bool gen_noise(uint8_t* buffer, int w, int h, const float* params,
               int num_params);

// Perlin noise generator
// Params[0]: Seed
// Params[1]: Frequency (Scale)
// Params[2]: Amplitude
// Params[3]: Amplitude decay (e.g. 0.5)
// Params[4]: Number of octaves (int)
bool gen_perlin(uint8_t* buffer, int w, int h, const float* params,
                int num_params);

// Example: Grid pattern
bool gen_grid(uint8_t* buffer, int w, int h, const float* params,
              int num_params);

// Post-process: Make texture periodic by blending edges
// Params[0]: Border size ratio (0.0 - 0.5), default 0.1
bool make_periodic(uint8_t* buffer, int w, int h, const float* params,
                   int num_params);

#if !defined(DEMO_STRIP_ALL)
// Test-only: 256x256 noise generator
bool gen_noise_256(uint8_t* buffer, int w, int h, const float* params,
                   int num_params);

// Test-only: Failing generator
bool gen_fail(uint8_t* buffer, int w, int h, const float* params,
              int num_params);
#endif

} // namespace procedural