Ogre Reference Manual (v) 3.2 synthesizer

Source: Internet
Author: User

3.2 Synthesizer Compositor

The synthesizer framework is a Ogre API for full-screen post-processing. You can define synthesizers by script rather than by API. You can easily make the viewport instance builder.

Synthesizer Basics

Whether you want to replace or mix with the main render window, the post-processing effect is to render the scene to the texture first. When the scene is rendered to a texture, you can render it as a full-screen quad to push the scene image to the fragment shader for processing. The post-processing render target can be a final result (render window) or another render texture, enabling multiple transformations of the image. You can convert multiple times between a pair of textures without having to use a separate texture for each stage. Finally, you can output the results by full-screen quadrilateral. This step replaces the entire render window (where the main render window does not need to render the scene) or blends.

Defined

Compositor synthesizer

Defines a full-screen effect for viewports. This section provides details on how to define with a synth script

Compositor Instance Synthesizer Example

A synthesizer instance for a viewport. Created by the synthesizer definition, refer to the 3.2.4 application synthesizer.

Compositor Chain synthesizer Chain

You can instantiate multiple synthesizers on a single viewport, each with the previous output as input. A viewport that is associated with one or more synthesizers creates a synthesizer chain

Target render destination (texture or final output)

As a result of a series of rendering operations, the render target can be the final output (default, no declaration required), or as an intermediate rendering texture (defined by the texure pin line). You can set the size and pixel format for render targets that are not output targets.

Output target outputs

Similar to the render target, as the final result of all operations. The size and pixel formats are determined by the application environment and cannot be set in the script to declare the target channel for the output target

Target Pass Destination Channel

A render target may need to be rendered several times to achieve some compositing effects. In particular, if you convert back and forth between a pair of textures, each render target will contain more than one target channel. The target channel is declared via target () or target_output line, and the last target channel is the final output target channel with only one render target.

Pass Channel

A target channel can contain multiple channels to implement its own actions, such as rendering the original scene, obtaining the previous synthesizer render result, rendering a full-screen quadrilateral, or emptying one or more buffers. Typically, a target channel uses a "Render_scene" channel or a ' Render_quad ' channel. The Clear Channel can be used in both cases.

Script loading

The synthesizer script is loaded when the resource group is initialized, and the ogre is parsed by the '. Compositor ' file under the resource location. You can manually parse the synthesizer script by Compositorserializer::p Arsescript.

Example:

Compositor b&w

{technique {

Define render target rt0 (texture)

Texture rt0 target_width target_height pf_a8r8g8b8

Target rt0//destination channel, render to render target rt0 (texture)

{

Input previous//inputs data from the previous synthesizer or scene

}

Target_output//Output target

{

Input none//no input (empty output first)

Pass Render_quad//channel, render as full-screen quad

{

Material Ogre/compositor/blackandwhite//Specify the material used for rendering

Input 0 rt0//The first texture used for the material: rt0

}

}

}

}

The synthesizer must have a name, the name must be unique, the name can contain a path character '/', the character can be used to logically divide the quality, but also help avoid duplication, the engine is not based on this tree structure processing. If the name contains spaces, enclose them in double quotation marks.

3.2.1 Technique Technology

Synthesizer techniques are similar to materials and are used to describe a way to achieve results. Multiple techniques can be defined so that the hardware does not support degradation processing. The hardware support for the technology is based on two aspects:

Material

Renders a full-screen quad-shaped channel that requires a material, and the channel degrades when the material is not supported

Texture format

Not all of the requested format hardware is supported, especially the floating-point format. In this case, the hardware typically downgrades the request format to a hardware-supported format. When using synths, you may want different ways. In evaluating the technology, the synthesizer first checks the original pixel format support and skips to the next technique if not supported. When there is no matching technology, it will be checked again, allowing the use of a hardware degraded texture format.

As with the material technology, the first declared technology takes precedence

The technology contains the following inline elements:

Texture

Declares a rendered texture for subsequent target channels

Format: Texture <Name> <Width> <Height> <pixel format> [<MRT Pixel format2>] [<MRT Pixel Form Atn>] [pooled] [gamma] [NO_FSAA] [Depth_pool <poolid>] [<scope>]

