Sophia Digital Art ★Code is Art★

Displacement shader

Written by Bruce LANE on August 03, 2019

Displacement shader

2D image

The idea is to transform a 2D image as a texture mapped on a sphere and make it audio-reactive.

Audio-reactive sphere

I used openFrameworks with a vertex shader to achieve this. openFrameworks version 0.9.8 allowed to use gluQuadric functions, but it’s not available in version 0.10 and above anymore.

uniform sampler2D colormap;
uniform sampler2D bumpmap;
varying vec2 TexCoord;
uniform float maxHeight;
uniform vec3 twod;

void main(void) {
TexCoord = gl_MultiTexCoord0.st;
vec4 bumpColor = texture2D(bumpmap, TexCoord);
float df = twod.x*bumpColor.x + twod.y*bumpColor.y + twod.z*bumpColor.z;
vec4 newVertexPos = vec4(gl_Normal * df * maxHeight, 0.0) + gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * newVertexPos;
}