Remove trailing spaces

This commit is contained in:
raysan5 2021-10-19 14:57:12 +02:00
commit fec0ce34c5
80 changed files with 310 additions and 311 deletions

View file

@ -18,7 +18,7 @@ vec2 SampleSphericalMap(vec3 v)
void main() void main()
{ {
// Normalize local position // Normalize local position
vec2 uv = SampleSphericalMap(normalize(fragPosition)); vec2 uv = SampleSphericalMap(normalize(fragPosition));
// Fetch color from texture map // Fetch color from texture map

View file

@ -19,8 +19,8 @@ void main()
else texelColor = textureCube(environmentMap, fragPosition); else texelColor = textureCube(environmentMap, fragPosition);
vec3 color = vec3(texelColor.x, texelColor.y, texelColor.z); vec3 color = vec3(texelColor.x, texelColor.y, texelColor.z);
if (doGamma)// Apply gamma correction if (doGamma) // Apply gamma correction
{ {
color = color/(color + vec3(1.0)); color = color/(color + vec3(1.0));
color = pow(color, vec3(1.0/2.2)); color = pow(color, vec3(1.0/2.2));

View file

@ -19,7 +19,7 @@ vec2 SampleSphericalMap(vec3 v)
void main() void main()
{ {
// Normalize local position // Normalize local position
vec2 uv = SampleSphericalMap(normalize(fragPosition)); vec2 uv = SampleSphericalMap(normalize(fragPosition));
// Fetch color from texture map // Fetch color from texture map

View file

@ -20,7 +20,7 @@ void main()
else color = texture(environmentMap, fragPosition).rgb; else color = texture(environmentMap, fragPosition).rgb;
if (doGamma)// Apply gamma correction if (doGamma)// Apply gamma correction
{ {
color = color/(color + vec3(1.0)); color = color/(color + vec3(1.0));
color = pow(color, vec3(1.0/2.2)); color = pow(color, vec3(1.0/2.2));
} }

View file

@ -7,18 +7,18 @@ attribute vec3 vertexPosition;
uniform mat4 mvp; uniform mat4 mvp;
uniform float currentTime; uniform float currentTime;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
void main() void main()
{ {
// Unpack data from vertexPosition // Unpack data from vertexPosition
vec2 pos = vertexPosition.xy; vec2 pos = vertexPosition.xy;
float period = vertexPosition.z; float period = vertexPosition.z;
// Calculate final vertex position (jiggle it around a bit horizontally) // Calculate final vertex position (jiggle it around a bit horizontally)
pos += vec2(100.0, 0.0) * sin(period * currentTime); pos += vec2(100.0, 0.0) * sin(period * currentTime);
gl_Position = mvp * vec4(pos.x, pos.y, 0.0, 1.0); gl_Position = mvp * vec4(pos.x, pos.y, 0.0, 1.0);
// Calculate the screen space size of this particle (also vary it over time) // Calculate the screen space size of this particle (also vary it over time)
gl_PointSize = 10.0 - 5.0 * abs(sin(period * currentTime)); gl_PointSize = 10.0 - 5.0 * abs(sin(period * currentTime));
} }

View file

@ -7,18 +7,18 @@ in vec3 vertexPosition;
uniform mat4 mvp; uniform mat4 mvp;
uniform float currentTime; uniform float currentTime;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
void main() void main()
{ {
// Unpack data from vertexPosition // Unpack data from vertexPosition
vec2 pos = vertexPosition.xy; vec2 pos = vertexPosition.xy;
float period = vertexPosition.z; float period = vertexPosition.z;
// Calculate final vertex position (jiggle it around a bit horizontally) // Calculate final vertex position (jiggle it around a bit horizontally)
pos += vec2(100, 0) * sin(period * currentTime); pos += vec2(100, 0) * sin(period * currentTime);
gl_Position = mvp * vec4(pos, 0.0, 1.0); gl_Position = mvp * vec4(pos, 0.0, 1.0);
// Calculate the screen space size of this particle (also vary it over time) // Calculate the screen space size of this particle (also vary it over time)
gl_PointSize = 10 - 5 * abs(sin(period * currentTime)); gl_PointSize = 10 - 5 * abs(sin(period * currentTime));
} }

View file

@ -16,8 +16,8 @@ void main()
{ {
// Texel color fetching from texture sampler // Texel color fetching from texture sampler
vec4 texelColor = texture2D(texture0, fragTexCoord); vec4 texelColor = texture2D(texture0, fragTexCoord);
// NOTE: Implement here your fragment shader code // NOTE: Implement here your fragment shader code
gl_FragColor = texelColor*colDiffuse; gl_FragColor = texelColor*colDiffuse;
} }

View file

@ -13,14 +13,14 @@ uniform mat4 mvp;
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor; varying vec4 fragColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
void main() void main()
{ {
// Send vertex attributes to fragment shader // Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord; fragTexCoord = vertexTexCoord;
fragColor = vertexColor; fragColor = vertexColor;
// Calculate final vertex position // Calculate final vertex position
gl_Position = mvp*vec4(vertexPosition, 1.0); gl_Position = mvp*vec4(vertexPosition, 1.0);
} }

View file

@ -19,14 +19,14 @@ const float renderHeight = 450.0;
vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308); vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308);
vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703); vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703);
void main() void main()
{ {
// Texel color fetching from texture sampler // Texel color fetching from texture sampler
vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight.x; vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight.x;
tc += texture2D(texture0, fragTexCoord + vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; tc += texture2D(texture0, fragTexCoord + vec2(offset.y)/renderWidth, 0.0).rgb*weight.y;
tc += texture2D(texture0, fragTexCoord - vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; tc += texture2D(texture0, fragTexCoord - vec2(offset.y)/renderWidth, 0.0).rgb*weight.y;
tc += texture2D(texture0, fragTexCoord + vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; tc += texture2D(texture0, fragTexCoord + vec2(offset.z)/renderWidth, 0.0).rgb*weight.z;
tc += texture2D(texture0, fragTexCoord - vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; tc += texture2D(texture0, fragTexCoord - vec2(offset.z)/renderWidth, 0.0).rgb*weight.z;

View file

@ -18,9 +18,9 @@ void main()
// Texel color fetching from texture sampler // Texel color fetching from texture sampler
vec4 texelColor0 = texture2D(texture0, fragTexCoord); vec4 texelColor0 = texture2D(texture0, fragTexCoord);
vec4 texelColor1 = texture2D(texture1, fragTexCoord); vec4 texelColor1 = texture2D(texture1, fragTexCoord);
float x = fract(fragTexCoord.s); float x = fract(fragTexCoord.s);
float final = smoothstep(divider - 0.1, divider + 0.1, x); float final = smoothstep(divider - 0.1, divider + 0.1, x);
gl_FragColor = mix(texelColor0, texelColor1, final); gl_FragColor = mix(texelColor0, texelColor1, final);
} }

View file

@ -18,27 +18,27 @@ float lumThreshold02 = 0.7;
float lumThreshold03 = 0.5; float lumThreshold03 = 0.5;
float lumThreshold04 = 0.3; float lumThreshold04 = 0.3;
void main() void main()
{ {
vec3 tc = vec3(1.0, 1.0, 1.0); vec3 tc = vec3(1.0, 1.0, 1.0);
float lum = length(texture2D(texture0, fragTexCoord).rgb); float lum = length(texture2D(texture0, fragTexCoord).rgb);
if (lum < lumThreshold01) if (lum < lumThreshold01)
{ {
if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
} }
if (lum < lumThreshold02) if (lum < lumThreshold02)
{ {
if (mod(gl_FragCoord .x - gl_FragCoord .y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); if (mod(gl_FragCoord .x - gl_FragCoord .y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
} }
if (lum < lumThreshold03) if (lum < lumThreshold03)
{ {
if (mod(gl_FragCoord .x + gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); if (mod(gl_FragCoord .x + gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
} }
if (lum < lumThreshold04) if (lum < lumThreshold04)
{ {
if (mod(gl_FragCoord .x - gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); if (mod(gl_FragCoord .x - gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
} }

View file

@ -29,12 +29,12 @@ vec4 PostFX(sampler2D tex, vec2 uv)
int remX = int(mod(cPos.x, size)); int remX = int(mod(cPos.x, size));
int remY = int(mod(cPos.y, size)); int remY = int(mod(cPos.y, size));
if (remX == 0 && remY == 0) tlPos = cPos; if (remX == 0 && remY == 0) tlPos = cPos;
vec2 blPos = tlPos; vec2 blPos = tlPos;
blPos.y += (size - 1.0); blPos.y += (size - 1.0);
if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y))))) if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
{ {
if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0); if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
@ -45,7 +45,7 @@ vec4 PostFX(sampler2D tex, vec2 uv)
if (invert == 1) c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; if (invert == 1) c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
else c = vec4(0.0, 0.0, 0.0, 1.0); else c = vec4(0.0, 0.0, 0.0, 1.0);
} }
return c; return c;
} }

View file

@ -17,21 +17,21 @@ vec2 VectorRotateTime(vec2 v, float speed)
{ {
float time = uTime*speed; float time = uTime*speed;
float localTime = fract(time); // The time domain this works on is 1 sec. float localTime = fract(time); // The time domain this works on is 1 sec.
if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0; if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0;
else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4.0*sin(2.0*PI*localTime - PI/2.0); else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4.0*sin(2.0*PI*localTime - PI/2.0);
else if ((localTime >= 0.50) && (localTime < 0.75)) angle = PI*0.25; else if ((localTime >= 0.50) && (localTime < 0.75)) angle = PI*0.25;
else if ((localTime >= 0.75) && (localTime < 1.00)) angle = PI/4.0*sin(2.0*PI*localTime); else if ((localTime >= 0.75) && (localTime < 1.00)) angle = PI/4.0*sin(2.0*PI*localTime);
// Rotate vector by angle // Rotate vector by angle
v -= 0.5; v -= 0.5;
v = mat2(cos(angle), -sin(angle), sin(angle), cos(angle))*v; v = mat2(cos(angle), -sin(angle), sin(angle), cos(angle))*v;
v += 0.5; v += 0.5;
return v; return v;
} }
float Rectangle(in vec2 st, in float size, in float fill) float Rectangle(in vec2 st, in float size, in float fill)
{ {
float roundSize = 0.5 - size/2.0; float roundSize = 0.5 - size/2.0;
float left = step(roundSize, st.x); float left = step(roundSize, st.x);
@ -43,7 +43,7 @@ float Rectangle(in vec2 st, in float size, in float fill)
} }
void main() void main()
{ {
vec2 fragPos = fragTexCoord; vec2 fragPos = fragTexCoord;
fragPos.xy += uTime/9.0; fragPos.xy += uTime/9.0;
@ -52,7 +52,7 @@ void main()
vec2 fpos = fract(fragPos); // Get the fractional coords vec2 fpos = fract(fragPos); // Get the fractional coords
fpos = VectorRotateTime(fpos, 0.2); fpos = VectorRotateTime(fpos, 0.2);
float alpha = Rectangle(fpos, 0.216, 1.0); float alpha = Rectangle(fpos, 0.216, 1.0);
vec3 color = vec3(0.3, 0.3, 0.3); vec3 color = vec3(0.3, 0.3, 0.3);

View file

@ -20,7 +20,7 @@ void main()
// Linearize depth value // Linearize depth value
float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear)); float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear));
// Calculate final fragment color // Calculate final fragment color
gl_FragColor = vec4(depth, depth, depth, 1.0f); gl_FragColor = vec4(depth, depth, depth, 1.0f);
} }

View file

@ -23,13 +23,13 @@ void main()
// The following two variables need to be set per eye // The following two variables need to be set per eye
vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter; vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter;
vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter; vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter;
// Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter) // Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter)
vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1] vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1]
float rSq = theta.x*theta.x + theta.y*theta.y; float rSq = theta.x*theta.x + theta.y*theta.y;
vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq);
//vec2 tc = LensCenter + Scale*theta1; //vec2 tc = LensCenter + Scale*theta1;
// Detect whether blue texture coordinates are out of range since these will scaled out the furthest // Detect whether blue texture coordinates are out of range since these will scaled out the furthest
vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq); vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq);
vec2 tcBlue = LensCenter + Scale*thetaBlue; vec2 tcBlue = LensCenter + Scale*thetaBlue;

