From 65b299c6cfdfd85a79833641c96b41babd50c872 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Mon, 25 Jan 2021 17:53:04 +0100 Subject: [PATCH] Replace tabs by 4 spaces --- .../models/resources/shaders/glsl330/brdf.fs | 26 ++-- .../resources/shaders/glsl330/prefilter.fs | 26 ++-- .../resources/shaders/glsl330/skybox.fs | 2 +- .../resources/shaders/glsl100/bloom.fs | 2 +- .../resources/shaders/glsl100/dream_vision.fs | 2 +- .../resources/shaders/glsl100/raymarching.fs | 112 +++++++++--------- .../resources/shaders/glsl100/sobel.fs | 38 +++--- .../resources/shaders/glsl100/spotlight.fs | 88 +++++++------- .../shaders/resources/shaders/glsl100/wave.fs | 18 +-- .../resources/shaders/glsl120/bloom.fs | 2 +- .../resources/shaders/glsl120/dream_vision.fs | 2 +- .../resources/shaders/glsl120/sobel.fs | 38 +++--- .../resources/shaders/glsl330/bloom.fs | 2 +- .../resources/shaders/glsl330/dream_vision.fs | 2 +- .../resources/shaders/glsl330/eratosthenes.fs | 6 +- .../resources/shaders/glsl330/raymarching.fs | 112 +++++++++--------- .../resources/shaders/glsl330/reload.fs | 26 ++-- .../resources/shaders/glsl330/sobel.fs | 38 +++--- .../resources/shaders/glsl330/spotlight.fs | 58 ++++----- .../shaders/resources/shaders/glsl330/wave.fs | 18 +-- 20 files changed, 309 insertions(+), 309 deletions(-) diff --git a/examples/models/resources/shaders/glsl330/brdf.fs b/examples/models/resources/shaders/glsl330/brdf.fs index d04bc6618..f2774f81c 100644 --- a/examples/models/resources/shaders/glsl330/brdf.fs +++ b/examples/models/resources/shaders/glsl330/brdf.fs @@ -41,27 +41,27 @@ float RadicalInverseVdC(uint bits) // Compute Hammersley coordinates vec2 Hammersley(uint i, uint N) { - return vec2(float(i)/float(N), RadicalInverseVdC(i)); + return vec2(float(i)/float(N), RadicalInverseVdC(i)); } // Integrate number of importance samples for (roughness and NoV) vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness) { - float a = roughness*roughness; - float phi = 2.0 * PI * Xi.x; - float cosTheta = sqrt((1.0 - Xi.y)/(1.0 + (a*a - 1.0)*Xi.y)); - float sinTheta = sqrt(1.0 - cosTheta*cosTheta); + float a = roughness*roughness; + float phi = 2.0 * PI * Xi.x; + float cosTheta = sqrt((1.0 - Xi.y)/(1.0 + (a*a - 1.0)*Xi.y)); + float sinTheta = sqrt(1.0 - cosTheta*cosTheta); - // Transform from spherical coordinates to cartesian coordinates (halfway vector) - vec3 H = vec3(cos(phi)*sinTheta, sin(phi)*sinTheta, cosTheta); + // Transform from spherical coordinates to cartesian coordinates (halfway vector) + vec3 H = vec3(cos(phi)*sinTheta, sin(phi)*sinTheta, cosTheta); - // Transform from tangent space H vector to world space sample vector - vec3 up = ((abs(N.z) < 0.999) ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0)); - vec3 tangent = normalize(cross(up, N)); - vec3 bitangent = cross(N, tangent); - vec3 sampleVec = tangent*H.x + bitangent*H.y + N*H.z; + // Transform from tangent space H vector to world space sample vector + vec3 up = ((abs(N.z) < 0.999) ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0)); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + vec3 sampleVec = tangent*H.x + bitangent*H.y + N*H.z; - return normalize(sampleVec); + return normalize(sampleVec); } float GeometrySchlickGGX(float NdotV, float roughness) diff --git a/examples/models/resources/shaders/glsl330/prefilter.fs b/examples/models/resources/shaders/glsl330/prefilter.fs index 941ea86c0..82f0f7710 100644 --- a/examples/models/resources/shaders/glsl330/prefilter.fs +++ b/examples/models/resources/shaders/glsl330/prefilter.fs @@ -54,26 +54,26 @@ float RadicalInverse_VdC(uint bits) vec2 Hammersley(uint i, uint N) { - return vec2(float(i)/float(N), RadicalInverse_VdC(i)); + return vec2(float(i)/float(N), RadicalInverse_VdC(i)); } vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness) { - float a = roughness*roughness; - float phi = 2.0*PI*Xi.x; - float cosTheta = sqrt((1.0 - Xi.y)/(1.0 + (a*a - 1.0)*Xi.y)); - float sinTheta = sqrt(1.0 - cosTheta*cosTheta); + float a = roughness*roughness; + float phi = 2.0*PI*Xi.x; + float cosTheta = sqrt((1.0 - Xi.y)/(1.0 + (a*a - 1.0)*Xi.y)); + float sinTheta = sqrt(1.0 - cosTheta*cosTheta); - // Transform from spherical coordinates to cartesian coordinates (halfway vector) - vec3 H = vec3(cos(phi)*sinTheta, sin(phi)*sinTheta, cosTheta); + // Transform from spherical coordinates to cartesian coordinates (halfway vector) + vec3 H = vec3(cos(phi)*sinTheta, sin(phi)*sinTheta, cosTheta); - // Transform from tangent space H vector to world space sample vector - vec3 up = ((abs(N.z) < 0.999) ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0)); - vec3 tangent = normalize(cross(up, N)); - vec3 bitangent = cross(N, tangent); - vec3 sampleVec = tangent*H.x + bitangent*H.y + N*H.z; + // Transform from tangent space H vector to world space sample vector + vec3 up = ((abs(N.z) < 0.999) ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0)); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + vec3 sampleVec = tangent*H.x + bitangent*H.y + N*H.z; - return normalize(sampleVec); + return normalize(sampleVec); } void main() diff --git a/examples/models/resources/shaders/glsl330/skybox.fs b/examples/models/resources/shaders/glsl330/skybox.fs index c7a17883e..dd8078e09 100644 --- a/examples/models/resources/shaders/glsl330/skybox.fs +++ b/examples/models/resources/shaders/glsl330/skybox.fs @@ -4,7 +4,7 @@ * * Copyright (c) 2017 Victor Fisac * -* 19-Jun-2020 - modified by Giuseppe Mastrangelo (@peppemas) - VFlip Support +* 19-Jun-2020 - modified by Giuseppe Mastrangelo (@peppemas) - VFlip Support * **********************************************************************************************/ diff --git a/examples/shaders/resources/shaders/glsl100/bloom.fs b/examples/shaders/resources/shaders/glsl100/bloom.fs index a8e1d20f7..673e0116a 100644 --- a/examples/shaders/resources/shaders/glsl100/bloom.fs +++ b/examples/shaders/resources/shaders/glsl100/bloom.fs @@ -14,7 +14,7 @@ uniform vec4 colDiffuse; const vec2 size = vec2(800, 450); // render size const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance -const float quality = 2.5; // lower = smaller glow, better quality +const float quality = 2.5; // lower = smaller glow, better quality void main() { diff --git a/examples/shaders/resources/shaders/glsl100/dream_vision.fs b/examples/shaders/resources/shaders/glsl100/dream_vision.fs index fa9c5b771..7014b5920 100644 --- a/examples/shaders/resources/shaders/glsl100/dream_vision.fs +++ b/examples/shaders/resources/shaders/glsl100/dream_vision.fs @@ -34,4 +34,4 @@ void main() color = color/9.5; gl_FragColor = color; -} \ No newline at end of file +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/raymarching.fs b/examples/shaders/resources/shaders/glsl100/raymarching.fs index c823e01eb..7535086b5 100644 --- a/examples/shaders/resources/shaders/glsl100/raymarching.fs +++ b/examples/shaders/resources/shaders/glsl100/raymarching.fs @@ -42,7 +42,7 @@ uniform vec2 resolution; float sdPlane( vec3 p ) { - return p.y; + return p.y; } float sdSphere( vec3 p, float s ) @@ -85,9 +85,9 @@ float sdHexPrism( vec3 p, vec2 h ) float sdCapsule( vec3 p, vec3 a, vec3 b, float r ) { - vec3 pa = p-a, ba = b-a; - float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 ); - return length( pa - ba*h ) - r; + vec3 pa = p-a, ba = b-a; + float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 ); + return length( pa - ba*h ) - r; } float sdEquilateralTriangle( in vec2 p ) @@ -154,19 +154,19 @@ float sdPryamid4(vec3 p, vec3 h ) // h = { cos a, sin a, height } float length2( vec2 p ) { - return sqrt( p.x*p.x + p.y*p.y ); + return sqrt( p.x*p.x + p.y*p.y ); } float length6( vec2 p ) { - p = p*p*p; p = p*p; - return pow( p.x + p.y, 1.0/6.0 ); + p = p*p*p; p = p*p; + return pow( p.x + p.y, 1.0/6.0 ); } float length8( vec2 p ) { - p = p*p; p = p*p; p = p*p; - return pow( p.x + p.y, 1.0/8.0 ); + p = p*p; p = p*p; p = p*p; + return pow( p.x + p.y, 1.0/8.0 ); } float sdTorus82( vec3 p, vec2 t ) @@ -195,7 +195,7 @@ float opS( float d1, float d2 ) vec2 opU( vec2 d1, vec2 d2 ) { - return (d1.xtmax ) break; t += res.x; - m = res.y; + m = res.y; } if( t>tmax ) m=-1.0; @@ -271,11 +271,11 @@ vec2 castRay( in vec3 ro, in vec3 rd ) float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax ) { - float res = 1.0; + float res = 1.0; float t = mint; for( int i=0; i<16; i++ ) { - float h = map( ro + rd*t ).x; + float h = map( ro + rd*t ).x; res = min( res, 8.0*h/t ); t += clamp( h, 0.02, 0.10 ); if( h<0.001 || t>tmax ) break; @@ -287,22 +287,22 @@ vec3 calcNormal( in vec3 pos ) { vec2 e = vec2(1.0,-1.0)*0.5773*0.0005; return normalize( e.xyy*map( pos + e.xyy ).x + - e.yyx*map( pos + e.yyx ).x + - e.yxy*map( pos + e.yxy ).x + - e.xxx*map( pos + e.xxx ).x ); + e.yyx*map( pos + e.yyx ).x + + e.yxy*map( pos + e.yxy ).x + + e.xxx*map( pos + e.xxx ).x ); /* - vec3 eps = vec3( 0.0005, 0.0, 0.0 ); - vec3 nor = vec3( - map(pos+eps.xyy).x - map(pos-eps.xyy).x, - map(pos+eps.yxy).x - map(pos-eps.yxy).x, - map(pos+eps.yyx).x - map(pos-eps.yyx).x ); - return normalize(nor); - */ + vec3 eps = vec3( 0.0005, 0.0, 0.0 ); + vec3 nor = vec3( + map(pos+eps.xyy).x - map(pos-eps.xyy).x, + map(pos+eps.yxy).x - map(pos-eps.yxy).x, + map(pos+eps.yyx).x - map(pos-eps.yyx).x ); + return normalize(nor); + */ } float calcAO( in vec3 pos, in vec3 nor ) { - float occ = 0.0; + float occ = 0.0; float sca = 1.0; for( int i=0; i<5; i++ ) { @@ -331,7 +331,7 @@ vec3 render( in vec3 ro, in vec3 rd ) vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8; vec2 res = castRay(ro,rd); float t = res.x; - float m = res.y; + float m = res.y; if( m>-0.5 ) { vec3 pos = ro + t*rd; @@ -339,7 +339,7 @@ vec3 render( in vec3 ro, in vec3 rd ) vec3 ref = reflect( rd, nor ); // material - col = 0.45 + 0.35*sin( vec3(0.05,0.08,0.10)*(m-1.0) ); + col = 0.45 + 0.35*sin( vec3(0.05,0.08,0.10)*(m-1.0) ); if( m<1.5 ) { @@ -349,9 +349,9 @@ vec3 render( in vec3 ro, in vec3 rd ) // lighting float occ = calcAO( pos, nor ); - vec3 lig = normalize( vec3(cos(-0.4 * runTime), sin(0.7 * runTime), -0.6) ); + vec3 lig = normalize( vec3(cos(-0.4 * runTime), sin(0.7 * runTime), -0.6) ); vec3 hal = normalize( lig-rd ); - float amb = clamp( 0.5+0.5*nor.y, 0.0, 1.0 ); + float amb = clamp( 0.5+0.5*nor.y, 0.0, 1.0 ); float dif = clamp( dot( nor, lig ), 0.0, 1.0 ); float bac = clamp( dot( nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0); float dom = smoothstep( -0.1, 0.1, ref.y ); @@ -360,31 +360,31 @@ vec3 render( in vec3 ro, in vec3 rd ) dif *= calcSoftshadow( pos, lig, 0.02, 2.5 ); dom *= calcSoftshadow( pos, ref, 0.02, 2.5 ); - float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0)* + float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0)* dif * (0.04 + 0.96*pow( clamp(1.0+dot(hal,rd),0.0,1.0), 5.0 )); - vec3 lin = vec3(0.0); + vec3 lin = vec3(0.0); lin += 1.30*dif*vec3(1.00,0.80,0.55); lin += 0.40*amb*vec3(0.40,0.60,1.00)*occ; lin += 0.50*dom*vec3(0.40,0.60,1.00)*occ; lin += 0.50*bac*vec3(0.25,0.25,0.25)*occ; lin += 0.25*fre*vec3(1.00,1.00,1.00)*occ; - col = col*lin; - col += 10.00*spe*vec3(1.00,0.90,0.70); + col = col*lin; + col += 10.00*spe*vec3(1.00,0.90,0.70); - col = mix( col, vec3(0.8,0.9,1.0), 1.0-exp( -0.0002*t*t*t ) ); + col = mix( col, vec3(0.8,0.9,1.0), 1.0-exp( -0.0002*t*t*t ) ); } - return vec3( clamp(col,0.0,1.0) ); + return vec3( clamp(col,0.0,1.0) ); } mat3 setCamera( in vec3 ro, in vec3 ta, float cr ) { vec3 cw = normalize(ta-ro); - vec3 cp = vec3(sin(cr), cos(cr),0.0); - vec3 cu = normalize( cross(cw,cp) ); - vec3 cv = normalize( cross(cu,cw) ); + vec3 cp = vec3(sin(cr), cos(cr),0.0); + vec3 cu = normalize( cross(cw,cp) ); + vec3 cv = normalize( cross(cu,cw) ); return mat3( cu, cv, cw ); } @@ -402,7 +402,7 @@ void main() vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y; #endif - // RAY: Camera is provided from raylib + // RAY: Camera is provided from raylib //vec3 ro = vec3( -0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x) ); vec3 ro = viewEye; @@ -413,10 +413,10 @@ void main() // ray direction vec3 rd = ca * normalize( vec3(p.xy,2.0) ); - // render + // render vec3 col = render( ro, rd ); - // gamma + // gamma col = pow( col, vec3(0.4545) ); tot += col; diff --git a/examples/shaders/resources/shaders/glsl100/sobel.fs b/examples/shaders/resources/shaders/glsl100/sobel.fs index 745562ad0..3e5c22dda 100644 --- a/examples/shaders/resources/shaders/glsl100/sobel.fs +++ b/examples/shaders/resources/shaders/glsl100/sobel.fs @@ -15,26 +15,26 @@ vec2 resolution = vec2(800.0, 450.0); void main() { - float x = 1.0/resolution.x; - float y = 1.0/resolution.y; + float x = 1.0/resolution.x; + float y = 1.0/resolution.y; - vec4 horizEdge = vec4(0.0); - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + vec4 horizEdge = vec4(0.0); + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; - vec4 vertEdge = vec4(0.0); - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + vec4 vertEdge = vec4(0.0); + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; - vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); - - gl_FragColor = vec4(edge, texture2D(texture0, fragTexCoord).a); + vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); + + gl_FragColor = vec4(edge, texture2D(texture0, fragTexCoord).a); } \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/spotlight.fs b/examples/shaders/resources/shaders/glsl100/spotlight.fs index c1202610e..c8d830381 100644 --- a/examples/shaders/resources/shaders/glsl100/spotlight.fs +++ b/examples/shaders/resources/shaders/glsl100/spotlight.fs @@ -5,9 +5,9 @@ precision mediump float; #define MAX_SPOTS 3 struct Spot { - vec2 pos; // window coords of spot - float inner; // inner fully transparent centre radius - float radius; // alpha fades out to this radius + vec2 pos; // window coords of spot + float inner; // inner fully transparent centre radius + float radius; // alpha fades out to this radius }; uniform Spot spots[MAX_SPOTS]; // Spotlight positions array @@ -15,63 +15,63 @@ uniform float screenWidth; // Width of the screen void main() { - float alpha = 1.0; + float alpha = 1.0; - // Get the position of the current fragment (screen coordinates!) - vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y); - - // Find out which spotlight is nearest - float d = 65000.0; // some high value - int fi = -1; // found index + // Get the position of the current fragment (screen coordinates!) + vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y); + + // Find out which spotlight is nearest + float d = 65000.0; // some high value + int fi = -1; // found index for (int i = 0; i < MAX_SPOTS; i++) { - for (int j = 0; j < MAX_SPOTS; j++) - { - float dj = distance(pos, spots[j].pos) - spots[j].radius + spots[i].radius; + for (int j = 0; j < MAX_SPOTS; j++) + { + float dj = distance(pos, spots[j].pos) - spots[j].radius + spots[i].radius; - if (d > dj) - { - d = dj; - fi = i; - } - } + if (d > dj) + { + d = dj; + fi = i; + } + } } // d now equals distance to nearest spot... // allowing for the different radii of all spotlights if (fi == 0) { - if (d > spots[0].radius) alpha = 1.0; - else - { - if (d < spots[0].inner) alpha = 0.0; - else alpha = (d - spots[0].inner)/(spots[0].radius - spots[0].inner); - } - } + if (d > spots[0].radius) alpha = 1.0; + else + { + if (d < spots[0].inner) alpha = 0.0; + else alpha = (d - spots[0].inner)/(spots[0].radius - spots[0].inner); + } + } else if (fi == 1) { - if (d > spots[1].radius) alpha = 1.0; - else - { - if (d < spots[1].inner) alpha = 0.0; - else alpha = (d - spots[1].inner)/(spots[1].radius - spots[1].inner); - } - } + if (d > spots[1].radius) alpha = 1.0; + else + { + if (d < spots[1].inner) alpha = 0.0; + else alpha = (d - spots[1].inner)/(spots[1].radius - spots[1].inner); + } + } else if (fi == 2) { - if (d > spots[2].radius) alpha = 1.0; - else - { - if (d < spots[2].inner) alpha = 0.0; - else alpha = (d - spots[2].inner)/(spots[2].radius - spots[2].inner); - } - } - - // Right hand side of screen is dimly lit, + if (d > spots[2].radius) alpha = 1.0; + else + { + if (d < spots[2].inner) alpha = 0.0; + else alpha = (d - spots[2].inner)/(spots[2].radius - spots[2].inner); + } + } + + // Right hand side of screen is dimly lit, // could make the threshold value user definable - if ((pos.x > screenWidth/2.0) && (alpha > 0.9)) alpha = 0.9; + if ((pos.x > screenWidth/2.0) && (alpha > 0.9)) alpha = 0.9; - // could make the black out colour user definable... + // could make the black out colour user definable... gl_FragColor = vec4(0, 0, 0, alpha); } diff --git a/examples/shaders/resources/shaders/glsl100/wave.fs b/examples/shaders/resources/shaders/glsl100/wave.fs index bcc156cc6..50c4e02f3 100644 --- a/examples/shaders/resources/shaders/glsl100/wave.fs +++ b/examples/shaders/resources/shaders/glsl100/wave.fs @@ -22,15 +22,15 @@ uniform float speedX; uniform float speedY; void main() { - float pixelWidth = 1.0 / size.x; - float pixelHeight = 1.0 / size.y; - float aspect = pixelHeight / pixelWidth; - float boxLeft = 0.0; - float boxTop = 0.0; + float pixelWidth = 1.0 / size.x; + float pixelHeight = 1.0 / size.y; + float aspect = pixelHeight / pixelWidth; + float boxLeft = 0.0; + float boxTop = 0.0; - vec2 p = fragTexCoord; - p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth; - p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight; + vec2 p = fragTexCoord; + p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth; + p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight; - gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor; + gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor; } diff --git a/examples/shaders/resources/shaders/glsl120/bloom.fs b/examples/shaders/resources/shaders/glsl120/bloom.fs index c28836b0d..f97c18ed7 100644 --- a/examples/shaders/resources/shaders/glsl120/bloom.fs +++ b/examples/shaders/resources/shaders/glsl120/bloom.fs @@ -12,7 +12,7 @@ uniform vec4 colDiffuse; const vec2 size = vec2(800, 450); // render size const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance -const float quality = 2.5; // lower = smaller glow, better quality +const float quality = 2.5; // lower = smaller glow, better quality void main() { diff --git a/examples/shaders/resources/shaders/glsl120/dream_vision.fs b/examples/shaders/resources/shaders/glsl120/dream_vision.fs index 4ca2a8634..cb97b2bd0 100644 --- a/examples/shaders/resources/shaders/glsl120/dream_vision.fs +++ b/examples/shaders/resources/shaders/glsl120/dream_vision.fs @@ -32,4 +32,4 @@ void main() color = color/9.5; gl_FragColor = color; -} \ No newline at end of file +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/sobel.fs b/examples/shaders/resources/shaders/glsl120/sobel.fs index a3f3f2bf7..73e72703a 100644 --- a/examples/shaders/resources/shaders/glsl120/sobel.fs +++ b/examples/shaders/resources/shaders/glsl120/sobel.fs @@ -13,26 +13,26 @@ vec2 resolution = vec2(800.0, 450.0); void main() { - float x = 1.0/resolution.x; - float y = 1.0/resolution.y; + float x = 1.0/resolution.x; + float y = 1.0/resolution.y; - vec4 horizEdge = vec4(0.0); - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + vec4 horizEdge = vec4(0.0); + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; - vec4 vertEdge = vec4(0.0); - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + vec4 vertEdge = vec4(0.0); + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; - vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); - - gl_FragColor = vec4(edge, texture2D(texture0, fragTexCoord).a); + vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); + + gl_FragColor = vec4(edge, texture2D(texture0, fragTexCoord).a); } \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/bloom.fs b/examples/shaders/resources/shaders/glsl330/bloom.fs index 333d5b059..549cde8f8 100644 --- a/examples/shaders/resources/shaders/glsl330/bloom.fs +++ b/examples/shaders/resources/shaders/glsl330/bloom.fs @@ -15,7 +15,7 @@ out vec4 finalColor; const vec2 size = vec2(800, 450); // render size const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance -const float quality = 2.5; // lower = smaller glow, better quality +const float quality = 2.5; // lower = smaller glow, better quality void main() { diff --git a/examples/shaders/resources/shaders/glsl330/dream_vision.fs b/examples/shaders/resources/shaders/glsl330/dream_vision.fs index 031158628..31d3fd2f3 100644 --- a/examples/shaders/resources/shaders/glsl330/dream_vision.fs +++ b/examples/shaders/resources/shaders/glsl330/dream_vision.fs @@ -31,4 +31,4 @@ void main() color = color/9.5; fragColor = color; -} \ No newline at end of file +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/eratosthenes.fs b/examples/shaders/resources/shaders/glsl330/eratosthenes.fs index 92d2d2571..14711222b 100644 --- a/examples/shaders/resources/shaders/glsl330/eratosthenes.fs +++ b/examples/shaders/resources/shaders/glsl330/eratosthenes.fs @@ -38,9 +38,9 @@ vec4 Colorizer(float counter, float maxSize) void main() { - vec4 color = vec4(1.0); - float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid. - int value = int(scale*floor(fragTexCoord.y*scale)+floor(fragTexCoord.x*scale)); // Group pixels into boxes representing integer values + vec4 color = vec4(1.0); + float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid. + int value = int(scale*floor(fragTexCoord.y*scale)+floor(fragTexCoord.x*scale)); // Group pixels into boxes representing integer values if ((value == 0) || (value == 1) || (value == 2)) finalColor = vec4(1.0); else diff --git a/examples/shaders/resources/shaders/glsl330/raymarching.fs b/examples/shaders/resources/shaders/glsl330/raymarching.fs index 3cec58a2b..5b0caa652 100644 --- a/examples/shaders/resources/shaders/glsl330/raymarching.fs +++ b/examples/shaders/resources/shaders/glsl330/raymarching.fs @@ -43,7 +43,7 @@ uniform vec2 resolution; float sdPlane( vec3 p ) { - return p.y; + return p.y; } float sdSphere( vec3 p, float s ) @@ -86,9 +86,9 @@ float sdHexPrism( vec3 p, vec2 h ) float sdCapsule( vec3 p, vec3 a, vec3 b, float r ) { - vec3 pa = p-a, ba = b-a; - float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 ); - return length( pa - ba*h ) - r; + vec3 pa = p-a, ba = b-a; + float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 ); + return length( pa - ba*h ) - r; } float sdEquilateralTriangle( in vec2 p ) @@ -155,19 +155,19 @@ float sdPryamid4(vec3 p, vec3 h ) // h = { cos a, sin a, height } float length2( vec2 p ) { - return sqrt( p.x*p.x + p.y*p.y ); + return sqrt( p.x*p.x + p.y*p.y ); } float length6( vec2 p ) { - p = p*p*p; p = p*p; - return pow( p.x + p.y, 1.0/6.0 ); + p = p*p*p; p = p*p; + return pow( p.x + p.y, 1.0/6.0 ); } float length8( vec2 p ) { - p = p*p; p = p*p; p = p*p; - return pow( p.x + p.y, 1.0/8.0 ); + p = p*p; p = p*p; p = p*p; + return pow( p.x + p.y, 1.0/8.0 ); } float sdTorus82( vec3 p, vec2 t ) @@ -196,7 +196,7 @@ float opS( float d1, float d2 ) vec2 opU( vec2 d1, vec2 d2 ) { - return (d1.xtmax ) break; t += res.x; - m = res.y; + m = res.y; } if( t>tmax ) m=-1.0; @@ -272,11 +272,11 @@ vec2 castRay( in vec3 ro, in vec3 rd ) float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax ) { - float res = 1.0; + float res = 1.0; float t = mint; for( int i=0; i<16; i++ ) { - float h = map( ro + rd*t ).x; + float h = map( ro + rd*t ).x; res = min( res, 8.0*h/t ); t += clamp( h, 0.02, 0.10 ); if( h<0.001 || t>tmax ) break; @@ -288,22 +288,22 @@ vec3 calcNormal( in vec3 pos ) { vec2 e = vec2(1.0,-1.0)*0.5773*0.0005; return normalize( e.xyy*map( pos + e.xyy ).x + - e.yyx*map( pos + e.yyx ).x + - e.yxy*map( pos + e.yxy ).x + - e.xxx*map( pos + e.xxx ).x ); + e.yyx*map( pos + e.yyx ).x + + e.yxy*map( pos + e.yxy ).x + + e.xxx*map( pos + e.xxx ).x ); /* - vec3 eps = vec3( 0.0005, 0.0, 0.0 ); - vec3 nor = vec3( - map(pos+eps.xyy).x - map(pos-eps.xyy).x, - map(pos+eps.yxy).x - map(pos-eps.yxy).x, - map(pos+eps.yyx).x - map(pos-eps.yyx).x ); - return normalize(nor); - */ + vec3 eps = vec3( 0.0005, 0.0, 0.0 ); + vec3 nor = vec3( + map(pos+eps.xyy).x - map(pos-eps.xyy).x, + map(pos+eps.yxy).x - map(pos-eps.yxy).x, + map(pos+eps.yyx).x - map(pos-eps.yyx).x ); + return normalize(nor); + */ } float calcAO( in vec3 pos, in vec3 nor ) { - float occ = 0.0; + float occ = 0.0; float sca = 1.0; for( int i=0; i<5; i++ ) { @@ -332,7 +332,7 @@ vec3 render( in vec3 ro, in vec3 rd ) vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8; vec2 res = castRay(ro,rd); float t = res.x; - float m = res.y; + float m = res.y; if( m>-0.5 ) { vec3 pos = ro + t*rd; @@ -340,7 +340,7 @@ vec3 render( in vec3 ro, in vec3 rd ) vec3 ref = reflect( rd, nor ); // material - col = 0.45 + 0.35*sin( vec3(0.05,0.08,0.10)*(m-1.0) ); + col = 0.45 + 0.35*sin( vec3(0.05,0.08,0.10)*(m-1.0) ); if( m<1.5 ) { @@ -350,9 +350,9 @@ vec3 render( in vec3 ro, in vec3 rd ) // lighting float occ = calcAO( pos, nor ); - vec3 lig = normalize( vec3(cos(-0.4 * runTime), sin(0.7 * runTime), -0.6) ); + vec3 lig = normalize( vec3(cos(-0.4 * runTime), sin(0.7 * runTime), -0.6) ); vec3 hal = normalize( lig-rd ); - float amb = clamp( 0.5+0.5*nor.y, 0.0, 1.0 ); + float amb = clamp( 0.5+0.5*nor.y, 0.0, 1.0 ); float dif = clamp( dot( nor, lig ), 0.0, 1.0 ); float bac = clamp( dot( nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0); float dom = smoothstep( -0.1, 0.1, ref.y ); @@ -361,31 +361,31 @@ vec3 render( in vec3 ro, in vec3 rd ) dif *= calcSoftshadow( pos, lig, 0.02, 2.5 ); dom *= calcSoftshadow( pos, ref, 0.02, 2.5 ); - float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0)* + float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0)* dif * (0.04 + 0.96*pow( clamp(1.0+dot(hal,rd),0.0,1.0), 5.0 )); - vec3 lin = vec3(0.0); + vec3 lin = vec3(0.0); lin += 1.30*dif*vec3(1.00,0.80,0.55); lin += 0.40*amb*vec3(0.40,0.60,1.00)*occ; lin += 0.50*dom*vec3(0.40,0.60,1.00)*occ; lin += 0.50*bac*vec3(0.25,0.25,0.25)*occ; lin += 0.25*fre*vec3(1.00,1.00,1.00)*occ; - col = col*lin; - col += 10.00*spe*vec3(1.00,0.90,0.70); + col = col*lin; + col += 10.00*spe*vec3(1.00,0.90,0.70); - col = mix( col, vec3(0.8,0.9,1.0), 1.0-exp( -0.0002*t*t*t ) ); + col = mix( col, vec3(0.8,0.9,1.0), 1.0-exp( -0.0002*t*t*t ) ); } - return vec3( clamp(col,0.0,1.0) ); + return vec3( clamp(col,0.0,1.0) ); } mat3 setCamera( in vec3 ro, in vec3 ta, float cr ) { vec3 cw = normalize(ta-ro); - vec3 cp = vec3(sin(cr), cos(cr),0.0); - vec3 cu = normalize( cross(cw,cp) ); - vec3 cv = normalize( cross(cu,cw) ); + vec3 cp = vec3(sin(cr), cos(cr),0.0); + vec3 cu = normalize( cross(cw,cp) ); + vec3 cv = normalize( cross(cu,cw) ); return mat3( cu, cv, cw ); } @@ -403,7 +403,7 @@ void main() vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y; #endif - // RAY: Camera is provided from raylib + // RAY: Camera is provided from raylib //vec3 ro = vec3( -0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x) ); vec3 ro = viewEye; @@ -414,10 +414,10 @@ void main() // ray direction vec3 rd = ca * normalize( vec3(p.xy,2.0) ); - // render + // render vec3 col = render( ro, rd ); - // gamma + // gamma col = pow( col, vec3(0.4545) ); tot += col; diff --git a/examples/shaders/resources/shaders/glsl330/reload.fs b/examples/shaders/resources/shaders/glsl330/reload.fs index 9891a4b5f..21ce18e02 100644 --- a/examples/shaders/resources/shaders/glsl330/reload.fs +++ b/examples/shaders/resources/shaders/glsl330/reload.fs @@ -15,26 +15,26 @@ uniform float time; // Total run time (in secods) // Draw circle vec4 DrawCircle(vec2 fragCoord, vec2 position, float radius, vec3 color) { - float d = length(position - fragCoord) - radius; - float t = clamp(d, 0.0, 1.0); - return vec4(color, 1.0 - t); + float d = length(position - fragCoord) - radius; + float t = clamp(d, 0.0, 1.0); + return vec4(color, 1.0 - t); } void main() { - vec2 fragCoord = gl_FragCoord.xy; - vec2 position = vec2(mouse.x, resolution.y - mouse.y); - float radius = 40.0; + vec2 fragCoord = gl_FragCoord.xy; + vec2 position = vec2(mouse.x, resolution.y - mouse.y); + float radius = 40.0; // Draw background layer vec4 colorA = vec4(0.2,0.2,0.8, 1.0); vec4 colorB = vec4(1.0,0.7,0.2, 1.0); - vec4 layer1 = mix(colorA, colorB, abs(sin(time*0.1))); + vec4 layer1 = mix(colorA, colorB, abs(sin(time*0.1))); - // Draw circle layer - vec3 color = vec3(0.9, 0.16, 0.21); - vec4 layer2 = DrawCircle(fragCoord, position, radius, color); - - // Blend the two layers - finalColor = mix(layer1, layer2, layer2.a); + // Draw circle layer + vec3 color = vec3(0.9, 0.16, 0.21); + vec4 layer2 = DrawCircle(fragCoord, position, radius, color); + + // Blend the two layers + finalColor = mix(layer1, layer2, layer2.a); } diff --git a/examples/shaders/resources/shaders/glsl330/sobel.fs b/examples/shaders/resources/shaders/glsl330/sobel.fs index a1430cdd0..f317ae328 100644 --- a/examples/shaders/resources/shaders/glsl330/sobel.fs +++ b/examples/shaders/resources/shaders/glsl330/sobel.fs @@ -16,26 +16,26 @@ uniform vec2 resolution = vec2(800, 450); void main() { - float x = 1.0/resolution.x; - float y = 1.0/resolution.y; + float x = 1.0/resolution.x; + float y = 1.0/resolution.y; - vec4 horizEdge = vec4(0.0); - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; - horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; - horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + vec4 horizEdge = vec4(0.0); + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; - vec4 vertEdge = vec4(0.0); - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; - vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; - vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + vec4 vertEdge = vec4(0.0); + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; - vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); - - finalColor = vec4(edge, texture2D(texture0, fragTexCoord).a); + vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); + + finalColor = vec4(edge, texture2D(texture0, fragTexCoord).a); } \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/spotlight.fs b/examples/shaders/resources/shaders/glsl330/spotlight.fs index 97a4377b4..c573be8f3 100644 --- a/examples/shaders/resources/shaders/glsl330/spotlight.fs +++ b/examples/shaders/resources/shaders/glsl330/spotlight.fs @@ -12,9 +12,9 @@ out vec4 finalColor; #define MAX_SPOTS 3 struct Spot { - vec2 pos; // window coords of spot - float inner; // inner fully transparent centre radius - float radius; // alpha fades out to this radius + vec2 pos; // window coords of spot + float inner; // inner fully transparent centre radius + float radius; // alpha fades out to this radius }; uniform Spot spots[MAX_SPOTS]; // Spotlight positions array @@ -22,44 +22,44 @@ uniform float screenWidth; // Width of the screen void main() { - float alpha = 1.0; + float alpha = 1.0; - // Get the position of the current fragment (screen coordinates!) - vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y); - - // Find out which spotlight is nearest - float d = 65000; // some high value - int fi = -1; // found index + // Get the position of the current fragment (screen coordinates!) + vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y); + + // Find out which spotlight is nearest + float d = 65000; // some high value + int fi = -1; // found index for (int i = 0; i < MAX_SPOTS; i++) { - for (int j = 0; j < MAX_SPOTS; j++) - { - float dj = distance(pos, spots[j].pos) - spots[j].radius + spots[i].radius; + for (int j = 0; j < MAX_SPOTS; j++) + { + float dj = distance(pos, spots[j].pos) - spots[j].radius + spots[i].radius; - if (d > dj) - { - d = dj; - fi = i; - } - } + if (d > dj) + { + d = dj; + fi = i; + } + } } // d now equals distance to nearest spot... // allowing for the different radii of all spotlights if (fi != -1) { - if (d > spots[fi].radius) alpha = 1.0; - else - { - if (d < spots[fi].inner) alpha = 0.0; - else alpha = (d - spots[fi].inner) / (spots[fi].radius - spots[fi].inner); - } - } - - // Right hand side of screen is dimly lit, + if (d > spots[fi].radius) alpha = 1.0; + else + { + if (d < spots[fi].inner) alpha = 0.0; + else alpha = (d - spots[fi].inner) / (spots[fi].radius - spots[fi].inner); + } + } + + // Right hand side of screen is dimly lit, // could make the threshold value user definable - if ((pos.x > screenWidth/2.0) && (alpha > 0.9)) alpha = 0.9; + if ((pos.x > screenWidth/2.0) && (alpha > 0.9)) alpha = 0.9; finalColor = vec4(0, 0, 0, alpha); } diff --git a/examples/shaders/resources/shaders/glsl330/wave.fs b/examples/shaders/resources/shaders/glsl330/wave.fs index f139f3957..43efee234 100644 --- a/examples/shaders/resources/shaders/glsl330/wave.fs +++ b/examples/shaders/resources/shaders/glsl330/wave.fs @@ -23,15 +23,15 @@ uniform float speedX; uniform float speedY; void main() { - float pixelWidth = 1.0 / size.x; - float pixelHeight = 1.0 / size.y; - float aspect = pixelHeight / pixelWidth; - float boxLeft = 0.0; - float boxTop = 0.0; + float pixelWidth = 1.0 / size.x; + float pixelHeight = 1.0 / size.y; + float aspect = pixelHeight / pixelWidth; + float boxLeft = 0.0; + float boxTop = 0.0; - vec2 p = fragTexCoord; - p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth; - p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight; + vec2 p = fragTexCoord; + p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth; + p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight; - finalColor = texture(texture0, p)*colDiffuse*fragColor; + finalColor = texture(texture0, p)*colDiffuse*fragColor; }