no control flow in shader, hth for htc

This commit is contained in:
Hannes Janetzek 2012-09-07 21:12:57 +02:00
parent c01aa685a2
commit 9b697cc05d

View File

@ -18,6 +18,7 @@ package org.mapsforge.android.glrenderer;
class Shaders {
final static String lineVertexShader = ""
// + "#version 130\n"
+ "precision mediump float;"
+ "uniform mat4 mvp;"
+ "attribute vec2 a_position;"
@ -33,6 +34,7 @@ class Shaders {
// last two bits of a_st hold the texture coordinates
// TODO use bit operations when available!
+ " v_st = u_width * (abs(mod(a_st,4.0)) - 1.0);"
// + " v_st = u_width * vec2(ivec2(a_st) & 3 - 1);"
+ "}";
// final static String lineVertexShader = ""
@ -57,19 +59,14 @@ class Shaders {
+ "varying vec2 v_st;"
+ "const float zero = 0.0;"
+ "void main() {"
+ " vec4 color = u_color;"
+ " float len;"
+ " if (v_st.t == zero)"
+ " len = abs(v_st.s);"
+ " else "
// + " if (v_st.t == zero)"
// + " len = abs(v_st.s);"
// + " else "
+ " len = length(v_st);"
// fade to alpha. u_wscale is the width in pixel which should be faded,
// u_width - len the position of this fragment on the perpendicular to the line
+ "color *= smoothstep(zero, u_wscale, u_width - len);"
+ "if (color.a < 0.02)"
+ " discard;"
+ " else"
+ " gl_FragColor = color;"
+ " gl_FragColor = smoothstep(zero, u_wscale, u_width - len) * u_color;"
+ "}";
// final static String lineFragmentShader = ""