Merge pull request #534 from Gustl22/format_shader

format shaders
This commit is contained in:
Emux 2018-04-29 18:54:10 +03:00 committed by GitHub
commit b240be8ba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 8 deletions

View File

@ -6,7 +6,9 @@ attribute vec4 a_pos;
void main() { void main() {
gl_Position = u_mvp * a_pos; gl_Position = u_mvp * a_pos;
} }
$$ $$
#ifdef GLES #ifdef GLES
precision highp float; precision highp float;
#endif #endif

View File

@ -22,7 +22,9 @@ main(){
// last two bits hold the texture coordinates. // last two bits hold the texture coordinates.
v_st = abs(mod(dir, 4.0)) - 1.0; v_st = abs(mod(dir, 4.0)) - 1.0;
} }
$$ $$
#ifdef GLES #ifdef GLES
precision highp float; precision highp float;
#endif #endif

View File

@ -48,9 +48,9 @@ main(){
if (u_mode == 2.0) { // dashed texture if (u_mode == 2.0) { // dashed texture
step = 1.0; step = 1.0;
} }
vec4 c=texture2D(tex,vec2(abs(mod(v_st.s+1.0,step)),(v_st.t+1.0)*0.5)); vec4 c = texture2D(tex, vec2(abs(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 {
/* distance on perpendicular to the line */ /* distance on perpendicular to the line */

View File

@ -12,6 +12,7 @@ main(){
v_st2 = clamp(a_pos.xy, 0.0, 1.0) * (4.0 / u_scale.y); v_st2 = clamp(a_pos.xy, 0.0, 1.0) * (4.0 / u_scale.y);
gl_Position = u_mvp * a_pos; gl_Position = u_mvp * a_pos;
} }
$$ $$
#ifdef GLES #ifdef GLES

View File

@ -21,7 +21,6 @@ uniform vec2 u_pixel;
varying vec2 tex_pos; 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;
} }

View File

@ -38,7 +38,7 @@ float compareDepths(in float depth1, in float depth2, inout float far) {
// if far reduce left bell width to avoid self-shadowing // if far reduce left bell width to avoid self-shadowing
float garea = max((1.0 - far) * 2.0, 0.1); float garea = max((1.0 - far) * 2.0, 0.1);
//return (step(diff, 0.0) * -0.1) + pow(2.7182, -2.0 * pow(diff - gdisplace,2.0) / pow(garea, 2.0)); //return (step(diff, 0.0) * -0.1) + pow(2.7182, -2.0 * pow(diff - gdisplace, 2.0) / pow(garea, 2.0));
return pow(2.7182, -2.0 * pow(diff - gdisplace,2.0) / pow(garea, 2.0)); return pow(2.7182, -2.0 * pow(diff - gdisplace,2.0) / pow(garea, 2.0));
} }
@ -85,7 +85,7 @@ main(void){
vec4 color = texture2D(u_texColor, tex_pos); vec4 color = texture2D(u_texColor, tex_pos);
float depth = texture2D(u_tex, tex_pos).x; float depth = texture2D(u_tex, tex_pos).x;
float fog = pow(depth,3.0); float fog = pow(depth, 3.0);
//return; //return;
depth = getDepth(depth); depth = getDepth(depth);
@ -137,7 +137,7 @@ main(void){
// } // }
// gl_FragColor = vec4(vao, 1.0) * texture2D(u_texColor, tex_pos.xy); // 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(gl_TexCoord[0].xy, 0.0, 1.0);
// gl_FragColor = vec4(tex_pos.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(gl_FragCoord.xy / u_screen, 0.0, 1.0);
} }