User Guide Cancel

GLSLFX Shaders | Substance 3D Designer

  1. Substance 3D home
  2. User guide
  3. Glossary
  4. Getting started
    1. Getting started
    2. Activation and licenses
    3. System requirements
    4. Overview
      1. Overview
      2. What is a Substance 3D file?
    5. Workflow overview
    6. Shortcuts
    7. Tutorials & learning
  5. Interface
    1. Interface
    2. Customizing your workspace
    3. Home screen
    4. Main toolbar
    5. Preferences
      1. Preferences
      2. Project settings
      3. Version control
    6. Explorer
      1. Explorer
      2. Send to... / Interoperability
    7. Graph view
      1. Graph view
      2. Link creation modes
      3. Graph items
        1. Graph items
        2. Dot node (also Portal)
        3. Frame
        4. Comment
        5. Pin
    8. Library
      1. Library
      2. Managing custom content and filters
    9. Properties
    10. 2D view
    11. 3D view
      1. 3D view
      2. Material properties
      3. GLSLFX shaders
      4. Switching your shaders to OpenGL Core Profile
      5. Iray
    12. Dependency manager
  6. Resources
    1. Resources
    2. Importing, linking and new resources
    3. Bitmap resource
      1. Bitmap resource
      2. Bitmap painting tools
    4. Vector graphics (SVG) resource
      1. Vector graphics (SVG) resource
      2. Vector editing tools
    5. 3D scene resource
    6. AxF (Appearance eXchange Format)
    7. Font resource
    8. Warnings from dependencies
  7. Substance graphs
    1. Substance graphs
    2. Substance graph key concepts
    3. Creating a Substance graph
      1. Creating a Substance graph
      2. Graph instances / Sub-graphs
    4. Exposing a parameter
      1. Exposing a parameter
      2. Parameter presets
      3. Visible if: control visibility of inputs, outputs and parameters
    5. Graph parameters
    6. Inheritance in Substance graphs
    7. Output size
    8. Values in Substance graphs
    9. Publishing Substance 3D asset files (SBSAR)
    10. Exporting bitmaps
    11. Exporting PSD files
    12. Sample Substance graphs
    13. Warnings in Substance graphs
    14. Nodes reference for Substance graphs
      1. Nodes reference for Substance graphs
      2. Atomic nodes
        1. Atomic nodes
        2. Bitmap
        3. Blend
          1. Blend
          2. Blending modes description
        4. Blur
        5. Channel shuffle
        6. Curve
        7. Directional blur
        8. Directional warp
        9. Distance
        10. Emboss
        11. FX-map
        12. Gradient (Dynamic)
        13. Gradient map
        14. Grayscale conversion
        15. HSL
        16. Levels
        17. Normal
        18. Pixel processor
        19. SVG
        20. Sharpen
        21. Text
        22. Transformation 2D
        23. Uniform color
        24. Value processor
        25. Warp
        26. Output
        27. Input
      3. Node library
        1. Node library
        2. Texture generators
          1. Texture generators
          2. Noises
            1. Noises
            2. 3D Perlin noise
            3. 3D Perlin noise fractal
            4. 3D Ridged noise fractal
            5. 3D Simplex noise
            6. 3D Voronoi
            7. 3D Voronoi fractal
            8. 3D Worley noise
            9. Anisotropic noise
            10. Blue noise fast
            11. BnW spots 1
            12. BnW spots 2
            13. BnW spots 3
            14. Cells 1
            15. Cells 2
            16. Cells 3
            17. Cells 4
            18. Clouds 1
            19. Clouds 2
            20. Clouds 3
            21. Creased
            22. Crystal 1
            23. Crystal 2
            24. Directional noise 1
            25. Directional noise 2
            26. Directional noise 3
            27. Directional noise 4
            28. Directional scratches
            29. Dirt 1
            30. Dirt 2
            31. Dirt 3
            32. Dirt 4
            33. Dirt 5
            34. Dirt gradient
            35. Fluid
            36. Fractal sum 1
            37. Fractal sum 2
            38. Fractal sum 3
            39. Fractal sum 4
            40. Fractal sum base
            41. Fur 1
            42. Fur 2
            43. Fur 3
            44. Gaussian noise
            45. Gaussian spots 1
            46. Gaussian spots 2
            47. Grunge concrete
            48. Grunge Damas
            49. Grunge galvanic large
            50. Grunge galvanic small
            51. Grunge leaks
            52. Grunge leaky paint
            53. Grunge map 001
            54. Grunge map 002
            55. Grunge map 003
            56. Grunge map 004
            57. Grunge map 005
            58. Grunge map 006
            59. Grunge map 007
            60. Grunge map 008
            61. Grunge map 009
            62. Grunge map 010
            63. Grunge map 011
            64. Grunge map 012
            65. Grunge map 013
            66. Grunge map 014
            67. Grunge map 015
            68. Grunge rough dirty
            69. Grunge rust fine
            70. Grunge scratches dirty
            71. Grunge scratches fine
            72. Grunge scratches rough
            73. Grunge shavings
            74. Grunge splashes dusty
            75. Grunge spots
            76. Grunge spots dirty
            77. Liquid
            78. Messy fibers 1
            79. Messy fibers 2
            80. Messy fibers 3
            81. Microscope view
            82. Moisture noise
            83. Perlin noise
            84. Plasma
            85. Caustics
            86. Voronoi
            87. Voronoi fractal
            88. Waveform 1
            89. White noise
            90. White noise fast
          3. Patterns
            1. Patterns
            2. 3D linear gradient
            3. 3D volume mask
            4. Alveolus
            5. Arc pavement
            6. Brick 1
            7. Brick 2
            8. Brick generator
            9. Checker 1
            10. Cube 3D
            11. Cube 3D GBuffers
            12. Fibers 1
            13. Fibers 2
            14. Gaussian 1
            15. Gaussian 2
            16. Gradient axial
            17. Gradient axial reflected
            18. Gradient circular
            19. Gradient linear 1
            20. Gradient linear 2
            21. Gradient linear 3
            22. Gradient radial
            23. Height extrude
            24. Mesh 1
            25. Mesh 2
            26. Panorama shape
            27. Polygon 1
            28. Polygon 2
            29. Scratches generator
            30. Shape
            31. Shape extrude
            32. Shape mapper
            33. Shape splatter
            34. Shape splatter blend
            35. Shape splatter data extract
            36. Shape splatter to mask
            37. Splatter
            38. Splatter circular
            39. Star
            40. Starburst
            41. Stripes
            42. Tile generator
            43. Tile random
            44. Tile random 2
            45. Tile sampler
            46. Triangle grid
            47. Weave 1
            48. Weave 2
            49. Weave generator
        3. Filters
          1. Filters
          2. Adjustments
            1. Adjustments
            2. Apply color palette
            3. Auto levels
            4. Channel mixer
            5. Chrominance extract
            6. Clamp
            7. Color match
            8. Color to mask
            9. Contrast/Luminosity
            10. Convert to linear
            11. Convert to sRGB
            12. Create color palette (16)
            13. Grayscale conversion advanced
            14. Hald CLUT
            15. HDR range viewer
            16. Height map frequencies mapper
            17. Highpass
            18. Histogram compute
            19. Histogram equalize
            20. Histogram range
            21. Histogram render
            22. Histogram scan
            23. Non-uniform histogram scan
            24. Histogram select
            25. Histogram shift
            26. ID to mask grayscale
            27. Invert
            28. Lighting cancel high frequencies
            29. Lighting cancel low frequencies
            30. Luminance highpass
            31. Min max
            32. Modify color palette
            33. Pow
            34. Quantize color (Simple)
            35. Quantize color
            36. Quantize grayscale
            37. Replace color
            38. Replace color range
            39. Threshold
            40. View color palette
          3. Blending
            1. Blending
            2. Color (Blend node)
            3. Color burn
            4. Color dodge
            5. Difference
            6. Dissolve
            7. Linear burn
            8. Luminosity (Blend node)
            9. Multi switch
            10. Switch
          4. Blurs
            1. Blurs
            2. Anisotropic blur
            3. Blur HQ
            4. Non-uniform blur
            5. Radial blur
            6. Slope blur
          5. Channels
            1. Channels
            2. RGBA merge
            3. RGBA split
            4. Alpha merge
            5. Alpha split
            6. Pre-multiplied to straight
            7. Straight to pre-multiplied
          6. Effects
            1. Effects
            2. 3D texture position
            3. 3D texture SDF
            4. 3D texture surface render
            5. 3D texture volume render
            6. Ambient occlusion (HBAO)
            7. Ambient occlusion (RTAO)
            8. Anisotropic Kuwahara color
            9. Anisotropic Kuwahara grayscale
            10. Bevel
            11. Bevel smooth
            12. Cross section
            13. Curvature
            14. Curvature smooth
            15. Curvature sobel
            16. Diffusion color
            17. Diffusion grayscale
            18. Diffusion UV
            19. Directional distance
            20. Edge detect
            21. Emboss with gloss
            22. Extend shape
            23. Flood fill
            24. Flood fill mapper
            25. Flood fill to Bbox size
            26. Flood Fill to gradient
            27. Flood Fill to grayscale/color
            28. Flood Fill to index
            29. Flood Fill to position
            30. Flood Fill to random color
            31. Flood Fill to random grayscale
            32. FXAA
            33. Glow
            34. Mosaic
            35. Multi directional warp
            36. Non-uniform directional warp
            37. Reaction diffusion fast
            38. RT irradiance
            39. RT shadow
            40. Shadows
            41. Shape drop shadow
            42. Shape glow
            43. Shape stroke
            44. Summed area table
            45. Swirl
            46. Uber emboss
            47. Vector morph
            48. Vector warp
          7. Normal map
            1. Normal map
            2. Bent normal
            3. Facing normal
            4. Height normal blender
            5. Height to normal world units
            6. Normal blend
            7. Normal combine
            8. Normal invert
            9. Normal normalize
            10. Normal sobel
            11. Normal to height
            12. Normal to height HQ
            13. Normal transform
            14. Normal uncombine
            15. Normal vector rotation
          8. Tiling
            1. Tiling
            2. Make it tile patch
            3. Make it tile photo
          9. Transforms
            1. Transforms
            2. 3D texture offset
            3. Auto crop
            4. Cartesian to polar
            5. Clone (Filter node)
            6. Mirror (Filter node)
            7. Noise upscale 1
            8. Noise upscale 2
            9. Noise upscale 3
            10. Non-square transform
            11. Non-uniform rotation
            12. Polar to cartesian
            13. Quad transform
            14. Safe transform
            15. Skew
            16. Symmetry
            17. Symmetry slice
            18. Trapezoid transform
        4. Material filters
          1. Material filters
          2. 1-click
            1. 1-Click
            2. Bitmap to material light
          3. Effects (Material)
            1. Effects (Material)
            2. Height blend
            3. Material height blend
            4. Season filter
            5. Snow cover
            6. Water level
          4. Transforms (Material)
            1. Transforms (Material)
            2. Material transform
          5. Blending (Material)
            1. Blending (Material)
            2. Material adjustment blend
            3. Material blend
            4. Material color blend
            5. Material switch
            6. Multi-material blend
          6. PBR utilities
            1. PBR utilities
            2. BaseColor / Metallic / Roughness converter
            3. Base material
            4. PBR Albedo safe color
            5. PBR BaseColor / Metallic validate
            6. PBR Dielectric F0
            7. PBR Metal reflectance
            8. PBR render
            9. PBR render mapping
          7. Scan processing
            1. Scan processing
            2. AO cancellation
            3. Atlas scatter
            4. Atlas splitter
            5. Clone patch
            6. Color equalizer
            7. Crop
            8. Material clone patch
            9. Material crop
            10. Multi-angle to Albedo
            11. Multi-angle to Normal
            12. Multi-clone patch
            13. Multi-color equalizer
            14. Multi-crop
            15. Smart auto tile
        5. Mesh-based generators
          1. Mesh-based generators
          2. Mask generators
            1. Mask generators
            2. Bottom to top
            3. Cloth wear
            4. Dirt
            5. Dripping rust
            6. Dust
            7. Edge blur
            8. Edge damages
            9. Edge dirt
            10. Edge notch
            11. Edge select
            12. Edge speckle
            13. Edge wear
            14. Fiber glass edge wear
            15. Grease
            16. Ground dirt
            17. Leaks
            18. Leather wear
            19. Light
            20. Mask builder
            21. Metal edge eear
            22. Paint wear
            23. Selective dirt
            24. Sun bleach
            25. Surface brush
          3. Weathering
            1. Weathering
            2. Cracks weathering
            3. Fabric weathering
            4. Leather weathering
            5. Metal weathering
            6. Moss weathering
            7. Rock weathering
            8. Rust weathering
          4. Utilities (Mesh-based generators)
            1. Utilities (Mesh-based generators)
            2. 3D planar projection
            3. Material mesh data blender
            4. Material selector
            5. Mesh data combiner
            6. Triplanar
        6. Spline & Path tools
          1. Spline & Path tools
          2. Working with Path & Spline tools
          3. Path tools
            1. Path tools
            2. Paths format specifications
            3. Paths 2D transform
            4. Mask to Ppths
            5. Paths to spline
            6. Paths polygon
            7. Preview paths
            8. Paths warp
            9. Quad transform on path
            10. Paths select
            11. Paths vertex processor
            12. Paths vertex processor simple
          4. Spline tools
            1. Spline tools
            2. Paths to Spline
            3. Point list
            4. Scatter on Spline color
            5. Scatter on Spline grayscale
            6. Spline 2D transform
            7. Spline (Cubic)
            8. Spline (Poly quadratic)
            9. Spline append
            10. Spline bridge (2 Splines)
            11. Spline bridge (List)
            12. Spline bridge mapper color
            13. Spline bridge mapper grayscale
            14. Spline circle
            15. Spline fill
            16. Spline flow mapper
            17. Spline mapper color
            18. Spline mapper grayscale
            19. Spline merge list
            20. Spline render
            21. Spline sample height
            22. Spline sample thickness
            23. Spline select
            24. Spline warp
            25. UV mapper color
            26. UV mapper grayscale
        7. 3D view (Library)
          1. 3D view (Library)
          2. HDRI tools
            1. HDRI tools
            2. Blackbody
            3. Color temperature adjustment
            4. Exposure
            5. Exposure preview
            6. HDR merge
            7. Nadir extract
            8. Nadir patch
            9. Panorama 3D position
            10. Panorama rotation
            11. Gradient 2 points
            12. Gradient linear (HDRI)
            13. Line light
            14. Physical sun/sky
            15. Plane light
            16. Shape light
            17. Sphere light
            18. Straighten horizon
  8. Substance function graphs
    1. Substance function graphs
    2. What is a Substance function graph?
    3. Create and edit a Substance function graph
    4. The Substance function graph
    5. Variables
      1. Variables
      2. Built-in variables
      3. Get a variable value
      4. Create a variable
    6. FX-maps
      1. FX-Maps
      2. How it works
      3. The Iterate node
      4. The Quadrant node
      5. Using Substance function graphs in FX-Maps
        1. Using Substance function graphs
          in FX-Maps
        2. Iterate and $number variable
        3. Using the Sampler nodes
        4. Using the Set/Sequence nodes
    7. Warnings in Substance function graphs
    8. Sample Substance function graphs
    9. Nodes reference for Substance function graphs
      1. Nodes reference for Substance function graphs
      2. Function nodes overview
      3. Constant nodes
      4. Vector and Swizzle nodes
      5. Get nodes
      6. Sampler nodes
      7. Cast nodes
      8. Operator nodes
      9. Logical nodes
      10. Comparison nodes
      11. Function nodes
      12. Control nodes
  9. MDL graphs
    1. MDL graphs
    2. Main MDL graph concepts
    3. Creating an MDL graph
    4. MDL library
    5. Exposing parameters in MDL graphs
    6. Substance graphs and MDL materials
    7. Exporting MDL content
    8. Warnings in MDL graphs
    9. MDL learning resources
  10. Bakers
    1. Bakers
    2. Bakers legacy interface
  11. Best practices
    1. Best practices
    2. Filesize reduction guidelines
    3. Graph creation etiquette
    4. Performance optimization guidelines
  12. Pipeline and project configuration
    1. Pipeline and project configuration
    2. Project configuration files - SBSPRJ
    3. Configuration list - SBSCFG
    4. User preferences - Automating setup
    5. Retrieving the installation path
    6. Environment variables
  13. Color management
    1. Color management
    2. Spot colors (Pantone)
  14. Package metadata
  15. Scripting
    1. Scripting
    2. Plugin basics
    3. Plugin search paths
    4. Plugins packages
    5. Plugin manager
    6. Python editor
    7. Accessing graphs and selections
    8. Nodes and properties
    9. Undo and redo
    10. Application callbacks
    11. Creating user interface elements
    12. Adding actions to the Explorer toolbar
    13. Using color management
    14. Using spot colors
    15. Logging
    16. Using threads
    17. Debugging plugins using Visual Studio Code
    18. Porting previous plugins
    19. Packaging plugins
    20. Scripting API reference
  16. Technical issues
    1. Technical issues
    2. Warnings and errors
    3. Cannot create/load a project
    4. Application does not start
    5. Crash when rendering graphs
    6. Parameters not working as expected
    7. Incorrect image output
    8. 3D View issues
    9. User interface issues
    10. Python issues
    11. Substance model graph feature is missing
  17. Release notes
    1. Release notes
    2. All changes
    3. Version 14.0
    4. Version 13.1
    5. Version 13.0
    6. Version 12.4
    7. Version 12.3
    8. Version 12.2
    9. Version 12.1
    10. Version 11.3
    11. Version 11.2
    12. Version 2021.1 (11.1)
    13. Old versions
      1. Old versions
      2. Version 2020.2 (10.2)
      3. Version 2020.1 (10.1)
      4. Version 2019.3 (9.3)
      5. Version 2019.2 (9.2)
      6. Version 2019.1 (9.1)

