Reduce light emission to just a few spheres

This commit is contained in:
numzero 2024-12-29 18:30:01 +03:00
parent 127b7a4077
commit 06715b9797

View File

@ -1,5 +1,5 @@
use glam::{vec3, Vec3}; use glam::{vec3, Vec3};
use rand_distr::{Distribution, LogNormal, Uniform}; use rand_distr::{Bernoulli, Distribution, Uniform};
pub struct SphereParams { pub struct SphereParams {
pub radius: f32, pub radius: f32,
@ -16,7 +16,7 @@ pub struct SphereParamsDistribution {
pub drad: Uniform<f32>, pub drad: Uniform<f32>,
pub dpos: Uniform<f32>, pub dpos: Uniform<f32>,
pub dcol: Uniform<f32>, pub dcol: Uniform<f32>,
pub demit: LogNormal<f32>, pub demit: Bernoulli,
pub dampl: Uniform<f32>, pub dampl: Uniform<f32>,
pub dfreq: Uniform<f32>, pub dfreq: Uniform<f32>,
pub dphase: Uniform<f32>, pub dphase: Uniform<f32>,
@ -29,7 +29,7 @@ impl Default for SphereParamsDistribution {
drad: Uniform::new(0.01, 0.10), drad: Uniform::new(0.01, 0.10),
dpos: Uniform::new(-1.0, 1.0), dpos: Uniform::new(-1.0, 1.0),
dcol: Uniform::new(0.0, 1.0), dcol: Uniform::new(0.0, 1.0),
demit: LogNormal::new(-0.8, 2.0).unwrap(), demit: Bernoulli::new(0.1).unwrap(),
dampl: Uniform::new(0.3, 0.8), dampl: Uniform::new(0.3, 0.8),
dfreq: Uniform::new(0.2, 1.5), dfreq: Uniform::new(0.2, 1.5),
dphase: Uniform::new(0., 2. * std::f32::consts::PI), dphase: Uniform::new(0., 2. * std::f32::consts::PI),
@ -44,7 +44,7 @@ impl SphereParamsDistribution {
origin: self.dpos.sample3(rgen), origin: self.dpos.sample3(rgen),
radius: self.drad.sample(rgen), radius: self.drad.sample(rgen),
color: self.dcol.sample3(rgen).normalize(), color: self.dcol.sample3(rgen).normalize(),
alpha: self.demit.sample(rgen), alpha: if self.demit.sample(rgen) { 10.0 } else { 0.0 },
glossiness: self.dgloss.sample(rgen), glossiness: self.dgloss.sample(rgen),
amplitudes: self.dampl.sample3(rgen), amplitudes: self.dampl.sample3(rgen),
frequencies: self.dfreq.sample3(rgen), frequencies: self.dfreq.sample3(rgen),