343
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Template:Non-stable|version=2019.3|progress=80}} | |||
{{Template:Non-stable|version=2019.3|progress= | |||
{{infobox subsystem | {{infobox subsystem | ||
Line 17: | Line 15: | ||
}} | }} | ||
The '''Compositor''' aims to bring multi-pass rendering to FlightGear. It encapsulates a rendering pipeline and exposes its parameters to the [[Property Tree]]. The pipeline used on each physical viewport defined on the [[Howto:Configure camera view windows||CameraGroup settings]] can be changed via the <compositor/> tag containing a valid path to the Compositor XML file. | |||
== Background == | == Background == | ||
Line 62: | Line 58: | ||
|script_version = 0.36 | |script_version = 0.36 | ||
}}</ref> | }}</ref> | ||
The corresponding set of patches (topic branches) were put up for review in 08/2018 to discuss the underlying approach and hopefully get this merged in 2019. | The corresponding set of patches (topic branches) were put up for review in 08/2018 to discuss the underlying approach and hopefully get this merged in 2019. | ||
== | == Features == | ||
* Completely independent of other parts of the simulator, i.e. it's part of SimGear and can be used in a standalone fashion if needed, ala Canvas. | * Completely independent of other parts of the simulator, i.e. it's part of SimGear and can be used in a standalone fashion if needed, ala Canvas. | ||
Line 80: | Line 67: | ||
* Its functionality overlaps Rembrandt: what can be done with Rembrandt can be done with the Compositor, but not vice versa. | * Its functionality overlaps Rembrandt: what can be done with Rembrandt can be done with the Compositor, but not vice versa. | ||
* Fully configurable via a XML interface without compromising performance (ala Effects, using PropertyList files). | * Fully configurable via a XML interface without compromising performance (ala Effects, using PropertyList files). | ||
* Flexible, expandable and compatible with modern graphics. | * Flexible, expandable and compatible with modern graphics. | ||
* It doesn't increase the hardware requirements, it expands the hardware range FG can run on. People with integrated GPUs (Intel HD etc) can run a Compositor with a single pass that renders directly to the screen like before, while people with more powerful cards can run a Compositor that implements deferred rendering, for example. | * It doesn't increase the hardware requirements, it expands the hardware range FG can run on. People with integrated GPUs (Intel HD etc) can run a Compositor with a single pass that renders directly to the screen like before, while people with more powerful cards can run a Compositor that implements deferred rendering, for example. | ||
The Compositor is in an usable state right now: it works but there are no effects or pipelines developed for it. There are also some bugs and features that don't work as expected because of some hardcoded assumptions in the FlightGear Viewer code. | |||
The Compositor is in an usable state right now: it works but there are | |||
no effects or pipelines developed for it. There are also some bugs and | |||
features that don't work as expected because of some hardcoded | |||
assumptions in the FlightGear Viewer code | |||
== Elements == | == Elements == | ||
Line 166: | Line 76: | ||
=== Buffers === | === Buffers === | ||
A buffer represents a texture or, more generically, a region of GPU memory. | A buffer represents a texture or, more generically, a region of GPU memory. It can have the following parameters: | ||
; '''name''' | |||
: Passes will be able to address the buffer by this name. | |||
; '''type''' | |||
: Any texture type allowed by OpenGL: 1d, 2d, 2d-array, 2d-multisample, 3d, rect or cubemap. | |||
; '''width''' | |||
: Texture width. It's possible to write 'screen' to use the physical viewport width. | |||
; '''screen-width-scale''' | |||
: If 'screen' was used, this controls the width scaling factor. | |||
; '''height''' | |||
: Texture height. It's possible to write 'screen' to use the physical viewport height. | |||
; '''screen-height-scale''' | |||
: If 'screen' was used, this controls the height scaling factor. | |||
; '''depth''' | |||
: Texture depth. | |||
; '''internal-format''', '''source-format''' and '''source-type''' | |||
: They specify the texture format. They correspond to the arguments ''internalformat'', ''format'' and ''type'' respectively of the OpenGL function ''glTexImage2D''. | |||
; '''min-filter''' and '''mag-filter''' (Optional) | |||
: They change the minification and magnification filtering respectively. Possible values are: linear, linear-mipmap-linear, linear-mipmap-nearest, nearest, nearest-mipmap-linear and nearest-mipmap-nearest. The default value for both filters is linear. | |||
; '''wrap-s''', '''wrap-t''' and '''wrap-r''' (Optional) | |||
: They change the wrap mode for each coordinate. Possible values are: clamp, clamp-to-edge, clamp-to-border, repeat and mirror. The default value for every coordinate is clamp-to-border. | |||
A typical [[PropertyList XML File|property tree structure]] describing a buffer may be as follows: | A typical [[PropertyList XML File|property tree structure]] describing a buffer may be as follows: | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<buffer> | |||
<name>color</name> | |||
<type>2d</type> | |||
<width>screen</width> | |||
<height>screen</height> | |||
<screen-width-scale>1.5</screen-width-scale> | |||
<screen-height-scale>1.5</screen-height-scale> | |||
<internal-format>rgba8</internal-format> | |||
<source-format>rgba</source-format> | |||
<source-type>ubyte</source-type> | |||
<min-filter>nearest-mipmap-nearest</min-filter> | |||
<mag-filter>nearest-mipmap-nearest</mag-filter> | |||
<wrap-s>repeat</wrap-s> | |||
<wrap-t>repeat</wrap-t> | |||
</buffer> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Passes === | === Passes === | ||
A pass wraps around an [http://public.vrac.iastate.edu/vancegroup/docs/OpenSceneGraphReferenceDocs-3.0/a00089.html osg::Camera]. | A pass wraps around an [http://public.vrac.iastate.edu/vancegroup/docs/OpenSceneGraphReferenceDocs-3.0/a00089.html osg::Camera]. The following types of passes are supported: | ||
; '''shadow-map''' | |||
: Renders the scene from a light's point of view. | |||
; '''scene''' | |||
: Renders the scene from the point of view given by the CameraGroup. | |||
; '''quad''' | |||
: Renders a fullscreen quad with an optional [[Effects|effect]] applied. Useful for screen space shaders (like SSAO, Screen Space Reflections or bloom) and deferred rendering. | |||
Passes can render to a buffer (Render to Texture), to several buffers (Multiple Render Targets) or directly to the | Passes can render to a buffer (Render to Texture), to several buffers (Multiple Render Targets) or directly to the framebuffer. This allows chaining of multiple passes, sharing buffers between them. They can also receive other buffers as input, so effects can access them as textures. | ||
Example XML for a '' | Example XML for a ''scene'' type pass: | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<pass> | |||
<name>forward-lighting</name> | |||
<type>scene</type> | |||
<clear-color type="vec4d">0 0 0 0</clear-color> | |||
<clustered-forward/> | |||
<attachment> | |||
<buffer>color</buffer> | |||
<component>color0</component> | |||
<multisample-samples>4</multisample-samples> | |||
<multisample-color-samples>4</multisample-color-samples> | |||
</attachment> | |||
<attachment> | |||
<buffer>depth</buffer> | |||
<component>depth</component> | |||
</attachment> | |||
</pass> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 238: | Line 177: | ||
== Known Issues == | == Known Issues == | ||
* | * Setting a buffer scale factor different from 1.0 and rendering to it might not scale the splash screen correctly. | ||
* | * No error handling when the Compositor wasn't found. FlightGear should quit gracefully but right now it segfaults. | ||
* Hardcoded Z handling. Better handling of depth is required to allow, for example, near and far cameras to prevent Z-fighting. | |||
== Related == | == Related == | ||
{{Appendix}} | {{Appendix}} |
edits