Radeon ProRender

Textured Material Creation

Materials are shaders that are attached to rpr_shape meshes for texture and shading.

There is a large number of shader nodes that can be used. Nodes are atomic pieces of shaders which calculate an output color based on inputs. Inputs can be floating point values, textures or even other nodes. By connecting nodes together with inputs, a “node tree” can be formed which calculates a complex material.

In this case we create an image texture with a image map of scratches. The image texture is set as the “data” input of a texture node RPR_MATERIAL_NODE_IMAGE_TEXTURE. That Texture node is then set as the “color” input of a diffuse shader - RPR_MATERIAL_NODE_DIFFUSE. The final shader of a node tree is attached to a shape with rprShapeSetMaterial().

rpr_material_node diffuse1;
{
	rpr_image img1;
	const std::string pathImageFileA = "../../Resources/Textures/scratched.png";
	status = rprContextCreateImageFromFile(context, pathImageFileA.c_str(), &img1);
	if (status == RPR_ERROR_IO_ERROR)
	{
		std::cout << "Error : " << pathImageFileA << " not found.\n";
		return -1;
	}
	assert(status == RPR_SUCCESS);

	rpr_material_node tex;
	CHECK(rprMaterialSystemCreateNode(matsys, RPR_MATERIAL_NODE_IMAGE_TEXTURE, &tex));

	// Set image data.
	CHECK(rprMaterialNodeSetInputImageData(tex, "data", img1));

	CHECK(rprMaterialSystemCreateNode(matsys, RPR_MATERIAL_NODE_DIFFUSE, &diffuse1));

	// Set diffuse color parameter to gray.
	CHECK(rprMaterialNodeSetInputN(diffuse1, "color", tex));

	CHECK(rprShapeSetMaterial(plane, diffuse1));
}