Private Member Functions

VR3Shaders Struct Reference

Global static shaders struct. More...

#include <VR3Shaders.h>

List of all members.

Static Public Attributes

Default Rendering Shaders

This section contains strings used to build our default shader programs. Each string represents a full vertex, fragment, geometry shader or single shader parts. Notice that all default shaders are hardcoded and hidden from the user, they replace the old OpenGL static pipeline.

static const char * FS_computeshadows
 Occlusion computation shader object.
static const char * FS_computeshadows_token
 Occlusion computation shader object source token.
static const char * FS_computeIBL
 Environment mapping calculation shader object.
static const char * VS_nodisp
 No displacement mapping vertex shader main body.
static const char * VS_disp
 Displacement mapping vertex shader main body.
static const char * GS_disp
 Displacement mapping geometry shader main body.
static const char * FS_FFF
 No textures fragment shading.
static const char * FS_TFF
 Diffuse texture only fragment shader.
static const char * FS_FTF
 Light mapping only fragment shader.
static const char * FS_TTF
 Diffuse texture mapping with Light mapping fragment shader.
static const char * FS_FFT
 Normal mapping only fragment shader.
static const char * FS_TFT
 Diffuse texture mapping with normal mapping fragment shader.
Background Rendering Shaders

This section contains the shaders used to render the scene background. In the current implementation, only VR3TEX_2D and VR3TEX_CUBE_MAP backgrounds are supported and a shader program may be built for each of them.

static const char * VS_bg2D
 2D texture background vertex shader.
static const char * FS_bg2D
 2D texture background fragment shader.
static const char * VS_bgCube
 Cube map background vertex shader.
static const char * FS_bgCube
 Cube map background fragment shader.
Shadow Map Rendering Shaders

This section contains the shaders used to render the shadow map.

static const char * VS_shadowmap
 shadow map vertex shader
static const char * FS_shadowmap
 shadow map fragment shader
Blurring Shaders

This section contains the shaders used to blur the shadow map. Future extensions may use these shaders also to blur something else, like the entire scene. We use a separable gaussian blurring filter, meaning that the image filtering is performed in two steps, the first blurs the image horizontally and the second vertically. We create two distinct programs for this purpose, the vertex shader is the same in both programs but the fragment shader differs.

static const char * VS_blur
 Blurring vertex shader.
static const char * FS_blur [2]
 Blurring fragment shaders.
Text Rendering Shaders

This section contains the shaders used to render text strings. In string shading, we always have that the required texture coordinate to access the character texture are the same as the received vertex position data (before being transformed).

static const char * VS_text
 text vertex shader.
static const char * FS_text
 text fragment shader.

Private Member Functions

 VR3Shaders ()
 Private constructor to avoid explicit instantiation.

Detailed Description

Global static shaders struct.

This struct is used to store global static constant shader strings, used to build the shaders source code.

Definition at line 28 of file VR3Shaders.h.


Constructor & Destructor Documentation

VR3Shaders::VR3Shaders (  ) [private]

Private constructor to avoid explicit instantiation.


Member Data Documentation

const char* VR3Shaders::FS_bg2D [static]

2D texture background fragment shader.

Definition at line 246 of file VR3Shaders.h.

const char* VR3Shaders::FS_bgCube [static]

Cube map background fragment shader.

Definition at line 252 of file VR3Shaders.h.

const char* VR3Shaders::FS_blur[2] [static]

Blurring fragment shaders.

This is an array of two fragment shaders, the first represents the fragment shader used for horizontal blurring and the second is the fragment shader used for vertical blurring.

Definition at line 310 of file VR3Shaders.h.

const char* VR3Shaders::FS_computeIBL [static]

Environment mapping calculation shader object.

This code is used when the user enables environment mapping for the current scene, material ambient component is ignored when using Image-Based Lighting.

When dealing with environment mapping, the uniform variable eyePosObj is loaded with the eye position in world space, not in object space.

Definition at line 69 of file VR3Shaders.h.

const char* VR3Shaders::FS_computeshadows [static]

Occlusion computation shader object.

This code is used to compute the fragment darkening due to shadow projection in the scene. We use an Exponential Variance Shadow Map algorithm implementation to obtain convincing penumbras. We compute an upper bound for the visibility function using the Chebyshev's inequality as required by the exponential variance shadow mapping algorithm. Note that we are using both a positive and a negative warp function, by doing this we are able to manage non-planar receivers and we experience light bleeding only if both ESM and VSM would fail.

Definition at line 51 of file VR3Shaders.h.

Occlusion computation shader object source token.

This string is a source code token to use when building the shadow computation shader program. Based on the code posted by Andrew Lauritzen on the Beyond3D online forum in 2008.

Definition at line 59 of file VR3Shaders.h.

const char* VR3Shaders::FS_FFF [static]

No textures fragment shading.

This fragment shader is used when only Phong or flat shading is requested with the proper mesh material.

  • no diffuse texture
  • no light mapping
  • no normal mapping

Definition at line 181 of file VR3Shaders.h.

const char* VR3Shaders::FS_FFT [static]

Normal mapping only fragment shader.

This fragment shader is used when only normal mapping is enabled without any other texture.

  • no diffuse texture
  • no light mapping
  • normal mapping

Definition at line 219 of file VR3Shaders.h.

const char* VR3Shaders::FS_FTF [static]

Light mapping only fragment shader.

This fragment shader is used when only light mapping is enabled, with no other textures on the material. Notice that in this case only the diffuse material color is significant.

  • no diffuse texture
  • light mapping
  • no normal mapping

Definition at line 200 of file VR3Shaders.h.

const char* VR3Shaders::FS_shadowmap [static]

shadow map fragment shader

