This is the documentation for Enlighten.

Debugging with IClusteringOutput

The IClusteringOutput object contains the following:

  • Mesh data that can be used to render the leaf clusters
  • Positions and normals for each of the duster points
  • Internal data, used to develop the algorithms

The items of interest are the first two: cluster meshes and duster points.

Loading the data

Usually at runtime you simply create a new IClusteringOutput object, and serialise the data into it.

IClusteringOutput* clustering = LoadInterface<IClusteringOutput>("<myfilename>");

If you are not using the LoadInterface helper functions, call Create and then Load yourself.

Cluster meshes

There is one GeoTriangleList for each leaf mesh. Each triangle is just three vertex locations. Converting this into a format that is suitable for rendering is an implementation issue.

Duster points

For each cluster there is also a list of duster point locations and normals. The indices of these correspond to the dusters in the radCore.

Sample code

The following code fills the data object with the triangle vertices, and a colour for each cluster that is the colour of the cluster input lighting. This very useful visualisation shows how the input lighting is being applied to the system. If you just want to see clusters, use a random colour instead of extracting duster lighting.

s32 litPoints	= Enlighten::GetNumberOfPointsInInputWorkspace(workspace);
s32 litClusters	= Enlighten::GetNumberOfClustersInInputWorkspace(workspace);

GEO_ASSERT(clustering->GetNumLeafClusters() == litClusters);

Enlighten::InputWorkspaceDebugPoint debugPoint;
s32 duster = 0;
for (s32 n=0; n<clustering->GetNumLeafClusters(); n++)
{
	// Copy triangle position data
	data.ClusterTriangles[n] = clustering->GetClusterMesh(n);

	// Extract triangle colour data
	Enlighten::GetInputWorkspaceLitDebugPoint(workspace, &debugPoint, duster, lightingBuffer);
	data.ClusterColours[n] = VConstruct(
		debugPoint.m_LightValue[0],			// red colour for cluster n
		debugPoint.m_LightValue[1],			// green colour for cluster n
		debugPoint.m_LightValue[2],			// blue colour for cluster n
		1.0f);

	s32 dusterCount = clustering->GetDusterPoints(n)->GetSize();
	duster += dusterCount;
}
GEO_ASSERT(duster == litPoints);

Note that all dusters within a cluster have the same input lighting, so you need to read only one of them per cluster. Then increment the system-wide duster index by the number of dusters in this cluster.