Archive for June 9th, 2009

09
Jun
09

Simple X-Ray Shader

From Ogre3D.

/* Vertex Shader */

varying vec3 P;
varying vec3 N;
varying vec3 I;

void main()
{
	//Transform vertex by modelview and projection matrices
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
	
	// Position in clip space
	P = vec3(gl_ModelViewMatrix * gl_Vertex);
	
	// Normal transform (transposed model-view inverse)
	N = gl_NormalMatrix * gl_Normal;
	
	// Incident vector
	I = P;
	
	// Forward current color and texture coordinates after applying texture matrix
	gl_FrontColor = gl_Color;
	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}

/* Fragment Shader */

varying vec3 P;
varying vec3 N;
varying vec3 I;

uniform float EdgeFalloff;

void main()
{
	float opacity = dot(normalize(N), normalize(-I));
	opacity = abs(opacity);
	opacity = 1.0 - pow(opacity, EdgeFalloff);
	
	gl_FragColor = opacity * gl_Color;
}
Advertisements
09
Jun
09

More Clips

Yet another Random-Walk variation.

NVIDIA vBomb shader GLSL-conversion




Twitter

June 2009
M T W T F S S
« May   Jul »
1234567
891011121314
15161718192021
22232425262728
2930  

Links

Blog Stats

  • 474,654 hits