Example #1
0
// BluePaint Method Definitions
BSDF *BluePaint::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading) const {
	// Declare bluepaint coefficients
	static float diffuse[3] = {  0.3094f,    0.39667f,   0.70837f  };
	static float xy0[3] =     {  0.870567f,  0.857255f,  0.670982f };
	static float z0[3] =      {  0.803624f,  0.774290f,  0.586674f };
	static float e0[3] =      { 21.820103f, 18.597755f,  7.472717f };
	static float xy1[3] =     { -0.451218f, -0.406681f, -0.477976f };
	static float z1[3] =      {  0.023123f,  0.017625f,  0.227295f };
	static float e1[3] =      {  2.774499f,  2.581499f,  3.677653f };
	static float xy2[3] =     { -1.031545f, -1.029426f, -1.026588f };
	static float z2[3] =      {  0.706734f,  0.696530f,  0.687715f };
	static float e2[3] =      { 66.899060f, 63.767912f, 57.489181f };
	static Spectrum xy[3] = { Spectrum(xy0), Spectrum(xy1), Spectrum(xy2) };
	static Spectrum z[3] = { Spectrum(z0), Spectrum(z1), Spectrum(z2) };
	static Spectrum e[3] = { Spectrum(e0), Spectrum(e1), Spectrum(e2) };
	// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
	DifferentialGeometry dgs;
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	bsdf->Add(BSDF_ALLOC(Lafortune)(Spectrum(diffuse), 3, xy, xy, z, e,
		BxDFType(BSDF_REFLECTION | BSDF_DIFFUSE)));
	return bsdf;
}
// BrushedMetal Method Definitions
BSDF *BrushedMetal::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading) const {
	// Declare brushedmetal coefficients
	static float diffuse[3] = { 0, 0, 0 };
	static float xy0[3] =     {  -1.11854f, -1.11845f, -1.11999f  };
	static float z0[3] =      {   1.01272f,  1.01469f,  1.01942f  };
	static float e0[3] =      {  15.8708f,  15.6489f,  15.4571f   };
	static float xy1[3] =     {  -1.05334f, -1.06409f, -1.08378f  };
	static float z1[3] =      {   0.69541f,  0.662178f, 0.626672f };
	static float e1[3] =      { 111.267f,   88.9222f,  65.2179f   };
	static float xy2[3] =     {  -1.01684f, -1.01635f, -1.01529f  };
	static float z2[3] =      {   1.00132f,  1.00112f,  1.00108f  };
	static float e2[3] =      { 180.181f,  184.152f,  195.773f    };
	static Spectrum xy[3] = { Spectrum(xy0), Spectrum(xy1), Spectrum(xy2) };
	static Spectrum z[3] = { Spectrum(z0), Spectrum(z1), Spectrum(z2) };
	static Spectrum e[3] = { Spectrum(e0), Spectrum(e1), Spectrum(e2) };
	// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
	DifferentialGeometry dgs;
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	bsdf->Add(BSDF_ALLOC(Lafortune)(Spectrum(*diffuse), 3, xy, xy, z, e,
		BxDFType(BSDF_REFLECTION | BSDF_GLOSSY)));
	return bsdf;
}
Example #3
0
// PlasticMaterial Method Definitions
BSDF *PlasticMaterial::GetBSDF(const DifferentialGeometry &dgGeom,
                               const DifferentialGeometry &dgShading,
                               MemoryArena &arena) const {
    // Allocate _BSDF_, possibly doing bump mapping with _bumpMap_
    DifferentialGeometry dgs;
    if (bumpMap)
        Bump(bumpMap, dgGeom, dgShading, &dgs);
    else
        dgs = dgShading;
    BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);
    Spectrum kd = Kd->Evaluate(dgs).Clamp();
    if (!kd.IsBlack()) {
        BxDF *diff = BSDF_ALLOC(arena, Lambertian)(kd);
        bsdf->Add(diff);
    }
    Spectrum ks = Ks->Evaluate(dgs).Clamp();
    if (!ks.IsBlack()) {
        Fresnel *fresnel = BSDF_ALLOC(arena, FresnelDielectric)(1.5f, 1.f);
        float rough = roughness->Evaluate(dgs);
        BxDF *spec = BSDF_ALLOC(arena, Microfacet)
                       (ks, fresnel, BSDF_ALLOC(arena, Blinn)(1.f / rough));
        bsdf->Add(spec);
    }
    return bsdf;
}
Example #4
0
// Felt Method Definitions
BSDF *Felt::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading) const {
	// Declare felt coefficients
	static float diffuse[3] = {  0.025865f,  0.025865f,  0.025865f};
	static float xy0[3] =     { -0.304075f, -0.304075f, -0.304075f};
	static float z0[3] =      { -0.065992f, -0.065992f, -0.065992f};
	static float e0[3] =      {  3.047892f,  3.047892f,  3.047892f};
	static float xy1[3] =     { -0.749561f, -0.749561f, -0.749561f};
	static float z1[3] =      { -1.167929f, -1.167929f, -1.167929f};
	static float e1[3] =      {  6.931827f,  6.931827f,  6.931827f};
	static float xy2[3] =     {  1.004921f,  1.004921f,  1.004921f};
	static float z2[3] =      { -0.205529f, -0.205529f, -0.205529f};
	static float e2[3] =      { 94.117332f, 94.117332f, 94.117332f};
	static Spectrum xy[3] = { Spectrum(xy0), Spectrum(xy1), Spectrum(xy2) };
	static Spectrum z[3] = { Spectrum(z0), Spectrum(z1), Spectrum(z2) };
	static Spectrum e[3] = { Spectrum(e0), Spectrum(e1), Spectrum(e2) };
	// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
	DifferentialGeometry dgs;
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	bsdf->Add(BSDF_ALLOC(Lafortune)(Spectrum(diffuse), 3, xy, xy, z, e,
		BxDFType(BSDF_REFLECTION | BSDF_DIFFUSE)));
	return bsdf;
}
// Skin Method Definitions
BSDF *Skin::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading) const {
	// Declare skin coefficients
	static float diffuse[3] = {  0.428425f,  0.301341f,  0.331054f};
	static float xy0[3] =     { -1.131747f, -1.016939f, -0.966018f};
	static float z0[3] =      { -1.209182f, -1.462488f, -1.222419f};
	static float e0[3] =      {  6.421658f,  3.699932f,  3.524889f};
	static float xy1[3] =     { -0.546570f, -0.643533f, -0.638934f};
	static float z1[3] =      {  0.380123f,  0.410559f,  0.437367f};
	static float e1[3] =      {  3.685044f,  4.266495f,  4.539742f};
	static float xy2[3] =     { -0.998888f, -1.020153f, -1.027479f};
	static float z2[3] =      {  0.857998f,  0.703913f,  0.573625f};
	static float e2[3] =      { 64.208486f, 63.919687f, 43.809866f};
	static Spectrum xy[3] = { Spectrum(xy0), Spectrum(xy1), Spectrum(xy2) };
	static Spectrum z[3] = { Spectrum(z0), Spectrum(z1), Spectrum(z2) };
	static Spectrum e[3] = { Spectrum(e0), Spectrum(e1), Spectrum(e2) };
	// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
	DifferentialGeometry dgs;
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	bsdf->Add(BSDF_ALLOC(Lafortune)(Spectrum(diffuse), 3, xy, xy, z, e,
		BxDFType(BSDF_REFLECTION | BSDF_DIFFUSE)));
	return bsdf;
}
Example #6
0
// MirrorMaterial Method Definitions
BSDF *MirrorMaterial::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading, MemoryArena &arena) const {
    // Allocate _BSDF_, possibly doing bump mapping with _bumpMap_
    DifferentialGeometry dgs;
    if (bumpMap)
        Bump(bumpMap, dgGeom, dgShading, &dgs);
    else
        dgs = dgShading;
    BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);
    Spectrum R = Kr->Evaluate(dgs).Clamp();

    if (!R.IsBlack()) {
        float x,y,z;
        x = dgs.p.x;
        y = dgs.p.y;
        z = dgs.p.z;
        float rad = sqrt((x-(-4))*(x-(-4)) + (y-1)*(y-1) + (z-15)*(z-15));
        float c = 15.f;
//        if (rad < c) {// 11->20, 14
            bsdf->Add(BSDF_ALLOC(arena, SpecularReflection)(R,
                BSDF_ALLOC(arena, FresnelNoOp)()));
//        } else {
//            bsdf->Add(BSDF_ALLOC(arena, SpecularReflection)(R,
//                BSDF_ALLOC(arena, FresnelNoOp)()));
//        }
    }
    return bsdf;
}
Example #7
0
// Primer Method Definitions
BSDF *Primer::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading) const {
	// Declare primer coefficients
	static float diffuse[3] = {  0.118230f,  0.121218f,  0.133209f};
	static float xy0[3] =     { -0.399286f, -1.033473f, -1.058104f};
	static float z0[3] =      {  0.167504f,  0.009545f, -0.068002f};
	static float e0[3] =      {  2.466633f,  7.637253f,  8.117645f};
	static float xy1[3] =     { -1.041861f, -1.100108f, -1.087779f};
	static float z1[3] =      {  0.014375f, -0.198147f, -0.053605f};
	static float e1[3] =      {  7.993722f, 29.446268f, 41.988990f};
	static float xy2[3] =     { -1.098605f, -0.379883f, -0.449038f};
	static float z2[3] =      { -0.145110f,  0.159127f,  0.173224f};
	static float e2[3] =      { 31.899719f,  2.372852f,  2.636161f};
	static Spectrum xy[3] = { Spectrum(xy0), Spectrum(xy1), Spectrum(xy2) };
	static Spectrum z[3] = { Spectrum(z0), Spectrum(z1), Spectrum(z2) };
	static Spectrum e[3] = { Spectrum(e0), Spectrum(e1), Spectrum(e2) };
	// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
	DifferentialGeometry dgs;
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	bsdf->Add(BSDF_ALLOC(Lafortune)(Spectrum(diffuse), 3, xy, xy, z, e,
		BxDFType(BSDF_REFLECTION | BSDF_DIFFUSE)));
	return bsdf;
}
BSDF *custom_material_phong::GetBSDF(const DifferentialGeometry &dgGeom,
		const DifferentialGeometry &dgShading) const {
	
	//not sure about this yet
	DifferentialGeometry dgs=dgShading;
	
	//or this:
	//allocate memory for BSDF, poiting bsdf to a new BSDF
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	
	//allocate to diff a custom BxDF with reflection spectrum kd
	Spectrum kd = Kd->Evaluate(dgs).Clamp();
	BxDF *diff = BSDF_ALLOC(custom_BxDF_phongDiffuse)(kd);
	
	//my specular reflectance
	Spectrum ks = Ks->Evaluate(dgs).Clamp();
	BxDF *spec = BSDF_ALLOC(custom_BxDF_phongSpecular)(ks,float(n));

	
	//add both diff and spec BSDFS to the BSDF of this material
	//***sets the BSDF of this material
	bsdf->Add(diff);
	bsdf->Add(spec);
	
	return bsdf;
}
// custom_material Method Definitions
BSDF *custom_material::GetBSDF(const DifferentialGeometry &dgGeom,
		const DifferentialGeometry &dgShading) const {
	
	//issue debugging warning
	//Warning("custom_material\n");
	
	//declare geometry that will be used in BRDF
	DifferentialGeometry dgs;
	
	//if there is to be a bump map, call Bump, which modifies dgs
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
		
	//allocate memory for BSDF, poiting bsdf to a new BSDF
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	
	//set a spectrum kd to the spectrum stored in texure Kd
	//***gets color spectrum of diffuse reflection***
	Spectrum kd = Kd->Evaluate(dgs).Clamp();
	
	//allocate to diff a custom BxDF with reflection spectrum kd
	//***diffuse reflection characteristics***
	BxDF *diff = BSDF_ALLOC(custom_BxDF3)(kd);
	
	/* commented dpl 10 august 2005
	// specular reflectance from pbrt's plastic model
	//allocate to (temp) fresnes a fresneldielectric bsdf with
	//parameters (1.5, 1)
	//***will set part of specular reflection properties***
	Fresnel *fresnel =
		BSDF_ALLOC(FresnelDielectric)(1.5f, 1.f);
	
	//set a spectrum ks to the spectrum stored in the texture Ks
	//***gets color spectrum of specular reflection***
	Spectrum ks = Ks->Evaluate(dgs).Clamp();
	
	//get the roughness from roughness (?)
	float rough = roughness->Evaluate(dgs);
	
	//allocate memory for specular reflection BSDF
	//***sets specular BSDF according to microfacet model
	//with color params ks, fresnel and blinn models (?) ***
	BxDF *spec = BSDF_ALLOC(Microfacet)(ks, fresnel,
		BSDF_ALLOC(Blinn)(1.f / rough));
	*/
	
	//my specular reflectance
	Spectrum ks = Ks->Evaluate(dgs).Clamp();
	BxDF *spec = BSDF_ALLOC(custom_BxDF2)(ks);
	
	//add both diff and spec BSDFS to the BSDF of this material
	//***sets the BSDF of this material
	bsdf->Add(diff);
	bsdf->Add(spec);
	
	return bsdf;
}
Example #10
0
void createBlinn2(BSDF* bsdf)
{
    const float blinnExponent = 2.0;
    Spectrum Ks(1);
    MicrofacetDistribution* distribution = BSDF_ALLOC(arena, Blinn)(blinnExponent);
    Fresnel* fresnel = BSDF_ALLOC(arena, FresnelNoOp)();
    BxDF* bxdf = BSDF_ALLOC(arena, Microfacet)(Ks, fresnel, distribution);
    bsdf->Add(bxdf);
}
Example #11
0
void createFresnelBlend30(BSDF* bsdf)
{
    Spectrum d(0.5);
    Spectrum s(0.5);
    float exponent = 30.0;

    MicrofacetDistribution* distribution = BSDF_ALLOC(arena, Blinn)(exponent);
    BxDF* bxdf = BSDF_ALLOC(arena, FresnelBlend)(d, s, distribution);
    bsdf->Add(bxdf);
}
Example #12
0
void createAniso30_30(BSDF* bsdf)
{
    const float aniso1 = 30.0;
    const float aniso2 = 30.0;
    Spectrum Ks(1);
    MicrofacetDistribution* distribution =
        BSDF_ALLOC(arena, Anisotropic(aniso1, aniso2));
    Fresnel* fresnel = BSDF_ALLOC(arena, FresnelNoOp)();
    BxDF* bxdf = BSDF_ALLOC(arena, Microfacet)(Ks, fresnel, distribution);
    bsdf->Add(bxdf);
}
Example #13
0
void createSubstrate(BSDF* bsdf)
{
    // Taken from substrate.cpp

    Spectrum d(0.5);
    Spectrum s(0.5);
    float u = 0.1;
    float v = 0.1;

    bsdf->Add(BSDF_ALLOC(arena, FresnelBlend)(d, s,
                                              BSDF_ALLOC(arena, Anisotropic)(1.f/u, 1.f/v)));
}
Example #14
0
// Mirror Method Definitions
BSDF *Mirror::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading) const {
	// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
	DifferentialGeometry dgs;
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	Spectrum R = Kr->Evaluate(dgs).Clamp();
	if (!R.Black())
		bsdf->Add(BSDF_ALLOC(SpecularReflection)(R,
			BSDF_ALLOC(FresnelNoOp)()));
	return bsdf;
}
Example #15
0
void createBlinn30and0(BSDF* bsdf)
{
    const float blinnExponent1 = 30.0;
    Spectrum Ks(0.5);
    MicrofacetDistribution* distribution1 = BSDF_ALLOC(arena, Blinn)(blinnExponent1);
    Fresnel* fresnel = BSDF_ALLOC(arena, FresnelNoOp)();
    BxDF* bxdf1 = BSDF_ALLOC(arena, Microfacet)(Ks, fresnel, distribution1);
    bsdf->Add(bxdf1);

    const float blinnExponent2 = 0.0;
    MicrofacetDistribution* distribution2 = BSDF_ALLOC(arena, Blinn)(blinnExponent2);
    BxDF* bxdf2 = BSDF_ALLOC(arena, Microfacet)(Ks, fresnel, distribution2);
    bsdf->Add(bxdf2);
}
Example #16
0
void createPlastic(BSDF* bsdf)
{
    // Taken from plastic.cpp

    Spectrum kd(0.5);
    BxDF *diff = BSDF_ALLOC(arena, Lambertian)(kd);
    Fresnel *fresnel = BSDF_ALLOC(arena, FresnelDielectric)(1.5f, 1.f);
    Spectrum ks = (0.5);
    float rough = 0.1;
    BxDF *spec = BSDF_ALLOC(arena, Microfacet)(ks, fresnel,
                                               BSDF_ALLOC(arena, Blinn)(1.f / rough));
    bsdf->Add(diff);
    bsdf->Add(spec);
}
Example #17
0
void createShinyMetal(BSDF* bsdf)
{
    // Taken from shinymetal.cpp

    Spectrum spec(0.5);
    float rough = 0.1;
    Spectrum R(0.5);

    MicrofacetDistribution *md = BSDF_ALLOC(arena, Blinn)(1.f / rough);
    Spectrum k = 0.;
    Fresnel *frMf = BSDF_ALLOC(arena, FresnelConductor)(FresnelApproxEta(spec), k);
    Fresnel *frSr = BSDF_ALLOC(arena, FresnelConductor)(FresnelApproxEta(R), k);
    bsdf->Add(BSDF_ALLOC(arena, Microfacet)(1., frMf, md));
    bsdf->Add(BSDF_ALLOC(arena, SpecularReflection)(1., frSr));
}
Example #18
0
void createOrenNayar20(BSDF* bsdf)
{
    Spectrum Kd(1);
    float sigma = 0.0;
    BxDF* bxdf = BSDF_ALLOC(arena, OrenNayar)(Kd, sigma);
    bsdf->Add(bxdf);
}
Example #19
0
// Substrate Method Definitions
BSDF *Substrate::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading) const {
	// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
	DifferentialGeometry dgs;
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	Spectrum d = Kd->Evaluate(dgs).Clamp();
	Spectrum s = Ks->Evaluate(dgs).Clamp();
	float u = nu->Evaluate(dgs);
	float v = nv->Evaluate(dgs);

	bsdf->Add(BSDF_ALLOC(FresnelBlend)(d, s, BSDF_ALLOC(Anisotropic)(1.f/u, 1.f/v)));
	return bsdf;
}
Example #20
0
BSDF *MeasuredMaterial::GetBSDF(const DifferentialGeometry &dgGeom,
                                const DifferentialGeometry &dgShading,
                                MemoryArena &arena) const {
    // Allocate _BSDF_, possibly doing bump mapping with _bumpMap_
    DifferentialGeometry dgs;
    if (bumpMap)
        Bump(bumpMap, dgGeom, dgShading, &dgs);
    else
        dgs = dgShading;
    BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);
    if (regularHalfangleData)
        bsdf->Add(BSDF_ALLOC(arena, RegularHalfangleBRDF)
            (regularHalfangleData, nThetaH, nThetaD, nPhiD));
    else if (thetaPhiData)
        bsdf->Add(BSDF_ALLOC(arena, IrregIsotropicBRDF)(thetaPhiData));
    return bsdf;
}
Example #21
0
// KdSubsurfaceMaterial Method Definitions
BSDF *KdSubsurfaceMaterial::GetBSDF(const DifferentialGeometry &dgGeom,
              const DifferentialGeometry &dgShading,
              MemoryArena &arena) const {
    // Allocate _BSDF_, possibly doing bump mapping with _bumpMap_
    DifferentialGeometry dgs;
    if (bumpMap)
        Bump(bumpMap, dgGeom, dgShading, &dgs);
    else
        dgs = dgShading;
    BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);
    Spectrum R = Kr->Evaluate(dgs).Clamp();
    float ior = index->Evaluate(dgs);
    if (!R.IsBlack())
        bsdf->Add(BSDF_ALLOC(arena, SpecularReflection)(R,
            BSDF_ALLOC(arena, FresnelDielectric)(1., ior)));
    return bsdf;
}
Example #22
0
BSDF *MetalMaterial::GetBSDF(const DifferentialGeometry &dgGeom,
        const DifferentialGeometry &dgShading, MemoryArena &arena) const {
    // Allocate _BSDF_, possibly doing bump mapping with _bumpMap_
    DifferentialGeometry dgs;
    if (bumpMap)
        Bump(bumpMap, dgGeom, dgShading, &dgs);
    else
        dgs = dgShading;
    BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);

	float rough = roughness->Evaluate(dgs);
	MicrofacetDistribution *md = BSDF_ALLOC(arena, Blinn)(1.f / rough);

	Fresnel *frMf = BSDF_ALLOC(arena, FresnelConductor)(eta->Evaluate(dgs),
		k->Evaluate(dgs));
	bsdf->Add(BSDF_ALLOC(arena, Microfacet)(1., frMf, md));
    return bsdf;
}
// Matte Method Definitions
BSDF *danMatte::GetBSDF(const DifferentialGeometry &dgGeom,
		const DifferentialGeometry &dgShading) const {
	// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
	DifferentialGeometry dgs;
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	// Evaluate textures for _Matte_ material and allocate BRDF
	Spectrum r = Kd->Evaluate(dgs).Clamp();
	float sig = Clamp(sigma->Evaluate(dgs), 0.f, 90.f);
	if (sig == 0.)
		bsdf->Add(BSDF_ALLOC(Lambertian)(r));
	else
		bsdf->Add(BSDF_ALLOC(OrenNayar)(r, sig));
	return bsdf;
	return bsdf;
}
Example #24
0
BSSRDF *KdSubsurfaceMaterial::GetBSSRDF(const DifferentialGeometry &dgGeom,
              const DifferentialGeometry &dgShading,
              MemoryArena &arena) const {
    float ior = index->Evaluate(dgShading);
    float mfp = meanfreepath->Evaluate(dgShading);
    Spectrum kd = Kd->Evaluate(dgShading).Clamp();
    Spectrum sigma_a, sigma_prime_s;
    SubsurfaceFromDiffuse(kd, mfp, ior, &sigma_a, &sigma_prime_s);
    return BSDF_ALLOC(arena, BSSRDF)(sigma_a, sigma_prime_s, ior);
}
BSDF *custom_material_matte::GetBSDF(const DifferentialGeometry &dgGeom,
		const DifferentialGeometry &dgShading) const {
	
	//not sure about this yet
	DifferentialGeometry dgs=dgShading;
	
	//or this:
	//allocate memory for BSDF, poiting bsdf to a new BSDF
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	
	//allocate to diff a custom BxDF with reflection spectrum kd
	Spectrum kd = Kd->Evaluate(dgs).Clamp();
	BxDF *diff = BSDF_ALLOC(custom_BxDF_Lambertian)(kd);
		
	//add both diff and spec BSDFS to the BSDF of this material
	bsdf->Add(diff);
	
	return bsdf;
}
// Plastic Method Definitions
BSDF *plastic_dan::GetBSDF(const DifferentialGeometry &dgGeom,
		const DifferentialGeometry &dgShading) const {
	// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
	DifferentialGeometry dgs;
	if (bumpMap)
		Bump(bumpMap, dgGeom, dgShading, &dgs);
	else
		dgs = dgShading;
	BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
	Spectrum kd = Kd->Evaluate(dgs).Clamp();
	BxDF *diff = BSDF_ALLOC(Lambertian)(kd);
	Fresnel *fresnel =
		BSDF_ALLOC(FresnelDielectric)(1.5f, 1.f);
	Spectrum ks = Ks->Evaluate(dgs).Clamp();
	float rough = roughness->Evaluate(dgs);
	BxDF *spec = BSDF_ALLOC(Microfacet)(ks, fresnel,
		BSDF_ALLOC(Blinn)(1.f / rough));
	bsdf->Add(diff);
	bsdf->Add(spec);
	return bsdf;
}
BSDF *SkinSubsurfaceMaterial::GetBSDF(const DifferentialGeometry &dgGeom,
                const DifferentialGeometry &dgShading,
                MemoryArena &arena) const {
     DifferentialGeometry dgs;
    if (bumpMap)
        Bump(bumpMap, dgGeom, dgShading, &dgs);
    else
        dgs = dgShading;
    BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);
    
    Spectrum kd = Kd->Evaluate(dgs).Clamp();
    if (!kd.IsBlack()){
        BxDF *diff = BSDF_ALLOC(arena, Lambertian)(kd);
        bsdf->Add(diff);
    }
    
    float e = eta->Evaluate(dgs);
    Fresnel *fresnel = BSDF_ALLOC(arena,FresnelDielectric)(1.,e);
    float rough = 0.35f;
    BxDF *spec = BSDF_ALLOC(arena,Microfacet)(rho_s, fresnel, BSDF_ALLOC(arena, Beckmann)(rough));
    bsdf->Add(spec);
    return bsdf;
}
// SubsurfaceMaterial Method Definitions
BSDF *SubsurfaceMaterial::GetBSDF(const DifferentialGeometry &dgGeom,
        const DifferentialGeometry &dgShading, MemoryArena &arena) const {
    // Allocate _BSDF_, possibly doing bump mapping with _bumpMap_
    DifferentialGeometry dgs;
    
    // Trisha: This is a hack-y way to determine if we should use the NormalMap over the BumpMap. If the NormalMap is zero at this pixel value, we skip over it.
    Spectrum normalSpectrum = normalMap->Evaluate(dgShading);
    
    if (!normalSpectrum.IsBlack())
        NormalMap(normalMap, dgGeom, dgShading, &dgs);
    else if (bumpMap)
        Bump(bumpMap, dgGeom, dgShading, &dgs);
    else
        dgs = dgShading;
    
    BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);
    Spectrum R = Kr->Evaluate(dgs).Clamp();
    float e = eta->Evaluate(dgs);
    if (!R.IsBlack())
        bsdf->Add(BSDF_ALLOC(arena, SpecularReflection)(R,
            BSDF_ALLOC(arena, FresnelDielectric)(1., e)));
    return bsdf;
}
Example #29
0
// UberMaterial Method Definitions
BSDF *UberMaterial::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading, MemoryArena &arena) const {
    // Allocate _BSDF_, possibly doing bump mapping with _bumpMap_
    DifferentialGeometry dgs;
    if (bumpMap)
        Bump(bumpMap, dgGeom, dgShading, &dgs);
    else
        dgs = dgShading;
    BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);

    Spectrum op = opacity->Evaluate(dgs).Clamp();
    if (op != Spectrum(1.)) {
        BxDF *tr = BSDF_ALLOC(arena, SpecularTransmission)(-op + Spectrum(1.), 1., 1.);
        bsdf->Add(tr);
    }

    Spectrum kd = op * Kd->Evaluate(dgs).Clamp();
    if (!kd.IsBlack()) {
        BxDF *diff = BSDF_ALLOC(arena, Lambertian)(kd);
        bsdf->Add(diff);
    }

    float e = eta->Evaluate(dgs);
    Spectrum ks = op * Ks->Evaluate(dgs).Clamp();
    if (!ks.IsBlack()) {
        Fresnel *fresnel = BSDF_ALLOC(arena, FresnelDielectric)(e, 1.f);
        float rough = roughness->Evaluate(dgs);
        BxDF *spec = BSDF_ALLOC(arena, Microfacet)(ks, fresnel, BSDF_ALLOC(arena, Blinn)(1.f / rough));
        bsdf->Add(spec);
    }

    Spectrum kr = op * Kr->Evaluate(dgs).Clamp();
    if (!kr.IsBlack()) {
        Fresnel *fresnel = BSDF_ALLOC(arena, FresnelDielectric)(e, 1.f);
        bsdf->Add(BSDF_ALLOC(arena, SpecularReflection)(kr, fresnel));
    }

    Spectrum kt = op * Kt->Evaluate(dgs).Clamp();
    if (!kt.IsBlack())
        bsdf->Add(BSDF_ALLOC(arena, SpecularTransmission)(kt, e, 1.f));

    return bsdf;
}
Example #30
0
// GlassMaterial Method Definitions
BSDF *GlassMaterial::GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading, MemoryArena &arena) const {
    DifferentialGeometry dgs;
    
    // Trisha: This is a hack-y way to determine if we should use the NormalMap over the BumpMap. If the NormalMap is zero at this pixel value, we skip over it.
    Spectrum normalSpectrum = normalMap->Evaluate(dgShading);
    
    if (!normalSpectrum.IsBlack())
        NormalMap(normalMap, dgGeom, dgShading, &dgs);
    else if (bumpMap)
        Bump(bumpMap, dgGeom, dgShading, &dgs);
    else
        dgs = dgShading;
    
    float ior = index->Evaluate(dgs);
    BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn, ior);
    Spectrum R = Kr->Evaluate(dgs).Clamp();
    Spectrum T = Kt->Evaluate(dgs).Clamp();
    if (!R.IsBlack())
        bsdf->Add(BSDF_ALLOC(arena, SpecularReflection)(R,
            BSDF_ALLOC(arena, FresnelDielectric)(1., ior)));
    if (!T.IsBlack())
        bsdf->Add(BSDF_ALLOC(arena, SpecularTransmission)(T, 1., ior));
    return bsdf;
}