GLSLFX Shaders

GLSLFX files make the bridge between the application and the glsl shader files.
It allows to use any glsl shader without having to modify the code.


File Format

GLSLFX file format is a XML file. Comments are supported.

Header and Root node

The XML root node element is named glslfx.

<?xml version="1.0" encoding="UTF-8"?>
<glslfx version="1.0.0" author="allegorithmic.com">
    <!-- BODY -->
    <!-- ... -->
</glslfx>

Body

Technique

XML Element that describes a technique. A technique is a variation of the current FX. A GLSLFX can contain multiple techniques but at least one technique has to be defined.

The geometry will be rendered with one of the techniques defined by the application.

Name: technique

Attributes:

  • name: Any string used to name the technique
<!-- TECHNIQUES -->
<technique name="LowResShader">
    <!-- ... -->
</technique>
<!-- ... -->
<technique name="HighResShader">
    <!-- ... -->
</technique>

The XML element can have multiples children. The elements defined in a techniques override the elements defined globally.

For example, it is used to override some uniforms values and obtain FX variation for this technique.

Render Pass

XML Element that describes a render pass. A render pass describes the rendering of the geometry.

A technique can contain multiple render passes that will be executed sequentially. A technique containing no render pass is equivalent to a technique containing an 'onscreen' render pass.

