summaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-06-27 02:56:55 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-06-27 02:56:55 +0200
commite2d40c3fb1723eb1dde87248a08f489d26b684f6 (patch)
tree961a309a41f54854c5989056c4a77bc11db387d9 /shaders
parent761d6d077042c7d679606bbc113050118eb60fc1 (diff)
Simplified rotation shader code.
Diffstat (limited to 'shaders')
-rw-r--r--shaders/bullet_fragment.glsl7
-rw-r--r--shaders/bullet_vertex.glsl15
2 files changed, 9 insertions, 13 deletions
diff --git a/shaders/bullet_fragment.glsl b/shaders/bullet_fragment.glsl
index 5e8becd..55e29ff 100644
--- a/shaders/bullet_fragment.glsl
+++ b/shaders/bullet_fragment.glsl
@@ -1,12 +1,9 @@
-varying mat4 v_tex_rot;
+varying mat3 v_tex_rot;
uniform sampler2D tex;
void main() {
vec2 l_uv = gl_TexCoord[0].xy;
- const vec2 l_offset = vec2(0.5, 0.5);
- l_uv -= l_offset;
- l_uv = vec2(v_tex_rot * vec4(l_uv, 0.0, 1.0));
- l_uv += l_offset;
+ l_uv = vec2(v_tex_rot * vec3(l_uv, 0.5));
gl_FragColor = texture2D(tex, l_uv);
float M = max(max(gl_FragColor.x, gl_FragColor.y), gl_FragColor.z);
float C = M - min(min(gl_FragColor.x, gl_FragColor.y), gl_FragColor.z);
diff --git a/shaders/bullet_vertex.glsl b/shaders/bullet_vertex.glsl
index 0843be2..0717b0a 100644
--- a/shaders/bullet_vertex.glsl
+++ b/shaders/bullet_vertex.glsl
@@ -1,14 +1,13 @@
-varying mat4 v_tex_rot;
+varying mat3 v_tex_rot;
void main() {
vec4 l_position = gl_Vertex;
- vec2 l_direction = normalize(vec2(l_position.z, l_position.w));
- v_tex_rot = mat4(l_direction.x, l_direction.y, 0.0, 0.0,
- -l_direction.y, l_direction.x, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0);
- l_position.z = 0.0;
- l_position.w = 1.0;
+ vec2 l_direction = normalize(l_position.zw);
+ v_tex_rot = mat3(
+ l_direction.x, l_direction.y, 0.0,
+ -l_direction.y, l_direction.x, 0.0,
+ 1.0 - l_direction.x + l_direction.y, 1.0 - l_direction.y - l_direction.x, 0.0);
+ l_position.zw = vec2(0.0, 1.0);
gl_FrontColor = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * l_position;
}