A new shader to make beautifull lightbeams

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13073 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
samuncle
2013-07-04 02:32:11 +00:00
parent eecf0b67f6
commit bb64fec5d0
2 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
// Jean-manuel clemencon supertuxkart
// Creates a cone lightbeam effect by smoothing edges
// Original idea: http://udn.epicgames.com/Three/VolumetricLightbeamTutorial.html
// TODO: Soft edges when it intesects geometry
// Some artefacts are still visible
uniform sampler2D main_texture;
uniform float transparency;
varying vec2 uv;
varying vec3 eyeVec;
varying vec3 normal;
void main()
{
float inter = dot(normal, eyeVec);
float m = texture2D(main_texture, vec2(0.5, uv.y)).r;
gl_FragColor = vec4(1.0,1.0,0.8, 1.0);
gl_FragColor.a = inter * inter * inter * inter * m;
}

View File

@@ -0,0 +1,22 @@
// Jean-manuel clemencon supertuxkart
// Creates a cone lightbeam effect by smoothing edges
uniform float time;
varying vec2 uv;
varying vec3 eyeVec;
varying vec3 normal;
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewMatrix * gl_Vertex;
eyeVec = normalize(-gl_Position).xyz;
normal = gl_NormalMatrix * gl_Normal;
gl_Position = ftransform();
uv = gl_TexCoord[0].st;
}