After much head-banging, hair-tearing, and forum posting, I’ve finally managed to work out a vertex shader to allow the raytraced isosurface blobs to be rotated. The code was surprisingly simple, in the end.
uniform vec4 M0; // Rotation matrix column 0
uniform vec4 M1; // Rotation matrix column 1
uniform vec4 M2; // Rotation matrix column 2
uniform vec4 M3; // Rotation matrix column 3
uniform vec3 Camera; // Camera position (transformed to eye position)
varying vec4 eyePos; // Eye position to fragment shader
void main()
{
/*
Transforms texture coordinates and position of virtual camera to be
send to raytracing fragment shader code.
*/
// Assemble rotation matrix from vec4 inputs
mat4 rotate = mat4(M0,M1,M2,M3);
// Set tex to GL texture coordinates
vec4 tex = gl_TextureMatrix[0] * gl_MultiTexCoord0;
tex = tex * 2.0 - 1.0;
// Rotate texture coordinates
tex = rotate * tex;
// Transform camera position with rotation matrix
eyePos = vec4(Camera,1.0);
// Rotate camera
eyePos = rotate * eyePos;
// Transform vertex by modelview and projection matrices
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// Forward texture coordinates
gl_TexCoord[0] = tex;
}
I don’t know if this is the best, or most efficient way of doing it, but it seems to work. I can now rotate the blobs around on any axis, and move the camera around. This method seems much simpler than the VVVV setup I was trying to emulate, too. Perhaps it’s not as flexible. I can’t tell though, as I’ve never managed to get the effect to run in VVVV under XP on my laptop. User Error, almost certainly…