Format shaders (#654)
This commit is contained in:
parent
48a5c36c31
commit
fc452a76e7
@ -18,4 +18,3 @@ uniform vec4 u_color;
|
|||||||
void main() {
|
void main() {
|
||||||
gl_FragColor = u_color;
|
gl_FragColor = u_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,9 +14,9 @@ varying vec4 color;
|
|||||||
const float ff = 255.0;
|
const float ff = 255.0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The diffuse of surface dependent on the light position
|
* The diffuse of surface dependent on the light position.
|
||||||
*
|
*
|
||||||
* @param r_norm - the normal vector of vertex's face
|
* @param r_norm the normal vector of vertex's face
|
||||||
*/
|
*/
|
||||||
float diffuse(in vec3 r_norm) {
|
float diffuse(in vec3 r_norm) {
|
||||||
float l = dot(normalize(r_norm), normalize(u_light));
|
float l = dot(normalize(r_norm), normalize(u_light));
|
||||||
@ -62,8 +62,7 @@ void main() {
|
|||||||
color.rgb *= diffuse(r_norm) * z * h;
|
color.rgb *= diffuse(r_norm) * z * h;
|
||||||
}
|
}
|
||||||
color *= u_alpha;
|
color *= u_alpha;
|
||||||
}
|
} else if (u_mode == 3) {
|
||||||
else if (u_mode == 3) {
|
|
||||||
// outline
|
// outline
|
||||||
float z = (0.98 - gl_Position.z * 0.02);
|
float z = (0.98 - gl_Position.z * 0.02);
|
||||||
color = u_color[3] * z;
|
color = u_color[3] * z;
|
||||||
|
|||||||
@ -12,7 +12,6 @@ uniform float u_height;
|
|||||||
varying vec2 v_st;
|
varying vec2 v_st;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
// scale extrusion to u_width pixel
|
// scale extrusion to u_width pixel
|
||||||
// just ignore the two most insignificant bits.
|
// just ignore the two most insignificant bits.
|
||||||
vec2 dir = a_pos.zw;
|
vec2 dir = a_pos.zw;
|
||||||
@ -42,8 +41,7 @@ void main() {
|
|||||||
#else
|
#else
|
||||||
len = texture2D(tex, v_st).a;
|
len = texture2D(tex, v_st).a;
|
||||||
#endif
|
#endif
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// flat cap line
|
// flat cap line
|
||||||
len = abs(v_st.s);
|
len = abs(v_st.s);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,6 @@ uniform float u_height;
|
|||||||
varying vec2 v_st;
|
varying vec2 v_st;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
// scale extrusion to u_width pixel
|
// scale extrusion to u_width pixel
|
||||||
// just ignore the two most insignificant bits.
|
// just ignore the two most insignificant bits.
|
||||||
vec2 dir = a_pos.zw;
|
vec2 dir = a_pos.zw;
|
||||||
@ -48,8 +47,7 @@ void main() {
|
|||||||
#endif
|
#endif
|
||||||
vec2 st_width = fwidth(v_st);
|
vec2 st_width = fwidth(v_st);
|
||||||
fuzz = max(st_width.s, st_width.t);
|
fuzz = max(st_width.s, st_width.t);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
/* flat cap line */
|
/* flat cap line */
|
||||||
len = abs(v_st.s);
|
len = abs(v_st.s);
|
||||||
fuzz = fwidth(v_st.s);
|
fuzz = fwidth(v_st.s);
|
||||||
|
|||||||
@ -18,8 +18,7 @@ void main() {
|
|||||||
// vec2 dir = u_width * a_pos0.zw;
|
// vec2 dir = u_width * a_pos0.zw;
|
||||||
pos = vec4(a_pos0.xy + (u_width * a_pos0.zw), 0.0, 1.0);
|
pos = vec4(a_pos0.xy + (u_width * a_pos0.zw), 0.0, 1.0);
|
||||||
v_st = vec2(a_len0.x / u_pscale, 1.0);
|
v_st = vec2(a_len0.x / u_pscale, 1.0);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// vec2 dir = u_width * a_pos1.zw;
|
// vec2 dir = u_width * a_pos1.zw;
|
||||||
pos = vec4(a_pos1.xy - (u_width * a_pos1.zw), 0.0, 1.0);
|
pos = vec4(a_pos1.xy - (u_width * a_pos1.zw), 0.0, 1.0);
|
||||||
v_st = vec2(a_len1.x / u_pscale, -1.0);
|
v_st = vec2(a_len1.x / u_pscale, -1.0);
|
||||||
|
|||||||
@ -18,8 +18,7 @@ void main() {
|
|||||||
// vec2 dir = u_width * a_pos0.zw;
|
// vec2 dir = u_width * a_pos0.zw;
|
||||||
pos = vec4(a_pos0.xy + (u_width * a_pos0.zw), 0.0, 1.0);
|
pos = vec4(a_pos0.xy + (u_width * a_pos0.zw), 0.0, 1.0);
|
||||||
v_st = vec2(a_len0.x / u_pscale, 1.0);
|
v_st = vec2(a_len0.x / u_pscale, 1.0);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// vec2 dir = u_width * a_pos1.zw;
|
// vec2 dir = u_width * a_pos1.zw;
|
||||||
pos = vec4(a_pos1.xy - (u_width * a_pos1.zw), 0.0, 1.0);
|
pos = vec4(a_pos1.xy - (u_width * a_pos1.zw), 0.0, 1.0);
|
||||||
v_st = vec2(a_len1.x / u_pscale, -1.0);
|
v_st = vec2(a_len1.x / u_pscale, -1.0);
|
||||||
@ -54,10 +53,8 @@ void main() {
|
|||||||
vec4 c = texture2D(tex, vec2(mod(v_st.s + 1.0, step), (v_st.t + 1.0) * 0.5));
|
vec4 c = texture2D(tex, vec2(mod(v_st.s + 1.0, step), (v_st.t + 1.0) * 0.5));
|
||||||
float fuzz = fwidth(c.a);
|
float fuzz = fwidth(c.a);
|
||||||
gl_FragColor = (c * u_color) * smoothstep(0.5 - fuzz, 0.5 + fuzz, c.a);
|
gl_FragColor = (c * u_color) * smoothstep(0.5 - fuzz, 0.5 + fuzz, c.a);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
/* No dash array or texture */
|
/* No dash array or texture */
|
||||||
|
|
||||||
/* distance on perpendicular to the line */
|
/* distance on perpendicular to the line */
|
||||||
float dist = abs(v_st.t);
|
float dist = abs(v_st.t);
|
||||||
float fuzz = fwidth(v_st.t);
|
float fuzz = fwidth(v_st.t);
|
||||||
|
|||||||
@ -22,5 +22,3 @@ varying vec2 tex_pos;
|
|||||||
void main() {
|
void main() {
|
||||||
gl_FragColor = texture2D(u_texColor, tex_pos) * 0.8;
|
gl_FragColor = texture2D(u_texColor, tex_pos) * 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -181,4 +181,3 @@ void main() {
|
|||||||
//gl_FragColor = vec4(0.5 - vao, max(0.5, ao));
|
//gl_FragColor = vec4(0.5 - vao, max(0.5, ao));
|
||||||
gl_FragColor = vec4(color.rgb - ao, max(color.a, ao));
|
gl_FragColor = vec4(color.rgb - ao, max(color.a, ao));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,6 @@ void addAO(in float depth, in float x1, in float y1, in float x2, in float y2, i
|
|||||||
float z_22 = getDepth(texture2D(u_tex, vec2(x2, y2)).x);
|
float z_22 = getDepth(texture2D(u_tex, vec2(x2, y2)).x);
|
||||||
//depth = 0.99 * depth + (z_11 + z_12 + z_21 + z_22) * (0.25 * 0.01);
|
//depth = 0.99 * depth + (z_11 + z_12 + z_21 + z_22) * (0.25 * 0.01);
|
||||||
|
|
||||||
|
|
||||||
float f_11;
|
float f_11;
|
||||||
float d_11 = compareDepths(depth, z_11, f_11);
|
float d_11 = compareDepths(depth, z_11, f_11);
|
||||||
|
|
||||||
@ -107,7 +106,6 @@ void main() {
|
|||||||
// increase sampling area:
|
// increase sampling area:
|
||||||
pw *= 1.7;
|
pw *= 1.7;
|
||||||
ph *= 1.7;
|
ph *= 1.7;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//vec3 vao = vec3(fog * pow(ao / float(iterations * 8), 1.2));
|
//vec3 vao = vec3(fog * pow(ao / float(iterations * 8), 1.2));
|
||||||
@ -120,17 +118,14 @@ void main() {
|
|||||||
//gl_FragColor = vec4(0.5 - vao, max(0.5, ao));
|
//gl_FragColor = vec4(0.5 - vao, max(0.5, ao));
|
||||||
gl_FragColor = vec4(color.rgb - ao, max(color.a, ao));
|
gl_FragColor = vec4(color.rgb - ao, max(color.a, ao));
|
||||||
|
|
||||||
|
|
||||||
//gl_FragColor = color - (fog * vec4(vao, 0.0));
|
//gl_FragColor = color - (fog * vec4(vao, 0.0));
|
||||||
|
|
||||||
|
|
||||||
//gl_FragColor = vec4(vec3(0.8) - vao, 1.0);
|
//gl_FragColor = vec4(vec3(0.8) - vao, 1.0);
|
||||||
|
|
||||||
//color *= 0.5;
|
//color *= 0.5;
|
||||||
|
|
||||||
//gl_FragColor = vec4(color.rgb - fog * vao, max(color.a, ao));
|
//gl_FragColor = vec4(color.rgb - fog * vao, max(color.a, ao));
|
||||||
|
|
||||||
|
|
||||||
//gl_FragColor = vec4(1.0) - (vec4(vao, 0.0));
|
//gl_FragColor = vec4(1.0) - (vec4(vao, 0.0));
|
||||||
//gl_FragColor = vec4((color.rgb + vao)*0.5, color.a);
|
//gl_FragColor = vec4((color.rgb + vao)*0.5, color.a);
|
||||||
|
|
||||||
|
|||||||
@ -16,8 +16,7 @@ void main() {
|
|||||||
float coord_scale = 1.0 / u_coord_scale;
|
float coord_scale = 1.0 / u_coord_scale;
|
||||||
if (abs(mod(vertex.x, 2.0)) == 0.0) {
|
if (abs(mod(vertex.x, 2.0)) == 0.0) {
|
||||||
pos = u_proj * (u_mv * vec4(vertex.xy + dir * u_scale, 0.0, 1.0));
|
pos = u_proj * (u_mv * vec4(vertex.xy + dir * u_scale, 0.0, 1.0));
|
||||||
}
|
} else { // place as billboard
|
||||||
else { // place as billboard
|
|
||||||
vec4 center = u_mv * vec4(vertex.xy, 0.0, 1.0);
|
vec4 center = u_mv * vec4(vertex.xy, 0.0, 1.0);
|
||||||
pos = u_proj * (center + vec4(dir * coord_scale, 0.0, 0.0));
|
pos = u_proj * (center + vec4(dir * coord_scale, 0.0, 0.0));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user