# In-depth pipeline
RenderGraph is a mechanism for recommending custom pipelines provided by the small game framework to developers, and the future development direction is also the same. By then, it will become a complete resource and will continue to be optimized.
However, developers may still want to understand some of the lower-level mechanisms and make more in-depth customizations. The mini game framework also provides such interfaces. In fact, these more in-depth content may also be used when customizing nodes.
# A little thought
Before the text, we can think about a question-what is the rendering pipeline. This has different answers at different levels. For the application layer, what it cares about is how to manage graphics resources, and then filter and draw them, so the simplest abstraction of the rendering pipeline is:
Start of one frame -> Set rendering target -> Clear screen -> Prepare to render list -> Use list to render -> End of one frame
Of course, the content in the beginning of a frame and the end of a frame can be very scalable, but in theory, as long as these basic functions are available, you can build a rendering of any complexity Process.
The small game framework provides these capabilities through several interfaces, which is also the foundation of RenderGraph.
# renderEnv
Some methods are on renderEnv
:
- beginFrame: start a frame.
- endFrame: end a frame.
- setRenderTarget: Set the current rendering target to be drawn.
- clearView: Use a View to clear the rendering target currently in use.
# Camera
Another part of the method is on top of camera
, which provides:
- Cull: Use the camera to cull the current scene.
- clear: directly use the camera's View to clear the screen of the current scene, which is equivalent to the
renderEnv.clearView
operation. - draw: Use the camera to draw a batch of objects to the current rendering target.
- drawLight: Use the camera to draw a shadow map generated by a certain parallel light.
# Use Cases
The following is an example of implementing a simple pipeline directly using the underlying interface:
// Create a rendering list
const renderList = new engine.ScalableList(1024);
// The following is the loop of each frame
// start a frame
engine.renderEnv.beginFrame();
// Set the render target
engine.renderEnv.setRenderTarget(camera.renderTarget);
// Remove the scene and save it to the rendering list
camera.cull(renderList,'ForwardBase');
// Clear the render target
camera.clear();
// draw
camera.draw(renderList,'ForwardBase');
// end a frame
engine.renderEnv.endFrame();