This fragment shader receives fragment positions from the vertex shader, those position are calculated before applying the projection transformation and therefore are in light space coordinates. The fragment shader merely stores the four moments as required by the full dual-warp EVSM tecnique, using all four channels of our 32 bit floating point texture.

Definition at line 283 of file VR3Shaders.h.

const char* VR3Shaders::FS_text [static]

text fragment shader.

When using this shader, the intensity values obtained from the GDI+ Windows API are scaled from [0,64] to [0,255] by using a simple constant scaling factor (255/64 = 3.984375).

Definition at line 335 of file VR3Shaders.h.

const char* VR3Shaders::FS_TFF [static]

Diffuse texture only fragment shader.

This fragment shader is used when only Phong or flat shading is requested with the proper mesh material and diffuse texture.

  • diffuse texture
  • no light mapping
  • no normal mapping

Definition at line 190 of file VR3Shaders.h.

const char* VR3Shaders::FS_TFT [static]

Diffuse texture mapping with normal mapping fragment shader.

This fragment shader is used when normal mapping is enabled with a diffuse texture on the material.

  • diffuse texture
  • no light mapping
  • normal mapping

Definition at line 228 of file VR3Shaders.h.

const char* VR3Shaders::FS_TTF [static]

Diffuse texture mapping with Light mapping fragment shader.

This fragment shader is used when light mapping is enabled with a diffuse texture. Notice that in this case only the diffuse material color is significant.

  • diffuse texture
  • light mapping
  • no normal mapping

Definition at line 210 of file VR3Shaders.h.

const char* VR3Shaders::GS_disp [static]

Displacement mapping geometry shader main body.

The following geometry shader is used to tessellate each triangle in the mesh in order to produce new vertices that are displaced according to a given displacement map when a diffuse texture is available.

This shader is written to handle normal mapping and diffuse texture mapping, if diffuse texture mapping is not required, then some changes are made directly when loading the source code.

There is an implementation dependent limit to the number of vertices a geometry shader can emit, but there is also an implementation dependent limit to the number of total components a geometry shader can emit. This second limit is more tight and is read from the VRlib code using the GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS constant. As an example, assume the limit is 1024 components. We have the following output active varying variables (when using diffuse texture mapping). smooth out vec2 diffTexCoord; smooth out vec2 lightNormalMapCoord; smooth out vec3 fragPositionObj; out gl_PerVertex { vec4 gl_Position; }; Which means 11 components for each emitted vertex. Therefore, we may emit at most floor(1024/11) vertices, that is 93 vertices. other possible combinations are:

  • Displacement mapping without diffuse texture mapping: 9 components -> 113 vertices

The number is computed based on the implementation dependent limit and the VRLib code takes care of replacing a token string in the shader source stating how many vertices are emitted.

We use a linear subdivision tessellation algorithm subdividing each triangle edge in TF sub-edges obtaining TF triangle strips from each triangle.

  An example with TF = 3:

           V0
           /\
          /  \        <- first triangle strip
         /____\
        / \  / \      <- second triangle strip
       /___\/___\
      /\   /\   /\    <- third triangle strip
     /__\_/__\_/__\
   V1              V2

The number of vertices emitted by using the set of triangle strips above is:

  TF*(TF+2)

And the number of polygons generated from a single triangle is:

  TF*TF

Therefore, with a limit of 93 vertices, our maximum TF would be 8, that generates 80 vertices per triangle.

In OpenGL version 4.0 (and corresponding GLSL version), two new pipeline stages have been added, with two new types of shaders:

  • Tessellation Control Shader
  • Tessellation Evaluation Shader

Those two stages are designed for efficient tessellation, we decided not to use them because at the time of writing OpenGL version 4.0 and above are not widely supported by graphic drivers.

We always produce the fragment position in object coordinates, even in case of light mapping. When using light maps, the fragment position is useless for lighting computation, but it is necessary when also using shadow maps (therefore we always produce it).

Definition at line 172 of file VR3Shaders.h.

const char* VR3Shaders::VS_bg2D [static]

2D texture background vertex shader.

Definition at line 243 of file VR3Shaders.h.

const char* VR3Shaders::VS_bgCube [static]

Cube map background vertex shader.

Definition at line 249 of file VR3Shaders.h.

const char* VR3Shaders::VS_blur [static]

Blurring vertex shader.

Shared in horizontal and vertical blurring programs.

Definition at line 303 of file VR3Shaders.h.

const char* VR3Shaders::VS_disp [static]

Displacement mapping vertex shader main body.

The following (almost complete) vertex shader is used when rendering with displacement mapping, some line of codes will be added before compiling to allow the different parameters to be used when needed. Please note that no vertex position transformation takes place in this vertex shader.

Definition at line 89 of file VR3Shaders.h.

const char* VR3Shaders::VS_nodisp [static]

No displacement mapping vertex shader main body.

The following (almost complete) vertex shader is used when rendering without displacement mapping, some line of codes will be added before compiling to allow the different parameters to be used when needed. We always produce the fragment position in object coordinates, even in case of light mapping. When using light maps, the fragment position is useless for lighting computation, but it is necessary when also using shadow maps (therefore we always produce it).

Definition at line 80 of file VR3Shaders.h.

const char* VR3Shaders::VS_shadowmap [static]

shadow map vertex shader

This vertex shader is the vertex shader used when rendering the shadow map each frame. Note that no color or lighting details are needed when rendering the shadow map and we only need to render the geometry. In particular, we will write to the depth buffer a linear metric. Note that any type of texturing will be ignored when rendering the shadow map, this also means that displacement maps applied to objects will not have any effect.

Definition at line 273 of file VR3Shaders.h.

const char* VR3Shaders::VS_text [static]

text vertex shader.

Definition at line 328 of file VR3Shaders.h.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines