|
| 1 | +# Custom Render Pipelines |
| 2 | + |
| 3 | +To create a custom render pipeline, first create a new RenderPipeline asset in the **Assets** panel, then create a RenderPipeline script, and then select the corresponding RenderPipeline script in the Pipeline asset to edit the corresponding properties. |
| 4 | + |
| 5 | +RenderFlow and RenderStage are created and edited in the same way. In the created Pipeline script, add properties and make them editable in the **Inspector** panel just like any other user script, but note that it is not an option to drag and drop entities in the scene, as the RenderPipeline is not bound to a specific scene. |
| 6 | + |
| 7 | +## Properties and methods in RenderPipeline |
| 8 | + |
| 9 | +- `flows`: The RenderFlow contained in the RenderPipeline. |
| 10 | + |
| 11 | +- `renderTextures`: the RenderTextures that can be created when the RenderPipeline is started. |
| 12 | + |
| 13 | + - `name`: the name of the RenderTexture, which can be obtained by the `getRenderTexture` function of the RenderPipeline after creation. |
| 14 | + - `type`: the type of the RenderTexture. |
| 15 | + - `viewType`: the corresponding TextureView type of the RenderTexture. |
| 16 | + - `usage`: the binding type of the RenderTexture, used to determine whether it is `color` or `depth_stencil`. |
| 17 | + - `formate`: the channel format of the RenderTexture. |
| 18 | + - `width`: width of the RenderTexture, -1 means the width of the window. |
| 19 | + - `height`: height of the RenderTexture, -1 means the height of the window. |
| 20 | + |
| 21 | +- `framebuffers`: the FrameBuffer that can be created when RenderPipeline starts. |
| 22 | + |
| 23 | + - `name`: the name of the FrameBuffer, it can be retrieved by the `getFrameBuffer` function of RenderPipeline after creation. |
| 24 | + - `renderPass`: the ID of the RenderPass configured in the RenderPipeline. |
| 25 | + - `colorViews`: TextureView bound to the ColorAttachment, specifying the RenderTexture configured in the RenderPipeline. |
| 26 | + - `depthStencilView`: TextureView bound to DepthStencilAttachment. specifies the RenderTexture configured in the RenderPipeline. |
| 27 | +- `renderPasses`: the RenderPasses that can be created when the RenderPipeline is started. |
| 28 | + - `index`: ID of the RenderPass, which can be obtained by the `getRenderPass` function of the RenderPipeline. |
| 29 | + - `colorAttachments`: the description of the ColorAttachment, the operation of the ColorAttachment when drawing the FrameBuffer. |
| 30 | + - `depthStencilAttachment`: the description of the DepthStencilAttachment, the operation of the DepthStencilAttachment when drawing the FrameBuffer. |
| 31 | + |
| 32 | +- `getTextureView` (name: string), `getRenderTexture` (name: string): get the RenderTexture configured in renderTextures. |
| 33 | +- `getFrameBuffer` (name: string): get the FrameBuffer configured in `framebuffers`. |
| 34 | +- `getRenderPass` (stage: number): get the RenderPass configured in renderPasses. |
| 35 | +- `initialize` (info: IRenderPipelineInfo): initialize function for creating a RenderPipeline by script, the RenderPipeline must be initialized before it can be used. |
| 36 | +- `activate` (root: Root): initialization function used when loading a RenderPipeline through an asset. |
| 37 | +- `render` (view: RenderView): logic for rendering the scene. |
| 38 | +- `updateUBOs` (view: RenderView): update the global UniformBuffer. |
| 39 | +- `sceneCulling` (view: RenderView): scene culling, renderable objects are saved in `_renderObjects` after culling. |
| 40 | + |
| 41 | +## Properties and methods in RenderFlow |
| 42 | + |
| 43 | +- `name`: the name of the RenderFlow. |
| 44 | +- `priority`: the order of execution of the RenderFlow in the RenderPipeline. |
| 45 | +- `type`: the type of the RenderFlow. |
| 46 | + - `SCENE`: used to draw the scene, this type will be executed for each camera. |
| 47 | + - `POSTPROCESS`: post-processing, this type is specified separately for each camera. |
| 48 | + - `UI`: used to draw the UI. |
| 49 | +- `stages`: RenderStage included in RenderFlow. |
| 50 | + |
| 51 | +## Properties and methods in RenderStage |
| 52 | + |
| 53 | +- `name`: the name of the RenderStage. |
| 54 | +- `priority`: the order of execution of the RenderStage in the RenderFlow. |
| 55 | +- `frameBuffer`: the FrameBuffer that the RenderStage will draw to, should be set to the FrameBuffer configured in the RenderPipeline, or set to `window` to indicate that the default FrameBuffer is used. |
| 56 | +- `renderQueues`: render queue, used to control the rendering order of objects. |
| 57 | + - `isTransparent`: marks whether the render queue is semi-transparent. |
| 58 | + - `sortMode`: <br>`FRONT_TO_BACK`: sort from front to back; <br>`BACK_TO_FRONT`: sort from back to front. |
| 59 | + - `stages`: specifies which passes in the render queue render material, should be specified as the `phase` in the `pass`. |
| 60 | + - `sortRenderQueue()`: sort the render queue. |
| 61 | + - `executeCommandBuffer` (view: RenderView): execute the render command. |
0 commit comments