Adapt / refactor shader uniforms and attributes
This commit is contained in:
@@ -26,7 +26,7 @@ $$
|
||||
#ifdef GLES
|
||||
precision highp float;
|
||||
#endif
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D u_tex;
|
||||
uniform float u_fade;
|
||||
uniform int u_mode;
|
||||
uniform vec4 u_color;
|
||||
@@ -39,7 +39,7 @@ void main() {
|
||||
#ifdef DESKTOP_QUIRKS
|
||||
len = length(v_st);
|
||||
#else
|
||||
len = texture2D(tex, v_st).a;
|
||||
len = texture2D(u_tex, v_st).a;
|
||||
#endif
|
||||
} else {
|
||||
// flat cap line
|
||||
|
||||
@@ -29,7 +29,7 @@ $$
|
||||
#ifdef GLES
|
||||
precision highp float;
|
||||
#endif
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D u_tex;
|
||||
uniform int u_mode;
|
||||
uniform vec4 u_color;
|
||||
uniform float u_fade;
|
||||
@@ -43,7 +43,7 @@ void main() {
|
||||
#ifdef DESKTOP_QUIRKS
|
||||
len = length(v_st);
|
||||
#else
|
||||
len = texture2D(tex, v_st).a;
|
||||
len = texture2D(u_tex, v_st).a;
|
||||
#endif
|
||||
vec2 st_width = fwidth(v_st);
|
||||
fuzz = max(st_width.s, st_width.t);
|
||||
|
||||
@@ -38,7 +38,7 @@ uniform vec4 u_color;
|
||||
uniform vec4 u_bgcolor;
|
||||
uniform float u_pwidth;
|
||||
varying vec2 v_st;
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D u_tex;
|
||||
uniform int u_mode;
|
||||
|
||||
void main() {
|
||||
@@ -50,7 +50,7 @@ void main() {
|
||||
}
|
||||
// use lineLength mod texture step (mod is always positive)
|
||||
// add 1.0 to avoid static line textures while zooming
|
||||
vec4 c = texture2D(tex, vec2(mod(v_st.s + 1.0, step), (v_st.t + 1.0) * 0.5));
|
||||
vec4 c = texture2D(u_tex, vec2(mod(v_st.s + 1.0, step), (v_st.t + 1.0) * 0.5));
|
||||
float fuzz = fwidth(c.a);
|
||||
gl_FragColor = (c * u_color) * smoothstep(0.5 - fuzz, 0.5 + fuzz, c.a);
|
||||
} else {
|
||||
|
||||
@@ -19,11 +19,11 @@ $$
|
||||
precision highp float;
|
||||
#endif
|
||||
uniform vec4 u_color;
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D u_tex;
|
||||
uniform vec2 u_scale;
|
||||
varying vec2 v_st;
|
||||
varying vec2 v_st2;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = mix(texture2D(tex, v_st), texture2D(tex, v_st2), u_scale.x);
|
||||
gl_FragColor = mix(texture2D(u_tex, v_st), texture2D(u_tex, v_st2), u_scale.x);
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@ $$
|
||||
precision highp float;
|
||||
#endif
|
||||
uniform vec4 u_color;
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D u_tex;
|
||||
uniform vec2 u_scale;
|
||||
varying vec2 v_st;
|
||||
varying vec2 v_st2;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = mix(texture2D(tex, v_st), texture2D(tex, v_st2), u_scale.x) * u_color;
|
||||
gl_FragColor = mix(texture2D(u_tex, v_st), texture2D(u_tex, v_st2), u_scale.x) * u_color;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#ifdef GLES
|
||||
precision highp float;
|
||||
#endif
|
||||
attribute vec2 vertex;
|
||||
attribute vec2 tex_coord;
|
||||
attribute vec2 a_pos;
|
||||
attribute vec2 a_tex_coord;
|
||||
uniform mat4 u_mvp;
|
||||
varying vec2 tex_c;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_mvp * vec4(vertex, 0.0, 1.0);
|
||||
tex_c = tex_coord;
|
||||
gl_Position = u_mvp * vec4(a_pos, 0.0, 1.0);
|
||||
tex_c = a_tex_coord;
|
||||
}
|
||||
|
||||
$$
|
||||
@@ -16,10 +16,10 @@ $$
|
||||
#ifdef GLES
|
||||
precision highp float;
|
||||
#endif
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D u_tex;
|
||||
uniform float u_alpha;
|
||||
varying vec2 tex_c;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(tex, tex_c) * u_alpha;
|
||||
gl_FragColor = texture2D(u_tex, tex_c) * u_alpha;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifdef GLES
|
||||
precision highp float;
|
||||
#endif
|
||||
attribute vec4 vertex;
|
||||
attribute vec2 tex_coord;
|
||||
attribute vec4 a_pos;
|
||||
attribute vec2 a_tex_coord;
|
||||
uniform mat4 u_mv;
|
||||
uniform mat4 u_proj;
|
||||
uniform float u_scale;
|
||||
@@ -12,16 +12,16 @@ varying vec2 tex_c;
|
||||
|
||||
void main() {
|
||||
vec4 pos;
|
||||
vec2 dir = vertex.zw;
|
||||
vec2 dir = a_pos.zw;
|
||||
float coord_scale = 1.0 / u_coord_scale;
|
||||
if (abs(mod(vertex.x, 2.0)) == 0.0) {
|
||||
pos = u_proj * (u_mv * vec4(vertex.xy + dir * u_scale, 0.0, 1.0));
|
||||
if (abs(mod(a_pos.x, 2.0)) == 0.0) {
|
||||
pos = u_proj * (u_mv * vec4(a_pos.xy + dir * u_scale, 0.0, 1.0));
|
||||
} else { // place as billboard
|
||||
vec4 center = u_mv * vec4(vertex.xy, 0.0, 1.0);
|
||||
vec4 center = u_mv * vec4(a_pos.xy, 0.0, 1.0);
|
||||
pos = u_proj * (center + vec4(dir * coord_scale, 0.0, 0.0));
|
||||
}
|
||||
gl_Position = pos;
|
||||
tex_c = tex_coord * u_div;
|
||||
tex_c = a_tex_coord * u_div;
|
||||
}
|
||||
|
||||
$$
|
||||
@@ -29,9 +29,9 @@ $$
|
||||
#ifdef GLES
|
||||
precision highp float;
|
||||
#endif
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D u_tex;
|
||||
varying vec2 tex_c;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(tex, tex_c.xy);
|
||||
gl_FragColor = texture2D(u_tex, tex_c.xy);
|
||||
}
|
||||
|
||||
@@ -171,8 +171,8 @@ public class BitmapBucket extends TextureBucket {
|
||||
return;
|
||||
uMVP = getUniform("u_mvp");
|
||||
uAlpha = getUniform("u_alpha");
|
||||
aPos = getAttrib("vertex");
|
||||
aTexCoord = getAttrib("tex_coord");
|
||||
aPos = getAttrib("a_pos");
|
||||
aTexCoord = getAttrib("a_tex_coord");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -95,8 +95,8 @@ public class TextureBucket extends RenderBucket {
|
||||
uScale = getUniform("u_scale");
|
||||
uCoordScale = getUniform("u_coord_scale");
|
||||
uTexSize = getUniform("u_div");
|
||||
aPos = getAttrib("vertex");
|
||||
aTexCoord = getAttrib("tex_coord");
|
||||
aPos = getAttrib("a_pos");
|
||||
aTexCoord = getAttrib("a_tex_coord");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user