Spectrum GonioPhotometricLight::Sample_L(const Scene *scene, const LightSample &ls, float u1, float u2, float time, Ray *ray, Normal *Ns, float *pdf) const { *ray = Ray(lightPos, UniformSampleSphere(ls.uPos[0], ls.uPos[1]), 0.f, INFINITY, time); *Ns = (Normal)ray->d; *pdf = UniformSpherePdf(); return Intensity * Scale(ray->d); }
// sample ray from light Spectrum PointLight::sample_l( const Intersection& intersect , const LightSample* ls , Vector& dirToLight , float* distance , float* pdfw , float* emissionPdf , float* cosAtLight , Visibility& visibility ) const { // Get light position const Vector _dirToLight = light_pos - intersect.intersect; // Normalize vec const float sqrLen = _dirToLight.SquaredLength(); const float len = sqrt(sqrLen); dirToLight = _dirToLight / len; // setup visibility ray const float delta = 0.01f; visibility.ray = Ray( light_pos , -dirToLight , 0 , 0.0f , len - delta ); // direction pdf from 'intersect' to light source w.r.t solid angle if( pdfw ) *pdfw = sqrLen; if( cosAtLight ) *cosAtLight = 1.0f; if( distance ) *distance = len; // product of pdf of sampling a point w.r.t surface area and a direction w.r.t direction if( emissionPdf ) *emissionPdf = UniformSpherePdf(); return intensity; }
Spectrum GonioPhotometricLight::Sample_L(const Scene *scene, float u1, float u2, float u3, float u4, Ray *ray, float *pdf) const { ray->o = lightPos; ray->d = UniformSampleSphere(u1, u2); *pdf = UniformSpherePdf(); return Intensity * Scale(ray->d); }
Spectrum GonioPhotometricLight::Sample_L(const Scene *scene, const LightSample &ls, float u1, float u2, Ray *ray, Normal *Ns, float *pdf) const { ray->o = lightPos; ray->d = UniformSampleSphere(ls.uPos[0], ls.uPos[1]); *Ns = (Normal)ray->d; *pdf = UniformSpherePdf(); return Intensity * Scale(ray->d); }
Spectrum GonioPhotometricLight::Sample_L(const Point2f &sample1, const Point2f &sample2, Float time, Ray *ray, Normal3f *Ns, Float *pdfPos, Float *pdfDir) const { *ray = Ray(pLight, UniformSampleSphere(sample1), Infinity, time, 0, medium); *Ns = (Normal3f)ray->d; *pdfPos = 1.f; *pdfDir = UniformSpherePdf(); return intensity * Scale(ray->d); }
Spectrum PointLight::Sample_Le(const Point2f &u1, const Point2f &u2, Float time, Ray *ray, Normal3f *nLight, Float *pdfPos, Float *pdfDir) const { *ray = Ray(pLight, UniformSampleSphere(u1), Infinity, time, mediumInterface.inside); *nLight = (Normal3f)ray->d; *pdfPos = 1; *pdfDir = UniformSpherePdf(); return I; }
Spectrum GonioPhotometricLight::Sample_Le(const Point2f &u1, const Point2f &u2, Float time, Ray *ray, Normal3f *nLight, Float *pdfPos, Float *pdfDir) const { *ray = Ray(pLight, UniformSampleSphere(u1), Infinity, time, 0, mediumInterface.inside); *nLight = (Normal3f)ray->d; *pdfPos = 1.f; *pdfDir = UniformSpherePdf(); return intensity * Scale(ray->d); }
// sample a ray from light Spectrum PointLight::sample_l( const LightSample& ls , Ray& r , float* pdfW , float* pdfA , float* cosAtLight ) const { // sample a new ray r.m_fMin = 0.0f; r.m_fMax = FLT_MAX; r.m_Ori = light_pos; r.m_Dir = UniformSampleSphere( ls.u , ls.v ); // product of pdf of sampling a point w.r.t surface area and a direction w.r.t direction if( pdfW ) *pdfW = UniformSpherePdf(); // pdf w.r.t surface area if( pdfA ) *pdfA = 1.0f; if( cosAtLight ) *cosAtLight = 1.0f; return intensity; }
void GonioPhotometricLight::Pdf(const Ray &, const Normal3f &, Float *pdfPos, Float *pdfDir) const { *pdfPos = 0.f; *pdfDir = UniformSpherePdf(); }
void PointLight::Pdf_Le(const Ray &, const Normal3f &, Float *pdfPos, Float *pdfDir) const { *pdfPos = 0; *pdfDir = UniformSpherePdf(); }
void GonioPhotometricLight::Pdf_Le(const Ray &, const Normal3f &, Float *pdfPos, Float *pdfDir) const { ProfilePhase _(Prof::LightPdf); *pdfPos = 0.f; *pdfDir = UniformSpherePdf(); }
void PointLight::Pdf_Le(const Ray &, const Normal3f &, Float *pdfPos, Float *pdfDir) const { ProfilePhase _(Prof::LightPdf); *pdfPos = 0; *pdfDir = UniformSpherePdf(); }