#ifndef OPTICS_H #define OPTICS_H #include #include 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_ready(const PsfKernelCache *cache, FILE *stream); 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 32-bit RGB FITS. */ int write_hdr_fits(const char *path, const double *hdr, int width, int height, double horizontal_fov_deg); #endif #endif