Sh

[Home] [About] [Download] [Shaders] [Forum] [People] [SF Project]

Diffuse shader

This demo shows basic Lambertian shading. The shading is calculated at each fragment, using interpolated normals and light directions from the vertex program.

Source files: [diffuse.cpp]


Gooch with Silhouette Detection

This demo shades the object interior using Gooch's NPR lighting model from SIGGRAPH 98 and uses a vertex-shader implementation of Hertzmann's silhouette identification algorithm from SIGGRAPH 2000 to draw silhouette edges.

Source files: [edgegooch.cpp]

Written by: Bryan Chan


Environment-mapping shader

Sh supports cubemaps as one of its texture types. This shader computes a reflection vector at each fragment and uses it as a direction to lookup a cube-map value.

The screenshot shows part of the University of Waterloo's Computer Graphics Lab used as an environment map.

Source files: [EnvironmentShader.cpp]


Glass and Lucite shaders

Glass can be roughly simulated by refracting a ray through the front surface only and then indexing into an environment map. By refracting each of R, G, and B by different amounts, dispersive materials (such as lucite) can be simulated. A Fresnel term is also used here to blend between the result of the refraction and a reflection implemented using the same environment map.

It should be noted that Sh can also implement this effect using HDR images: floating-point cube maps are simulated, if necessary, with shader code.

Source files: [GlassShader.cpp] [LuciteShader.cpp]

The simple glass shader uses only one refractive index.

The more complicated lucite case is rendered using three spectra.


Seven-segment LCD shader

This LCD display shader takes a number as a uniform parameter, and displays it similar to a seven-segment LCD display.

It is an interesting shader, not only because it is a little different from other shaders, but because it makes use of Sh's long tuple support to represent the seven-segment state in seven-tuples, uses C++ arrays to store variables, and uses simple C++ metaprogramming (trivial in Sh) to allow a variety of different shaders to be generated from the same function. For example, handling negative numbers, a grid, and fractional digits can be turned on or off at construction time.

Source files: [LCD.cpp] [LCD.hpp]

Written by: Stefanus Du Toit


Particle System

This particle system demonstrates Sh's new Stream abstraction.

The particle states (position and velocity) are passed into the GPU as a stream of data. A GPU program is then executed to update the state according to physical equations and some collision detection. Sh takes care of transporting the data between the host and the GPU - the programmer need not concern him or herself with details such as whether to use a fragment or vertex program, splitting the program into multiple passes, or dealing with PBuffers and similar APIs.

Written by: Stefanus Du Toit

At this point, only gravity is acting on the particles.

As the particles intersect with spheres, they bounce off, but lose some energy to friction.

Here we see particles bouncing off the ground as well as the spheres.

When the particles slow down to a halt, puddles form.

Almost 16000 particles are shown here.


Perlin Noise Shader

This set of shaders based on Perlin's improved noise function.

Source files: [Noise.cpp]

Written by: Bryan Chan

The simple wood shader uses a single octave of signed Perlin noise to perturb circular bands. The colours were generated using a sawtooth function to blend between light and dark wood.

The more complex wood shader re-uses much of the simple wood shader; however instead of a single octave of noise, it adds several octaves for more convincing turbulence. It also adds noise along the radial direction of the circular bands to randomize the width of each ring in the wood.

The marble shader is very similar to the complex wood shader, except instead of circular bands, it uses simple linear bands along the x direction and it uses a smoothstepped colour mapping.


Phong shader

The Phong shader uses the modified Blinn-Phong model. Diffuse values are calculated in the vertex shader. Interpolated normals and half-vectors are used to calculate specular highlights in the fragment shader.

The size of the specular lobe is controlled by a parameter.

Source files: [PhongShader.cpp]


Worley Shader

This shader is based on Steven Worley's cellular texture basis function.

Source files: [WorleyShader.cpp]

Written by: Zaid Mian and Bryan Chan

This "blobby" version of the Worley shader is meant to simulate organic matter. The specular component of the Phong lighting model is modulated based on the distance function. The coeffecients used here are 1*C1.

In this image the Worley distance function is clamped to produce polka dots centered around the randomly-scattered feature points. The coefficients used for this shader are (1*C1)(clamped).

A combination of different octaves and different distance functions yields this lava-like texture. Intermediate colour values are not clamped to the [0,1] range, producing yellow instead of white highlights in some areas. The coefficients used for this shader are (-1*C1 + 1.2*C2)(Manhattan distance) - (1*C2 + 1*C3)(Euclidean distance squared, scaled texture coordinates).

With these parameters, a giraffe-skin-like texture is created using a sum of clamped Worley textures. In this case we use the Manhattan distance metric. The coefficients used are (-1*C1 + 1*C2)(Clamped) + (-1*C2 + 1*C3)(Clamped).

This circuit-like image shows a simple combination of two Worley textures that use the Manhattan distance metric, and the C4 distance function (distance to 4th closest feature point). The coefficients used in this shader are (1*C4)(Manhattan distance) + (1*C4)(Manhattan distance, scaled texture coordinates).



Copyright 2003-2010 Intel Corporation.