예제 #1
0
Reference<Material> MakeMaterial(const string &name,
        const Transform &mtl2world,
        const TextureParams &mp) {
    Material *material = NULL;
    if (name == "matte")
        material = CreateMatteMaterial(mtl2world, mp);
    else if (name == "plastic")
        material = CreatePlasticMaterial(mtl2world, mp);
    else if (name == "translucent")
        material = CreateTranslucentMaterial(mtl2world, mp);
    else if (name == "glass")
        material = CreateGlassMaterial(mtl2world, mp);
    else if (name == "mirror")
        material = CreateMirrorMaterial(mtl2world, mp);
    else if (name == "mix") {
        string m1 = mp.FindString("namedmaterial1", "");
        string m2 = mp.FindString("namedmaterial2", "");
        Reference<Material> mat1 = graphicsState.namedMaterials[m1];
        Reference<Material> mat2 = graphicsState.namedMaterials[m2];
        if (!mat1) {
            Error("Named material \"%s\" undefined.  Using \"matte\"",
                  m1.c_str());
            mat1 = MakeMaterial("matte", curTransform[0], mp);
        }
        if (!mat2) {
            Error("Named material \"%s\" undefined.  Using \"matte\"",
                  m2.c_str());
            mat2 = MakeMaterial("matte", curTransform[0], mp);
        }

        material = CreateMixMaterial(mtl2world, mp, mat1, mat2);
    }
    else if (name == "metal")
        material = CreateMetalMaterial(mtl2world, mp);
    else if (name == "substrate")
        material = CreateSubstrateMaterial(mtl2world, mp);
    else if (name == "uber")
        material = CreateUberMaterial(mtl2world, mp);
    else if (name == "skin")
        material = CreateSkinMaterial(mtl2world, mp);
    else if (name == "skindj")
        material = CreateSkinDJMaterial(mtl2world, mp);
    else if (name == "subsurface")
        material = CreateSubsurfaceMaterial(mtl2world, mp);
    else if (name == "skinsubsurface")
        material = CreateSkinSubsurfaceMaterial(mtl2world, mp);
    else if (name == "kdsubsurface")
        material = CreateKdSubsurfaceMaterial(mtl2world, mp);
    else if (name == "measured")
        material = CreateMeasuredMaterial(mtl2world, mp);
    else if (name == "shinymetal")
        material = CreateShinyMetalMaterial(mtl2world, mp);
    else
        Warning("Material \"%s\" unknown.", name.c_str());
    mp.ReportUnused();
    if (!material) Error("Unable to create material \"%s\"", name.c_str());
    return material;
}
예제 #2
0
Reference<Texture<Spectrum> > MakeSpectrumTexture(const string &name,
                                                  const Transform &tex2world, const TextureParams &tp) {
    Texture<Spectrum> *tex = NULL;
    if (name == "constant")
        tex = CreateConstantSpectrumTexture(tex2world, tp);
    else if (name == "scale")
        tex = CreateScaleSpectrumTexture(tex2world, tp);
    else if (name == "mix")
        tex = CreateMixSpectrumTexture(tex2world, tp);
    else if (name == "bilerp")
        tex = CreateBilerpSpectrumTexture(tex2world, tp);
    else if (name == "imagemap")
        tex = CreateImageSpectrumTexture(tex2world, tp);
    else if (name == "uv")
        tex = CreateUVSpectrumTexture(tex2world, tp);
    else if (name == "checkerboard")
        tex = CreateCheckerboardSpectrumTexture(tex2world, tp);
    else if (name == "dots")
        tex = CreateDotsSpectrumTexture(tex2world, tp);
    else if (name == "fbm")
        tex = CreateFBmSpectrumTexture(tex2world, tp);
    else if (name == "wrinkled")
        tex = CreateWrinkledSpectrumTexture(tex2world, tp);
    else if (name == "marble")
        tex = CreateMarbleSpectrumTexture(tex2world, tp);
    else if (name == "windy")
        tex = CreateWindySpectrumTexture(tex2world, tp);
    else
        Warning("Spectrum texture \"%s\" unknown.", name.c_str());
    tp.ReportUnused();
    return tex;
}
예제 #3
0
Reference<Texture<float> > MakeFloatTexture(const string &name,
                                            const Transform &tex2world, const TextureParams &tp) {
    Texture<float> *tex = NULL;
    if (name == "constant")
        tex = CreateConstantFloatTexture(tex2world, tp);
    else if (name == "scale")
        tex = CreateScaleFloatTexture(tex2world, tp);
    else if (name == "mix")
        tex = CreateMixFloatTexture(tex2world, tp);
    else if (name == "bilerp")
        tex = CreateBilerpFloatTexture(tex2world, tp);
    else if (name == "imagemap")
        tex = CreateImageFloatTexture(tex2world, tp);
    else if (name == "uv")
        tex = CreateUVFloatTexture(tex2world, tp);
    else if (name == "checkerboard")
        tex = CreateCheckerboardFloatTexture(tex2world, tp);
    else if (name == "dots")
        tex = CreateDotsFloatTexture(tex2world, tp);
    else if (name == "fbm")
        tex = CreateFBmFloatTexture(tex2world, tp);
    else if (name == "wrinkled")
        tex = CreateWrinkledFloatTexture(tex2world, tp);
    else if (name == "marble")
        tex = CreateMarbleFloatTexture(tex2world, tp);
    else if (name == "windy")
        tex = CreateWindyFloatTexture(tex2world, tp);
    else
        Warning("Float texture \"%s\" unknown.", name.c_str());
    tp.ReportUnused();
    return tex;
}
COREDLL Reference<Texture<Spectrum> > MakeSpectrumTexture(const string &name,
		const Transform &tex2world, const TextureParams &tp) {
	TexturePlugin *plugin = GetPlugin<TexturePlugin>(name, texturePlugins,
		PluginSearchPath);
	if (plugin) {
		Reference<Texture<Spectrum> > ret =
			plugin->CreateSpectrumTex(tex2world, tp);
		tp.ReportUnused();
		return ret;
	}
	return NULL;
}
COREDLL Reference<Material> MakeMaterial(const string &name,
		const Transform &mtl2world,
		const TextureParams &mp) {
	MaterialPlugin *plugin = GetPlugin<MaterialPlugin>(name, materialPlugins,
		PluginSearchPath);
	if (plugin) {
		Reference<Material> ret =
			plugin->CreateMaterial(mtl2world, mp);
		mp.ReportUnused();
		return ret;
	}
	return NULL;
}
예제 #6
0
파일: api.cpp 프로젝트: tdapper/pbrt-v3
std::shared_ptr<Material> MakeMaterial(const std::string &name,
                                       const TextureParams &mp) {
    Material *material = nullptr;
    if (name == "" || name == "none")
        return nullptr;
    else if (name == "matte")
        material = CreateMatteMaterial(mp);
    else if (name == "plastic")
        material = CreatePlasticMaterial(mp);
    else if (name == "translucent")
        material = CreateTranslucentMaterial(mp);
    else if (name == "glass")
        material = CreateGlassMaterial(mp);
    else if (name == "hair")
        material = CreateHairMaterial(mp);
    else if (name == "mirror")
        material = CreateMirrorMaterial(mp);
    else if (name == "mix") {
        std::string m1 = mp.FindString("namedmaterial1", "");
        std::string m2 = mp.FindString("namedmaterial2", "");
        std::shared_ptr<Material> mat1 = graphicsState.namedMaterials[m1];
        std::shared_ptr<Material> mat2 = graphicsState.namedMaterials[m2];
        if (!mat1) {
            Error("Named material \"%s\" undefined.  Using \"matte\"",
                  m1.c_str());
            mat1 = MakeMaterial("matte", mp);
        }
        if (!mat2) {
            Error("Named material \"%s\" undefined.  Using \"matte\"",
                  m2.c_str());
            mat2 = MakeMaterial("matte", mp);
        }

        material = CreateMixMaterial(mp, mat1, mat2);
    } else if (name == "metal")
        material = CreateMetalMaterial(mp);
    else if (name == "substrate")
        material = CreateSubstrateMaterial(mp);
    else if (name == "uber")
        material = CreateUberMaterial(mp);
    else if (name == "subsurface")
        material = CreateSubsurfaceMaterial(mp);
    else if (name == "kdsubsurface")
        material = CreateKdSubsurfaceMaterial(mp);
    else if (name == "fourier")
        material = CreateFourierMaterial(mp);
    else
        Warning("Material \"%s\" unknown.", name.c_str());

    if ((name == "subsurface" || name == "kdsubsurface") &&
        (renderOptions->IntegratorName != "path" &&
         (renderOptions->IntegratorName != "volpath")))
        Warning(
            "Subsurface scattering material \"%s\" used, but \"%s\" "
            "integrator doesn't support subsurface scattering. "
            "Use \"path\" or \"volpath\".",
            name.c_str(), renderOptions->IntegratorName.c_str());

    mp.ReportUnused();
    if (!material) Error("Unable to create material \"%s\"", name.c_str());
    return std::shared_ptr<Material>(material);
}