Archive for May 1st, 2008

01
May

Quaternion Julia Raytraced in QC

Yeah, yeah, I know.. it’s not big and it’s not clever (especially since I got the code from Keenan Crane via tonfilm more-or-less wholesale)…. but I like fractals. What can I say….

This one is DEFINITELY not realtime, on my MacBook Pro, at least. Fullscreen, each frame takes about 20 seconds to render. Looks nice though.




Note to self:
Look out for Clear patches set to Layer 2 at the top level of a composition.
Took me MUCH too long to spot that one….

01
May

Isosurface Raytracer Vertex Shader (Finally)

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…




 

May 2008
M T W T F S S
« Apr   Jun »
 1234
567891011
12131415161718
19202122232425
262728293031  

Categories

Links

Blog Stats

  • 24,716 hits