The elements defined in a render pass override the elements defined in the parent technique.

Name: pass

Attributes:

  • output
  • offscreen: The rendering will be done into user defined render targets
  • onscreen: The rendering will be done into the default render target
<!-- TECHNIQUES -->
<technique name="MultipassTechnique">
    <!-- RENDER PASSES -->
    <pass output="offscreen">
         <!-- ... -->
    </pass>
    <!-- ... -->
    <pass output="onscreen">
         <!-- ... -->
    </pass>
</technique>

Shaders

Set the GLSL shader files for each type.

XML Element Definition:

Name: shader

Attributes:

  • type: The GLSL shader type;
  • filename: The path of the glsl shader file. Can be absolute or relative to the GLSLFX file;
  • primitiveType: The method to render the primitive.
'type' ValueDescription
vertexVertex shader
geometryGeometry shader
tess_controlTessellation Control shader
tess_evalTessellation Evaluation shader
fragmentFragment shader
'primitiveType' ValueDescription
pointRender as points
lineloopRender as line loop
patch[1..N]Render as patches with [1..N] vertices
<!-- TECHNIQUES -->
<technique name="Tessellation">
    <!-- SHADERS -->
    <shader type="vertex" filename="tessellation_parallax/tessellation/vs.glsl" primitiveType="patch4"/>
    <shader type="tess_control" filename="tessellation_parallax/tessellation/tcs.glsl"/>
    <shader type="tess_eval" filename="tessellation_parallax/tessellation/tes.glsl"/>
    <shader type="fragment" filename="tessellation_parallax/fs.glsl"/>
</technique>

Properties

Allow to set up some part of the OpenGL state.

Name: property

