.TH "ttypt/chaff_glsl.h" 3 "chaff" \" -*- nroff -*- .ad l .nh .SH 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\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br \fR#include \fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBchaff_gl_uniforms_t\fP" .br .ti -1c .RI "struct \fBchaff_glsl_ref_vec4_t\fP" .br .RI "4-component float vector returned by CPU reference 3D/4D gradient noise evaluators\&. " .ti -1c .RI "struct \fBchaff_glsl_ref_vec5_t\fP" .br .RI "5-component float vector (value + 4D gradient) returned by 4D reference evaluators\&. " .ti -1c .RI "struct \fBchaff_surf_ubo_t\fP" .br .RI "std140-aligned GPU Uniform Buffer Object representation of \fBchaff_surf_t\fP\&. " .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBCHAFF_GLSL_VERSION\fP" .br .RI "GLSL ES 3\&.0 header directive with highp float/int precision\&. " .ti -1c .RI "#define \fBCHAFF_GLSL_HASH_FN\fP" .br .ti -1c .RI "#define \fBCHAFF_GLSL_GRAD2D_NORM\fP 0\&.70710678f" .br .RI "Normalization factor for 2D GLSL gradient noise\&. " .ti -1c .RI "#define \fBCHAFF_GLSL_GRAD4D_NORM\fP 0\&.72f" .br .RI "Normalization factor for 4D GLSL gradient noise\&. " .ti -1c .RI "#define \fBCHAFF_GLSL_DEFAULT_RIDGE_OCTAVE_STEP\fP 0\&.25f" .br .RI "Default per-octave ridge step increment for GLSL multi-warp evaluation\&. " .ti -1c .RI "#define \fBCHAFF_GLSL_GRAD_NOISE_FN\fP" .br .ti -1c .RI "#define \fBCHAFF_GLSL_BAND_FN\fP" .br .ti -1c .RI "#define \fBCHAFF_GLSL_EVAL_FN\fP" .br .ti -1c .RI "#define \fBCHAFF_GLSL_EVAL_MULTI_FN\fP" .br .RI "GLSL ES 3\&.0 multi-layer warped noise evaluation shader snippet\&. " .ti -1c .RI "#define \fBCHAFF_GLSL_FULLSCREEN_FRAG\fP" .br .RI "Complete fullscreen GLSL ES 3\&.0 fragment shader source for noise evaluation\&. " .ti -1c .RI "#define \fBCHAFF_MULTI_WARP_PARAMS_DEFAULT\fP" .br .RI "Default initializer macro for chaff_multi_warp_params_t\&. " .ti -1c .RI "#define \fBCHAFF_GLSL_SURF_FN\fP" .br .RI "GLSL ES 3\&.0 continuous multi-scale surface evaluator matching \fBchaff_surf\&.h\fP\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "static const char * \fBchaff_glsl_fragment_shader_source\fP (void)" .br .RI "Return the complete GLSL ES 3\&.0 fullscreen fragment shader source string\&. " .ti -1c .RI "static uint32_t \fBchaff_glsl_ref_rotl32\fP (uint32_t x, int r)" .br .ti -1c .RI "static uint32_t \fBchaff_glsl_ref_hash2\fP (int16_t y, int16_t x, uint32_t seed)" .br .RI "CPU reference implementation of GLSL chaff_hash2()\&. " .ti -1c .RI "static float \fBchaff_glsl_ref_sample_octave\fP (float wx, float wy, unsigned shift, unsigned vshift, uint32_t seed)" .br .RI "CPU reference implementation of single-octave 2D GLSL noise sampling\&. " .ti -1c .RI "static uint32_t \fBchaff_glsl_ref_hash3\fP (int16_t x, int16_t y, int16_t z, uint32_t seed)" .br .RI "CPU reference implementation of GLSL chaff_hash3()\&. " .ti -1c .RI "static float \fBchaff_glsl_ref_sample_3d_ex\fP (float wx, float wy, float wz, unsigned shift, unsigned vshift, uint32_t seed)" .br .RI "CPU reference implementation of extended 3D GLSL noise sampling\&. " .ti -1c .RI "static float \fBchaff_glsl_ref_sample_3d\fP (float wx, float wy, float wz, unsigned shift, uint32_t seed)" .br .RI "CPU reference implementation of 3D GLSL noise sampling\&. " .ti -1c .RI "static \fBchaff_glsl_ref_vec4_t\fP \fBchaff_glsl_ref_sample_grad_3d_ex\fP (float wx, float wy, float wz, unsigned shift, unsigned vshift, uint32_t seed)" .br .RI "CPU reference implementation of extended 3D value-noise with analytical gradient\&. " .ti -1c .RI "static \fBchaff_glsl_ref_vec4_t\fP \fBchaff_glsl_ref_sample_grad_3d\fP (float wx, float wy, float wz, unsigned shift, uint32_t seed)" .br .RI "CPU reference implementation of 3D value-noise with analytical gradient\&. " .ti -1c .RI "static uint32_t \fBchaff_glsl_ref_hash4\fP (int16_t x, int16_t y, int16_t z, int16_t w, uint32_t seed)" .br .RI "CPU reference implementation of GLSL chaff_hash4()\&. " .ti -1c .RI "static float \fBchaff_glsl_ref_sample_4d_ex\fP (float wx, float wy, float wz, float ww, unsigned shift, unsigned vshift, uint32_t seed)" .br .RI "CPU reference implementation of extended 4D GLSL noise sampling\&. " .ti -1c .RI "static float \fBchaff_glsl_ref_sample_4d\fP (float wx, float wy, float wz, float ww, unsigned shift, uint32_t seed)" .br .RI "CPU reference implementation of 4D GLSL noise sampling\&. " .ti -1c .RI "static \fBchaff_glsl_ref_vec5_t\fP \fBchaff_glsl_ref_sample_grad_4d_ex\fP (float wx, float wy, float wz, float ww, unsigned shift, unsigned vshift, uint32_t seed)" .br .RI "CPU reference implementation of extended 4D value-noise with analytical gradient\&. " .ti -1c .RI "static \fBchaff_glsl_ref_vec5_t\fP \fBchaff_glsl_ref_sample_grad_4d\fP (float wx, float wy, float wz, float ww, unsigned shift, uint32_t seed)" .br .RI "CPU reference implementation of 4D value-noise with analytical gradient\&. " .ti -1c .RI "static void \fBchaff_glsl_ref_grad_dir\fP (int32_t cx, int32_t cy, uint32_t seed, float *out_gx, float *out_gy)" .br .ti -1c .RI "static void \fBchaff_glsl_ref_grad_noise2d_ex\fP (float px, float py, uint32_t seed, float grad_norm, float *out_val, float *out_gx, float *out_gy)" .br .RI "CPU reference implementation of extended 2D gradient noise with custom norm\&. " .ti -1c .RI "static void \fBchaff_glsl_ref_grad_noise2d\fP (float px, float py, uint32_t seed, float *out_val, float *out_gx, float *out_gy)" .br .RI "CPU reference implementation of 2D GLSL gradient noise\&. " .ti -1c .RI "static void \fBchaff_glsl_ref_value_grad_noise2d\fP (float px, float py, uint32_t seed, float *out_val, float *out_gx, float *out_gy)" .br .RI "CPU reference implementation of 2D value-gradient noise\&. " .ti -1c .RI "static float \fBchaff_glsl_ref_lowpass_weight\fP (float wavelength, float step_wu)" .br .RI "CPU reference implementation of GLSL Nyquist low-pass weight\&. " .ti -1c .RI "static float \fBchaff_glsl_ref_band_weight\fP (float wavelength, float fine_step_wu, float coarse_step_wu)" .br .RI "CPU reference implementation of GLSL Nyquist band-pass weight\&. " .ti -1c .RI "static void \fBchaff_glsl_ref_grad4\fP (int32_t cx, int32_t cy, int32_t cz, int32_t cw, uint32_t seed, float out_g[4])" .br .RI "CPU reference 4D gradient vector lookup\&. " .ti -1c .RI "static \fBchaff_glsl_ref_vec4_t\fP \fBchaff_glsl_ref_grad_noise4d_ex\fP (float px, float py, float pz, float pw, uint32_t seed, float grad_norm)" .br .RI "CPU reference implementation of extended 4D gradient noise with custom norm\&. " .ti -1c .RI "static \fBchaff_glsl_ref_vec4_t\fP \fBchaff_glsl_ref_grad_noise4d\fP (float px, float py, float pz, float pw, uint32_t seed)" .br .RI "CPU reference implementation of 4D GLSL gradient noise\&. " .ti -1c .RI "static float \fBchaff_glsl_ref_eval_uniforms\fP (const \fBchaff_gl_uniforms_t\fP *u, float frag_x, float frag_y)" .br .RI "CPU reference evaluator matching the GLSL uniform-driven noise cascade\&. " .ti -1c .RI "static float \fBchaff_glsl_ref_smoothstep\fP (float e0, float e1, float x)" .br .RI "CPU reference implementation matching GLSL smoothstep(e0, e1, x)\&. " .ti -1c .RI "static void \fBchaff_glsl_ref_curl_2d\fP (float px, float py, uint32_t seed, float *out_vx, float *out_vy)" .br .RI "CPU reference implementation of 2D GLSL curl noise\&. " .ti -1c .RI "static void \fBchaff_glsl_ref_eval_multi_warped_ex\fP (const chaff_multi_warp_params_t *params, float wx, float wy, float base_shift, uint32_t seed, float texel_span, float *out_val, float *out_gx, float *out_gy)" .br .RI "CPU reference implementation of extended multi-layer warped GLSL noise\&. " .ti -1c .RI "static void \fBchaff_surf_pack_ubo\fP (const \fBchaff_surf_t\fP *c, \fBchaff_surf_ubo_t\fP *out)" .br .RI "Pack a host \fBchaff_surf_t\fP descriptor into a std140-aligned \fBchaff_surf_ubo_t\fP\&. " .in -1c .SH "Detailed Description" .PP Canonical GLSL ES 3\&.0 / WebGL 2 shader source contract, UBO packing helpers, and bit-exact CPU reference evaluators for libchaff\&. \fBttypt/chaff_glsl\&.h\fP — Canonical GPU Shader Contract for libchaff\&. .PP Exposes GLSL ES 3\&.0 / WebGL 2 shader source strings and uniform layouts for hardware-accelerated procedural noise on clients\&. .PP INVARIANT: Bit-exact corner hashing matching XXH32(p, 4, seed) on CPU\&. Zero OpenGL/EGL runtime library links or compile-time dependencies on server\&. .SH "Macro Definition Documentation" .PP .SS "#define CHAFF_GLSL_BAND_FN" \fBValue:\fP .nf "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" .PP .fi Continuous scale-space C2 Nyquist low-pass and complementary band-pass weights .SS "#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\&. .SS "#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\&. .SS "#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\&. .SH "Function Documentation" .PP .SS "void chaff_glsl_ref_grad_dir (int32_t cx, int32_t cy, uint32_t seed, float * out_gx, float * out_gy)\fR [inline]\fP, \fR [static]\fP" Reference C mirrors for CHAFF_GLSL_GRAD_NOISE_FN .SS "uint32_t chaff_glsl_ref_rotl32 (uint32_t x, int r)\fR [inline]\fP, \fR [static]\fP" Reference C implementation of the exact GLSL shader logic for CPU-GPU parity verification .SH "Author" .PP Generated automatically by Doxygen for chaff from the source code\&.