text: /*
   * BSD 2-Clause License
   *
   * Copyright (c) 2020, Christoph Neuhauser
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions are met:
   *
   * * Redistributions of source code must retain the above copyright notice, this
   *   list of conditions and the following disclaimer.
   *
   * * Redistributions in binary form must reproduce the above copyright notice,
   *   this list of conditions and the following disclaimer in the documentation
   *   and/or other materials provided with the distribution.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  
  THREE.LinkedListHeader = {
  
      code: [
          "#extension GL_ARB_shader_image_load_store : require",
  
          // Use early z-test to cull transparent fragments occluded by opaque fragments.
          // Additionaly, use fragment interlock.
          "layout(early_fragment_tests) in;",
  
          // gl_FragCoord will be used for pixel centers at integer coordinates.
          // See https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_FragCoord.xhtml
          "in vec4 gl_FragCoord;",
  
          // A fragment node stores rendering information about one specific fragment
          "struct LinkedListFragmentNode {",
              // RGBA color of the node
              "uint color;",
              // Depth value of the fragment (in view space)
              "float depth;",
              // The index of the next node in "nodes" array
              "uint next;",
          "};",
  
          // Fragment and link buffer (linked list). Stores "nodesPerPixel" number of fragments.
          "layout (std430, binding = 0) coherent buffer FragmentBuffer {",
              "LinkedListFragmentNode fragmentBuffer[];",
          "};",
  
          // Start-offset buffer (mapping pixels to first pixel in the buffer) of size viewportW*viewportH.
          "layout (std430, binding = 1) coherent buffer StartOffsetBuffer {",
              "uint startOffset[];",
          "};",
  
          // Position of the first free fragment node in the linked list
          "layout(binding = 0, offset = 0) uniform atomic_uint fragCounter;",
          //"layout(binding = 2) buffer FragCounterBuffer {",
          //    "uint fragCounter;",
          //"};",
  
          // Number of fragments we can store in total
          "uniform int linkedListSize;",
  
          "uniform int viewportW;\n"
      ].join( "\n" )
  
  };
  