Attributes:

  • name: The name of the property to set. The name is based on the OpenGL function or glEnum name:
    • Enums syntax: Without the 'GL_' prefix, in lower case. Examples: glEnable(GL_BLEND_ENABLE) => """, glDisable(GL_CULL_FACE) => """
    • Functions syntax: without the 'gl' prefix, in lower case and with all words separated with '_' character. Example: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) => ""
  • value: The value of the property.
'name' Values'value' ValuesDescription
blend_enabledbooleanEnable/disable the blending mode

true

false
blend_funcstring, stringSet the sources and destination blending functions

zerofor OpenGL enum GL_ZERO

onefor OpenGL enum GL_ONE

src_colorfor OpenGL enum GL_SRC_COLOR

one_minus_src_colorfor OpenGL enum GL_ONE_MINUS_SRC_COLOR

dst_colorfor OpenGL enum GL_DST_COLOR

one_minus_dst_colorfor OpenGL enum GL_ONE_MINUS_DST_COLOR

src_alphafor OpenGL enum GL_SRC_ALPHA

one_minus_src_alphafor OpenGL enum GL_ONE_MINUS_SRC_ALPHA

dst_alphafor OpenGL enum GL_DST_ALPHA

one_minus_dst_alphafor OpenGL enum GL_ONE_MINUS_DST_ALPHA

constant_colorfor OpenGL enum GL_CONSTANT_COLOR

one_minus_constant_colorfor OpenGL enum GL_ONE_MINUS_CONSTANT_COLOR

constant_alphafor OpenGL enum GL_CONSTANT_ALPHA

one_minus_constant_alphafor OpenGL enum GL_ONE_MINUS_CONSTANT_ALPHA

src_alpha_saturatefor OpenGL enum GL_SRC_ALPHA_SATURATE

src1_colorfor OpenGL enum GL_SRC1_COLOR

one_minus_src1_colorfor OpenGL enum GL_ONE_MINUS_SRC1_COLOR

src1_alphafor OpenGL enum GL_SRC1_ALPHA

one_minus_src1_alphafor OpenGL enum GL_ONE_MINUS_SRC1_ALPHA
cull_face_enabledbooleanEnable/disable the face culling

true

false
cull_face_modestringSet the face culling mode

frontfor OpenGL enum GL_FRONT

backfor OpenGL enum GL_BACK

front_and_backfor OpenGL enum GL_FRONT_AND_BACK
depth_funcstringSet the depth compare function

neverfor OpenGL enum GL_NEVER

lessfor OpenGL enum GL_LESS

lequalfor OpenGL enum GL_LEQUAL

equalfor OpenGL enum GL_EQUAL

notequalfor OpenGL enum GL_NOTEQUAL

gequalfor OpenGL enum GL_GEQUAL

greaterfor OpenGL enum GL_GREATER

alwaysfor OpenGL enum GL_ALWAYS
<!-- TECHNIQUES -->
<technique name="LowResShader">
    <!-- PROPERTIES -->
    <property name="blend_enabled" value="true"/>
    <property name="blend_func" value="src_alpha,one_minus_src_alpha"/>
    <property name="cull_face_enabled" value="true"/>
    <property name="cull_face_mode" value="back"/>
    <property name="depth_func" value="lequal"/>
 </technique>

Uniforms

Allow to override some uniforms defined globally or in the parent technique. This allow to change shader behavior for this technique or render pass.

See the Uniforms section below for more details about their definition.

<!-- TECHNIQUES -->
<technique name="Tesselation">
    <!-- SHADERS -->
    <shader type="vertex" filename="tessellation_parallax/tessellation/vs.glsl" primitiveType="patch4"/>
    <shader type="tess_control" filename="tessellation_parallax/tessellation/tcs.glsl"/>
    <shader type="tess_eval" filename="tessellation_parallax/tessellation/tes.glsl"/>
    <shader type="fragment" filename="tessellation_parallax/fs.glsl"/>

    <!-- UNIFORMS -->
    <uniform name="parallax_mode" guiName="Parallax Mode" min="0" max="0" />
    <uniform name="enableTilingInFS" guiName="Tiling Enabled In FS" min="0" max="0" />
    <uniform name="tessellationFactor" guiName="Tessellation Factor" default="4" min="1" max="64" guiStep="1" guiWidget="slider"/>
</technique>

<technique name="Parallax">
    <!-- RENDER PASSES -->
    <pass output="onscreen">
        <!-- SHADERS -->
        <shader type="vertex" filename="tessellation_parallax/parallax/vs.glsl"/>
        <shader type="fragment" filename="tessellation_parallax/fs.glsl"/>

        <!-- UNIFORMS -->
        <uniform name="parallax_mode" guiName="Parallax Mode" min="1" max="1" />
        <uniform name="enableTilingInFS" guiName="Tiling Enabled In FS" min="1" max="1" />
    </pass>
</technique>

Render Targets

For 'offscreen' render passes, render targets must be defined in the render pass.

Name: output

Attributes:

  • attachment: The OpenGL attachment point, inspired by the OpenGL names:
    GL_COLOR_ATTACHMENT[0..3] => 'color[0..3]'
    GL_DEPTH_ATTACHMENT => 'depth'

  • name: the name of the render target.
    It can be used in a later render pass to bind this render target as a sampler.

  • format: the internal format of the render target.

  • clear: optional attribute that defines a clear value.
    If present, the render target will be cleared to this value at the beginning of the render pass.
    If missing, the render target will keep its previous content.
<!-- TECHNIQUES -->
<technique name="Parallax Occlusion">
    <!-- RENDER PASSES -->
    <pass output="offscreen">
        <!-- ... -->
        <!-- RENDER TARGETS -->
        <output attachment="color0" name="sssDiffuse" format="rgba16f"  clear="0.0,0.0,0.0,0.0"/>
        <output attachment="depth"  name="sssDepth"  format="depth42f" clear="1.0"/>
    </pass>
</technique>
Note:

