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