Render targets define the form of the final rendered output you want to create when you render your scene.
Most types of render targets require you to specify one or more bake instances: mesh instances (or point clouds) in your scene for which the output specified by the target will be created. A target without bake instances will not actually render any output (except for camera targets; see below).
Beast supports several different types of render targets, described in the following sections. The type of render target you should use depends on how you plan to use the rendered data in your game, and on the type of objects you are baking (mesh instance or point clouds).
The texture target bakes the lighting information for one or more mesh instances into a single output texture. All mesh instances that you add to the texture target are baked together into a single UV space.
The texture target supports all types of render passes.
To create a texture target, call the ILBCreateTextureTarget() function. In your call, you need to specify the width and height of the final texture that will be generated to hold the baked lightmap.
In addition, you can use the following API functions to configure each bake instance you add to your texture target:
The atlased texture target bakes its instances together into a single texture like the texture target, but places the lightmap generated for each instance into an unoccupied area of UV space. If the number of baked lightmaps exceeds the UV space available in the output resolution set for the target, the atlased texture target will create additional output textures as necessary. The layout of the UV space in the output textures is atlased, so that you can retrieve the UV coordinates for each instance.
The atlased texture target supports all types of render passes.
To create an atlased texture target, call the ILBCreateAtlasedTextureTarget() function.
In addition, you can use the following API functions to configure your atlased texture target. See the function descriptions for details.
The resolution for each target is re-scaled relative to a frequency threshold. If the frequency of the lighting data for the target is above this value, the resolution of the target's lightmap is not decreased. If the frequency is below this value, the resolution of the target's lightmap is scaled downward relative to the threshold. By default, the re-scaling threshold is set to 1.0, but you can customize it by calling by calling ILBSetAtlasRescaleFrequencyThreshold().
You can use the following API functions to configure each bake instance that you add to your atlased texture target. See the function descriptions for details.
The vertex target bakes lighting information for each vertex in the mesh instances that you add to the vertex target. The output is a list of values for each vertex, in the same order in which the vertices were added to your mesh.
The vertex target supports all types of render passes.
To create a vertex target, call the ILBCreateVertexTarget() function.
The point cloud target bakes lighting information for a point cloud. It works like the vertex target, but instead of generating and returning lighting data for each vertex in a mesh, it generates the data for each point in the point clouds that you set up for the target.
Supported passes are Illumination SH and Lua.
To create a point cloud target, call the ILBCreatePointCloudTarget() function.
The camera target renders a still image of the scene as seen from the point of view of a specific camera in the scene.
The only type of render pass supported by the camera target is the full shading pass.
To create a camera target, call the ILBCreateCameraTarget() function. In your call, you need to specify the camera that will be used to generate the image, and the width and height of the image.
When creating a live camera target, you can specify the target as a standard frame render or a special bake mode. The bake mode will result in a frame buffer from the point-of-view of the camera, but is actually baking texture and vertex lightmap targets in the view. The camera mode is chosen using ILBCameraTargetSetRenderMode().
You set up render targets in the context of setting up and running a rendering job. For more information about how to set up a render target in the overall context of rendering a scene, see Rendering the Scene.
For each bake instance that you want to set up for your target:
ILBTargetHandle atlasTarget; ILBCreateAtlasedTextureTarget(job, _T("atlasTarget"), 512, 512, 0, &atlasTarget); for (size_t i = 0; i < myMeshInstances.size(); i++) { ILBTargetEntityHandle entity; ILBAddBakeInstance(atlasTarget, myMeshInstances[i], &entity); } ILBTargetEntityHandle entity; ILBAddBakeInstance(atlasTarget, floorInstance, &entity); ILBSetBakeResolution(entity, 128, 128);
You can enable a world-space filter for preview baking of texture and vertex targets. This filter smooths over noise, UV seams, and seams between objects with adjacent surfaces.
To enable the filter, you call the ILBEnableWorldSpaceFilter() function, and specify the target and the type of light component you want to filter. For example, to set up the filter for indirect light:
ILBEnableWorldSpaceFilter(target, ILB_WSFC_INDIRECT);
The size of the filter automatically adapts to the resolution and variance of your baking target. However, you may occasionally find that you get better results by tweaking its kernel size. Use the ILBSetWorldSpaceFilterSize() function. For example:
ILBSetWorldSpaceFilterSize(target, ILB_WSFC_INDIRECT, 2.0f);
The default filter size is 1.0. Therefore, specifying 2.0 as in the example above doubles the radius of the filter kernel.
API functions related to the creation and setup of render targets are declared in the beasttarget.h and beasttargetentity.h files.