Color render targets are forbidden in an 'onscreen' render pass, but a depth render target can be shared with any render pass (but it's likely to break rendering when mixing multiple materials in the scene).

About formats

For depth formats, all depth-only (no stencil) OpenGL formats are supported:

  • GL_DEPTH_COMPONENT16 => 'depth26'
  • GL_DEPTH_COMPONENT24 => 'depth34'
  • GL_DEPTH_COMPONENT32 => 'depth42'
  • GL_DEPTH_COMPONENT32F => 'depth42f'

For color formats, the name is based on OpenGL enum names, without the 'GL_' prefix, in lower case.
Three channel formats (RGB) are not supported, use an RGBA format instead.
Bit depth per channel supported:

  • Normalized unsigned integer: 8, 16
  • Floating point: 16, 32

An exception to these rules is the GL_R11F_G11F_B10F format which is supported.:

  • GL_RGBA8 => 'rgba8'
  • GL_RGBA16F => 'rgba16f'
  • GL_SRGB8_ALPHA8 => 'srgb8_alpha8'
  • GL_R11F_G11F_B10F => 'r11f_g11f_b10f'
  • GL_RG16 => "rg16"

Samplers

Allow to override some samplers defined globally, they cannot be defined in a technique. This allow to define a sampler usage for this render pass, or to read from a render target of a previous render pass.

See the Samplers section for more details about their definition.

<!-- TECHNIQUES -->
<technique name="Parallax Occlusion">
    <!-- RENDER PASSES -->
    <pass output="offscreen">
        <!-- ... -->
        <!-- RENDER TARGETS -->
        <output attachment="color0" name="sssDiffuse" format="rgba16f"/>
        <output attachment="depth" name="sssDepth" format="depth42f"/>
    </pass>
    <pass output="onscreen">
        <!-- ... -->
        <!-- SAMPLERS -->
        <sampler name="baseColorMap" usage="basecolor,diffuse"/>
        <sampler name="sssDiffuseMap" outputName="sssDiffuse"/>
        <sampler name="sssDepthMap" outputName="sssDepth" />
    </pass>
</technique>

2. Input Vertex Format

This allow to define the semantic of each attributes define in the vertex shader.

XML Element Definition:

    • Name: 'vertexformat'

    • Attributes:

      • 'name': The name of the attribute as defined in the vertex shader.

      • 'semantic': The semantic of the attribute.

        'semantic' ValueDescription
        positionVertex position (float3)
        normalVertex normal (float3)
        texcoord[0..N]Vertex texture coordinate buffer N (float2)
        tangent[0..N]Vertex tangent buffer N (float4)
        binormal[0..N]Vertex binormal buffer N (float4)

Example:

<?xml version="1.0" encoding="UTF-8"?>
<glslfx version="1.0.0" author="allegorithmic.com">
     <!-- BODY -->
     <!-- ... -->

     <!-- INPUT VERTEX FORMAT -->
     <vertexformat name="iVS_Position" semantic="position"/>
     <vertexformat name="iVS_Normal" semantic="normal"/>
     <vertexformat name="iVS_UV" semantic="texcoord0"/>
     <vertexformat name="iVS_Tangent" semantic="tangent0"/>
     <vertexformat name="iVS_Binormal" semantic="binormal0"/>
</glslfx>

3. Samplers

This allow to define the usage of each samplers.
It is used by the application to known which texture to set in the specified samplers.

XML Element Definition:

    • Name: 'sampler'

    • Attributes:

      • 'name': The name of the sampler variable in the shader file.

      • 'usage': The usage of the sampler. It matches the usage specified in the Ouput node of the graph.

        'usage' ValueDescription
        diffuseDiffuse map
        opacityOpacity map
        emissiveEmissive map
        ambientocclusionAmbient occlusion map
        ambientAmbient map
        maskMask map
        detailnormalDetail Normal map
        normalNormal map
        bumpBump map
        heightHeight map
        displacementDisplacement map
        specularlevelSpecular level map
        specularcolorSpecular color map
        specularSpecular map
        glossinessGlossiness map
        roughnessRoughness map
        anisotropylevelAnisothropy level map
        anisotropyangleAnisothropy angle map
        transmissiveTransmissive map
        reflectionReflection map
        refractionRefraction map
        environmentEnvironment map (cube map)
        panoramaThe Panorama Map (Latitude/Longitude Map)
        bluenoisemaskA 256x256 dithering texture
        • Multiple usages are supported.
          • Example:
           <!-- SAMPLERS -->
            <sampler name="baseColorMap" usage="basecolor,diffuse"/>
             <!-- ... -->
      • 'isHidden': Boolean that indicates if the sampler should appear in the GUI

        • Example:
             <!-- SAMPLERS -->
            <sampler name="bluenoiseMask" usage="bluenoisemask" ishidden="true"/>
             <!-- ... -->
      • Wrapping Mode:

        NameValue
        texture_wrap_s, texture_wrap_t, texture_wrap_r


        clamp_to_edge
        clamp_to_border
        mirrored_repeat
        repeat

      • Texture Filter

        NameValue
        texture_min_filter, texture_mag_filter


        nearest
        linear
        nearest_mipmap_nearest
        linear_mipmap_nearest
        nearest_mipmap_linear
        linear_mipmap_linear

Example:

<?xml version="1.0" encoding="UTF-8"?>
<glslfx version="1.0.0" author="allegorithmic.com">
     <!-- BODY -->
     <!-- ... -->

     <!-- SAMPLERS -->
     <sampler name="baseColorMap" usage="basecolor,diffuse"/>
     <sampler name="heightMap" usage="height"/>
     <sampler name="normalMap" usage="normal"/>
     <sampler name="detailNormalMap" usage="detailNormal"/>
     <sampler name="environmentMap" usage="environment"/>
     <sampler name="bluenoiseMask" usage="bluenoisemask" ishidden="true"/>
     <sampler name="sssDiffuseMap" usage="sssDiffuse"/>
</glslfx>

4. Uniforms

This allow to add additional information on each shader uniforms.

XML Element Definition:

    • Name: 'uniform'

    • Attributes:

      • 'name': The name of the uniform in the shader file.

      • 'semantic': The semantic of the uniform. (All matrices are float16).

        'semantic' ValueDescription
        worldWorld Matrix (float16)
        worldinversetransposeWorld Inverse Transpose Matrix (float16)
        worldviewprojectionWorld View Projection Matrix (float16)
        viewinverseWorld Inverse Matrix (float16)
        worldviewWorld View Matrix (float16)
        modelviewModel View Matrix (float16)
        projectionProjection Matrix (float16)
        ambientScene Ambient Color (float3)
        lightposition[0..N]Position of the scene's Nth light (float3)
        lightcolor[0..N]Color of the scene's Nth light (float3)
        lightintensity[0..N]Intensity of the scene's Nth light (float)
        globaltimeCurrent time in secs (float)
        resolutionViewport resolution (int2)
        mouseMouse position (int2)
        samplespostablesizeNumber of samples to use to compute the environment lighting (int)
        irradianceshcoefsThe array of spherical harmonics vectors (float3[10])
        panoramamipmapheightNumber of mipmap levels in the panorama map (float)
        panoramarotationAngle Rotation angle of the panorama map (float)
        panoramaintensityIntensity of the panorama map (float)
        computebinormalinfragmentshaderDoes the binormal be computedt per fragment ? (if not then per vertex) (bool)
        isdirectxnormalIs the normal map format DirectX ? (bool)
        uvwscaleScale values of u, v, w (float3)
        renderuvtileRender only 1 UV tile ? (bool)
        uvtilecoordsUV tile coordinate to render (int2)

Example:

<?xml version="1.0" encoding="UTF-8"?>
<glslfx version="1.0.0" author="allegorithmic.com">
     <!-- BODY -->
     <!-- ... -->

     <!-- MATRICES -->
     <uniform name="worldMatrix" semantic="world"/>
     <uniform name="worldViewProjMatrix" semantic="worldviewprojection"/>
     <uniform name="worldViewMatrix" semantic="worldview"/>
     <uniform name="worldInverseTransposeMatrix" semantic="worldinversetranspose"/>
     <uniform name="viewInverseMatrix" semantic="viewinverse"/>
     <uniform name="modelViewMatrix" semantic="modelview"/>
     <uniform name="projectionMatrix" semantic="projection"/>
</glslfx>

Example:

<?xml version="1.0" encoding="UTF-8"?>
<glslfx version="1.0.0" author="allegorithmic.com">
    <!-- BODY -->
    <!-- ... -->

    <!-- SCENE PARAMETERS -->
    <uniform name="AmbiColor" semantic="ambient"/>
    <uniform name="Lamp0Pos" semantic="lightposition0"/>
    <uniform name="Lamp0Color" semantic="lightcolor0"/>
    <uniform name="Lamp1Pos" semantic="lightposition1"/>
    <uniform name="Lamp1Color" semantic="lightcolor1"/>
</glslfx>

Other parameters

Other additional information can be add to each uniforms to:

    • define the default value
    • clamp values
    • control the way the uniform will be display in the application:
    • set the label
    • set the widget info used to edit the value in the application:
    • widget name, min, max, increment/decrement step
    • group uniforms in group widgets

As the Uniforms can be override for each techniques, it allows to display a specific gui setup for each techniques.

XML Element Definition:

    • Name: 'uniform'

    • Attributes:

      • 'name': The name of the uniform in the shader file.

      • 'default': The uniform default value

      • 'min': The min value of the validity range

      • 'max': The max value of the validity range

      • 'guiName': The name of the uniform in the GUI of the application

      • 'guiGroup': The name of the group to put the uniform in the GUI of the application

      • 'guiWidget': The name of the widget used to edit the uniform value in the GUI of application

        'guiWidget' ValueDescription
        sliderSlider widget for floatN
        angleAngle widget for float
        colorColor widget for float3, float4 color
        checkboxCheckBox widget for bool
      • 'guiMin': The min value of the widget

      • 'guiMax': The max value of the widget


Example: Tessellation/Parallax

Parallax Vertex Shader File

Located in .\tessellation_parallax\parallax\vs.glsl

Content:

#version 120

attribute vec4 iVS_Position;
attribute vec4 iVS_Normal;
attribute vec2 iVS_UV;
attribute vec4 iVS_Tangent;
attribute vec4 iVS_Binormal;

varying vec3 iFS_Normal;
varying vec2 iFS_UV;
varying vec3 iFS_Tangent;
varying vec3 iFS_Binormal;
varying vec3 iFS_PointWS;

uniform mat4 worldMatrix;
uniform mat4 worldViewProjMatrix;

void main()
{
gl_Position = worldViewProjMatrix * iVS_Position;
iFS_Normal = iVS_Normal.xyz;
iFS_UV = iVS_UV;
iFS_Tangent = iVS_Tangent.xyz;
iFS_Binormal = iVS_Binormal.xyz;
iFS_PointWS = (worldMatrix * iVS_Position).xyz;
}

Tessellation Vertex Shader File

Located in .\tessellation_parallax\tessellation\vs.glsl

Content:

#version 120

attribute vec4 iVS_Position;
attribute vec4 iVS_Normal;
attribute vec2 iVS_UV;
attribute vec4 iVS_Tangent;
attribute vec4 iVS_Binormal;

varying vec4 oVS_Normal;
varying vec2 oVS_UV;
varying vec4 oVS_Tangent;
varying vec4 oVS_Binormal;

void main()
{
gl_Position = iVS_Position;
oVS_Normal = iVS_Normal;
oVS_UV = iVS_UV;
oVS_Tangent = iVS_Tangent;
oVS_Binormal = iVS_Binormal;
}

Tessellation Control Shader File

Located in .\tessellation_parallax\tessellation\tcs.glsl

Content:

#version 400 core
#extension GL_ARB_tessellation_shader : enable

layout(vertices = 3) out;

in vec4 oVS_Normal[];
in vec2 oVS_UV[];
in vec4 oVS_Tangent[];
in vec4 oVS_Binormal[];

out vec4 oTCS_Normal[];
out vec2 oTCS_UV[];
out vec4 oTCS_Tangent[];
out vec4 oTCS_Binormal[];

uniform float tessellationFactor;

void main()
{
gl_TessLevelOuter[0] = tessellationFactor;
gl_TessLevelOuter[1] = tessellationFactor;
gl_TessLevelOuter[2] = tessellationFactor;
gl_TessLevelInner[0] = tessellationFactor;
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;

oTCS_Normal[gl_InvocationID] = oVS_Normal[gl_InvocationID];
oTCS_UV[gl_InvocationID] = oVS_UV[gl_InvocationID];
oTCS_Tangent[gl_InvocationID] = oVS_Tangent[gl_InvocationID];
oTCS_Binormal[gl_InvocationID] = oVS_Binormal[gl_InvocationID];
}

Tessellation Evaluation Shader File

Located in .\tessellation_parallax\tessellation\tcs.glsl

Content:

#version 400 core

layout(triangles, equal_spacing, ccw) in;

in vec4 oTCS_Normal[];
in vec2 oTCS_UV[];
in vec4 oTCS_Tangent[];
in vec4 oTCS_Binormal[];

uniform mat4 worldMatrix;
uniform mat4 worldViewProjMatrix;

uniform sampler2D heightMap;

uniform float tiling = 1.0f;
uniform float heightMapScale = 1.0f;

out vec3 iFS_Normal;
out vec2 iFS_UV;
out vec3 iFS_Tangent;
out vec3 iFS_Binormal;
out vec3 iFS_PointWS;

vec3 interpolate3D(vec3 v0, vec3 v1, vec3 v2, vec3 uvw)
{
return uvw.x * v0 + uvw.y * v1 + uvw.z * v2;
}

vec2 interpolate2D(vec2 v0, vec2 v1, vec2 v2, vec3 uvw)
{
return uvw.x * v0 + uvw.y * v1 + uvw.z * v2;
}

void main()
{
vec3 uvw = gl_TessCoord.xyz;

vec3 newPos = interpolate3D(gl_in[0].gl_Position.xyz, gl_in[1].gl_Position.xyz, gl_in[2].gl_Position.xyz, uvw);
vec3 newNormal = normalize(interpolate3D(oTCS_Normal[0].xyz, oTCS_Normal[1].xyz, oTCS_Normal[2].xyz, uvw));
vec3 newTangent = normalize(interpolate3D(oTCS_Tangent[0].xyz, oTCS_Tangent[1].xyz, oTCS_Tangent[2].xyz, uvw));
vec3 newBinormal = normalize(interpolate3D(oTCS_Binormal[0].xyz, oTCS_Binormal[1].xyz, oTCS_Binormal[2].xyz, uvw));
vec2 newUV = interpolate2D(oTCS_UV[0], oTCS_UV[1], oTCS_UV[2], uvw);

float heightTexSample = texture(heightMap, newUV * tiling).x * 2.0 - 1.0;
newPos += newNormal * heightTexSample * heightMapScale;

vec4 obj_pos = vec4(newPos, 1);
gl_Position = worldViewProjMatrix * obj_pos;

iFS_UV = newUV * tiling;
iFS_Tangent = newTangent;
iFS_Binormal = newBinormal;
iFS_Normal = newNormal;
iFS_PointWS = (worldMatrix * obj_pos).xyz;
}

Fragment Shader File

Located in .\tessellation_parallax\fs.glsl

Content:

#version 120

// #define ALG_NORMAL_DIRECTX
#define ALG_NORMAL_OPENGL

#ifdef ALG_NORMAL_DIRECTX
// #define FLIP_NORMAL_X
#define FLIP_NORMAL_Y
// #define FLIP_NORMAL_Z
#endif //#ifdef ALG_NORMAL_DIRECTX

#ifdef ALG_NORMAL_OPENGL
// #define FLIP_NORMAL_X
#define FLIP_NORMAL_Y
// #define FLIP_NORMAL_Z
#endif //#ifdef ALG_NORMAL_OPENGL

varying vec3 iFS_Normal;
varying vec2 iFS_UV;
varying vec3 iFS_Tangent;
varying vec3 iFS_Binormal;
varying vec3 iFS_PointWS;

uniform vec3 Lamp0Pos = vec3(0.0f,0.0f,70.0f);
uniform vec3 Lamp0Color = vec3(1.0f,1.0f,1.0f);
uniform vec3 Lamp1Pos = vec3(70.0f,0.0f,0.0f);
uniform vec3 Lamp1Color = vec3(0.198f,0.198f,0.198f);
uniform bool flipNormal = true;
uniform float TilingDetail = 3.0f;
uniform float SpecExpon = 50.0;
uniform float Ks = 1.0;
uniform int parallax_mode = 0;
uniform float tessellationFactor = 4.0;
uniform float heightMapScale = 1.0f;
uniform float Depth_detail = 0.5f;
uniform float Kr = 0.5f;
uniform int KF_on = 1;
uniform float KFs = 1.0f;
uniform vec3 AmbiColor = vec3(0.07f,0.07f,0.07f);
uniform float tiling = 1.0f;
uniform int enableTilingInFS = 0;

uniform sampler2D heightMap;
uniform sampler2D normalMap;
uniform sampler2D detailNormalMap;
uniform sampler2D emissiveMap;
uniform sampler2D diffuseMap;
uniform sampler2D specularMap;
uniform sampler2D opacityMap;
uniform samplerCube environmentMap;

uniform mat4 worldMatrix;
uniform mat4 worldInverseTransposeMatrix;
uniform mat4 viewInverseMatrix;

vec4 litFct(float NdotL, float NdotH, float specExp)
{
float ambient = 1.0;
float diffuse = max(NdotL, 0.0);
float specular = step(0.0, NdotL) * pow(max(0.0, NdotH), specExp);
return vec4(ambient, diffuse, specular, 1.0);
}

vec3 lerpFct(vec3 v0, vec3 v1, float percent)
{
return v0 + (v1-v0) * percent;
}

// Phong Shading
void phong_shading(
in vec3 LightColor,
in vec3 normalWS,
in vec3 pointToLightDirWS,
in vec3 pointToCameraDirWS,
inout vec3 DiffuseContrib,
inout vec3 SpecularContrib)
{
vec3 Hn = normalize(pointToCameraDirWS + pointToLightDirWS);
vec4 litV = litFct(dot(normalWS, pointToLightDirWS), dot(normalWS, Hn), SpecExpon);
DiffuseContrib = litV.y * LightColor;
SpecularContrib = litV.y * litV.z * Ks * LightColor;
}

vec3 fixNormalSample(vec3 v)
{
vec3 result = v - vec3(0.5,0.5,0.5);

#ifdef FLIP_NORMAL_X
result.x = -result.x;
#endif // ifdef FLIP_NORMAL_X
#ifdef FLIP_NORMAL_Y
result.y = -result.y;
#endif // ifdef FLIP_NORMAL_Y
#ifdef FLIP_NORMAL_Z
result.z = -result.z;
#endif // ifdef FLIP_NORMAL_Z

return result;
}

vec3 normalVecOSToWS(vec3 normal)
{
return normal;
}

void main()
{
vec3 cameraPosWS = viewInverseMatrix[3].xyz;
vec3 pointToLight0DirWS = normalize(Lamp0Pos - iFS_PointWS);
vec3 pointToLight1DirWS = normalize(Lamp1Pos - iFS_PointWS);
vec3 pointToCameraDirWS = normalize(cameraPosWS);
vec3 normalOS = normalize(iFS_Normal);
vec3 tangentOS = normalize(iFS_Tangent);
vec3 binormalOS = normalize(iFS_Binormal);

// ------------------------------------------
// Make sure the TBN is Orthonormalized
binormalOS = normalize(cross(normalOS, tangentOS));
tangentOS = normalize(cross(binormalOS, normalOS));

vec3 cumulatedNormalOS = normalOS;

// ------------------------------------------
// Update UV
float a = dot(normalOS,-pointToCameraDirWS);
vec3 s = vec3(dot(pointToCameraDirWS,tangentOS), dot(pointToCameraDirWS,binormalOS), a);
vec2 uv = enableTilingInFS == 0 ? iFS_UV : (iFS_UV * tiling);
float height = texture2D(heightMap,uv).x * 2.0 - 1.0 ;
float parallax = parallax_mode == 0 ? (tessellationFactor / 100000.f + heightMapScale / 500.f) : (heightMapScale / 50.f);
uv += (height * s.xy * parallax) ;

// ------------------------------------------
// Add Normal from normalMap
vec3 normalTS = texture2D(normalMap,uv).xyz;
normalTS = fixNormalSample(normalTS);
vec3 normalMapOS = normalTS.x*tangentOS + normalTS.y*binormalOS;
cumulatedNormalOS = cumulatedNormalOS + normalMapOS;
cumulatedNormalOS = normalize(cumulatedNormalOS);

// ------------------------------------------
// Add detail normalmap
vec3 normalDetailTS = texture2D(detailNormalMap,uv*TilingDetail).xyz;
normalDetailTS = fixNormalSample(normalDetailTS);
vec3 variableNormalDetailTS = lerpFct(vec3(0.0,0.0,0.5),normalDetailTS,Depth_detail);
vec3 normalDetailOS = variableNormalDetailTS.x*tangentOS + variableNormalDetailTS.y*binormalOS;
cumulatedNormalOS = cumulatedNormalOS + normalDetailOS;
cumulatedNormalOS = normalize(cumulatedNormalOS);

if (length(normalTS)<0.0001)
cumulatedNormalOS = normalOS;

vec3 cumulatedNormalWS = normalVecOSToWS(cumulatedNormalOS);

// ------------------------------------------
// Compute Diffuse & Specular

// Light 0 contribution
vec3 diffContrib = vec3(0, 0, 0);
vec3 specContrib = vec3(0, 0, 0);
phong_shading(Lamp0Color, cumulatedNormalWS, pointToLight0DirWS, pointToCameraDirWS, diffContrib, specContrib);

// Light 1 contribution
vec3 diffContrib2 = vec3(0, 0, 0);
vec3 specContrib2 = vec3(0, 0, 0);
phong_shading(Lamp1Color, cumulatedNormalWS, pointToLight1DirWS, pointToCameraDirWS, diffContrib2, specContrib2);

diffContrib += diffContrib2;
specContrib += specContrib2;

vec4 diffuseColor = texture2D(diffuseMap,uv);

vec3 specularColor = texture2D(specularMap,uv).rgb;
vec3 R = reflect(pointToCameraDirWS,cumulatedNormalWS);
vec3 reflColor = Kr * textureCube(environmentMap,R.xyz).bgr;

float FallofRefl;

if (KFs >= 0.0)
FallofRefl = max((1-dot(pointToCameraDirWS/(KFs),cumulatedNormalWS)),0)*KF_on;
else
FallofRefl = (1-max(((1-dot(pointToCameraDirWS/(-KFs),cumulatedNormalWS))),0))*KF_on;

if (KF_on == 0)
FallofRefl=1.0;

vec3 Ambiant_final = diffuseColor.rgb*AmbiColor;

// ------------------------------------------
vec3 emissive = texture2D(emissiveMap,uv).xyz;

vec3 finalcolor = Ambiant_final
+ specularColor*specContrib
+ diffuseColor.rgb*diffContrib
+ (reflColor*specularColor*FallofRefl)
+ emissive;

// Final Color
vec4 finalColor4 = vec4(finalcolor, texture2D(opacityMap,uv));

gl_FragColor = finalColor4;
}

GLSLFX File

The glslfx file defines two techniques to render the geometry:

  • One uses the hardware tessellation technique
  • The other based on a parallax effect that will be used as a fall-back if the user hardware don't support the Tessellation.

Located in .\tessellation_parallax\fs.glsl

Content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sbsbatchnode SYSTEM "glslfx.dtd">
<glslfx version="1.0.0" author="allegorithmic.com">

    <!-- TECHNIQUES -->
    <technique name="Tesselation">
        <!-- PROPERTIES -->
        <property name="blend_enabled" value="true"/>
        <property name="blend_func" value="src_alpha,one_minus_src_alpha"/>
        <property name="cull_face_enabled" value="true"/>
        <property name="cull_face_mode" value="back"/>

        <!-- SHADERS -->
        <shader type="vertex" filename="tessellation_parallax/tessellation/vs.glsl" primitiveType="patch4"/>
        <shader type="tess_control" filename="tessellation_parallax/tessellation/tcs.glsl"/>
        <shader type="tess_eval" filename="tessellation_parallax/tessellation/tes.glsl"/>
        <shader type="fragment" filename="tessellation_parallax/fs.glsl"/>

        <!-- UNIFORMS -->
        <uniform name="parallax_mode" guiName="Parallax Mode" min="0" max="0" />
        <uniform name="enableTilingInFS" guiName="Tiling Enabled In FS" min="0" max="0" />
        <uniform name="tessellationFactor" guiName="Tessellation Factor" default="4" min="1" max="64" guiStep="1" guiWidget="slider"/>
    </technique>

    <technique name="Parallax">
        <!-- PROPERTIES -->
        <property name="blend_enabled" value="true"/>
        <property name="blend_func" value="src_alpha,one_minus_src_alpha"/>
        <property name="cull_face_enabled" value="true"/>
        <property name="cull_face_mode" value="back"/>

        <!-- SHADERS -->
        <shader type="vertex" filename="tessellation_parallax/parallax/vs.glsl"/>
        <shader type="fragment" filename="tessellation_parallax/fs.glsl"/>

        <!-- UNIFORMS -->
        <uniform name="parallax_mode" guiName="Parallax Mode" min="1" max="1" />
        <uniform name="enableTilingInFS" guiName="Tiling Enabled In FS" min="1" max="1" />

    </technique>

    <!-- INPUT VERTEX FORMAT -->
    <vertexformat name="iVS_Position" semantic="position"/>
    <vertexformat name="iVS_Normal" semantic="normal"/>
    <vertexformat name="iVS_UV" semantic="texcoord0"/>
    <vertexformat name="iVS_Tangent" semantic="tangent0"/>
    <vertexformat name="iVS_Binormal" semantic="binormal0"/>

    <!-- SAMPLERS -->
    <sampler name="diffuseMap" usage="diffuse"/>
    <sampler name="heightMap" usage="height"/>
    <sampler name="normalMap" usage="normal"/>
    <sampler name="detailNormalMap" usage="detailNormal"/>
    <sampler name="emissiveMap" usage="emissive"/>
    <sampler name="specularMap" usage="specular"/>
    <sampler name="opacityMap" usage="opacity"/>
    <sampler name="environmentMap" usage="environment"/>

    <!-- MATRICES -->
    <uniform name="worldMatrix" semantic="world"/>
    <uniform name="worldViewProjMatrix" semantic="worldviewprojection"/>
    <uniform name="worldViewMatrix" semantic="worldview"/>
    <uniform name="worldInverseTransposeMatrix" semantic="worldinversetranspose"/>
    <uniform name="viewInverseMatrix" semantic="viewinverse"/>
    <uniform name="modelViewMatrix" semantic="modelview"/>
    <uniform name="projectionMatrix" semantic="projection"/>

    <!-- SCENE PARAMETERS -->
    <uniform name="AmbiColor" semantic="ambient"/>
    <uniform name="Lamp0Pos" semantic="lightposition0"/>
    <uniform name="Lamp0Color" semantic="lightcolor0"/>
    <uniform name="Lamp1Pos" semantic="lightposition1"/>
    <uniform name="Lamp1Color" semantic="lightcolor1"/>

    <!-- UNIFORMS -->
    <uniform name="tiling" guiName="Tiling" default="1" min="1" guiWidget="slider" guiMax="10"/>
    <uniform name="heightMapScale" guiGroup="Height" guiName="Scale" default="1" min="0" guiWidget="slider" guiMin="-50" guiMax="50" />
    <uniform name="TilingDetail" guiGroup="Detail Normal" guiName="Tiling" default="3" min="1" guiWidget="slider" guiMax="10"/>
    <uniform name="Depth_detail" guiGroup="Detail Normal" guiName="Intensity" default="0.5" min="0" max="1" guiStep="0.05" guiWidget="slider"/>
    <uniform name="SpecExpon" guiGroup="Specular" guiName="Power" default="50" min="1" guiWidget="slider" guiMax="128"/>
    <uniform name="Ks" guiGroup="Specular" guiName="Intensity" default="1" min="0" guiWidget="slider" guiMax="3"/>
    <uniform name="Kr" guiGroup="Reflection" guiName="Intensity" default="0.5" min="0" max="1" guiStep="0.01" guiWidget="slider"/>
    <uniform name="KF_on" guiGroup="Reflection" guiName="Falloff" default="1" min="0" max="1" guiStep="1" guiWidget="slider"/>
    <uniform name="KFs" guiGroup="Reflection" guiName="Falloff Size" default="1" min="-1" max="1" guiStep="0.05" guiWidget="slider"/>

</glslfx>



 Adobe

Get help faster and easier

New user?

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online