summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippo Argiolas <filippo.argiolas@gmail.com>2010-04-24 20:43:39 +0200
committerFilippo Argiolas <filippo.argiolas@gmail.com>2010-04-24 20:43:39 +0200
commitbce3332d94ad13d1b0ac06de208811b176c3c94b (patch)
treee3653480a3acba850fe7bf3e3638664e07c21537
parent3a43353ac9dabba9470cc78595a2a46b490ad414 (diff)
tunnel: get rid of polar coordinates conversion
Get rid of polar coordinates in the tunnel effect as the same can easily be done just clamping the radius and multiplying. Remove the evil atan() call that uses branching and a lot of unneeded alu instructions. Now works on i915!
-rw-r--r--gst/gl/effects/gstgleffectssources.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/gst/gl/effects/gstgleffectssources.c b/gst/gl/effects/gstgleffectssources.c
index 4defe95..a334fad 100644
--- a/gst/gl/effects/gstgleffectssources.c
+++ b/gst/gl/effects/gstgleffectssources.c
@@ -171,14 +171,12 @@ const gchar *tunnel_fragment_source =
" vec2 tex_size = vec2 (width, height);"
" vec2 texturecoord = gl_TexCoord[0].xy;"
" vec2 normcoord;"
- /* little trick with normalized coords to obtain a circle */
- " normcoord = texturecoord / tex_size.x - tex_size / tex_size.x;"
+ /* little trick with normalized coords to obtain a circle with
+ * rect textures */
+ " normcoord = (texturecoord - tex_size) / tex_size.x;"
" float r = length(normcoord);"
- " float phi = atan(normcoord.y, normcoord.x);"
- " r = clamp (r, 0.0, 0.5);" /* is there a way to do this without polars? */
- " normcoord.x = r * cos(phi);"
- " normcoord.y = r * sin(phi); "
- " texturecoord = (normcoord + tex_size/tex_size.x) * tex_size.x;"
+ " normcoord *= clamp (r, 0.0, 0.5) / r;"
+ " texturecoord = (normcoord * tex_size.x) + tex_size;"
" vec4 color = texture2DRect (tex, texturecoord); "
" gl_FragColor = color;"
"}";