Prakash
Prakash (Sanskrit: light, illumination) -- optics and light simulation for AGNOS
Physics of light: ray optics, wave optics, spectral math, lens geometry, atmospheric scattering, and physically-based rendering primitives. Built on hisab for math foundations.
Quick Start
use ;
use ;
use ;
use ;
// Snell's law: light entering glass from air at 30 degrees
let refracted = snell.unwrap;
// How much light reflects off glass at normal incidence?
let reflectance = fresnel_normal; // ~4%
// What color is 550nm light?
let green = wavelength_to_rgb.unwrap;
// What color is a 2700K warm bulb?
let warm = color_temperature_to_rgb;
// Where does a 50mm lens focus an object at 2 meters?
let image_dist = thin_lens_image_distance.unwrap;
let mag = magnification;
// Malus's law: light through a polarizer at 45 degrees
let transmitted = malus_law; // 50%
Modules
| Module | Description |
|---|---|
ray |
Geometric optics: Snell's law, Fresnel equations (s/p/normal/unpolarized), reflection (2D/3D), critical angle, Brewster angle, Beer-Lambert, total internal reflection. 12 built-in materials with refractive indices. Sequential ray tracer, optical system builder, paraxial analysis, cardinal point finder. |
wave |
Wave optics: interference intensity, single/double slit diffraction, diffraction grating, thin film reflectance, Malus's law, polarization (Jones vectors/calculus). 2D Fraunhofer diffraction (FFT), multi-source interference patterns, PSF from wavefront error. |
spectral |
Wavelength to RGB conversion, Planck blackbody radiance, Wien displacement law, color temperature to RGB, photon energy (J and eV), wavelength/frequency conversion. CIE 1931 2-degree observer, XYZ tristimulus, SPD integration, standard illuminants (A/D50/D65/E/F2/F11), color rendering index (CRI). Physical constants (c, h, k_B). |
lens |
Thin lens equation, magnification, lensmaker's equation, combined focal length, depth of field, f-number/NA, mirror focal length, lens classification. |
pbr |
Physically-based rendering: Fresnel-Schlick, GGX/Beckmann NDF, geometry Smith, Cook-Torrance specular BRDF, Lambert diffuse, IOR-to-F0 conversion. Full metallic-roughness pipeline. |
atmosphere |
Atmospheric optics: Rayleigh and Mie scattering, sky color computation, air mass, optical depth. |
error |
Unified error types for all modules. |
Feature Flags
| Feature | Default | Description |
|---|---|---|
ray |
yes | Geometric optics, sequential ray tracing, optical system builder |
wave |
yes | Wave optics, interference, diffraction, polarization, FFT patterns |
spectral |
yes | Spectral math, CIE color science, blackbody, color temperature |
lens |
yes | Thin lens, lensmaker, mirrors, depth of field |
pbr |
no | Cook-Torrance BRDF, Fresnel-Schlick, GGX/Beckmann NDF |
atmosphere |
no | Rayleigh/Mie scattering, sky color, air mass |
ai |
no | Daimon/hoosh integration (network deps) |
logging |
no | Structured logging via PRAKASH_LOG env var |
full |
-- | Enables all features |
Examples
| Example | Features | Description |
|---|---|---|
basic_optics |
ray, spectral, lens |
Snell's law, Fresnel, wavelength-to-RGB, thin lens |
rainbow |
ray, spectral |
Rainbow simulation via raindrop refraction |
camera_lens |
ray, spectral, lens |
Camera lens system analysis with prescriptions |
pbr_materials |
pbr |
PBR material shading with Cook-Torrance BRDF |
Run an example:
Architecture
prakash (this crate)
+-- hisab (math: vectors, geometry, calculus, numerical methods)
Consumer Crates
| Crate | Usage |
|---|---|
| soorat | PBR shading |
| kiran | Physically-based lighting |
| ranga | Lens effects |
Building
License
GPL-3.0 -- see LICENSE.