NAME
ttypt/chaff_glsl.h - Canonical GLSL ES 3.0 / WebGL 2 shader source contract, UBO packing helpers, and bit-exact CPU reference evaluators for libchaff.
SYNOPSIS
#include <stdint.h>
#include <math.h>
#include <ttypt/chaff_surf.h>
Data Structures
4-component float vector returned by CPU reference 3D/4D gradient noise evaluators.
5-component float vector (value + 4D gradient) returned by 4D reference evaluators.
std140-aligned GPU Uniform Buffer Object representation of chaff_surf_t.
Macros
GLSL ES 3.0 header directive with highp float/int precision.
Normalization factor for 2D GLSL gradient noise.
Normalization factor for 4D GLSL gradient noise.
Default per-octave ridge step increment for GLSL multi-warp evaluation.
GLSL ES 3.0 multi-layer warped noise evaluation shader snippet.
Complete fullscreen GLSL ES 3.0 fragment shader source for noise evaluation.
Default initializer macro for chaff_multi_warp_params_t.
GLSL ES 3.0 continuous multi-scale surface evaluator matching chaff_surf.h.
Functions
Return the complete GLSL ES 3.0 fullscreen fragment shader source string.
CPU reference implementation of GLSL chaff_hash2().
CPU reference implementation of single-octave 2D GLSL noise sampling.
CPU reference implementation of GLSL chaff_hash3().
CPU reference implementation of extended 3D GLSL noise sampling.
CPU reference implementation of 3D GLSL noise sampling.
CPU reference implementation of extended 3D value-noise with analytical gradient.
CPU reference implementation of 3D value-noise with analytical gradient.
CPU reference implementation of GLSL chaff_hash4().
CPU reference implementation of extended 4D GLSL noise sampling.
CPU reference implementation of 4D GLSL noise sampling.
CPU reference implementation of extended 4D value-noise with analytical gradient.
CPU reference implementation of 4D value-noise with analytical gradient.
CPU reference implementation of extended 2D gradient noise with custom norm.
CPU reference implementation of 2D GLSL gradient noise.
CPU reference implementation of 2D value-gradient noise.
CPU reference implementation of GLSL Nyquist low-pass weight.
CPU reference implementation of GLSL Nyquist band-pass weight.
CPU reference 4D gradient vector lookup.
CPU reference implementation of extended 4D gradient noise with custom norm.
CPU reference implementation of 4D GLSL gradient noise.
CPU reference evaluator matching the GLSL uniform-driven noise cascade.
CPU reference implementation matching GLSL smoothstep(e0, e1, x).
CPU reference implementation of 2D GLSL curl noise.
CPU reference implementation of extended multi-layer warped GLSL noise.
Pack a host chaff_surf_t descriptor into a std140-aligned chaff_surf_ubo_t.
Detailed Description
Canonical GLSL ES 3.0 / WebGL 2 shader source contract, UBO packing helpers, and bit-exact CPU reference evaluators for libchaff.
ttypt/chaff_glsl.h โ Canonical GPU Shader Contract for libchaff.
Exposes GLSL ES 3.0 / WebGL 2 shader source strings and uniform layouts for hardware-accelerated procedural noise on clients.
INVARIANT: Bit-exact corner hashing matching XXH32(p, 4, seed) on CPU. Zero OpenGL/EGL runtime library links or compile-time dependencies on server.
Macro Definition Documentation
#define CHAFF_GLSL_BAND_FN
Value:
"float chaff_lowpass_weight(float wavelength, float step_wu) {\n" \
" if (step_wu <= 0.0) return 1.0;\n" \
" float t = clamp((wavelength - 2.0 * step_wu) / (2.0 * step_wu), 0.0, 1.0);\n" \
" return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n" \
"}\n" \
"float chaff_band_weight(float wavelength, float fine_step_wu, float coarse_step_wu) {\n" \
" float w_fine = chaff_lowpass_weight(wavelength, fine_step_wu);\n" \
" if (w_fine <= 0.0) return 0.0;\n" \
" float w_coarse = chaff_lowpass_weight(wavelength, coarse_step_wu);\n" \
" return w_fine * (1.0 - w_coarse);\n" \
"}\n"
Continuous scale-space C2 Nyquist low-pass and complementary band-pass weights
#define CHAFF_GLSL_EVAL_FN
Continuous cubic Hermite interpolation matching noise_wcorners and noise_wstep. Evaluates corner vertices at cell = floor(world_pos / 2^shift) * 2^shift.
#define CHAFF_GLSL_GRAD_NOISE_FN
Continuous C2-quintic 2D and 4D gradient noise with analytical spatial derivatives. Loop-free explicit corner evaluations for consumer GPU shader compiler friendliness.
#define CHAFF_GLSL_HASH_FN
Bit-exact XXH32 hash for 2D, 3D, and 4D lattice coordinates in GLSL ES 3.0. Memory layout matches int16_t va[2] = { y, x }, va[3] = { y, x, z }, and va[4] = { y, x, z, w } in little-endian.
Function Documentation
void chaff_glsl_ref_grad_dir (int32_t cx, int32_t cy, uint32_t seed, float * out_gx, float * out_gy) [inline], [static]
Reference C mirrors for CHAFF_GLSL_GRAD_NOISE_FN
uint32_t chaff_glsl_ref_rotl32 (uint32_t x, int r) [inline], [static]
Reference C implementation of the exact GLSL shader logic for CPU-GPU parity verification
Author
Generated automatically by Doxygen for chaff from the source code.