Name The name of the texture, which must be unique within the synthesizer. Used to reference when the target channel renders to the texture, or as a material input when the channel renders a full-screen quadrilateral

width/height Texture Size, you can specify a fixed size or the physical size based on the associated viewport of the synthesizer. Based on the viewport through ' target_width ', ' target_height ', target_width_scaled <factor> ' and ' target_height_scaled <factor>

Factor to the corresponding zoom multiplier

The Pixel forat pixel format determines the amount of memory used, the available color channels, and the color channel precision. Available formats include: Pf_a8r8g8b8, Pf_r8g8b8a8, Pf_r8g8b8, Pf_float16_rgba, Pf_float16_rgb, Pf_float16_r, Pf_float32_rgba, PF_ Float32_rgb, Pf_float32_r.

pooled if provided, requires textures to be shared between synthesizer samples, saving memory

Gamma If provided, requires RGB gamma correction when writing textures, you need to convert back in the texture material, such as when rendering quadrilateral. This option is automatically valid when rendering to this texture using the Render_scene channel, while the associated viewport supports RGB write.

NO_FSAA Turn off anti-aliasing (anti-aliasing), use this option to override the default value and disable FSAA when rendering to this texture using render_scene channels, while the associated viewport turns on Fass.

Depth_pool This parameter is used to set the depth buffer to use the depth-swap pool ID (poold). This directive is not related to the pooled directive. The same depth buffer will be shared when all synths render textures have the same poodid (if render system support also includes render Windows), the default is 1, and 0 indicates that no depth buffer is used, which saves performance and memory.

Scope Texture Access, there are three kinds:

Local_scope default value, only the synthesizer can accommodate

Chain_scope subsequent synthesizers of the same synthesizer chain are available

Global_scope the entire application is available

directives affect the creation of textures, global_scope textures are created only once, cannot be combined with pooled directives, and cannot depend on viewport size

Example: Texture rt0 pf_r8g8b8a8

Texture Rt1 target_width target_height Pf_float32_rgb

You can repeat Pixcel Format, so that the texture will become MRT (multi-render target, multiple render targets) for the GPU to write multiple textures at once. When a shader is written to MRT, all targets need to be written, otherwise the result is undefined. In addition, although you can specify different pixel formats, you need the same bit depth, because most of the graphics cards do not support the bit depths that are unrelated to each other. If the graphics card does not support the number of MRT you need, the technology will skip (degenerate). Note: MRT is typically used for ogre deferred rendering of Gbuffer (Geometry buffer geometry buffer)

Texture_ref

Declares a texture reference for use in textures in other synths

Format: Texture_ref <local name> <reference compositor> <reference Texture name>

You need to ensure that the referenced texture is scoped (chain/global_scope), and that the referenced synth should precede the current synthesizer.

Example: Texture_ref gbuffer gbuffercompositor mrt_output

Scheme

Set up a synthesizer scheme for switching between different technologies via Compositorinstance::setscheme.

Format: Material_scheme <Name>

Compositor_logic

Establish association management between synthesizers and code. When the synthesizer is created, the synthesizer logic is notified so that the synth is ready to work (such as increasing the listener). Synthesizer logic can be registered via Compositormanager::registercompositorlogic

Format: Compositor_logic <Name>

3.2.2 Target Channel

The target channel is the rendering of the target, including the rendered texture or the final output. You can render a rendered texture multiple times by using multiple target channels, which is useful for rendering back and forth between a pair of rendered textures for complex effects, such as blurring.

There are two types of target channels:

Render to texture target <textureName> {}

Render to final output Target_output {}

The two channels are the same, the difference being that target_output can only have one

The target channel contains the property values:

Input

What you have entered

Intput (None | previous), default None

None no input, which means the channel produces content. Note: None only means no input, clear pass is still required for empty content

previous uses the content before the viewport, if the synthesizer is the first one is the original scene, not the output of the previous synthesizer in the synthesizer chain

Only_initial

Set to on indicates only one time at initialization time.

Format: only_initial (on | off), default off

Visibility_mask

Set the visibility flag bit for the internal Render_scene channel, mapped to Scenemanager::setvisibilitymask, need to be set to 10 decimal, not hexadecimal

Format: Visibility_mask <mask>

