Skip to content

Instantly share code, notes, and snippets.

@fp64
fp64 / anta.h
Created June 13, 2025 12:50
Processed data (scattering coefficient, phase function, etc.) for models from Optical Properties of Aerosols and Clouds (OPAC). 80% humidity assumed for all models.
static double anta_coef[61][3]={
//wavelength ext.coef sca.coef
// [um] [1/km] [1/km]
{ 2.500E-01,1.387E-02,1.386E-02},
{ 3.000E-01,1.389E-02,1.388E-02},
{ 3.500E-01,1.366E-02,1.364E-02},
{ 4.000E-01,1.321E-02,1.320E-02},
{ 4.500E-01,1.269E-02,1.268E-02},
{ 5.000E-01,1.210E-02,1.210E-02},
{ 5.500E-01,1.149E-02,1.148E-02},
# START OF HEADER
#
# Measured sky radiance data, from [1], converted
# into CIE XYZ tristimulus values (see [2]).
# See also [3] for visualization and additional info.
#
# Location: the roof of Rhodes Hall at Cornell University.
# Latitude: 42.443449
# Longitude: -76.481962
#
@fp64
fp64 / biquadratic.html
Created March 7, 2025 03:05
On integrals of biquadratic gaussians
<h1 class="line" data-line="0">On integrals of biquadratic gaussians</h1>
<p class="line" data-line="2">This short note aims to prove that</p>
<p class="line" data-line="4" align="center"><svg class="svg-preview" id="s2tex_0" style="vertical-align:-13.25626pt; opacity: 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="629" height="46" viewBox="1872.02 1482.793 375.99 27.497"><defs><path id="s35g2-6" d="M4.462-3.415h3.033c.185 0 .381 0 .381-.218s-.196-.218-.381-.218H4.462v-3.01c0-.175 0-.404-.218-.404s-.219.196-.219.37v3.044H.982c-.186 0-.382 0-.382.218s.196.218.382.218h3.043v2.979H.982c-.186 0-.382 0-.382.218S.796 0 .982 0h6.513c.185 0 .381 0 .381-.218s-.196-.218-.381-.218H4.462z"></path><path id="s35g2-7" d="M4.462-1.604h3.033c.185 0 .381 0 .381-.218s-.196-.218-.381-.218H4.462v-2.978h3.033c.185 0 .381 0 .381-.218s-.196-.219-.381-.219H.982c-.186 0-.382 0-.382.219s.196.218.382.218h3.043v2.978H.982c-.186 0-.382 0-.382.218s.196.218.382.218h3.043V1.44c0 .175 0 .37.219.37s.218
@fp64
fp64 / demo.c
Last active February 17, 2025 04:59
Somewhat basic WinAPI & SDL2 graphical program.
// Public Domain under http://unlicense.org, see link for details.
// Self-reference: https://gist.github.com/fp64/1a3166ca35118167af8839b40d4e7b94
// Minimalist version: https://gist.github.com/fp64/2e25143e754424d4a2f592d9493451bc
// Somewhat minimalistic dual-backend C program for plain WinAPI and SDL2,
// that creates a (possibly fullscreen) window and provides keyboard input
// and in-memory colorbuffer to draw to (no GAPI, i.e. softrender).
// Compilation, WinAPI (assuming MinGW):
// gcc -std=c99 -O2 demo.c -o demo.exe -mwindows -static
@fp64
fp64 / demo.c
Last active February 17, 2025 05:09
Basic WinAPI & SDL2 graphical program.
// Public Domain under http://unlicense.org, see link for details.
// Self-reference: https://gist.github.com/fp64/2e25143e754424d4a2f592d9493451bc
// Expanded version: https://gist.github.com/fp64/1a3166ca35118167af8839b40d4e7b94
// Minimalistic dual-backend C program for plain WinAPI and SDL2,
// that creates a (non-resizable) window and provides keyboard input
// and in-memory colorbuffer to draw to (no GAPI, i.e. softrender).
// Compilation, WinAPI (assuming MinGW):
// gcc -std=c99 -O2 demo.c -o demo.exe -mwindows -static
@fp64
fp64 / gohufont-11.h
Last active February 2, 2025 01:17
Gohufont embedded as C-style arrays
// Public Domain under http://unlicense.org, see link for details.
// NOTE: gohufont (https://font.gohu.org/) itself
// is licensed under WTFPL (http://www.wtfpl.net/about/).
// Bitmap font, embeded as a C/C++ array.
// NOTE: this file isn't a "proper" C/C++ header.
// You are expected to e.g. #include it in the middle of a .c file.
// Usage: pixel at position (x,y) from the lower-left
@fp64
fp64 / glhf.cpp
Created November 23, 2024 21:21
A proof-of-concept lossless random-access compressor for GLSL (and C).
// Public Domain under http://unlicense.org, see link for details.
// A lossless random-access compressor for GLSL (and C).
// Version 1.0.
// WARNING: proof-of-concept, may be buggy.
// See https://www.shadertoy.com/view/4cdyWN for usage example.
//
// Compilation:
// g++ -O3 glhf.cpp -o glhf
// Example of usage:
@fp64
fp64 / results.md
Last active August 8, 2025 02:30
Comparison of several sRGB↔Linear approximations

Update: added a few more functions.

Results, on AMD EPYC 7571.

Note: time for _identity functions is essentially pure overhead of the test setup.

sRGB→Linear:

Function Abs. error (Linf) Time, ns
// Public Domain under http://unlicense.org, see link for details.
// Simple self-contained software triangle rasterizer, largerly based on
// https://fgiesen.wordpress.com/2013/02/10/optimizing-the-basic-rasterizer/
// See also https://gist.github.com/rygorous/9b793cd21d876da928bf4c7f3e625908
// Not optimized for speed, but should be practical for
// less speed-intensive purposes.
#if 0
@fp64
fp64 / u16noise.h
Last active January 24, 2023 07:04
// Public Domain under http://unlicense.org, see link for details.
// Downsized version of u32noise.h ( https://gist.github.com/fp64/126289051f0c9e1b70bcba7c3e07a82f ).
// Probably useless as actual PRNGs, but may be helpful for testing.
#ifndef U16NOISE_H
#define U16NOISE_H
#include <stdint.h>