u_Mode uniform as integer
This commit is contained in:
parent
11a5d841f9
commit
c32652c066
@ -8,7 +8,7 @@ uniform mat4 u_mvp;
|
|||||||
uniform float u_width;
|
uniform float u_width;
|
||||||
// xy hold position, zw extrusion vector
|
// xy hold position, zw extrusion vector
|
||||||
attribute vec4 a_pos;
|
attribute vec4 a_pos;
|
||||||
uniform float u_mode;
|
uniform int u_mode;
|
||||||
uniform float u_height;
|
uniform float u_height;
|
||||||
varying vec2 v_st;
|
varying vec2 v_st;
|
||||||
void
|
void
|
||||||
@ -30,13 +30,13 @@ precision highp float;
|
|||||||
#endif
|
#endif
|
||||||
uniform sampler2D tex;
|
uniform sampler2D tex;
|
||||||
uniform float u_fade;
|
uniform float u_fade;
|
||||||
uniform float u_mode;
|
uniform int u_mode;
|
||||||
uniform vec4 u_color;
|
uniform vec4 u_color;
|
||||||
varying vec2 v_st;
|
varying vec2 v_st;
|
||||||
void
|
void
|
||||||
main(){
|
main(){
|
||||||
float len;
|
float len;
|
||||||
if (u_mode == 2.0) {
|
if (u_mode == 2) {
|
||||||
// round cap line
|
// round cap line
|
||||||
#ifdef DESKTOP_QUIRKS
|
#ifdef DESKTOP_QUIRKS
|
||||||
len = length(v_st);
|
len = length(v_st);
|
||||||
|
@ -8,7 +8,7 @@ uniform mat4 u_mvp;
|
|||||||
uniform float u_width;
|
uniform float u_width;
|
||||||
// xy hold position, zw extrusion vector
|
// xy hold position, zw extrusion vector
|
||||||
attribute vec4 a_pos;
|
attribute vec4 a_pos;
|
||||||
uniform float u_mode;
|
uniform int u_mode;
|
||||||
uniform float u_height;
|
uniform float u_height;
|
||||||
varying vec2 v_st;
|
varying vec2 v_st;
|
||||||
void
|
void
|
||||||
@ -32,7 +32,7 @@ $$
|
|||||||
precision highp float;
|
precision highp float;
|
||||||
#endif
|
#endif
|
||||||
uniform sampler2D tex;
|
uniform sampler2D tex;
|
||||||
uniform float u_mode;
|
uniform int u_mode;
|
||||||
uniform vec4 u_color;
|
uniform vec4 u_color;
|
||||||
uniform float u_fade;
|
uniform float u_fade;
|
||||||
varying vec2 v_st;
|
varying vec2 v_st;
|
||||||
@ -40,7 +40,7 @@ void
|
|||||||
main(){
|
main(){
|
||||||
float len;
|
float len;
|
||||||
float fuzz;
|
float fuzz;
|
||||||
if (u_mode == 2.0) {
|
if (u_mode == 2) {
|
||||||
/* round cap line */
|
/* round cap line */
|
||||||
#ifdef DESKTOP_QUIRKS
|
#ifdef DESKTOP_QUIRKS
|
||||||
len = length(v_st);
|
len = length(v_st);
|
||||||
@ -55,8 +55,8 @@ main(){
|
|||||||
len = abs(v_st.s);
|
len = abs(v_st.s);
|
||||||
fuzz = fwidth(v_st.s);
|
fuzz = fwidth(v_st.s);
|
||||||
}
|
}
|
||||||
// u_mode == 0.0 -> thin line
|
// u_mode == 0 -> thin line
|
||||||
// len = len * clamp(u_mode, len, 1.0);
|
// len = len * clamp(float(u_mode), len, 1.0);
|
||||||
if (fuzz > 2.0)
|
if (fuzz > 2.0)
|
||||||
gl_FragColor = u_color * 0.5;
|
gl_FragColor = u_color * 0.5;
|
||||||
else
|
else
|
||||||
|
@ -40,13 +40,13 @@ uniform vec4 u_bgcolor;
|
|||||||
uniform float u_pwidth;
|
uniform float u_pwidth;
|
||||||
varying vec2 v_st;
|
varying vec2 v_st;
|
||||||
uniform sampler2D tex;
|
uniform sampler2D tex;
|
||||||
uniform float u_mode;
|
uniform int u_mode;
|
||||||
void
|
void
|
||||||
main(){
|
main(){
|
||||||
if (u_mode >= 1.0) {
|
if (u_mode >= 1) {
|
||||||
/* Dash array or texture */
|
/* Dash array or texture */
|
||||||
float step = 2.0;
|
float step = 2.0;
|
||||||
if (u_mode == 2.0) { // dashed texture
|
if (u_mode == 2) { // dashed texture
|
||||||
step = 1.0;
|
step = 1.0;
|
||||||
}
|
}
|
||||||
// use lineLength mod texture step (mod is always positive)
|
// use lineLength mod texture step (mod is always positive)
|
||||||
|
@ -618,7 +618,7 @@ public class LineBucket extends RenderBucket {
|
|||||||
gl.uniform1f(uLineFade, (float) pixel);
|
gl.uniform1f(uLineFade, (float) pixel);
|
||||||
|
|
||||||
int capMode = 0;
|
int capMode = 0;
|
||||||
gl.uniform1f(uLineMode, capMode);
|
gl.uniform1i(uLineMode, capMode);
|
||||||
|
|
||||||
boolean blur = false;
|
boolean blur = false;
|
||||||
double width;
|
double width;
|
||||||
@ -682,16 +682,16 @@ public class LineBucket extends RenderBucket {
|
|||||||
if (lb.scale < 1.5/* || lb.line.fixed*/) {
|
if (lb.scale < 1.5/* || lb.line.fixed*/) {
|
||||||
if (capMode != CAP_THIN) {
|
if (capMode != CAP_THIN) {
|
||||||
capMode = CAP_THIN;
|
capMode = CAP_THIN;
|
||||||
gl.uniform1f(uLineMode, capMode);
|
gl.uniform1i(uLineMode, capMode);
|
||||||
}
|
}
|
||||||
} else if (lb.roundCap) {
|
} else if (lb.roundCap) {
|
||||||
if (capMode != CAP_ROUND) {
|
if (capMode != CAP_ROUND) {
|
||||||
capMode = CAP_ROUND;
|
capMode = CAP_ROUND;
|
||||||
gl.uniform1f(uLineMode, capMode);
|
gl.uniform1i(uLineMode, capMode);
|
||||||
}
|
}
|
||||||
} else if (capMode != CAP_BUTT) {
|
} else if (capMode != CAP_BUTT) {
|
||||||
capMode = CAP_BUTT;
|
capMode = CAP_BUTT;
|
||||||
gl.uniform1f(uLineMode, capMode);
|
gl.uniform1i(uLineMode, capMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.drawArrays(GL.TRIANGLE_STRIP,
|
gl.drawArrays(GL.TRIANGLE_STRIP,
|
||||||
@ -733,11 +733,11 @@ public class LineBucket extends RenderBucket {
|
|||||||
if (ref.roundCap) {
|
if (ref.roundCap) {
|
||||||
if (capMode != CAP_ROUND) {
|
if (capMode != CAP_ROUND) {
|
||||||
capMode = CAP_ROUND;
|
capMode = CAP_ROUND;
|
||||||
gl.uniform1f(uLineMode, capMode);
|
gl.uniform1i(uLineMode, capMode);
|
||||||
}
|
}
|
||||||
} else if (capMode != CAP_BUTT) {
|
} else if (capMode != CAP_BUTT) {
|
||||||
capMode = CAP_BUTT;
|
capMode = CAP_BUTT;
|
||||||
gl.uniform1f(uLineMode, capMode);
|
gl.uniform1i(uLineMode, capMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.drawArrays(GL.TRIANGLE_STRIP,
|
gl.drawArrays(GL.TRIANGLE_STRIP,
|
||||||
|
@ -385,7 +385,7 @@ public final class LineTexBucket extends LineBucket {
|
|||||||
LineTexBucket lb = (LineTexBucket) b;
|
LineTexBucket lb = (LineTexBucket) b;
|
||||||
LineStyle line = lb.line.current();
|
LineStyle line = lb.line.current();
|
||||||
|
|
||||||
gl.uniform1f(shader.uMode, line.dashArray != null ? 2 : (line.texture != null ? 1 : 0));
|
gl.uniform1i(shader.uMode, line.dashArray != null ? 2 : (line.texture != null ? 1 : 0));
|
||||||
|
|
||||||
if (line.texture != null)
|
if (line.texture != null)
|
||||||
line.texture.bind();
|
line.texture.bind();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user