示例#1
0
    static BidirPathVertex sample(const Scene& scene,
                           const Sensor& sensor,
                           const Vec2f& lensSample,
                           const Vec2f& imageSample) {
        RaySample raySample;
        Intersection I;
        float positionPdf, directionPdf, intersectionPdfWrtArea,
                sampledPointToIncidentDirectionJacobian;
        auto We = sensor.sampleExitantRay(scene, lensSample, imageSample, raySample, positionPdf, directionPdf, I,
                                          sampledPointToIncidentDirectionJacobian, intersectionPdfWrtArea);

        if(We == zero<Vec3f>() || raySample.pdf == 0.f) {
            return {};
        }
        We /= raySample.pdf;

        if(!I) {
            return {
                I,
                BSDF(),
                ScatteringEvent::Emission,
                0.f,
                directionPdf,
                0.f,
                raySample.pdf,
                We * I.Le,
                0u,
                false
            };
        }

        return {
            I,
            BSDF(-raySample.value.dir, I, scene),
            ScatteringEvent::Emission,
            sampledPointToIncidentDirectionJacobian,
            directionPdf,
            intersectionPdfWrtArea,
            positionPdf * intersectionPdfWrtArea,
            We,
            1u,
            false
        };
    }
示例#2
0
	static BSDF init_fresnel (const Vector3D& normal_, const Color& kr_, const Color& kt_, float ior_) {
		return BSDF (normal_, FRESNEL,
					 Color (0.f), Color (0.f), 0.f,
					 kr_, kt_, ior_); 
	}
示例#3
0
	static BSDF init_pure_refl (const Vector3D& normal_, const Color& kd_, const Color& kr_) {
		return BSDF (normal_, PURE_REFL,
					 kd_, Color (0.f), 0.f,
					 kr_, Color (0.f), 1.3f); /** hack for the IOR, should use different Fresnel equations */
	}
示例#4
0
	static BSDF init_blinn_phong (const Vector3D& normal_, const Color& kd_,
								  const Color& ks_, float shininess_) {
		return BSDF (normal_, BLINN_PHONG,
					 kd_, ks_, shininess_,
					 Color (0.f), Color (0.f), 0.f);
	}
示例#5
0
	static BSDF init_diffuse (const Vector3D& normal_, const Color& kd_) {
		return BSDF (normal_, DIFFUSE,
					 kd_, Color (0.f), 0.f,
					 Color (0.f), Color (0.f), 0.f);
	}