<?xml version="1.0" encoding="utf-8"?>

<PropertyList>
  <name>HDR</name>
  <!-- XXX: These won't be necessary once we go core profile only -->
  <use-osg-uniforms>true</use-osg-uniforms>
  <use-vertex-attribute-aliasing>true</use-vertex-attribute-aliasing>

  <!-- shader support for multiview rendering (e.g. VR) -->
  <multiview>
      <!-- bloomG buffer scales down to 1/128th,
           align views to prevent sampling outside of views in scaled
           intermediate frame buffers -->
      <view-align-mask>127</view-align-mask>

      <!-- SceneView stereo support,
           correct per-view handling with common uniform sequential passes -->
      <sceneview>true</sceneview>

      <!-- tiled (side-by-side) intermediate buffer support -->
      <intermediates-tiled>true</intermediates-tiled>
  </multiview>

  <!--
      G-Buffer layout
      ...........................................................................
      :                        :    Red    :  Green  :    Blue    :    Alpha    :
      :........................:...........:.........:............:.............:
      : G-Buffer 0 (RGB10_A2)  :        Normal       : Roughness  : Material ID :
      : G-Buffer 1 (RGBA8)     :             Base Color           : Dithering   :
      : G-Buffer 2 (RGBA8)     :  Material specific  : Metallic   : Occlusion   :
      : G-Buffer 3 (R11G11B10) :             Emission             :      -      :
      : Depth/Stencil          :      DEPTH24_STENCIL8 (Logarithmic depth)      :
      :........................:............:.........:...........:.............:

      Notes:
      - Two 10-bit channels is enough for normals, as long as we are using
      octahedron normal encoding.
      - Since the Material ID is stored in 2 bits, we can only have 4 different
      material types. The maximum value (3 or 1.0) is reserved for the standard
      PBR metallic-roughness material.
      - In 'Material specific params' fancier materials can use up to 16 bits
      to encode any information they might need (e.g. a clearcoat layer needs
      to store the clearcoat amount and roughness).
      - Materials that are very different from the standard should write
      whatever they need in the G-Buffer without adhering to this layout and use
      the stencil buffer and a separate render pass.
  -->
  <buffer include="screen-buffer.xml">
    <name>gbuffer0</name>
    <format>rgb10-a2</format>
  </buffer>
  <buffer include="screen-buffer.xml">
    <name>gbuffer1</name>
    <format>rgba8</format>
  </buffer>
  <buffer include="screen-buffer.xml">
    <name>gbuffer2</name>
    <format>rgba8</format>
  </buffer>
  <buffer include="screen-buffer.xml">
    <name>gbuffer3</name>
    <format>r11f-g11f-b10f</format>
  </buffer>
  <buffer include="screen-buffer.xml">
    <name>depth-stencil</name>
    <format>depth24-stencil8</format>
  </buffer>

  <!-- HDR shading result -->
  <buffer include="screen-buffer.xml">
    <name>hdr-result</name>
    <format>r11f-g11f-b10f</format>
  </buffer>

  <!-- HDR buffer just containing clouds -->
  <buffer include="cloud-buffer.xml">
    <name>clouds</name>
    <format>rgba16f</format>
  </buffer>
  <buffer include="cloud-buffer.xml">
    <name>clouds-depth-stencil</name>
    <format>depth24-stencil8</format>
  </buffer>

  <!-- Forward HDR buffer for front of clouds -->
  <buffer include="screen-buffer.xml">
    <name>hdr-forward</name>
    <format>rgba16f</format>
  </buffer>

  <!-- Final HDR buffer -->
  <buffer include="screen-buffer.xml">
    <name>hdr-final</name>
    <format>r11f-g11f-b10f</format>
  </buffer>

  <!-- Final LDR buffer -->
  <buffer include="screen-buffer.xml">
    <name>final</name>
    <format>rgb8</format>
  </buffer>

  <!-- Atmosphere LUTs -->
  <buffer>
    <name>transmittance</name>
    <type>2d</type>
    <width>256</width>
    <height>64</height>
    <format>rgba16f</format>
    <min-filter>linear</min-filter>
    <mag-filter>linear</mag-filter>
    <wrap-s>clamp-to-edge</wrap-s>
    <wrap-t>clamp-to-edge</wrap-t>
  </buffer>
  <buffer>
    <name>multiple-scattering</name>
    <type>2d</type>
    <width>32</width>
    <height>32</height>
    <format>rgba16f</format>
    <min-filter>linear</min-filter>
    <mag-filter>linear</mag-filter>
    <wrap-s>clamp-to-edge</wrap-s>
    <wrap-t>clamp-to-edge</wrap-t>
  </buffer>
  <buffer>
    <name>sky-view</name>
    <type>2d</type>
    <width>256</width>
    <height>256</height>
    <format>rgba16f</format>
    <min-filter>linear</min-filter>
    <mag-filter>linear</mag-filter>
    <wrap-s>repeat</wrap-s>
    <wrap-t>clamp-to-edge</wrap-t>
  </buffer>
  <buffer>
    <name>aerial-perspective</name>
    <type>3d-mvr</type>
    <width>64</width>
    <height>64</height>
    <depth>32</depth>
    <format>rgba16f</format>
    <min-filter>linear</min-filter>
    <mag-filter>linear</mag-filter>
    <wrap-s>clamp-to-edge</wrap-s>
    <wrap-t>clamp-to-edge</wrap-t>
    <wrap-r>clamp-to-edge</wrap-r>
  </buffer>

  <!-- Environment BRDF LUT -->
  <buffer>
    <name>envmap-brdf-lut</name>
    <type>2d</type>
    <width>512</width>
    <height>512</height>
    <format>rg16f</format>
    <min-filter>linear</min-filter>
    <mag-filter>linear</mag-filter>
    <wrap-s>clamp-to-edge</wrap-s>
    <wrap-t>clamp-to-edge</wrap-t>
  </buffer>

  <!-- Environment cubemap -->
  <buffer>
    <name>envmap</name>
    <type>cubemap</type>
    <width><property>/sim/rendering/hdr/envmap/cubemap-size</property></width>
    <height><property>/sim/rendering/hdr/envmap/cubemap-size</property></height>
    <format>r11f-g11f-b10f</format>
    <min-filter>linear-mipmap-linear</min-filter>
    <mag-filter>linear</mag-filter>
    <wrap-s>clamp-to-edge</wrap-s>
    <wrap-t>clamp-to-edge</wrap-t>
    <mipmap-levels>5</mipmap-levels>
  </buffer>
  <buffer>
    <name>prefiltered-envmap</name>
    <type>cubemap</type>
    <width><property>/sim/rendering/hdr/envmap/cubemap-size</property></width>
    <height><property>/sim/rendering/hdr/envmap/cubemap-size</property></height>
    <format>r11f-g11f-b10f</format>
    <min-filter>linear-mipmap-linear</min-filter>
    <mag-filter>linear</mag-filter>
    <wrap-s>clamp-to-edge</wrap-s>
    <wrap-t>clamp-to-edge</wrap-t>
    <mipmap-levels>5</mipmap-levels>
  </buffer>

  <!-- Shadow map atlas -->
  <buffer>
    <name>sun-shadowmap-atlas</name>
    <type>2d</type>
    <width><property>/sim/rendering/hdr/shadows/sun-atlas-size</property></width>
    <height><property>/sim/rendering/hdr/shadows/sun-atlas-size</property></height>
    <format>depth16</format>
    <wrap-s>clamp-to-border</wrap-s>
    <wrap-t>clamp-to-border</wrap-t>
    <min-filter>linear</min-filter>
    <mag-filter>linear</mag-filter>
    <border-color type="vec4d">1.0 1.0 1.0 1.0</border-color>
    <shadow-comparison>true</shadow-comparison>
  </buffer>

  <!-- Histogram for automatic exposure -->
  <buffer>
    <name>histogram-bins</name>
    <type>2d</type>
    <width>screen</width>
    <screen-width-scale><property>/sim/rendering/hdr/render-scale</property></screen-width-scale>
    <height>screen</height>
    <screen-height-scale><property>/sim/rendering/hdr/render-scale</property></screen-height-scale>
    <format>r8ui</format>
    <min-filter>nearest</min-filter>
    <mag-filter>nearest</mag-filter>
  </buffer>
  <buffer>
    <name>histogram-partial</name>
    <type>2d</type>
    <width>screen</width>
    <screen-width-scale><property>/sim/rendering/hdr/render-scale</property></screen-width-scale>
    <height>256</height>
    <format>r32ui</format>
    <min-filter>nearest</min-filter>
    <mag-filter>nearest</mag-filter>
  </buffer>
  <buffer>
    <name>histogram</name>
    <type>2d</type>
    <width>256</width>
    <height>1</height>
    <format>r32ui</format>
    <min-filter>nearest</min-filter>
    <mag-filter>nearest</mag-filter>
  </buffer>
  <buffer>
    <name>histogram-luminance</name>
    <type>2d</type>
    <width>1</width>
    <height>1</height>
    <format>r32f</format>
    <min-filter>nearest</min-filter>
    <mag-filter>nearest</mag-filter>
  </buffer>
  <buffer>
    <name>prev-luminance</name>
    <type>2d</type>
    <width>1</width>
    <height>1</height>
    <format>r32f</format>
    <min-filter>nearest</min-filter>
    <mag-filter>nearest</mag-filter>
  </buffer>

  <!-- Ambient Occlusion buffers -->
  <buffer include="ao-buffer.xml">
    <name>ao-noisy</name>
  </buffer>
  <buffer include="ao-buffer.xml">
    <name>ao-filtered</name>
  </buffer>

  <!-- Bloom buffers -->
  <buffer include="bloom-buffer.xml">
    <name>bloomA</name>
    <screen-width-scale>0.5</screen-width-scale>
    <screen-height-scale>0.5</screen-height-scale>
  </buffer>
  <buffer include="bloom-buffer.xml">
    <name>bloomB</name>
    <screen-width-scale>0.25</screen-width-scale>
    <screen-height-scale>0.25</screen-height-scale>
  </buffer>
  <buffer include="bloom-buffer.xml">
    <name>bloomC</name>
    <screen-width-scale>0.125</screen-width-scale>
    <screen-height-scale>0.125</screen-height-scale>
  </buffer>
  <buffer include="bloom-buffer.xml">
    <name>bloomD</name>
    <screen-width-scale>0.0625</screen-width-scale>
    <screen-height-scale>0.0625</screen-height-scale>
  </buffer>
  <buffer include="bloom-buffer.xml">
    <name>bloomE</name>
    <screen-width-scale>0.03125</screen-width-scale>
    <screen-height-scale>0.03125</screen-height-scale>
  </buffer>
  <buffer include="bloom-buffer.xml">
    <name>bloomF</name>
    <screen-width-scale>0.015625</screen-width-scale>
    <screen-height-scale>0.015625</screen-height-scale>
  </buffer>
  <buffer include="bloom-buffer.xml">
    <name>bloomG</name>
    <screen-width-scale>0.0078125</screen-width-scale>
    <screen-height-scale>0.0078125</screen-height-scale>
  </buffer>

  <buffer include="screen-buffer.xml">
    <name>highlight</name>
    <format>r8</format>
  </buffer>

  <!-- SMAA buffers -->
  <buffer include="screen-buffer.xml">
    <name>smaa-edges</name>
    <format>rgba8</format>
    <wrap-s>clamp-to-edge</wrap-s>
    <wrap-t>clamp-to-edge</wrap-t>
    <min-filter>linear</min-filter>
    <mag-filter>linear</mag-filter>
  </buffer>
  <buffer include="screen-buffer.xml">
    <name>smaa-blend</name>
    <format>rgba8</format>
    <wrap-s>clamp-to-edge</wrap-s>
    <wrap-t>clamp-to-edge</wrap-t>
    <min-filter>linear</min-filter>
    <mag-filter>linear</mag-filter>
  </buffer>

  <!--=======================================================================-->

  <!--
      Clear the G-Buffer if we are debugging it to avoid the dreaded
      'Solitaire Effect' :)
  -->
  <pass>
    <name>debug-clear-gbuffer</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/gbuffer-debug-clear</effect>
    <condition>
      <property>/sim/rendering/hdr/debug/show-gbuffer</property>
    </condition>
    <attachment>
      <component>color0</component>
      <buffer>gbuffer0</buffer>
    </attachment>
    <attachment>
      <component>color1</component>
      <buffer>gbuffer1</buffer>
    </attachment>
    <attachment>
      <component>color2</component>
      <buffer>gbuffer2</buffer>
    </attachment>
    <attachment>
      <component>color3</component>
      <buffer>gbuffer3</buffer>
    </attachment>
  </pass>

  <!--
      Clear the G-Buffer dither channel even without debugging, otherwise
      demosaic will treat the sky as dithered transparency.
  -->
  <pass>
    <name>clear-gbuffer</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/gbuffer-clear</effect>
    <condition>
      <not>
        <property>/sim/rendering/hdr/debug/show-gbuffer</property>
      </not>
    </condition>
    <attachment>
      <component>color0</component>
      <buffer>gbuffer1</buffer>
    </attachment>
  </pass>

  <!--
      BRDF convolution for the IBL split sum integral approximation.
  -->
  <pass>
    <name>envmap-brdf</name>
    <type>quad</type>
    <render-once>true</render-once>
    <effect>Effects/HDR/envmap-brdf</effect>
    <attachment>
      <component>color0</component>
      <buffer>envmap-brdf-lut</buffer>
    </attachment>
  </pass>

  <!--
      Reset the previous luminance value once, as the initial undefined value
      may result in a lengthy wait for exposure to adjust.
  -->
  <pass>
    <name>reset-luminance</name>
    <type>quad</type>
    <render-once>true</render-once>
    <effect>Effects/HDR/reset-luminance</effect>
    <attachment>
      <component>color0</component>
      <buffer>prev-luminance</buffer>
    </attachment>
  </pass>

  <!--
      Atmospheric scattering.
  -->
  <pass>
    <name>atmos-transmittance</name>
    <type>quad</type>
    <effect>Effects/HDR/atmos-transmittance</effect>
    <attachment>
      <component>color0</component>
      <buffer>transmittance</buffer>
    </attachment>
  </pass>
  <pass>
    <name>atmos-multiple-scattering</name>
    <type>quad</type>
    <effect>Effects/HDR/atmos-multiple-scattering</effect>
    <binding>
      <unit>0</unit>
      <buffer>transmittance</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>multiple-scattering</buffer>
    </attachment>
  </pass>
  <pass>
    <name>atmos-sky-view</name>
    <type>quad</type>
    <effect>Effects/HDR/atmos-sky-view</effect>
    <binding>
      <unit>0</unit>
      <buffer>transmittance</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>multiple-scattering</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>sky-view</buffer>
    </attachment>
  </pass>
  <!-- Compute version -->
  <pass>
    <name>atmos-aerial-perspective-compute</name>
    <type>compute</type>
    <multiview>multipass</multiview>
    <workgroup-size>
      <x>8</x>
      <y>8</y>
      <z>8</z>
    </workgroup-size>
    <global-size>
      <x>64</x>
      <y>64</y>
      <z>32</z>
    </global-size>
    <effect>Effects/HDR/atmos-aerial-perspective-compute</effect>
    <binding>
      <unit>0</unit>
      <buffer>transmittance</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>multiple-scattering</buffer>
    </binding>
    <image-binding>
      <unit>0</unit>
      <buffer>aerial-perspective</buffer>
      <access>write-only</access>
      <format>rgba16f</format>
      <layered>true</layered>
    </image-binding>
  </pass>
  <!-- Layered rendering version (no compute required) -->
  <pass>
    <name>atmos-aerial-perspective-layered</name>
    <type>quad</type>
    <effect>Effects/HDR/atmos-aerial-perspective-layered</effect>
    <binding>
      <unit>0</unit>
      <buffer>transmittance</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>multiple-scattering</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>aerial-perspective</buffer>
      <face>controlled-by-geometry-shader</face>
    </attachment>
  </pass>

  <!--
      Environment capture passes
      Render to a cubemap using forward rendering. Only render the skydome and
      very bare terrain since we want to make as few draw calls as possible.
      We also want to avoid doing an OSG cull traversal on many nodes as our
      scene graph structure isn't too well optimized.
  -->
  <pass include="env-capture-pass.xml">
    <name>env-capture0</name>
    <cubemap-face>0</cubemap-face>
    <attachment>
      <component>color0</component>
      <buffer>envmap</buffer>
      <face>0</face>
    </attachment>
    <render-condition>
      <property>/sim/rendering/hdr/envmap/should-render-face-0</property>
    </render-condition>
  </pass>
  <pass include="env-capture-pass.xml">
    <name>env-capture1</name>
    <cubemap-face>1</cubemap-face>
    <attachment>
      <component>color0</component>
      <buffer>envmap</buffer>
      <face>1</face>
    </attachment>
    <render-condition>
      <property>/sim/rendering/hdr/envmap/should-render-face-1</property>
    </render-condition>
  </pass>
  <pass include="env-capture-pass.xml">
    <name>env-capture2</name>
    <cubemap-face>2</cubemap-face>
    <attachment>
      <component>color0</component>
      <buffer>envmap</buffer>
      <face>2</face>
    </attachment>
    <render-condition>
      <property>/sim/rendering/hdr/envmap/should-render-face-2</property>
    </render-condition>
  </pass>
  <pass include="env-capture-pass.xml">
    <name>env-capture3</name>
    <cubemap-face>3</cubemap-face>
    <attachment>
      <component>color0</component>
      <buffer>envmap</buffer>
      <face>3</face>
    </attachment>
    <render-condition>
      <property>/sim/rendering/hdr/envmap/should-render-face-3</property>
    </render-condition>
  </pass>
  <pass include="env-capture-pass.xml">
    <name>env-capture4</name>
    <cubemap-face>4</cubemap-face>
    <attachment>
      <component>color0</component>
      <buffer>envmap</buffer>
      <face>4</face>
    </attachment>
    <render-condition>
      <property>/sim/rendering/hdr/envmap/should-render-face-4</property>
    </render-condition>
  </pass>
  <pass include="env-capture-pass.xml">
    <name>env-capture5</name>
    <cubemap-face>5</cubemap-face>
    <attachment>
      <component>color0</component>
      <buffer>envmap</buffer>
      <face>5</face>
      <!-- Generate the mips after writing to the last face -->
      <mipmap-generation>true</mipmap-generation>
    </attachment>
    <render-condition>
      <property>/sim/rendering/hdr/envmap/should-render-face-5</property>
    </render-condition>
  </pass>

  <!--
      Pre-filter the environment map
      We convolve the cubemap for five roughness values and store the results
      on the mipmap levels of the cubemap. Later passes will choose which mipmap
      level to use for reflections based on the roughness of the surface that's
      being lighted/rendered. The first mipmap level can just be copied from the
      original envmap as we'd like it to contain perfect mirror reflections.
      Diffuse lighting is approximated by using the highest mipmap level
      (roughness=1).
  -->
  <pass include="env-prefilter-pass.xml">
    <name>env-prefilter0</name>
    <effect>Effects/HDR/envmap-copy</effect>
    <attachment>
      <component>color0</component>
      <buffer>prefiltered-envmap</buffer>
      <face>0</face>
      <level>0</level>
    </attachment>
    <attachment>
      <component>color1</component>
      <buffer>prefiltered-envmap</buffer>
      <face>1</face>
      <level>0</level>
    </attachment>
    <attachment>
      <component>color2</component>
      <buffer>prefiltered-envmap</buffer>
      <face>2</face>
      <level>0</level>
    </attachment>
    <attachment>
      <component>color3</component>
      <buffer>prefiltered-envmap</buffer>
      <face>3</face>
      <level>0</level>
    </attachment>
    <attachment>
      <component>color4</component>
      <buffer>prefiltered-envmap</buffer>
      <face>4</face>
      <level>0</level>
    </attachment>
    <attachment>
      <component>color5</component>
      <buffer>prefiltered-envmap</buffer>
      <face>5</face>
      <level>0</level>
    </attachment>
  </pass>
  <pass include="env-prefilter-pass.xml">
    <name>env-prefilter1</name>
    <effect>Effects/HDR/envmap-prefilter1</effect>
    <attachment>
      <component>color0</component>
      <buffer>prefiltered-envmap</buffer>
      <face>0</face>
      <level>1</level>
    </attachment>
    <attachment>
      <component>color1</component>
      <buffer>prefiltered-envmap</buffer>
      <face>1</face>
      <level>1</level>
    </attachment>
    <attachment>
      <component>color2</component>
      <buffer>prefiltered-envmap</buffer>
      <face>2</face>
      <level>1</level>
    </attachment>
    <attachment>
      <component>color3</component>
      <buffer>prefiltered-envmap</buffer>
      <face>3</face>
      <level>1</level>
    </attachment>
    <attachment>
      <component>color4</component>
      <buffer>prefiltered-envmap</buffer>
      <face>4</face>
      <level>1</level>
    </attachment>
    <attachment>
      <component>color5</component>
      <buffer>prefiltered-envmap</buffer>
      <face>5</face>
      <level>1</level>
    </attachment>
  </pass>
  <pass include="env-prefilter-pass.xml">
    <name>env-prefilter2</name>
    <effect>Effects/HDR/envmap-prefilter2</effect>
    <attachment>
      <component>color0</component>
      <buffer>prefiltered-envmap</buffer>
      <face>0</face>
      <level>2</level>
    </attachment>
    <attachment>
      <component>color1</component>
      <buffer>prefiltered-envmap</buffer>
      <face>1</face>
      <level>2</level>
    </attachment>
    <attachment>
      <component>color2</component>
      <buffer>prefiltered-envmap</buffer>
      <face>2</face>
      <level>2</level>
    </attachment>
    <attachment>
      <component>color3</component>
      <buffer>prefiltered-envmap</buffer>
      <face>3</face>
      <level>2</level>
    </attachment>
    <attachment>
      <component>color4</component>
      <buffer>prefiltered-envmap</buffer>
      <face>4</face>
      <level>2</level>
    </attachment>
    <attachment>
      <component>color5</component>
      <buffer>prefiltered-envmap</buffer>
      <face>5</face>
      <level>2</level>
    </attachment>
  </pass>
  <pass include="env-prefilter-pass.xml">
    <name>env-prefilter3</name>
    <effect>Effects/HDR/envmap-prefilter3</effect>
    <attachment>
      <component>color0</component>
      <buffer>prefiltered-envmap</buffer>
      <face>0</face>
      <level>3</level>
    </attachment>
    <attachment>
      <component>color1</component>
      <buffer>prefiltered-envmap</buffer>
      <face>1</face>
      <level>3</level>
    </attachment>
    <attachment>
      <component>color2</component>
      <buffer>prefiltered-envmap</buffer>
      <face>2</face>
      <level>3</level>
    </attachment>
    <attachment>
      <component>color3</component>
      <buffer>prefiltered-envmap</buffer>
      <face>3</face>
      <level>3</level>
    </attachment>
    <attachment>
      <component>color4</component>
      <buffer>prefiltered-envmap</buffer>
      <face>4</face>
      <level>3</level>
    </attachment>
    <attachment>
      <component>color5</component>
      <buffer>prefiltered-envmap</buffer>
      <face>5</face>
      <level>3</level>
    </attachment>
  </pass>
  <pass include="env-prefilter-pass.xml">
    <name>env-prefilter4</name>
    <effect>Effects/HDR/envmap-prefilter4</effect>
    <attachment>
      <component>color0</component>
      <buffer>prefiltered-envmap</buffer>
      <face>0</face>
      <level>4</level>
    </attachment>
    <attachment>
      <component>color1</component>
      <buffer>prefiltered-envmap</buffer>
      <face>1</face>
      <level>4</level>
    </attachment>
    <attachment>
      <component>color2</component>
      <buffer>prefiltered-envmap</buffer>
      <face>2</face>
      <level>4</level>
    </attachment>
    <attachment>
      <component>color3</component>
      <buffer>prefiltered-envmap</buffer>
      <face>3</face>
      <level>4</level>
    </attachment>
    <attachment>
      <component>color4</component>
      <buffer>prefiltered-envmap</buffer>
      <face>4</face>
      <level>4</level>
    </attachment>
    <attachment>
      <component>color5</component>
      <buffer>prefiltered-envmap</buffer>
      <face>5</face>
      <level>4</level>
    </attachment>
  </pass>

  <!--
      G-Buffer pass
      This is the main forward pass. Here we skip the rendering of transparent
      objects and other geometry that should be forward rendered later (like the
      skydome, clouds, etc.)
  -->
  <pass>
    <name>geometry</name>
    <type>scene</type>
    <effect-scheme>hdr-geometry</effect-scheme>
    <clear-mask>depth stencil</clear-mask>
    <clear-depth>1.0</clear-depth>
    <cull-mask>0xfffff7ff</cull-mask>
    <clustered-shading>
      <tile-size>128</tile-size>
      <depth-slices>1</depth-slices>
      <num-threads>1</num-threads>
      <max-pointlights>1024</max-pointlights>
      <max-spotlights>1024</max-spotlights>
      <pbr-lights>true</pbr-lights>
      <expose-uniforms>false</expose-uniforms>
    </clustered-shading>
    <attachment>
      <component>color0</component>
      <buffer>gbuffer0</buffer>
    </attachment>
    <attachment>
      <component>color1</component>
      <buffer>gbuffer1</buffer>
    </attachment>
    <attachment>
      <component>color2</component>
      <buffer>gbuffer2</buffer>
    </attachment>
    <attachment>
      <component>color3</component>
      <buffer>gbuffer3</buffer>
    </attachment>
    <attachment>
      <component>depth</component>
      <buffer>depth-stencil</buffer>
    </attachment>
    <attachment>
      <component>stencil</component>
      <buffer>depth-stencil</buffer>
    </attachment>
  </pass>

  <!-- GTAO (Ground Truth Ambient Occlusion) -->
  <pass>
    <name>gtao</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/gtao</effect>
    <clear-mask>color</clear-mask>
    <clear-color type="vec4d">1.0 1.0 1.0 1.0</clear-color>
    <condition>
      <property>/sim/rendering/hdr/ambient-occlusion/enabled</property>
    </condition>
    <binding>
      <unit>0</unit>
      <buffer>gbuffer0</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>depth-stencil</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>ao-noisy</buffer>
    </attachment>
  </pass>
  <pass>
    <name>gtao-denoiser</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/gtao-denoiser</effect>
    <condition>
      <property>/sim/rendering/hdr/ambient-occlusion/enabled</property>
    </condition>
    <binding>
      <unit>0</unit>
      <buffer>ao-noisy</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>ao-filtered</buffer>
    </attachment>
  </pass>

  <!-- Shadow mapping pre-passes -->
  <pass include="csm-pass.xml">
    <name>csm0</name>
    <near-m>0.1</near-m>
    <far-m>2.0</far-m>
    <viewport>
      <x>0.0</x>
      <y>0.0</y>
      <width>0.5</width>
      <height>0.5</height>
    </viewport>
  </pass>
  <pass include="csm-pass.xml">
    <name>csm1</name>
    <near-m>2.0</near-m>
    <far-m>40.0</far-m>
    <viewport>
      <x>0.5</x>
      <y>0.0</y>
      <width>0.5</width>
      <height>0.5</height>
    </viewport>
  </pass>
  <pass include="csm-pass.xml">
    <name>csm2</name>
    <near-m>40.0</near-m>
    <far-m>150.0</far-m>
    <viewport>
      <x>0.0</x>
      <y>0.5</y>
      <width>0.5</width>
      <height>0.5</height>
    </viewport>
  </pass>
  <pass include="csm-pass.xml">
    <name>csm3</name>
    <near-m>150.0</near-m>
    <far-m>500.0</far-m>
    <viewport>
      <x>0.5</x>
      <y>0.5</y>
      <width>0.5</width>
      <height>0.5</height>
    </viewport>
  </pass>

  <!--
      Main shading pass (for opaque objects)
      Combine the G-Buffer and other buffers to compute the final shading value
      of the pixel in HDR.
  -->
  <pass>
    <name>shading-opaque</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/shading-opaque</effect>
    <use-shadow-pass>csm0</use-shadow-pass>
    <use-shadow-pass>csm1</use-shadow-pass>
    <use-shadow-pass>csm2</use-shadow-pass>
    <use-shadow-pass>csm3</use-shadow-pass>
    <use-clustered-uniforms>
      <pass>geometry</pass>
      <clusters-bind-unit>5</clusters-bind-unit>
      <indices-bind-unit>6</indices-bind-unit>
      <pointlights-bind-unit>13</pointlights-bind-unit>
      <spotlights-bind-unit>15</spotlights-bind-unit>
    </use-clustered-uniforms>
    <binding>
      <unit>0</unit>
      <buffer>gbuffer0</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>gbuffer1</buffer>
    </binding>
    <binding>
      <unit>2</unit>
      <buffer>gbuffer2</buffer>
    </binding>
    <binding>
      <unit>3</unit>
      <buffer>gbuffer3</buffer>
    </binding>
    <binding>
      <unit>4</unit>
      <buffer>depth-stencil</buffer>
    </binding>
    <binding>
      <unit>7</unit>
      <buffer>ao-filtered</buffer>
      <condition>
        <property>/sim/rendering/hdr/ambient-occlusion/enabled</property>
      </condition>
    </binding>
    <binding>
      <unit>8</unit>
      <buffer>envmap-brdf-lut</buffer>
    </binding>
    <binding>
      <unit>9</unit>
      <buffer>prefiltered-envmap</buffer>
    </binding>
    <binding>
      <unit>10</unit>
      <buffer>sun-shadowmap-atlas</buffer>
    </binding>
    <binding>
      <unit>11</unit>
      <buffer>aerial-perspective</buffer>
    </binding>
    <binding>
      <unit>12</unit>
      <buffer>transmittance</buffer>
    </binding>
    <binding>
      <unit>14</unit>
      <buffer>prev-luminance</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>hdr-result</buffer>
    </attachment>
    <attachment>
      <component>stencil</component>
      <buffer>depth-stencil</buffer>
    </attachment>
  </pass>

  <pass>
    <name>shading-water</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/shading-water</effect>
    <binding>
      <unit>0</unit>
      <buffer>gbuffer0</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>gbuffer1</buffer>
    </binding>
    <binding>
      <unit>3</unit>
      <buffer>depth-stencil</buffer>
    </binding>
    <binding>
      <unit>9</unit>
      <buffer>prefiltered-envmap</buffer>
    </binding>
    <binding>
      <unit>11</unit>
      <buffer>aerial-perspective</buffer>
    </binding>
    <binding>
      <unit>12</unit>
      <buffer>transmittance</buffer>
    </binding>
    <binding>
      <unit>14</unit>
      <buffer>prev-luminance</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>hdr-result</buffer>
    </attachment>
    <attachment>
      <component>stencil</component>
      <buffer>depth-stencil</buffer>
    </attachment>
  </pass>

  <!-- This pass generates a screen buffer containing clouds -->
  <pass>
    <name>clouds</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/cloudquad</effect>
    <binding>
      <unit>2</unit>
      <buffer>depth-stencil</buffer>
    </binding>
    <binding>
      <unit>11</unit>
      <buffer>aerial-perspective</buffer>
    </binding>
    <binding>
      <unit>12</unit>
      <buffer>transmittance</buffer>
    </binding>
    <binding>
      <unit>14</unit>
      <buffer>prev-luminance</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>clouds</buffer>
    </attachment>
    <attachment>
      <component>depth</component>
      <buffer>clouds-depth-stencil</buffer>
    </attachment>
  </pass>

  <!--
      Main forward pass
      Render all objects that couldn't be rendered on the G-Buffer, mainly
      transparent objects. This is also done in HDR.
      We reuse the depth buffer from the G-Buffer stage so we can take advantage
      of early depth testing.
  -->
  <pass>
    <name>clear-forward</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/gbuffer-clear</effect>
    <attachment>
      <component>color0</component>
      <buffer>hdr-forward</buffer>
    </attachment>
  </pass>
  <pass>
    <name>forward</name>
    <type>scene</type>
    <effect-scheme>hdr-forward</effect-scheme>
    <use-shadow-pass>csm0</use-shadow-pass>
    <use-shadow-pass>csm1</use-shadow-pass>
    <use-shadow-pass>csm2</use-shadow-pass>
    <use-shadow-pass>csm3</use-shadow-pass>
    <!--
        We should not be binding and attaching the depth buffer as that usually
        implies reading and writing to it at the same time, which will result in
        undefined behaviour. However, in the forward pass we don't write to the
        depth buffer (all Effects that use hdr-forward have write-mask=false).
    -->
    <binding>
      <unit>7</unit>
      <buffer>depth-stencil</buffer>
    </binding>
    <binding>
      <unit>8</unit>
      <buffer>envmap-brdf-lut</buffer>
    </binding>
    <binding>
      <unit>9</unit>
      <buffer>prefiltered-envmap</buffer>
    </binding>
    <binding>
      <unit>10</unit>
      <buffer>sun-shadowmap-atlas</buffer>
    </binding>
    <binding>
      <unit>11</unit>
      <buffer>aerial-perspective</buffer>
    </binding>
    <binding>
      <unit>12</unit>
      <buffer>transmittance</buffer>
    </binding>
    <binding>
      <unit>13</unit>
      <buffer>sky-view</buffer>
    </binding>
    <binding>
      <unit>14</unit>
      <buffer>prev-luminance</buffer>
    </binding>
    <binding>
      <unit>15</unit>
      <buffer>clouds-depth-stencil</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>hdr-result</buffer>
    </attachment>
    <attachment>
      <component>color1</component>
      <buffer>hdr-forward</buffer>
    </attachment>
    <attachment>
      <component>depth</component>
      <buffer>depth-stencil</buffer>
    </attachment>
    <attachment>
      <component>stencil</component>
      <buffer>depth-stencil</buffer>
    </attachment>
  </pass>

  <!--
      This pass essentially performs demosaicing on the bayer pattern produced
      by some semi-transparent objects in the deferred geometry pass.
  -->
  <pass>
    <name>demosaic</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/demosaic</effect>
    <binding>
      <unit>0</unit>
      <buffer>hdr-result</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>gbuffer1</buffer>
    </binding>
    <binding>
      <unit>2</unit>
      <buffer>depth-stencil</buffer>
    </binding>
    <binding>
      <unit>3</unit>
      <buffer>clouds</buffer>
    </binding>
    <binding>
      <unit>4</unit>
      <buffer>clouds-depth-stencil</buffer>
    </binding>
    <binding>
      <unit>5</unit>
      <buffer>hdr-forward</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>hdr-final</buffer>
    </attachment>
  </pass>

  <!--
      Auto exposure using a luminance histogram
      Based on the article by Alex Tardif:
      https://www.alextardif.com/HistogramLuminance.html

      The first step calculates the bin numbers of every pixel of the input HDR
      texture.

      If compute shaders aren't supported, we run two fragment shaders. The
      first calculate a partial histogram of the rows of the bin numbers
      texture, and the second aggregates them together to obtain a single
      histogram.

      If compute shaders are supported, a fragment shader resets the histogram
      buffer, followed by a compute shader to calculate the histogram of the bin
      numbers.

      The last step, which calculates the average scene luminance from the
      histogram, is identical even though it is implemented as a fragment shader.

      This technique will find the average luminance after multiplication by the
      albedo. This is not correct, but the alternative (keeping a luminance
      texture) is too expensive and not worth the trouble.
  -->
  <pass>
    <name>histogram-bin</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/histogram-bin</effect>
    <render-condition>
      <property>/sim/rendering/hdr/exposure-update</property>
    </render-condition>
    <binding>
      <unit>0</unit>
      <buffer>hdr-final</buffer>
    </binding>
    <binding>
      <unit>14</unit>
      <buffer>prev-luminance</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>histogram-bins</buffer>
    </attachment>
  </pass>
  <!-- Slower version without compute shaders -->
  <pass>
    <name>histogram-column</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/histogram-column</effect>
    <render-condition>
      <property>/sim/rendering/hdr/exposure-update</property>
    </render-condition>
    <binding>
      <unit>0</unit>
      <buffer>histogram-bins</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>histogram-partial</buffer>
    </attachment>
  </pass>
  <pass>
    <name>histogram-aggregate</name>
    <type>quad</type>
    <effect>Effects/HDR/histogram-aggregate</effect>
    <render-condition>
      <property>/sim/rendering/hdr/exposure-update</property>
    </render-condition>
    <binding>
      <unit>0</unit>
      <buffer>histogram-partial</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>histogram</buffer>
    </attachment>
  </pass>
  <!-- Faster version with compute shaders -->
  <pass>
    <name>histogram-clear</name>
    <type>quad</type>
    <effect>Effects/HDR/histogram-clear</effect>
    <render-condition>
      <property>/sim/rendering/hdr/exposure-update</property>
    </render-condition>
    <attachment>
      <component>color0</component>
      <buffer>histogram</buffer>
    </attachment>
  </pass>
  <pass>
    <name>histogram-compute</name>
    <type>compute</type>
    <workgroup-size>
      <x>256</x>
      <y>2</y>
    </workgroup-size>
    <global-size>
      <x>screen</x>
      <y>screen</y>
      <z>screen</z>
      <y-screen-scale>0.0625</y-screen-scale>
    </global-size>
    <effect>Effects/HDR/histogram-compute</effect>
    <render-condition>
      <property>/sim/rendering/hdr/exposure-update</property>
    </render-condition>
    <binding>
      <unit>0</unit>
      <buffer>histogram-bins</buffer>
    </binding>
    <image-binding>
      <unit>0</unit>
      <buffer>histogram</buffer>
      <access>read-write</access>
      <format>r32ui</format>
    </image-binding>
  </pass>
  <!-- End of faster version with compute shaders -->
  <pass>
    <name>histogram-luminance</name>
    <type>quad</type>
    <effect>Effects/HDR/histogram-luminance</effect>
    <render-condition>
      <property>/sim/rendering/hdr/exposure-update</property>
    </render-condition>
    <binding>
      <unit>0</unit>
      <buffer>histogram</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>prev-luminance</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>histogram-luminance</buffer>
    </attachment>
  </pass>
  <pass>
    <name>copy-prev-luminance</name>
    <type>quad</type>
    <effect>Effects/HDR/copy-prev-luminance</effect>
    <render-condition>
      <property>/sim/rendering/hdr/exposure-update</property>
    </render-condition>
    <binding>
      <unit>0</unit>
      <buffer>histogram-luminance</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>prev-luminance</buffer>
    </attachment>
  </pass>

  <!--
      Bloom effect from:
      "Next Generation Post Processing in Call of Duty Advanced Warfare",
      ACM Siggraph (2014).
  -->
  <pass>
    <name>bloom-downsample1</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/bloom-downsample-first</effect>
    <binding>
      <unit>0</unit>
      <buffer>hdr-final</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomA</buffer>
    </attachment>
  </pass>
  <pass include="bloom-downsample-rest.xml">
    <name>bloom-downsample2</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomA</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomB</buffer>
    </attachment>
  </pass>
  <pass include="bloom-downsample-rest.xml">
    <name>bloom-downsample3</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomB</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomC</buffer>
    </attachment>
  </pass>
  <pass include="bloom-downsample-rest.xml">
    <name>bloom-downsample4</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomC</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomD</buffer>
    </attachment>
  </pass>
  <pass include="bloom-downsample-rest.xml">
    <name>bloom-downsample5</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomD</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomE</buffer>
    </attachment>
  </pass>
  <pass include="bloom-downsample-rest.xml">
    <name>bloom-downsample6</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomE</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomF</buffer>
    </attachment>
  </pass>
  <pass include="bloom-downsample-rest.xml">
    <name>bloom-downsample7</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomF</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomG</buffer>
    </attachment>
  </pass>

  <pass include="bloom-upsample.xml">
    <name>bloom-upsample1</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomG</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomF</buffer>
    </attachment>
  </pass>
  <pass include="bloom-upsample.xml">
    <name>bloom-upsample2</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomF</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomE</buffer>
    </attachment>
  </pass>
  <pass include="bloom-upsample.xml">
    <name>bloom-upsample3</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomE</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomD</buffer>
    </attachment>
  </pass>
  <pass include="bloom-upsample.xml">
    <name>bloom-upsample4</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomD</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomC</buffer>
    </attachment>
  </pass>
  <pass include="bloom-upsample.xml">
    <name>bloom-upsample5</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomC</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomB</buffer>
    </attachment>
  </pass>
  <pass include="bloom-upsample.xml">
    <name>bloom-upsample6</name>
    <binding>
      <unit>0</unit>
      <buffer>bloomB</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>bloomA</buffer>
    </attachment>
  </pass>

  <!--
      Render objects that have a pick animation.
      The resulting texture is later used to highlight the objects by drawing a
      silhouette around them together with a slight tinge.
  -->
  <pass>
    <name>highlights</name>
    <type>scene</type>
    <effect-scheme>hdr-highlight</effect-scheme>
    <!-- Only render objects with PICK_BIT=1 -->
    <cull-mask>0x40</cull-mask>
    <clear-mask>color</clear-mask>
    <clear-color>0.0 0.0 0.0 0.0</clear-color>
    <attachment>
      <component>color0</component>
      <buffer>highlight</buffer>
    </attachment>
    <attachment>
      <component>depth</component>
      <buffer>depth-stencil</buffer>
    </attachment>
  </pass>

  <!--
      Post-processing
      Perform miscellaneous post-processing operations, namely tonemapping
      and exposure compensation. This process converts the HDR buffer into an
      LDR texture ready to be displayed on a screen.
  -->
  <pass>
    <name>post</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/postprocess</effect>
    <binding>
      <unit>0</unit>
      <buffer>hdr-final</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>bloomA</buffer>
    </binding>
    <binding>
      <unit>2</unit>
      <buffer>highlight</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>final</buffer>
    </attachment>
  </pass>

  <!--
      Final LDR post-processing passes that render to the screen
      For now they just do antialiasing.
  -->
  <!-- No AA -->
  <pass>
    <name>no-aa-display</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/trivial</effect>
    <condition>
      <equals>
        <property>/sim/rendering/hdr/antialiasing-technique</property>
        <value type="int">0</value>
      </equals>
    </condition>
    <binding>
      <unit>0</unit>
      <buffer>final</buffer>
    </binding>
  </pass>

  <!-- FXAA -->
  <pass>
    <name>fxaa</name>
    <type>quad</type>
    <multiview>true</multiview>
    <effect>Effects/HDR/fxaa</effect>
    <condition>
      <equals>
        <property>/sim/rendering/hdr/antialiasing-technique</property>
        <value type="int">1</value>
      </equals>
    </condition>
    <binding>
      <unit>0</unit>
      <buffer>final</buffer>
    </binding>
  </pass>

  <!--
      SMAA (Enhanced Subpixel Morphological Antialiasing)
      http://www.iryoku.com/smaa/
  -->
  <pass include="smaa-pass.xml">
    <name>smaa-edge-detection</name>
    <effect>Effects/HDR/smaa-edge-detection</effect>
    <clear-mask>color stencil</clear-mask>
    <clear-color type="vec4d">0.0 0.0 0.0 0.0</clear-color>
    <binding>
      <unit>0</unit>
      <buffer>final</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>smaa-edges</buffer>
    </attachment>
    <attachment>
      <component>stencil</component>
      <buffer>depth-stencil</buffer>
    </attachment>
  </pass>
  <pass include="smaa-pass.xml">
    <name>smaa-blending-weight-calculation</name>
    <effect>Effects/HDR/smaa-blending-weight-calculation</effect>
    <clear-mask>color</clear-mask>
    <clear-color type="vec4d">0.0 0.0 0.0 0.0</clear-color>
    <binding>
      <unit>0</unit>
      <buffer>smaa-edges</buffer>
    </binding>
    <attachment>
      <component>color0</component>
      <buffer>smaa-blend</buffer>
    </attachment>
    <attachment>
      <component>stencil</component>
      <buffer>depth-stencil</buffer>
    </attachment>
  </pass>
  <pass include="smaa-pass.xml">
    <name>smaa-neighborhood-blending</name>
    <effect>Effects/HDR/smaa-neighborhood-blending</effect>
    <binding>
      <unit>0</unit>
      <buffer>final</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>smaa-blend</buffer>
    </binding>
  </pass>

  <!-- Debug passes -->
  <pass include="debug-pass.xml">
    <name>debug-color</name>
    <effect>Effects/HDR/gbuffer-debug-color</effect>
    <geometry>
      <left>0.0</left>
      <bottom>0.0</bottom>
      <width>0.2</width>
      <height>0.2</height>
    </geometry>
    <binding>
      <unit>0</unit>
      <buffer>gbuffer1</buffer>
    </binding>
  </pass>
  <pass include="debug-pass.xml">
    <name>debug-forward</name>
    <effect>Effects/HDR/gbuffer-debug-color</effect>
    <geometry>
      <left>0.2</left>
      <bottom>0.0</bottom>
      <width>0.2</width>
      <height>0.2</height>
    </geometry>
    <binding>
      <unit>0</unit>
      <buffer>hdr-forward</buffer>
    </binding>
  </pass>
  <pass include="debug-pass.xml">
    <name>debug-normals</name>
    <effect>Effects/HDR/gbuffer-debug-normal</effect>
    <geometry>
      <left>0.8</left>
      <bottom>0.0</bottom>
      <width>0.2</width>
      <height>0.2</height>
    </geometry>
    <binding>
      <unit>0</unit>
      <buffer>gbuffer0</buffer>
    </binding>
  </pass>
  <pass include="debug-pass.xml">
    <name>debug-orm</name>
    <effect>Effects/HDR/gbuffer-debug-orm</effect>
    <geometry>
      <left>0.0</left>
      <bottom>0.8</bottom>
      <width>0.2</width>
      <height>0.2</height>
    </geometry>
    <binding>
      <unit>0</unit>
      <buffer>gbuffer0</buffer>
    </binding>
    <binding>
      <unit>1</unit>
      <buffer>gbuffer1</buffer>
    </binding>
    <binding>
      <unit>2</unit>
      <buffer>gbuffer2</buffer>
    </binding>
  </pass>
  <pass include="debug-pass.xml">
    <name>debug-matid</name>
    <effect>Effects/HDR/gbuffer-debug-matid</effect>
    <geometry>
      <left>0.0</left>
      <bottom>0.57</bottom>
      <width>0.2</width>
      <height>0.2</height>
    </geometry>
    <binding>
      <unit>0</unit>
      <buffer>gbuffer0</buffer>
    </binding>
  </pass>
  <pass include="debug-pass.xml">
    <name>debug-depth</name>
    <effect>Effects/HDR/gbuffer-debug-depth</effect>
    <geometry>
      <left>0.8</left>
      <bottom>0.8</bottom>
      <width>0.2</width>
      <height>0.2</height>
    </geometry>
    <binding>
      <unit>0</unit>
      <buffer>depth-stencil</buffer>
    </binding>
  </pass>

  <pass>
    <name>debug-histogram</name>
    <type>quad</type>
    <multiview>true</multiview>
    <clear-mask>depth</clear-mask>
    <effect>Effects/HDR/debug-histogram</effect>
    <condition>
      <property>/sim/rendering/hdr/debug/show-histogram</property>
    </condition>
    <geometry>
      <left>0.8</left>
      <bottom>0.57</bottom>
      <width>0.2</width>
      <height>0.2</height>
    </geometry>
    <binding>
      <unit>0</unit>
      <buffer>histogram</buffer>
    </binding>
  </pass>

  <pass>
    <name>debug-cloudquad</name>
    <type>quad</type>
    <multiview>true</multiview>
    <clear-mask>depth</clear-mask>
    <effect>Effects/HDR/debug-cloudquad</effect>
    <condition>
      <property>/sim/rendering/hdr/debug/show-clouds</property>
    </condition>
    <geometry>
      <left>0.8</left>
      <bottom>0.2</bottom>
      <width>0.2</width>
      <height>0.2</height>
    </geometry>
    <binding>
      <unit>0</unit>
      <buffer>clouds</buffer>
    </binding>
  </pass>


  <pass>
    <name>debug-aerial-perspective</name>
    <type>quad</type>
    <multiview>true</multiview>
    <clear-mask>depth</clear-mask>
    <effect>Effects/HDR/debug-aerial-perspective</effect>
    <condition>
      <property>/sim/rendering/hdr/debug/show-aerial-perspective</property>
    </condition>
    <geometry>
      <left>0.0</left>
      <bottom>0.23</bottom>
      <width>0.2</width>
      <height>0.2</height>
    </geometry>
    <binding>
      <unit>11</unit>
      <buffer>aerial-perspective</buffer>
    </binding>
    <binding>
      <unit>14</unit>
      <buffer>histogram-luminance</buffer>
    </binding>
  </pass>
</PropertyList>