Example: Visibility_mask 4294967295

Lod_bias

Sets the scene LOD offset for the internal Render_scene channel. The default value is 1.0, less than the meaning of low quality, greater than the meaning of high quality

Format: Lod_bias <value>

Shadows

Sets whether to render shadows for internal render_scene channels, default on

Material_scheme

Sets the material scheme for the internal Render_scene channel.

3.2.3 Synthesizer Channel

A channel is a render in the target channel

Format: Pass (Render_quad | clear | stencil | render_scene | render_custom) [customname] {}

The first parameter is a channel type, including:

Clear clears the color, depth, template buffer, set to fixed content

stencil Configuring template operations, Comparison functions, reference values

Render_scene perform regular scene rendering using the Visibility_mask\lod_bias\material_scheme settings for the target channel

Render_quad renders a quadrilateral on the entire render target by specifying a texture. There is no doubt that you will be using it to process the output of the channel to achieve full screen effect

render_custom user-defined synthesizer channel code callback interface (registered through Compositormanager::registecustomcompositionpass), you need to use the Customname parameter.

Channel Properties: Material

For the Render_quad type channel, sets the texture used to render the quadrilateral. You might use shaders in a material to achieve full-screen effects, and to map other texture targets using input for material texture binding, for example:

Pass Render_quad

{

Renders a fullscreen quad with a material

Material Ogre/compositor/ascii

Input 0 Rt0

}

Input

Used for the Render_quad type channel to set the texture used by the material.

Format: Input <samplerIndex> <Name> [<mrtindex>]

samplerindex Texture Index, [0, Ogre_max_texture_layers-1]

name of the render texture target referenced by

Mrtindex used to identify the surface of a MRT when the texture target is MRT

Cases:

Input 0 mrt0 0

Identifier

Set the identification number of the channel for registering the Synthesizer listener (Compositorinstance::addlistener)

Format: identifier <number>, default 0

Example: identifier 99945

Last_render_queue

For Render_scene channels, set the maximum render queue ID, default to RENDER_QUEUE_SKIES_LATE/95

Format: Last_render_queue <id>

Material_scheme

Set the scenario used by the channel to override the scenario settings for the target channel

Clear Type

The clear type channel defines the purge buffer parameters, including:

Buffers

Format: buffers [colour] [depth] [stencil]

Set the empty buffer

Colour_value

Set the cleared color buffer value

Format: Colour_value <red> <green> <blue> <alpha>, default 0 0 0 0

Depth_value

Set Depth Buffer value

Format: Depth_value <depth>, default 1.0

Stencil_value

Clear the post-template buffer value

Format: Stencil_value <value>, default 0

Stencil section

Stencil type Channel Settings

Check

Whether to enable template checking, format: check (on | off)

Comp_func

Compare function in Set comparison operation (Ref_value & Mask) comp_func (stencil Buffer value & Mask)

Format: Comp_func (always_fail | always_pass | less | less_equal | not_equal | greater_equal | greater)

Default Always_pass

Ref_value

Setting reference values

Format: Ref_value <value>, default 0

Mask

Setting the shielding bit

Format: Mask <value>, default 4294967295

Fail_op

Set the type of action when a template test fails (no depth test after template failure)

Format: fail_op (keep template value unchanged | Zero Clear 0 | Replace Set as reference | Increment template value plus 1, crop to maximum | decrement-1, crop to 0| increment_wrap +1, Max cycle to 0| Decre Ment_wrap-1, less than 0 loops for maximum value | Invert reverse)

Default Keep

Depth_fail_op

The template test succeeds, the deep test fails the operation, the same fail_op

Default Keep

Pass_op

The template \ Depth test is passed after the operation, with Fail_op

Default Keep

two_sided

The template tests whether double-sided, on applies the operation to the back polygon

Default off

3.2.4 Application Synthesizer

To add a compositor instance to a viewport:

Compositormanager::getsingleton (). Addcompositor (viewport, compositorname);

The default newly added synth is in an invalid state, enabling or disabling the synthesizer by:

Compositormanager::getsingleton (). setcompositorenabled (viewport, compositorname, enabledordisabled);

Ogre Reference Manual (v) 3.2 synthesizer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.