Optics: cache pixel-area Moffat kernels

This commit is contained in:
wyj committed 2026-08-28 13:53:06 -04:00
1 parent a71180706f
commit 80b891d2c8
10 files changed
+693 -56

No files matched your search

+37
View File
@@ -1,20 +1,57 @@
#ifndef OPTICS_H
#define OPTICS_H
#include <stddef.h>
#include <stdio.h>
typedef struct { double r, g, b; } LinearRgb;
typedef struct {
double fwhm_pixels;
double moffat_beta;
} PointSpreadFunction;
/* One immutable process-wide kernel for the one PSF parameter pair accepted
* by the current renderer. Its storage remains private to optics.c. */
typedef struct {
double fwhm_pixels, moffat_beta, alpha_pixels;
double max_radius_pixels, build_seconds;
float *weights;
int phase_resolution, radius_pixels;
int ready;
} PsfKernelCache;
typedef struct {
size_t cached_splats;
size_t direct_fallbacks;
} PsfSplatStats;
/* Integrate a Planck spectrum into absolute linear-sRGB spectral radiance
* (W m^-2 sr^-1), before catalog amplitude and display exposure. */
LinearRgb blackbody_to_linear_rgb(double temperature_K);
int psf_kernel_cache_init(PsfKernelCache *cache,
const PointSpreadFunction *psf);
void psf_kernel_cache_destroy(PsfKernelCache *cache);
void psf_kernel_cache_report(const PsfKernelCache *cache,
const PsfSplatStats *stats, FILE *stream);
/* Reference implementation: pixel-area-integrated Moffat with the same tail
* budgets as the cache-aware renderer. */
void splat_moffat_direct(double *hdr, int width, int height, double x, double y,
LinearRgb color, double flux,
const PointSpreadFunction *psf);
void splat_moffat(double *hdr, int width, int height, double x, double y,
LinearRgb color, double flux,
const PointSpreadFunction *psf);
/* Returns nonzero when this event used the direct reference fallback. */
int splat_moffat_cached(double *hdr, int width, int height, double x, double y,
LinearRgb color, double flux,
const PointSpreadFunction *psf,
const PsfKernelCache *cache);
/* Writes PNG when built with libpng; non-libpng builds use PPM fallback. */
int write_tonemapped_image(const char *path, const double *hdr, int width,
int height);
#ifdef ENABLE_HDR_DEBUG
/* Test-build-only: writes the pre-tone-mapping framebuffer as RGB float PFM. */
int write_hdr_pfm(const char *path, const double *hdr, int width, int height);
#endif
#endif