Format shaders (#654)
This commit is contained in:
parent
48a5c36c31
commit
fc452a76e7
@ -18,4 +18,3 @@ uniform vec4 u_color;
|
||||
void main() {
|
||||
gl_FragColor = u_color;
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,9 @@ varying vec4 color;
|
||||
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 l = dot(normalize(r_norm), normalize(u_light));
|
||||
@ -34,7 +34,7 @@ void main() {
|
||||
//depth = gl_Position.z;
|
||||
if (u_mode == -1) {
|
||||
;
|
||||
} else if(u_mode >= 0 && u_mode <= 2) {
|
||||
} else if (u_mode >= 0 && u_mode <= 2) {
|
||||
vec3 r_norm;
|
||||
if (u_mode == 0) {
|
||||
// roof / depth pass
|
||||
@ -45,7 +45,7 @@ void main() {
|
||||
float lightX = u_mode == 1 ? a_normal.y : a_normal.x;
|
||||
r_norm.x = (lightX / ff) * 2.0 - 1.0;
|
||||
// normal points y left or right (1 or -1)
|
||||
float dir = - 1.0 + (2.0 * abs(mod(lightX, 2.0)));
|
||||
float dir = -1.0 + (2.0 * abs(mod(lightX, 2.0)));
|
||||
// recreate y vector
|
||||
r_norm.y = dir * sqrt(clamp(1.0 - (r_norm.x * r_norm.x), 0.0, 1.0));
|
||||
r_norm.z = 0.0;
|
||||
@ -62,8 +62,7 @@ void main() {
|
||||
color.rgb *= diffuse(r_norm) * z * h;
|
||||
}
|
||||
color *= u_alpha;
|
||||
}
|
||||
else if (u_mode == 3) {
|
||||
} else if (u_mode == 3) {
|
||||
// outline
|
||||
float z = (0.98 - gl_Position.z * 0.02);
|
||||
color = u_color[3] * z;
|
||||
|
@ -21,7 +21,7 @@ void main() {
|
||||
// 1² - |xy|² = |z|²
|
||||
r_norm.xy = enc * 2.0 - 1.0;
|
||||
// normal points up or down (1,-1)
|
||||
float dir = - 1.0 + (2.0 * abs(mod(a_normal.x, 2.0)));
|
||||
float dir = -1.0 + (2.0 * abs(mod(a_normal.x, 2.0)));
|
||||
// recreate z vector
|
||||
r_norm.z = dir * sqrt(clamp(1.0 - (r_norm.x * r_norm.x + r_norm.y * r_norm.y), 0.0, 1.0));
|
||||
r_norm = normalize(r_norm);
|
||||
|
@ -33,7 +33,7 @@ void main() {
|
||||
vec2 pos = (v_pos.xy) / v_pos.w * u_screen;
|
||||
|
||||
float l = length(gl_FragCoord.xy - u_screen - pos.xy);
|
||||
float z = clamp(0.6, 1.0, 1.2 - (v_pos.z/ v_pos.w));
|
||||
float z = clamp(0.6, 1.0, 1.2 - (v_pos.z / v_pos.w));
|
||||
|
||||
gl_FragColor = u_color * (smoothstep(1.0, 0.0, l / u_width) * z);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ uniform float u_height;
|
||||
varying vec2 v_st;
|
||||
|
||||
void main() {
|
||||
|
||||
// scale extrusion to u_width pixel
|
||||
// just ignore the two most insignificant bits.
|
||||
vec2 dir = a_pos.zw;
|
||||
@ -42,8 +41,7 @@ void main() {
|
||||
#else
|
||||
len = texture2D(tex, v_st).a;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// flat cap line
|
||||
len = abs(v_st.s);
|
||||
}
|
||||
@ -59,5 +57,5 @@ void main() {
|
||||
// between 0 and 1 (it is greater 1 for all inner pixel).
|
||||
gl_FragColor = u_color * clamp((1.0 - len) / u_fade, 0.0, 1.0);
|
||||
// -> nicer for thin lines
|
||||
// gl_FragColor = u_color * clamp((1.0 - (len * len)) / u_fade, 0.0, 1.0);
|
||||
//gl_FragColor = u_color * clamp((1.0 - (len * len)) / u_fade, 0.0, 1.0);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ uniform float u_height;
|
||||
varying vec2 v_st;
|
||||
|
||||
void main() {
|
||||
|
||||
// scale extrusion to u_width pixel
|
||||
// just ignore the two most insignificant bits.
|
||||
vec2 dir = a_pos.zw;
|
||||
@ -48,8 +47,7 @@ void main() {
|
||||
#endif
|
||||
vec2 st_width = fwidth(v_st);
|
||||
fuzz = max(st_width.s, st_width.t);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* flat cap line */
|
||||
len = abs(v_st.s);
|
||||
fuzz = fwidth(v_st.s);
|
||||
@ -60,5 +58,5 @@ void main() {
|
||||
gl_FragColor = u_color * 0.5;
|
||||
else
|
||||
gl_FragColor = u_color * clamp((1.0 - len) / max(u_fade, fuzz), 0.0, 1.0);
|
||||
// gl_FragColor = u_color * clamp((1.0 - len), 0.0, 1.0);
|
||||
//gl_FragColor = u_color * clamp((1.0 - len), 0.0, 1.0);
|
||||
}
|
||||
|
@ -18,8 +18,7 @@ void main() {
|
||||
// vec2 dir = u_width * a_pos0.zw;
|
||||
pos = vec4(a_pos0.xy + (u_width * a_pos0.zw), 0.0, 1.0);
|
||||
v_st = vec2(a_len0.x / u_pscale, 1.0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// vec2 dir = u_width * a_pos1.zw;
|
||||
pos = vec4(a_pos1.xy - (u_width * a_pos1.zw), 0.0, 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;
|
||||
pos = vec4(a_pos0.xy + (u_width * a_pos0.zw), 0.0, 1.0);
|
||||
v_st = vec2(a_len0.x / u_pscale, 1.0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// vec2 dir = u_width * a_pos1.zw;
|
||||
pos = vec4(a_pos1.xy - (u_width * a_pos1.zw), 0.0, 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));
|
||||
float fuzz = fwidth(c.a);
|
||||
gl_FragColor = (c * u_color) * smoothstep(0.5 - fuzz, 0.5 + fuzz, c.a);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* No dash array or texture */
|
||||
|
||||
/* distance on perpendicular to the line */
|
||||
float dist = abs(v_st.t);
|
||||
float fuzz = fwidth(v_st.t);
|
||||
|
@ -22,5 +22,3 @@ varying vec2 tex_pos;
|
||||
void main() {
|
||||
gl_FragColor = texture2D(u_texColor, tex_pos) * 0.8;
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ float compareDepths(in float depth1, in float depth2, inout float far) {
|
||||
return pow(2.7182, -2.0 * pow(diff - gdisplace,2.0) / pow(garea, 2.0));
|
||||
}
|
||||
|
||||
void addAO(int run, inout float depth, in float x1, in float y1, in float x2, in float y2, inout float ao){
|
||||
void addAO(int run, inout float depth, in float x1, in float y1, in float x2, in float y2, inout float ao) {
|
||||
float z_11 = getDepth(texture2D(u_tex, vec2(x1, y1)).x);
|
||||
float z_12 = getDepth(texture2D(u_tex, vec2(x1, y2)).x);
|
||||
float z_21 = getDepth(texture2D(u_tex, vec2(x2, y1)).x);
|
||||
@ -149,7 +149,7 @@ void main() {
|
||||
//vec4 color = texture2D(u_texColor, tex_pos);
|
||||
|
||||
float depth = texture2D(u_tex, tex_pos).x;
|
||||
float foggy = pow(depth,3.0);
|
||||
float foggy = pow(depth, 3.0);
|
||||
|
||||
depth = getDepth(depth);
|
||||
|
||||
@ -181,4 +181,3 @@ void main() {
|
||||
//gl_FragColor = vec4(0.5 - vao, max(0.5, ao));
|
||||
gl_FragColor = vec4(color.rgb - ao, max(color.a, ao));
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ const vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
#define FXAA_REDUCE_MIN (1.0/128.0)
|
||||
|
||||
//float FxaaLuma(float3 rgb) {
|
||||
// return rgb.g * (0.587/0.299) + rgb.b;
|
||||
// return rgb.g * (0.587 / 0.299) + rgb.b;
|
||||
//}
|
||||
|
||||
void main() {
|
||||
@ -56,7 +56,7 @@ void main() {
|
||||
gl_FragColor = rgbM;
|
||||
return;
|
||||
}
|
||||
//return vec4(rgbM - (rgbNW + rgbNE)*0.25,1.0);
|
||||
//return vec4(rgbM - (rgbNW + rgbNE) * 0.25, 1.0);
|
||||
|
||||
float lumaNW = dot(rgbNW.rgb, luma);
|
||||
float lumaNE = dot(rgbNE.rgb, luma);
|
||||
@ -74,9 +74,9 @@ void main() {
|
||||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
||||
|
||||
// if (max(dir.x, dir.y) > 0.1){
|
||||
// if (max(dir.x, dir.y) > 0.1) {
|
||||
// gl_FragColor = vec4(dir*0.5, 0.0, 0.5);
|
||||
// } else{
|
||||
// } else {
|
||||
// gl_FragColor = vec4(rgbM.rgb * 0.2, 0.8);
|
||||
// }
|
||||
// return;
|
||||
@ -101,8 +101,8 @@ void main() {
|
||||
|
||||
//gl_FragColor = vec4(rgbM.rgb * 0.5, 1.0) + vec4(((1.0 - d) * rgbB.rgb + d * rgbA.rgb) - rgbM.rgb, 1.0) * 2.0;
|
||||
|
||||
// if ((lumaB < lumaMin) || (lumaB > lumaMax))
|
||||
// { return rgbA; } else { return rgbB; }
|
||||
//if ((lumaB < lumaMin) || (lumaB > lumaMax))
|
||||
// { return rgbA; } else { return rgbB; }
|
||||
}
|
||||
|
||||
//vec2 rcpFrame = vec2(1.0) / g_Resolution;
|
||||
|
@ -43,14 +43,13 @@ float compareDepths(in float depth1, in float depth2, inout float far) {
|
||||
return pow(2.7182, -2.0 * pow(diff - gdisplace,2.0) / pow(garea, 2.0));
|
||||
}
|
||||
|
||||
void addAO(in float depth, in float x1, in float y1, in float x2, in float y2, inout float ao){
|
||||
void addAO(in float depth, in float x1, in float y1, in float x2, in float y2, inout float ao) {
|
||||
float z_11 = getDepth(texture2D(u_tex, vec2(x1, y1)).x);
|
||||
float z_12 = getDepth(texture2D(u_tex, vec2(x1, y2)).x);
|
||||
float z_21 = getDepth(texture2D(u_tex, vec2(x2, y1)).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);
|
||||
|
||||
|
||||
float f_11;
|
||||
float d_11 = compareDepths(depth, z_11, f_11);
|
||||
|
||||
@ -77,10 +76,10 @@ void addAO(in float depth, in float x1, in float y1, in float x2, in float y2, i
|
||||
}
|
||||
|
||||
void main() {
|
||||
// randomization texture:
|
||||
// vec2 fres = vec2(20.0, 20.0);
|
||||
// vec3 random = texture2D(rand, gl_TexCoord[0].st * fres.xy);
|
||||
// random = random * 2.0 - vec3(1.0);
|
||||
//randomization texture:
|
||||
//vec2 fres = vec2(20.0, 20.0);
|
||||
//vec3 random = texture2D(rand, gl_TexCoord[0].st * fres.xy);
|
||||
//random = random * 2.0 - vec3(1.0);
|
||||
vec4 color = texture2D(u_texColor, tex_pos);
|
||||
float depth = texture2D(u_tex, tex_pos).x;
|
||||
|
||||
@ -107,7 +106,6 @@ void main() {
|
||||
// increase sampling area:
|
||||
pw *= 1.7;
|
||||
ph *= 1.7;
|
||||
|
||||
}
|
||||
|
||||
//vec3 vao = vec3(fog * pow(ao / float(iterations * 8), 1.2));
|
||||
@ -120,23 +118,20 @@ void main() {
|
||||
//gl_FragColor = vec4(0.5 - vao, max(0.5, ao));
|
||||
gl_FragColor = vec4(color.rgb - ao, max(color.a, ao));
|
||||
|
||||
|
||||
//gl_FragColor = color - (fog * vec4(vao, 0.0));
|
||||
|
||||
|
||||
//gl_FragColor = vec4(vec3(0.8) - vao, 1.0);
|
||||
|
||||
//color *= 0.5;
|
||||
|
||||
//gl_FragColor = vec4(color.rgb - fog * vao, max(color.a, ao));
|
||||
|
||||
|
||||
//gl_FragColor = vec4(1.0) - (vec4(vao, 0.0));
|
||||
//gl_FragColor = vec4((color.rgb + vao)*0.5, color.a);
|
||||
|
||||
// }
|
||||
// gl_FragColor = vec4(vao, 1.0) * texture2D(u_texColor, tex_pos.xy);
|
||||
// gl_FragColor = vec4(gl_TexCoord[0].xy, 0.0, 1.0);
|
||||
// gl_FragColor = vec4(tex_pos.xy, 0.0, 1.0);
|
||||
// gl_FragColor = vec4(gl_FragCoord.xy / u_screen, 0.0, 1.0);
|
||||
//}
|
||||
//gl_FragColor = vec4(vao, 1.0) * texture2D(u_texColor, tex_pos.xy);
|
||||
//gl_FragColor = vec4(gl_TexCoord[0].xy, 0.0, 1.0);
|
||||
//gl_FragColor = vec4(tex_pos.xy, 0.0, 1.0);
|
||||
//gl_FragColor = vec4(gl_FragCoord.xy / u_screen, 0.0, 1.0);
|
||||
}
|
||||
|
@ -16,8 +16,7 @@ void main() {
|
||||
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));
|
||||
}
|
||||
else { // place as billboard
|
||||
} else { // place as billboard
|
||||
vec4 center = u_mv * vec4(vertex.xy, 0.0, 1.0);
|
||||
pos = u_proj * (center + vec4(dir * coord_scale, 0.0, 0.0));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user