tinySceneGraph


TechGuides on tinySceneGraph

The TechGuide series provides insights into advanced techniques used in the tinyScenegraph renderer and scenegraph structures. The main themes are data organisation, performance optimisations and improved visual appearance. You'll find code fragments, step-by-step instructions, as well as links to further documentation.
  1. Procedural marble
  2. Vertex attributes
  3. X-ray rendering
  4. Partially resident textures, AMD
  5. Partially resident textures, ARB
  6. Handling multiple indices
  7. Render to 3D texture
  8. Model import using assimp
  9. Instanced Rendering
  10. Tessellation shader


Procedural Marble

Realism

Handling Vertex Attributes

bump-mapped wood
This guide shows how to develop a shader for procedural marble. The ideas are illustrated step by step, so you may find inspirations for other types of material shaders as well.
Procedural textures can easily scale in size without repeating anywhere or showing tiling artifacts. However, you need to pay attention to aliasing issues, which regular textures handle by mipmapping.
Procedural Marble in GLSL.

Generic vertex attributes are massively useful for for passing arbitrary information to the GPU, offloading processing work to the graphics card. Tangent vectors allow for accelerated bump map or displacement shading, models may be rendered in false colors to show physical properties like pressure or tension, particle speeds, etc.
This guide shows how to use generic attributes and organise data to gain performance.
Generic vertex attributes

Partially Resident Textures (AMD)

sparse texture

Partially Resident Textures (ARB)

x-ray
Partially resident textures (aka sparse textures) allow to allocate virtual memory for textures without immediately committing the entire memory in one chunk. Instead, pages of texels can be swapped into GPU memory on demand.
This guide shows the basic technique using the initial AMD extension and how it is used in tinySG to create textures or arbitrary size (MegaTextures).
Partially resident textures

The OpenGL architecture review board has taken the initial, AMD specific extension and released an ARB, cross-vendor version.
This guide explains how to use the ARB version of partially resident textures and explains differences wrt the former AMD implementation.
Partially resident textures - reloaded

Handling Multiple Indices / Normal Generation

Bismarck

Render to 3D Texture

Combiner
OpenGL indexed data supports just one shared index for all vertex attributes. Although easy to handle and fast to render, it causes some geometry to duplicate vertices in order to have different normals at the same position (i.e. for cube corners).
tinySG uses indexed data only on the host side and avoids it on the GPU almost entirely. When uploading data to the GPU, tinySG unrolls indexed data and stores attributes in an interleaved array. Read more on
tinySG index management.
This guide explains how to convert a polygon scene into a voxel texture. The technique may be useful for i.e. shadow calculations - a shader may sample the 3D texture multiple times to find occluders. tinySG's CFD module tinyFluids uses the technique to divide 3D space in fluid obstacles and empty space for calculating flow.
Render to 3D Texture

Data Import using Assimp

Veyron

Instanced Rendering

Moai
The asset import library assimp is an open-source, cross platform dataset loader with little to no external dependencies. Integration into 3D applications is very easy, all that needs to be done is to traverse the data structures returned by assimp and translate them into the applications scene graph.
This guide explains how it is done.
Assimp loader

Instanced Rendering is a way to render a vast amount of geometry with very few API calls and state changes. Thus, it is well suited to tune performance.
This guide gives code examples on instanced rendering and shows some use cases that you may not have in mind, yet.
Instanced Rendering

Faking x-ray

x-ray

Tessellation shader

x-ray
An x-ray effect is amazingly simple to create using standard OpenGL blending. It produces nice images and, like real x-rays, provides a quick insight in a model's complexity.
tinySG's scene editor implements an x-ray mode that basically disables rendering of shader- and material nodes, so all geometry in a scene is rendered with the x-ray blending settings. See how it is done in the guide on
x-ray rendering
Tessellation shader introduce a new stage in the programmable OpenGL pipeline. Sitting in between the vertex- and the geometry-shader, they allow to tessellate patches on the GPU, multiplying geometry send by the application.
This guide explains how to setup tessellation shaders and shows some sample use cases you may not have thought of, yet..
GPU tessellation



Copyright by Christian Marten, 2009-2016
Last change: 13.07.2016