Format shaders (#639)

This commit is contained in:
Gustl22 2019-01-25 21:38:26 +01:00 committed by Emux
parent 84d6b311ea
commit d219632825
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3
22 changed files with 74 additions and 68 deletions

View File

@ -3,6 +3,7 @@ precision highp float;
#endif
uniform mat4 u_mvp;
attribute vec4 a_pos;
void main() {
gl_Position = u_mvp * a_pos;
}
@ -13,6 +14,7 @@ $$
precision highp float;
#endif
uniform vec4 u_color;
void main() {
gl_FragColor = u_color;
}

View File

@ -4,6 +4,7 @@ precision highp float;
uniform mat4 u_mvp;
uniform float u_radius;
attribute vec2 a_pos;
void main() {
gl_Position = u_mvp * vec4(a_pos, 0.0, 1.0);
gl_PointSize = 2.0 * u_radius / gl_Position.z;
@ -21,6 +22,7 @@ uniform vec4 u_fill;
uniform float u_radius;
uniform vec4 u_stroke;
uniform float u_width;
void main() {
vec2 cxy = 2.0 * gl_PointCoord - 1.0;
float r = dot(cxy, cxy);

View File

@ -4,6 +4,7 @@ precision highp float;
uniform mat4 u_mvp;
attribute vec2 a_pos;
varying vec2 v_pos;
void main() {
gl_Position = u_mvp * vec4(a_pos, 0.0, 1.0);
v_pos = a_pos;
@ -19,6 +20,7 @@ uniform float u_radius;
uniform vec4 u_stroke;
uniform float u_width;
varying vec2 v_pos;
void main() {
gl_FragColor = u_fill;
}

View File

@ -9,10 +9,10 @@ uniform float u_zlimit;
attribute vec4 a_pos;
attribute vec2 a_light;
varying vec4 color;
varying float depth;
//varying float depth;
const float ff = 255.0;
void
main(){
void main() {
// change height by u_alpha
float height = a_pos.z * u_alpha;
if (height > u_zlimit) {
@ -61,7 +61,7 @@ $$
precision highp float;
#endif
varying vec4 color;
void
main(){
void main() {
gl_FragColor = color;
}

View File

@ -7,10 +7,9 @@ uniform float u_alpha;
attribute vec4 a_pos;
attribute vec2 a_light;
varying vec4 color;
varying float depth;
const float alpha = 1.0;
void
main(){
void main() {
// change height by u_alpha
vec4 pos = a_pos;
pos.z *= u_alpha;
@ -47,7 +46,7 @@ $$
precision highp float;
#endif
varying vec4 color;
void
main(){
void main() {
gl_FragColor = color;
}

View File

@ -11,8 +11,8 @@ uniform vec2 u_screen;
attribute vec2 a_pos;
varying vec4 v_pos;
varying vec2 s_pos;
void
main(){
void main() {
v_pos = u_mvp * vec4(a_pos, 0.0, 1.0);
s_pos = v_pos.xy / v_pos.w;
gl_Position = v_pos;
@ -28,8 +28,8 @@ uniform float u_width;
uniform vec2 u_screen;
varying vec4 v_pos;
varying vec2 s_pos;
void
main(){
void main() {
vec2 pos = (v_pos.xy) / v_pos.w * u_screen;
float l = length(gl_FragCoord.xy - u_screen - pos.xy);

View File

@ -11,8 +11,8 @@ attribute vec4 a_pos;
uniform int u_mode;
uniform float u_height;
varying vec2 v_st;
void
main(){
void main() {
// scale extrusion to u_width pixel
// just ignore the two most insignificant bits.
@ -33,8 +33,8 @@ uniform float u_fade;
uniform int u_mode;
uniform vec4 u_color;
varying vec2 v_st;
void
main(){
void main() {
float len;
if (u_mode == 2) {
// round cap line

View File

@ -11,8 +11,8 @@ attribute vec4 a_pos;
uniform int u_mode;
uniform float u_height;
varying vec2 v_st;
void
main(){
void main() {
// scale extrusion to u_width pixel
// just ignore the two most insignificant bits.
@ -36,8 +36,8 @@ uniform int u_mode;
uniform vec4 u_color;
uniform float u_fade;
varying vec2 v_st;
void
main(){
void main() {
float len;
float fuzz;
if (u_mode == 2) {

View File

@ -11,8 +11,8 @@ attribute vec2 a_len0;
attribute vec2 a_len1;
attribute float a_flip;
varying vec2 v_st;
void
main(){
void main() {
vec4 pos;
if (a_flip == 0.0) {
// vec2 dir = u_width * a_pos0.zw;
@ -39,8 +39,8 @@ uniform vec4 u_color;
uniform vec4 u_bgcolor;
uniform float u_pwidth;
varying vec2 v_st;
void
main(){
void main() {
/* distance on perpendicular to the line */
float dist = abs(v_st.t);
float fuzz = fwidth(v_st.t);

View File

@ -11,8 +11,8 @@ attribute vec2 a_len0; // x:lineLength, y:unused
attribute vec2 a_len1;
attribute float a_flip; // flip state
varying vec2 v_st;
void
main(){
void main() {
vec4 pos;
if (a_flip == 0.0) {
// vec2 dir = u_width * a_pos0.zw;
@ -41,8 +41,8 @@ uniform float u_pwidth;
varying vec2 v_st;
uniform sampler2D tex;
uniform int u_mode;
void
main(){
void main() {
if (u_mode >= 1) {
/* Dash array or texture */
float step = 2.0;

View File

@ -6,6 +6,7 @@ uniform float u_phase;
uniform float u_scale;
attribute vec2 a_pos;
varying vec2 v_tex;
void main() {
gl_Position = u_mvp * vec4(a_pos * u_scale * u_phase, 0.0, 1.0);
v_tex = a_pos;
@ -22,6 +23,7 @@ uniform float u_phase;
uniform vec2 u_dir;
uniform int u_mode;
uniform vec4 u_color;
void main() {
float len = 1.0 - length(v_tex);
if (u_mode == -1) {

View File

@ -6,6 +6,7 @@ uniform float u_phase;
uniform float u_scale;
attribute vec2 a_pos;
varying vec2 v_tex;
void main() {
gl_Position = u_mvp * vec4(a_pos * u_scale * u_phase, 0.0, 1.0);
v_tex = a_pos;
@ -22,6 +23,7 @@ uniform float u_phase;
uniform vec2 u_dir;
uniform int u_mode;
uniform vec4 u_color;
void main() {
float len = 1.0 - length(v_tex);
if (u_mode == -1) {

View File

@ -6,6 +6,7 @@ uniform float u_phase;
uniform float u_scale;
attribute vec2 a_pos;
varying vec2 v_tex;
void main() {
gl_Position = u_mvp * vec4(a_pos * u_scale * u_phase, 0.0, 1.0);
v_tex = a_pos;
@ -22,6 +23,7 @@ uniform float u_phase;
uniform vec2 u_dir;
uniform int u_mode;
uniform vec4 u_color;
void main() {
float len = 1.0 - length(v_tex);
if (u_mode == -1) {

View File

@ -4,8 +4,8 @@ precision highp float;
uniform mat4 u_mvp;
uniform float u_height;
attribute vec2 a_pos;
void
main(){
void main() {
gl_Position = u_mvp * vec4(a_pos, u_height, 1.0);
}
@ -15,7 +15,7 @@ $$
precision highp float;
#endif
uniform vec4 u_color;
void
main(){
void main() {
gl_FragColor = u_color;
}

View File

@ -6,6 +6,7 @@ uniform vec2 u_scale;
attribute vec4 a_pos;
varying vec2 v_st;
varying vec2 v_st2;
void main() {
v_st = clamp(a_pos.xy, 0.0, 1.0) * (2.0 / u_scale.y);
v_st2 = clamp(a_pos.xy, 0.0, 1.0) * (4.0 / u_scale.y);
@ -22,6 +23,7 @@ uniform sampler2D 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);
}

View File

@ -6,8 +6,8 @@ uniform vec2 u_scale;
attribute vec4 a_pos;
varying vec2 v_st;
varying vec2 v_st2;
void
main(){
void main() {
v_st = clamp(a_pos.xy, 0.0, 1.0) * (2.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;
@ -23,7 +23,7 @@ uniform sampler2D tex;
uniform vec2 u_scale;
varying vec2 v_st;
varying vec2 v_st2;
void
main(){
void main() {
gl_FragColor = mix(texture2D(tex, v_st), texture2D(tex, v_st2), u_scale.x) * u_color;
}

View File

@ -5,8 +5,7 @@ uniform vec2 u_pixel;
attribute vec4 a_pos;
varying vec2 tex_pos;
void main()
{
void main() {
gl_Position = a_pos;
tex_pos = (a_pos.xy + 1.0) * 0.5;
}
@ -20,7 +19,7 @@ uniform sampler2D u_texColor;
uniform vec2 u_pixel;
varying vec2 tex_pos;
void main(){
void main() {
gl_FragColor = texture2D(u_texColor, tex_pos) * 0.8;
}

View File

@ -8,9 +8,8 @@ varying vec2 tex_nw;
varying vec2 tex_ne;
varying vec2 tex_sw;
varying vec2 tex_se;
void
main()
{
void main() {
gl_Position = a_pos;
tex_pos = (a_pos.xy + 1.0) * 0.5;
vec2 pixel = u_pixel * 2.5;
@ -49,6 +48,7 @@ const int iterations = 2;
float getDepth(float posZ) {
return (2.0 * nearZ) / (nearZ + farZ - posZ * (farZ - nearZ));
}
float compareDepths(in float depth1, in float depth2, inout float far) {
// depth difference (0-100)
float diff = (depth1 - depth2) * 100.0;
@ -62,8 +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);
@ -97,9 +96,7 @@ addAO(int run, inout float depth, in float x1, in float y1, in float x2, in floa
* (d_22 + f_22 * (1.0 - d_22) * d_11);
}
void
main(){
void main() {
vec2 pixel = u_pixel * 3.15;
vec4 rgbNW = texture2D(u_texColor, tex_nw);

View File

@ -8,9 +8,8 @@ varying vec2 tex_nw;
varying vec2 tex_ne;
varying vec2 tex_sw;
varying vec2 tex_se;
void
main()
{
void main() {
gl_Position = a_pos;
tex_pos = (a_pos.xy + 1.0) * 0.5;
vec2 pixel = u_pixel * 2.5;
@ -43,8 +42,7 @@ const vec3 luma = vec3(0.299, 0.587, 0.114);
// return rgb.g * (0.587/0.299) + rgb.b;
//}
void
main(){
void main() {
vec2 pixel = u_pixel * 3.15;
vec4 rgbNW = texture2D(u_texColor, tex_nw);

View File

@ -4,8 +4,8 @@ precision highp float;
uniform vec2 u_pixel;
attribute vec4 a_pos;
varying vec2 tex_pos;
void
main(){
void main() {
gl_Position = a_pos;
tex_pos = (a_pos.xy + 1.0) * 0.5;
}
@ -29,6 +29,7 @@ const int iterations = 4;
float getDepth(float posZ) {
return (2.0 * nearZ) / (nearZ + farZ - posZ * (farZ - nearZ));
}
float compareDepths(in float depth1, in float depth2, inout float far) {
// depth difference (0-100)
float diff = (depth1 - depth2) * 100.0;
@ -42,8 +43,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(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);
@ -76,8 +76,7 @@ addAO(in float depth, in float x1, in float y1, in float x2, in float y2, inout
* (d_22 + f_22 * (1.0 - d_22) * d_11);
}
void
main(void){
void main() {
// randomization texture:
// vec2 fres = vec2(20.0, 20.0);
// vec3 random = texture2D(rand, gl_TexCoord[0].st * fres.xy);

View File

@ -5,8 +5,8 @@ attribute vec2 vertex;
attribute vec2 tex_coord;
uniform mat4 u_mvp;
varying vec2 tex_c;
void
main(){
void main() {
gl_Position = u_mvp * vec4(vertex, 0.0, 1.0);
tex_c = tex_coord;
}
@ -19,7 +19,7 @@ precision highp float;
uniform sampler2D tex;
uniform float u_alpha;
varying vec2 tex_c;
void
main(){
void main() {
gl_FragColor = texture2D(tex, tex_c) * u_alpha;
}

View File

@ -9,8 +9,8 @@ uniform float u_scale;
uniform float u_coord_scale;
uniform vec2 u_div;
varying vec2 tex_c;
void
main(){
void main() {
vec4 pos;
vec2 dir = vertex.zw;
float coord_scale = 1.0 / u_coord_scale;
@ -32,7 +32,7 @@ precision highp float;
#endif
uniform sampler2D tex;
varying vec2 tex_c;
void
main(){
void main() {
gl_FragColor = texture2D(tex, tex_c.xy);
}