expand_content

A processor is a component that, after the terrain and all masks are generated, provides some extra steps into the data. These are extracted from the main workflow to ensure compatibility and modularity. Some examples are those that can be found in Chunk Data Processors.

These kinds of processors can:

  • Generate new derived data from preexisting masks or data generated by the graph.
  • Provide alternative ways to create a mesh.
  • Ensure compatibility with other assets by working as a port.
  • Many other options.   The general workflow to create your own Processor goes like this:
  • Decide on what it processes, for example, Chunk Data, and implement the abstract class ChunkProcessor (ChunkProcessor). This will ensure that the component follows the correct lifecycle with the already-existing components, and provide some of the necessary methods to create your own processing.
  • Decide on what it gives, or the end result, for example MeshResult, and implement the interface IGenerate (IGenerate)
  • In case we are working with ChunkData, right after the data is received, it should add itself to the processor list via the AddProcessor. This ensures that the data will not be disposed when being used by other processors.
protected override void OnProcessDone(ChunkData chunk){
    chunk.worldFinalData.AddProcessor(this);
    ChunksToProcess.Add(chunk);
    if(chunk.InstantGeneration)
        UpdateRequests(true);
}

We should remove the component from there after the process is completely done, and the original data can be disposed and returned to the pool.

  • Work with the data.   - We can cache the data and store it into a list so that processes can be done asynchronously   - We can work immediately and make any changes necessary   - We can discard it and just return it to the pool

In this step, it is recommended to look at preexisting implementations to see how other components manage this workflow.

Shader

To create a custom shader, it is recommended to check the Minimal Shader and start from there. Otherwise, you can use any of the preexisting shaders to base your work on. All support has been transitioned to Shader Graph for compatibility reasons.