View file

@ -11,7 +11,7 @@ precision mediump float;
Each integer is tested to see if it is a prime number. Primes are colored white. Each integer is tested to see if it is a prime number. Primes are colored white.
Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer. Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer.
You can change the scale variable to make a larger or smaller grid. You can change the scale variable to make a larger or smaller grid.
Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers. Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers.
WARNING: If you make scale too large, your GPU may bog down! WARNING: If you make scale too large, your GPU may bog down!
@ -27,11 +27,11 @@ vec4 Colorizer(float counter, float maxSize)
{ {
float red = 0.0, green = 0.0, blue = 0.0; float red = 0.0, green = 0.0, blue = 0.0;
float normsize = counter/maxSize; float normsize = counter/maxSize;
red = smoothstep(0.3, 0.7, normsize); red = smoothstep(0.3, 0.7, normsize);
green = sin(3.14159*normsize); green = sin(3.14159*normsize);
blue = 1.0 - smoothstep(0.0, 0.4, normsize); blue = 1.0 - smoothstep(0.0, 0.4, normsize);
return vec4(0.8*red, 0.8*green, 0.8*blue, 1.0); return vec4(0.8*red, 0.8*green, 0.8*blue, 1.0);
} }
@ -41,7 +41,7 @@ void main()
float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid. float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid.
float value = scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale); // Group pixels into boxes representing integer values float value = scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale); // Group pixels into boxes representing integer values
int valuei = int(value); int valuei = int(value);
//if ((valuei == 0) || (valuei == 1) || (valuei == 2)) gl_FragColor = vec4(1.0); //if ((valuei == 0) || (valuei == 1) || (valuei == 2)) gl_FragColor = vec4(1.0);
//else //else
{ {

View file

@ -23,7 +23,7 @@ void main()
vec2 uv = vec2(0.0); vec2 uv = vec2(0.0);
vec2 xy = 2.0 * fragTexCoord.xy - 1.0; vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
float d = length(xy); float d = length(xy);
if (d < (2.0 - maxFactor)) if (d < (2.0 - maxFactor))
{ {
d = length(xy * maxFactor); d = length(xy * maxFactor);

View file

@ -54,7 +54,7 @@ void main()
if (lights[i].enabled == 1) if (lights[i].enabled == 1)
{ {
vec3 light = vec3(0.0); vec3 light = vec3(0.0);
if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position); if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position);
if (lights[i].type == LIGHT_POINT) light = normalize(lights[i].position - fragPosition); if (lights[i].type == LIGHT_POINT) light = normalize(lights[i].position - fragPosition);
@ -69,10 +69,10 @@ void main()
vec4 finalColor = (texelColor*((colDiffuse + vec4(specular,1))*vec4(lightDot, 1.0))); vec4 finalColor = (texelColor*((colDiffuse + vec4(specular,1))*vec4(lightDot, 1.0)));
finalColor += texelColor*(ambient/10.0); finalColor += texelColor*(ambient/10.0);
// Gamma correction // Gamma correction
finalColor = pow(finalColor, vec4(1.0/2.2)); finalColor = pow(finalColor, vec4(1.0/2.2));
// Fog calculation // Fog calculation
float dist = length(viewPos - fragPosition); float dist = length(viewPos - fragPosition);

View file

@ -16,10 +16,10 @@ void main()
{ {
// Texel color fetching from texture sampler // Texel color fetching from texture sampler
vec4 texelColor = texture2D(texture0, fragTexCoord)*colDiffuse*fragColor; vec4 texelColor = texture2D(texture0, fragTexCoord)*colDiffuse*fragColor;
// Convert texel color to grayscale using NTSC conversion weights // Convert texel color to grayscale using NTSC conversion weights
float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114)); float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
// Calculate final fragment color // Calculate final fragment color
gl_FragColor = vec4(gray, gray, gray, texelColor.a); gl_FragColor = vec4(gray, gray, gray, texelColor.a);
} }

View file

@ -52,7 +52,7 @@ void main()
We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared. We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared.
And once the magnitude squared is > 4, then magnitude > 2 is also true (saves computational power). And once the magnitude squared is > 4, then magnitude > 2 is also true (saves computational power).
*************************************************************************************************/ *************************************************************************************************/
// The pixel coordinates are scaled so they are on the mandelbrot scale // The pixel coordinates are scaled so they are on the mandelbrot scale
// NOTE: fragTexCoord already comes as normalized screen coordinates but offset must be normalized before scaling and zoom // NOTE: fragTexCoord already comes as normalized screen coordinates but offset must be normalized before scaling and zoom
vec2 z = vec2((fragTexCoord.x + offset.x/screenDims.x)*2.5/zoom, (fragTexCoord.y + offset.y/screenDims.y)*1.5/zoom); vec2 z = vec2((fragTexCoord.x + offset.x/screenDims.x)*2.5/zoom, (fragTexCoord.y + offset.y/screenDims.y)*1.5/zoom);
@ -70,10 +70,10 @@ void main()
// See http://linas.org/art-gallery/escape/escape.html for more information. // See http://linas.org/art-gallery/escape/escape.html for more information.
z = ComplexSquare(z) + c; z = ComplexSquare(z) + c;
z = ComplexSquare(z) + c; z = ComplexSquare(z) + c;
// This last part smooths the color (again see link above). // This last part smooths the color (again see link above).
float smoothVal = float(iter) + 1.0 - (log(log(length(z)))/log(2.0)); float smoothVal = float(iter) + 1.0 - (log(log(length(z)))/log(2.0));
// Normalize the value so it is between 0 and 1. // Normalize the value so it is between 0 and 1.
float norm = smoothVal/float(MAX_ITERATIONS); float norm = smoothVal/float(MAX_ITERATIONS);

Some files were not shown because too many files have changed in this diff Show more