From b4cd5e4ec9ba090874d80abaa8d7dbe9dae50416 Mon Sep 17 00:00:00 2001 From: curaga Date: Mon, 29 Jul 2013 14:40:42 +0000 Subject: [PATCH] Fix the lightbeam shader's inconsistent style git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13380 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/shaders/lightbeam.frag | 16 +++++----------- data/shaders/lightbeam.vert | 12 +++++------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/data/shaders/lightbeam.frag b/data/shaders/lightbeam.frag index 9ffaf7ba7..ff8a569e7 100644 --- a/data/shaders/lightbeam.frag +++ b/data/shaders/lightbeam.frag @@ -2,8 +2,7 @@ // 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 - +// Some artefacts are still visible uniform sampler2D main_texture; uniform float transparency; @@ -13,14 +12,9 @@ varying vec3 normal; void main() { + float inter = dot(normal, eyeVec); + float m = texture2D(main_texture, vec2(0.5, uv.y)).r; + float alpha = inter * inter * inter * inter * m; - - 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; + gl_FragColor = vec4(1.0, 1.0, 0.8, alpha); } diff --git a/data/shaders/lightbeam.vert b/data/shaders/lightbeam.vert index 5fe4d6917..3174ac643 100644 --- a/data/shaders/lightbeam.vert +++ b/data/shaders/lightbeam.vert @@ -1,6 +1,5 @@ // Jean-manuel clemencon supertuxkart // Creates a cone lightbeam effect by smoothing edges - uniform float time; varying vec2 uv; @@ -10,13 +9,12 @@ varying vec3 normal; void main() { gl_TexCoord[0] = gl_MultiTexCoord0; - gl_Position = gl_ModelViewMatrix * gl_Vertex; + vec4 viewp = gl_ModelViewMatrix * gl_Vertex; + eyeVec = normalize(-viewp).xyz; + normal = gl_NormalMatrix * gl_Normal; - eyeVec = normalize(-gl_Position).xyz; - normal = gl_NormalMatrix * gl_Normal; + gl_Position = ftransform(); - gl_Position = ftransform(); - - uv = gl_TexCoord[0].st; + uv = gl_TexCoord[0].st; }