Archive for March 7th, 2008

07
Mar
08

GLSL Texture Coordinate Error

GLSL Texture Coordinate Error 01

Result of using wrong texture coordinates.
Think I might use this one for something.

07
Mar
08

Truchet Tile

Just a little project inspired by this page.
Input is the iSight (but you probably can’t tell).

Truchet Tile QC 01

Truchet Tile QC 02

///////////////////////////
////	  Inputs       ////
///////////////////////////

// Video input
uniform sampler2D VideoIn;
// Truchet tile input
uniform sampler2D TexTile;
// Tile scale (0.01 > 0.5)
uniform vec2 Tile;

///////////////////////////
////	 Functions     ////
///////////////////////////

// Rotate 90 degrees
vec2 rotate90(vec2 phase)
{
	// Rotation matrix
	mat3 rotate = mat3(	0.0,-1.0,0.0,
					1.0,0.0,0.0,
					0.0,0.0,1.0);
	return (vec3(phase,1.0) * rotate).xy;
}

// Flip horizontally
vec2 flipX(vec2 phase)
{
	return vec2(1.0-phase.x,phase.y);
}

// Flip vertically
vec2 flipY(vec2 phase)
{
	return vec2(phase.x,1.0-phase.y);
}

///////////////////////////
////	 Main Loop     ////
///////////////////////////

void main()
{
	// Texture coordinates
	vec2 xy = gl_TexCoord[0].xy;
	
	// Tile coordinates
	vec2 phase = fract(xy / Tile);
	
	// Quantised texture coordinates
	vec2 phaseFloor = floor(xy / Tile) * Tile;
	
	// VideoIn color at quantised coords
	vec4 vid = texture2D(VideoIn,phaseFloor);
	
	// Luminosity of input video pixel
	vec4 lumcoeff = vec4(0.299,0.587,0.114,0.0);
	float lum = dot(vid,lumcoeff);
	
	// Transform texture tile lookup coords based in input luminosity
	vec2 sampleCoord =	(lum > 0.75) ? 	rotate90(phase) :
				(lum > 0.5) ?	flipX(phase) :
				(lum > 0.25) ? 	flipY(phase) :
				phase;
	
	// Output fragment color * tile color
	gl_FragColor = gl_Color * texture2D(TexTile, sampleCoord);
}

The TexTile image looks like this:

Truchet Tile Image

07
Mar
08

To Answer Memo’s Question…

If you look very carefully at the middle one,you might see me waving ;)

Superformula GLSL texTiles 01
Superformula GLSL texTiles 03
Superformula GLSL texTiles 02

07
Mar
08

Vertex Position Quantisation

3D pixellation!!
I’d like to prevent 45-degree faces appearing, but not sure how to go about that. Looks nice anyway.

Superformula GLSL Vertex-Quantised 01Superformula GLSL Vertex-Quantised 02
Superformula GLSL Vertex-Quantised 03Superformula GLSL Vertex-Quantised 04
Superformula GLSL Vertex-Quantised 05Superformula GLSL Vertex-Quantise 06

This is the Superformula being quantised. I’ve added a Mix control, to mix between the quantised and unquantised vertex positions, so the effect can be applied progressively. Needs some tweaking, but it’s quite a cool glitchy effect.




Twitter

March 2008
M T W T F S S
« Feb   Apr »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Links

Blog Stats

  • 401,217 hits

Follow

Get every new post delivered to your Inbox.

Join 36 other followers