|
|
@@ -385,7 +385,9 @@ To render, it needs a Scene with an Octree component, and a Camera that does not
|
|
|
|
|
|
By default there is one viewport, but the amount can be increased with the function \ref Renderer::SetNumViewports "SetNumViewports()". The viewport(s) should cover the entire screen or otherwise hall-of-mirrors artifacts may occur. By specifying a zero screen rectangle the whole window will be used automatically. The viewports will be rendered in ascending order, so if you want for example to have a small overlay window on top of the main viewport, use viewport index 0 for the main view, and 1 for the overlay.
|
|
|
|
|
|
-Either forward or light pre-pass rendering can be chosen, see \ref Renderer::SetLightPrepass "SetLightPrepass()". %Light pre-pass will be advantageous once there is a large number of per-pixel lights affecting each object, but its disadvantages are the lack of hardware multisampling and inability to choose the lighting model per material. In place of multisample antialiasing, the FXAA post-processing edge filter can be used, see \ref Renderer::SetEdgeFilter "SetEdgeFilter()" and \ref Renderer::SetEdgeFilterParameters "SetEdgeFilterParameters()".
|
|
|
+Viewports can have a chain of post-processing effects. See \ref Postprocessing "Post-processing" for more details.
|
|
|
+
|
|
|
+Either forward or light pre-pass rendering can be chosen, see \ref Renderer::SetLightPrepass "SetLightPrepass()". %Light pre-pass will be advantageous once there is a large number of per-pixel lights affecting each object, but its disadvantages are the lack of hardware multisampling and inability to choose the lighting model per material. In place of multisample antialiasing, a FXAA post-processing edge filter can be used, see the TestScene script application for an example of how to use.
|
|
|
|
|
|
The steps for rendering each viewport on each frame are roughly the following:
|
|
|
|
|
|
@@ -433,7 +435,7 @@ Note that many more optimization opportunities are possible at the content level
|
|
|
|
|
|
\section Rendering_Further Further details
|
|
|
|
|
|
-See also \ref Materials "Materials", \ref Lights "Lights and shadows", \ref Particles "Particle systems", \ref Zones "Zones", and \ref AuxiliaryViews "Auxiliary views".
|
|
|
+See also \ref Materials "Materials", \ref Lights "Lights and shadows", \ref Particles "Particle systems", \ref Postprocessing "Post-processing", \ref Zones "Zones", and \ref AuxiliaryViews "Auxiliary views".
|
|
|
|
|
|
See \ref ForwardPrepass "Forward and light pre-pass rendering" for detailed discussion on the two rendering modes.
|
|
|
|
|
|
@@ -681,6 +683,31 @@ Zones have two special flags: override mode and ambient gradient. If the camera
|
|
|
Zones also define a lightmask and a shadowmask (with all bits set by default.) An object's final lightmask for light culling is determined by ANDing the object lightmask and the zone lightmask. The final shadowmask is also calculated in the same way.
|
|
|
|
|
|
|
|
|
+\page Postprocessing Post-processing
|
|
|
+
|
|
|
+After a viewport's 3D scene content is rendered, post-processing effects can be applied to it. These are viewport-sized quads rendered with configurable vertex and pixel shaders, shader parameters and textures.
|
|
|
+
|
|
|
+The Viewport contains a vector of PostProcess pointers, into which they can be added. They are applied in order from first to last. Each post-processing effect can consist of a number of passes, represented by the class PostProcessPass. The last pass of the last effect will be rendered to the destination rendertarget, while the passes before will be rendered to an internal ping-pong buffer.
|
|
|
+
|
|
|
+In addition to configuring programmatically, the PostProcess can be configured with a XML file; use \ref PostProcess::LoadParameters "LoadParameters()" to specify the XML file to use. The format is the following:
|
|
|
+
|
|
|
+\code
|
|
|
+<postprocess>
|
|
|
+ <rendertarget name="RenderTargetName" size="x y" | sizedivisor="x y" format="rgb|rgba|float" filtered="true|false" />
|
|
|
+ <pass vs="VertexShaderName" ps="PixelShaderName" output="viewport|RenderTargetName" />
|
|
|
+ <texture unit="diffuse|normal|specular|detail|environment|emissive" name="viewport|RenderTargetName|TextureName" />
|
|
|
+ <parameter name="ShaderParameterName" value="x y z w" />
|
|
|
+ </pass>
|
|
|
+</postprocess>
|
|
|
+\endcode
|
|
|
+
|
|
|
+Rendertargets can either specify an absolute width and height, or a divisor for the viewport size (for example sizedivisor="2 2" would divide the viewport dimensions by two.) The rendertargets are shared by all passes. A pass can output either into a rendertarget or into the viewport. The current contents of the viewport (either the scene render or a previous post-process pass) can also be read as a texture; this will always use the other half of the ping-pong buffer to avoid sampling the texture being rendered.
|
|
|
+
|
|
|
+In addition to the user-definable shader parameters, the shader parameters GBufferOffsets and SampleOffsets will always be set according to the viewport coordinates and the viewport rendertarget size, so that the GetScreenPos() shader function will operate correctly, and adjacent pixels from the viewport can be sampled. See the EdgeFilter shader for an example.
|
|
|
+
|
|
|
+Note that when hardware multisampling is used in conjunction with post-processing, the multisampled backbuffer will first be resolved to the ping-pong buffer before rendering the post-process passes. This has a small performance cost.
|
|
|
+
|
|
|
+
|
|
|
\page AuxiliaryViews Auxiliary views
|
|
|
|
|
|
Auxiliary views are viewports defined into a RenderSurface. These will be rendered whenever the texture containing the surface is visible, and can be typically used to implement for example reflections. The texture in question must have been created in rendertarget mode, see Texture's \ref Texture2D::SetSize "SetSize()" function.
|