Exemple #1
0
std::shared_ptr<Light> MakeLight(const std::string &name,
                                 const ParamSet &paramSet,
                                 const Transform &light2world,
                                 const MediumInterface &mediumInterface) {
    std::shared_ptr<Light> light;
    if (name == "point")
        light =
            CreatePointLight(light2world, mediumInterface.outside, paramSet);
    else if (name == "spot")
        light = CreateSpotLight(light2world, mediumInterface.outside, paramSet);
    else if (name == "goniometric")
        light = CreateGoniometricLight(light2world, mediumInterface.outside,
                                       paramSet);
    else if (name == "projection")
        light = CreateProjectionLight(light2world, mediumInterface.outside,
                                      paramSet);
    else if (name == "distant")
        light = CreateDistantLight(light2world, paramSet);
    else if (name == "infinite" || name == "exinfinite")
        light = CreateInfiniteLight(light2world, paramSet);
    else
        Warning("Light \"%s\" unknown.", name.c_str());
    paramSet.ReportUnused();
    return light;
}
Exemple #2
0
// Object Creation Function Definitions
std::vector<std::shared_ptr<Shape>> MakeShapes(const std::string &name,
                                               const Transform *object2world,
                                               const Transform *world2object,
                                               bool reverseOrientation,
                                               const ParamSet &paramSet) {
    std::vector<std::shared_ptr<Shape>> shapes;
    std::shared_ptr<Shape> s;
    if (name == "sphere")
        s = CreateSphereShape(object2world, world2object, reverseOrientation,
                              paramSet);
    // Create remaining single _Shape_ types
    else if (name == "cylinder")
        s = CreateCylinderShape(object2world, world2object, reverseOrientation,
                                paramSet);
    else if (name == "disk")
        s = CreateDiskShape(object2world, world2object, reverseOrientation,
                            paramSet);
    else if (name == "cone")
        s = CreateConeShape(object2world, world2object, reverseOrientation,
                            paramSet);
    else if (name == "paraboloid")
        s = CreateParaboloidShape(object2world, world2object,
                                  reverseOrientation, paramSet);
    else if (name == "hyperboloid")
        s = CreateHyperboloidShape(object2world, world2object,
                                   reverseOrientation, paramSet);
    if (s != nullptr) shapes.push_back(s);

    // Create multiple-_Shape_ types
    else if (name == "curve")
        shapes = CreateCurveShape(object2world, world2object,
                                  reverseOrientation, paramSet);
    else if (name == "trianglemesh")
        shapes = CreateTriangleMeshShape(object2world, world2object,
                                         reverseOrientation, paramSet,
                                         &graphicsState.floatTextures);
    else if (name == "plymesh")
        shapes = CreatePLYMesh(object2world, world2object, reverseOrientation,
                               paramSet, &graphicsState.floatTextures);
    else if (name == "heightfield")
        shapes = CreateHeightfield(object2world, world2object,
                                   reverseOrientation, paramSet);
    else if (name == "loopsubdiv")
        shapes = CreateLoopSubdiv(object2world, world2object,
                                  reverseOrientation, paramSet);
    else if (name == "nurbs")
        shapes = CreateNURBS(object2world, world2object, reverseOrientation,
                             paramSet);
    else
        Warning("Shape \"%s\" unknown.", name.c_str());
    paramSet.ReportUnused();
    return shapes;
}
Exemple #3
0
std::shared_ptr<Primitive> MakeAccelerator(
    const std::string &name,
    const std::vector<std::shared_ptr<Primitive>> &prims,
    const ParamSet &paramSet) {
    std::shared_ptr<Primitive> accel;
    if (name == "bvh")
        accel = CreateBVHAccelerator(prims, paramSet);
    else if (name == "kdtree")
        accel = CreateKdTreeAccelerator(prims, paramSet);
    else
        Warning("Accelerator \"%s\" unknown.", name.c_str());
    paramSet.ReportUnused();
    return accel;
}
Exemple #4
0
std::shared_ptr<AreaLight> MakeAreaLight(const std::string &name,
                                         const Transform &light2world,
                                         const MediumInterface &mediumInterface,
                                         const ParamSet &paramSet,
                                         const std::shared_ptr<Shape> &shape) {
    std::shared_ptr<AreaLight> area;
    if (name == "area" || name == "diffuse")
        area = CreateDiffuseAreaLight(light2world, mediumInterface.outside,
                                      paramSet, shape);
    else
        Warning("Area light \"%s\" unknown.", name.c_str());
    paramSet.ReportUnused();
    return area;
}
Exemple #5
0
COREDLL void pbrtShape(const string &name,
                       const ParamSet &params) {
	VERIFY_WORLD("Shape");
	Reference<Shape> shape = MakeShape(name,
		curTransform, graphicsState.reverseOrientation,
		params);
	if (!shape) return;
	params.ReportUnused();
	// Initialize area light for shape
	AreaLight *area = NULL;
	if (graphicsState.areaLight != "")
		area = MakeAreaLight(graphicsState.areaLight,
		curTransform, graphicsState.areaLightParams, shape);
	// Initialize material for shape
	TextureParams mp(params,
	                 graphicsState.materialParams,
					 graphicsState.floatTextures,
					 graphicsState.spectrumTextures);
	Reference<Texture<float> > bump = NULL;
	Reference<Material> mtl;
	string Default = "duh";
	if(graphicsState.materialParams.FindOneString("reradiation", Default).compare(Default) != 0)
	{
		mtl = MakeMaterial(graphicsState.material, curTransform, mp);
	}else{
		mtl = MakeMaterial(graphicsState.material, curTransform, mp, &(graphicsState.materialParams));
	}
	if (!mtl)
		mtl = MakeMaterial("matte", curTransform, mp);
	if (!mtl)
		Severe("Unable to create \"matte\" material?!");
	// Create primitive and add to scene or current instance
	Reference<Primitive> prim =
		new GeometricPrimitive(shape, mtl, area);
	if (renderOptions->currentInstance) {
		if (area)
			Warning("Area lights not supported "
			        "with object instancing");
		renderOptions->currentInstance->push_back(prim);
	}
	else {
		renderOptions->primitives.push_back(prim);
		if (area != NULL) {
			// Add area light for primitive to light vector
			renderOptions->lights.push_back(area);
		}
	}
}
Exemple #6
0
std::shared_ptr<Medium> MakeMedium(const std::string &name,
                                   const ParamSet &paramSet,
                                   const Transform &medium2world) {
    Float sig_a_rgb[3] = {.0011f, .0024f, .014f},
          sig_s_rgb[3] = {2.55f, 3.21f, 3.77f};
    Spectrum sig_a = Spectrum::FromRGB(sig_a_rgb),
             sig_s = Spectrum::FromRGB(sig_s_rgb);
    std::string preset = paramSet.FindOneString("preset", "");
    bool found = GetMediumScatteringProperties(preset, &sig_a, &sig_s);
    if (preset != "" && !found)
        Warning("Material preset \"%s\" not found.  Using defaults.",
                preset.c_str());
    Float scale = paramSet.FindOneFloat("scale", 1.f);
    Float g = paramSet.FindOneFloat("g", 0.0f);
    sig_a = paramSet.FindOneSpectrum("sigma_a", sig_a) * scale;
    sig_s = paramSet.FindOneSpectrum("sigma_s", sig_s) * scale;
    Medium *m = NULL;
    if (name == "homogeneous") {
        m = new HomogeneousMedium(sig_a, sig_s, g);
    } else if (name == "heterogeneous") {
        int nitems;
        const Float *data = paramSet.FindFloat("density", &nitems);
        if (!data) {
            Error("No \"density\" values provided for heterogeneous medium?");
            return NULL;
        }
        int nx = paramSet.FindOneInt("nx", 1);
        int ny = paramSet.FindOneInt("ny", 1);
        int nz = paramSet.FindOneInt("nz", 1);
        Point3f p0 = paramSet.FindOnePoint3f("p0", Point3f(0.f, 0.f, 0.f));
        Point3f p1 = paramSet.FindOnePoint3f("p1", Point3f(1.f, 1.f, 1.f));
        if (nitems != nx * ny * nz) {
            Error(
                "GridDensityMedium has %d density values; expected nx*ny*nz = "
                "%d",
                nitems, nx * ny * nz);
            return NULL;
        }
        Transform data2Medium = Translate(Vector3f(p0)) *
                                Scale(p1.x - p0.x, p1.y - p0.y, p1.z - p0.z);
        m = new GridDensityMedium(sig_a, sig_s, g, nx, ny, nz,
                                  medium2world * data2Medium, data);
    } else
        Warning("Medium \"%s\" unknown.", name.c_str());
    paramSet.ReportUnused();
    return std::shared_ptr<Medium>(m);
}
Exemple #7
0
void Context::PortalShape(const string &n, const ParamSet &params) {
	VERIFY_WORLD("PortalShape");
	renderFarm->send("luxPortalShape", n, params);
	boost::shared_ptr<Primitive> sh(MakeShape(n, curTransform.StaticTransform(),
		graphicsState->reverseOrientation, params));
	if (!sh)
		return;
	params.ReportUnused();

	if (graphicsState->currentLight != "") {
		if (graphicsState->currentLightPtr0)
			graphicsState->currentLightPtr0->AddPortalShape(sh);

		if (graphicsState->currentLightPtr1)
			graphicsState->currentLightPtr1->AddPortalShape(sh);
	}
}
Exemple #8
0
// Object Creation Function Definitions
Reference<Shape> MakeShape(const string &name,
                           const Transform *object2world, const Transform *world2object,
                           bool reverseOrientation, const ParamSet &paramSet) {
    Shape *s = NULL;

    if (name == "sphere")
        s = CreateSphereShape(object2world, world2object,
                              reverseOrientation, paramSet);
    // Create remaining _Shape_ types
    else if(name == "wavefront")
        s = CreateWaveFrontShape(object2world, world2object, reverseOrientation,
                                 paramSet);

    else if (name == "cylinder")
        s = CreateCylinderShape(object2world, world2object, reverseOrientation,
                                paramSet);
    else if (name == "disk")
        s = CreateDiskShape(object2world, world2object, reverseOrientation,
                            paramSet);
    else if (name == "cone")
        s = CreateConeShape(object2world, world2object, reverseOrientation,
                            paramSet);
    else if (name == "paraboloid")
        s = CreateParaboloidShape(object2world, world2object, reverseOrientation,
                                  paramSet);
    else if (name == "hyperboloid")
        s = CreateHyperboloidShape(object2world, world2object, reverseOrientation,
                                   paramSet);
    else if (name == "trianglemesh")
        s = CreateTriangleMeshShape(object2world, world2object, reverseOrientation,
                                    paramSet, &graphicsState.floatTextures);
    else if (name == "heightfield")
        s = CreateHeightfieldShape(object2world, world2object, reverseOrientation,
                                   paramSet);
    else if (name == "loopsubdiv")
        s = CreateLoopSubdivShape(object2world, world2object, reverseOrientation,
                                  paramSet);
    else if (name == "nurbs")
        s = CreateNURBSShape(object2world, world2object, reverseOrientation,
                             paramSet);
    else
        Warning("Shape \"%s\" unknown.", name.c_str());
    paramSet.ReportUnused();
    return s;
}
Exemple #9
0
std::unique_ptr<Filter> MakeFilter(const std::string &name,
                                   const ParamSet &paramSet) {
    Filter *filter = nullptr;
    if (name == "box")
        filter = CreateBoxFilter(paramSet);
    else if (name == "gaussian")
        filter = CreateGaussianFilter(paramSet);
    else if (name == "mitchell")
        filter = CreateMitchellFilter(paramSet);
    else if (name == "sinc")
        filter = CreateSincFilter(paramSet);
    else if (name == "triangle")
        filter = CreateTriangleFilter(paramSet);
    else
        Warning("Filter \"%s\" unknown.", name.c_str());
    paramSet.ReportUnused();
    return std::unique_ptr<Filter>(filter);
}
Exemple #10
0
std::shared_ptr<Sampler> MakeSampler(const std::string &name,
                                     const ParamSet &paramSet,
                                     const Film *film) {
    Sampler *sampler = nullptr;
    if (name == "lowdiscrepancy" || name == "02sequence")
        sampler = CreateZeroTwoSequenceSampler(paramSet);
    else if (name == "maxmindist")
        sampler = CreateMaxMinDistSampler(paramSet);
    else if (name == "halton")
        sampler = CreateHaltonSampler(paramSet, film->GetSampleBounds());
    else if (name == "sobol")
        sampler = CreateSobolSampler(paramSet, film->GetSampleBounds());
    else if (name == "random")
        sampler = CreateRandomSampler(paramSet);
    else if (name == "stratified")
        sampler = CreateStratifiedSampler(paramSet);
    else
        Warning("Sampler \"%s\" unknown.", name.c_str());
    paramSet.ReportUnused();
    return std::shared_ptr<Sampler>(sampler);
}
Exemple #11
0
void Context::Shape(const string &n, const ParamSet &params) {
	VERIFY_WORLD("Shape");
	renderFarm->send("luxShape", n, params);
	const u_int sIdx = shapeNo++;
	u_int nItems;
	const string *sn = params.FindString("name", &nItems);
	if (!sn || *sn == "") {
		// generate name based on shape type and declaration index
		std::stringstream ss("");
		ss << "#" << sIdx << " (" << n << ")";
		const string sname = ss.str();
		const_cast<ParamSet &>(params).AddString("name", &sname);
	} else if (sn) {
		const string sname = "'" + *sn + "'";
		const_cast<ParamSet &>(params).AddString("name", &sname);
	}
	boost::shared_ptr<lux::Shape> sh(MakeShape(n, curTransform.StaticTransform(),
		graphicsState->reverseOrientation, params));
	if (!sh)
		return;
	params.ReportUnused();

	// Lotus - Set the material
	if (graphicsState->material)
		sh->SetMaterial(graphicsState->material);
	else {
		boost::shared_ptr<lux::Material> m(MakeMaterial("matte",
			curTransform.StaticTransform(), ParamSet()));
		sh->SetMaterial(m);
	}
	sh->SetExterior(graphicsState->exterior);
	sh->SetInterior(graphicsState->interior);

	// Create primitive and add to scene or current instance
	if (renderOptions->currentInstanceRefined) {
		if (graphicsState->areaLight != "") {
			LOG(LUX_WARNING,LUX_UNIMPLEMENT)<<"Area lights not supported with object instancing";
/*			// Lotus - add a decorator to set the arealight field
			boost::shared_ptr<Primitive> prim(
				new AreaLightPrimitive(pr, area));
			if (!prim->CanIntersect())
				prim->Refine(*(renderOptions->currentInstance),
					PrimitiveRefinementHints(false), prim);
			else
				renderOptions->currentInstance->push_back(prim);
			// Add area light for primitive to light vector
			renderOptions->currentLightInstance->push_back(area);*/
		} /*else*/ {
			renderOptions->currentInstanceSource->push_back(sh);
			if (!sh->CanIntersect())
				sh->Refine(*(renderOptions->currentInstanceRefined),
					PrimitiveRefinementHints(false), sh);
			else
				renderOptions->currentInstanceRefined->push_back(sh);
		}
	} else if (graphicsState->areaLight != "") {
		u_int lg = GetLightGroup();
		AreaLight *area = MakeAreaLight(graphicsState->areaLight,
			curTransform.StaticTransform(),
			graphicsState->areaLightParams, sh);
		if (area) {
			area->group = lg;
			area->SetVolume(graphicsState->exterior); //unused
		}
		// Lotus - add a decorator to set the arealight field
		boost::shared_ptr<Primitive> pr(sh);
		boost::shared_ptr<Primitive> prim(new AreaLightPrimitive(pr,
			area));
		renderOptions->primitives.push_back(prim);
		// Add area light for primitive to light vector
		renderOptions->lights.push_back(area);
	} else
		renderOptions->primitives.push_back(sh);
}