64 virtual bool has_area()
const = 0;
68 return pdf_area > 0 && pdf_dir > 0 && cos > 0
70 : EmissionSample(pos, dir,
rgb(0.0f), 1.0f, 1.0f, 1.0f);
74 return pdf_area > 0 && pdf_dir > 0 && cos > 0
76 : DirectLightingSample(pos,
rgb(0.0f), 1.0f, 1.0f, 1.0f);
86 return make_direct_sample(
pos, color, 1.0f, uniform_sphere_pdf(), 1.0f);
90 auto sample = sample_uniform_sphere(sampler(), sampler());
91 return make_emission_sample(
pos, sample.dir, color, 1.0f, sample.pdf, 1.0f);
111 : v0(v0), v1(v1), v2(v2), color(c)
113 n = cross(v1 - v0, v2 - v0);
114 auto len = length(n);
115 auto area = len * 0.5f;
116 inv_area = 1.0f / area;
117 n *= inv_area * 0.5f;
121 auto pos = sample(sampler);
124 return make_direct_sample(pos, color, inv_area, cosine_hemisphere_pdf(cos), cos);
128 auto pos = sample(sampler);
129 auto sample = sample_cosine_hemisphere(gen_local_coords(n), sampler(), sampler());
130 return make_emission_sample(
pos, sample.dir, color, inv_area, sample.pdf, dot(sample.dir, n));
134 auto cos = cosine_hemisphere_pdf(dot(
dir, n));
137 : EmissionValue(
rgb(0.0f), 1.0f, 1.0f);
152 return lerp(v0, v1, v2, u, v);
Base class for all lights.
Definition: lights.h:50
Sampler object, used at the level of the integrator to control how the random number generation is do...
Definition: samplers.h:12
rgb intensity
Intensity along the direction.
Definition: lights.h:39
float3 pos
Position on the light source.
Definition: lights.h:10
bool has_area() const override final
Returns true if the light has an area (i.e. can be hit by a ray).
Definition: lights.h:98
DirectLightingSample sample_direct(const float3 &from, Sampler &sampler) const override final
Samples direct illumination from this light source at the given point on a surface.
Definition: lights.h:120
float3 dir
Direction of the light going outwards.
Definition: lights.h:11
rgb intensity
Intensity along the direction.
Definition: lights.h:12
float cos
Cosine between the direction and the light source geometry.
Definition: lights.h:29
float pdf_area
Probability to sample the point on the light.
Definition: lights.h:27
EmissionValue emission(const float3 &, float, float) const override final
Returns the emission of a light source (only for light sources with an area).
Definition: lights.h:94
EmissionSample sample_emission(Sampler &sampler) const override final
Samples the emitting surface of the light.
Definition: lights.h:127
float pdf_area
Probability to sample the point on the light.
Definition: lights.h:13
DirectLightingSample sample_direct(const float3 &, Sampler &) const override final
Samples direct illumination from this light source at the given point on a surface.
Definition: lights.h:85
Emission value at a given point on the light surface.
Definition: lights.h:38
float pdf_dir
Probability to sample the direction on the light, conditioned on the point on the light source...
Definition: lights.h:14
float pdf_dir
Probability to sample the direction using emission sampling.
Definition: lights.h:41
EmissionSample sample_emission(Sampler &sampler) const override final
Samples the emitting surface of the light.
Definition: lights.h:89
float pdf_dir
Probability to sample the direction using emission sampling.
Definition: lights.h:28
Result from sampling a light source.
Definition: lights.h:9
float cos
Cosine between the direction and the light source geometry.
Definition: lights.h:15
Result from sampling direct lighting from a light source.
Definition: lights.h:24
Triangle light source, useful to represent area lights made of meshes.
Definition: lights.h:108
bool has_area() const override final
Returns true if the light has an area (i.e. can be hit by a ray).
Definition: lights.h:140
rgb intensity
Intensity along the direction.
Definition: lights.h:26
Simple point light, with intensity decreasing quadratically.
Definition: lights.h:81
EmissionValue emission(const float3 &dir, float, float) const override final
Returns the emission of a light source (only for light sources with an area).
Definition: lights.h:133
float3 pos
Position on the light source.
Definition: lights.h:25
float pdf_area
Probability to sample the point on the light.
Definition: lights.h:40