Archive for February 2nd, 2011

02
Feb
11

GLSL Crosshatch

Straight port of

http://learningwebgl.com/blog/?p=2858

Fragment Shader:

/*
	Straight port of code from

http://learningwebgl.com/blog/?p=2858

*/

uniform sampler2D Texture;

void main()
{
	float lum = length(texture2D(Texture, gl_TexCoord[0].xy).rgb);
	
	gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
	
	if (lum < 1.00) {
		if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {
			gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
		}
	}
	
	if (lum < 0.75) {
		if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {
			gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
		}
	}
	
	if (lum < 0.50) {
		if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {
			gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
		}
	}
	
	if (lum < 0.3) {
		if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {
			gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
		}
	}
}




Twitter

February 2011
M T W T F S S
« Jan   Mar »
 123456
78910111213
14151617181920
21222324252627
28  

Links

Blog Stats

  • 401,522 hits

Follow

Get every new post delivered to your Inbox.

Join 36 other followers