Remove trailing spaces on shaders

This commit is contained in:
Ray 2026-03-29 01:10:29 +01:00
commit fb0f83bc91
9 changed files with 137 additions and 137 deletions

View file

@ -52,12 +52,12 @@ void main()
float gray = GreyScale(cellColor);
int n = 4096;
// Character set from https://www.shadertoy.com/view/lssGDj
// Create new bitmaps https://thrill-project.com/archiv/coding/bitmap/
if (gray > 0.2) n = 65600; // :
if (gray > 0.3) n = 18725316; // v
if (gray > 0.4) n = 15255086; // o
if (gray > 0.4) n = 15255086; // o
if (gray > 0.5) n = 13121101; // &
if (gray > 0.6) n = 15252014; // 8
if (gray > 0.7) n = 13195790; // @

View file

@ -20,7 +20,7 @@ void main()
// NOTE: Implement here your fragment shader code
// final color is the color from the texture
// final color is the color from the texture
// times the tint color (colDiffuse)
// times the fragment color (interpolated vertex color)
finalColor = texelColor*colDiffuse*fragColor;

View file

@ -14,7 +14,7 @@ out vec4 finalColor;
void main()
{
vec4 texelColor = texture(texture0, fragTexCoord);
finalColor = texelColor*colDiffuse*fragColor;
gl_FragDepth = 1.0 - finalColor.z;
}

View file

@ -14,7 +14,7 @@ uniform mat4 matProjection;
void main()
{
vec4 worldPos = matModel*vec4(vertexPosition, 1.0);
fragPosition = worldPos.xyz;
fragPosition = worldPos.xyz;
fragTexCoord = vertexTexCoord;
mat3 normalMatrix = transpose(inverse(mat3(matModel)));

View file

@ -16,7 +16,7 @@ out vec4 finalColor;
void main()
{
vec4 texelColor = texture(texture0, fragTexCoord);
finalColor = texelColor*colDiffuse*fragColor;
gl_FragDepth = finalColor.z;
}

View file

@ -33,7 +33,7 @@ float sdHorseshoe(in vec3 p, in vec2 c, in float r, in float le, vec2 w)
p.xy = mat2(-c.x, c.y, c.y, c.x)*p.xy;
p.xy = vec2(((p.y > 0.0) || (p.x > 0.0))? p.x : l*sign(-c.x), (p.x>0.0)? p.y : l);
p.xy = vec2(p.x, abs(p.y - r)) - vec2(le, 0.0);
vec2 q = vec2(length(max(p.xy, 0.0)) + min(0.0, max(p.x, p.y)), p.z);
vec2 d = abs(q) - w;
return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
@ -54,7 +54,7 @@ float sdSixWayCutHollowSphere(vec3 p, float r, float h, float t)
vec2 q = vec2(length(ap.yz), ap.x);
float w = sqrt(r*r-h*h);
return ((h*q.x < w*q.y)? length(q - vec2(w, h)) : abs(length(q) - r)) - t;
}
@ -79,7 +79,7 @@ vec2 map(in vec3 pos)
{
vec2 res = vec2(sdHorseshoe(pos - vec3(-1.0, 0.08, 1.0), vec2(cos(1.3), sin(1.3)), 0.2, 0.3, vec2(0.03,0.5)), 11.5);
res = opU(res, vec2(sdSixWayCutHollowSphere(pos-vec3(0.0, 1.0, 0.0), 4.0, 3.5, 0.5), 4.5));
return res;
}
@ -105,8 +105,8 @@ vec2 raycast(in vec3 ro, in vec3 rd)
if (t > tmax) break;
vec2 h = map(ro + rd*t);
if (abs(h.x )< (0.0001*t))
{
res = vec2(t, h.y);
{
res = vec2(t, h.y);
break;
}
t += h.x;
@ -131,9 +131,9 @@ float calcSoftshadow(in vec3 ro, in vec3 rd, in float mint, in float tmax)
t += clamp(h, 0.01, 0.2);
if ((res < 0.004) || (t > tmax)) break;
}
res = clamp(res, 0.0, 1.0);
return res*res*(3.0-2.0*res);
}
@ -141,9 +141,9 @@ float calcSoftshadow(in vec3 ro, in vec3 rd, in float mint, in float tmax)
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 +
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);
}
@ -160,7 +160,7 @@ float calcAO(in vec3 pos, in vec3 nor)
sca *= 0.95;
if (occ>0.35) break;
}
return clamp(1.0 - 3.0*occ, 0.0, 1.0)*(0.5+0.5*nor.y);
}
@ -172,15 +172,15 @@ float checkersGradBox(in vec2 p)
// analytical integral (box filter)
vec2 i = 2.0*(abs(fract((p - 0.5*w)*0.5)-0.5) - abs(fract((p + 0.5*w)*0.5) - 0.5))/w;
// xor pattern
return (0.5 - 0.5*i.x*i.y);
return (0.5 - 0.5*i.x*i.y);
}
// https://www.shadertoy.com/view/tdS3DG
vec4 render(in vec3 ro, in vec3 rd)
{
{
// background
vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
// raycast scene
vec2 res = raycast(ro,rd);
float t = res.x;
@ -190,11 +190,11 @@ vec4 render(in vec3 ro, in vec3 rd)
vec3 pos = ro + t*rd;
vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal(pos);
vec3 ref = reflect(rd, nor);
// material
// material
col = 0.2 + 0.2*sin(m*2.0 + vec3(0.0,1.0,2.0));
float ks = 1.0;
if (m < 1.5)
{
float f = checkersGradBox(3.0*pos.xz);
@ -204,7 +204,7 @@ vec4 render(in vec3 ro, in vec3 rd)
// lighting
float occ = calcAO(pos, nor);
vec3 lin = vec3(0.0);
// sun
@ -245,7 +245,7 @@ vec4 render(in vec3 ro, in vec3 rd)
dif *= occ;
lin += col*0.25*dif*vec3(1.00,1.00,1.00);
}
col = lin;
col = mix(col, vec3(0.7,0.7,0.9), 1.0-exp(-0.0001*t*t*t));
@ -285,7 +285,7 @@ void main()
color = res.xyz;
depth = CalcDepth(rd,res.w);
}
finalColor = vec4(color , 1.0);
gl_FragDepth = depth;
}

View file

@ -24,7 +24,7 @@ void main()
// to the palette index by scaling up from [0..1] to [0..255]
int index = int(texelColor.r*255.0);
ivec3 color = palette[index];
//finalColor = texture(palette, texelColor.xy); // Alternative to ivec3
// Calculate final fragment color. Note that the palette color components

View file

@ -84,11 +84,11 @@ vec3 ComputePBR()
{
vec3 albedo = texture(albedoMap,vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb;
albedo = vec3(albedoColor.x*albedo.x, albedoColor.y*albedo.y, albedoColor.z*albedo.z);
float metallic = clamp(metallicValue, 0.0, 1.0);
float roughness = clamp(roughnessValue, 0.0, 1.0);
float ao = clamp(aoValue, 0.0, 1.0);
if (useTexMRA == 1)
{
vec4 mra = texture(mraMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y));
@ -133,18 +133,18 @@ vec3 ComputePBR()
vec3 F = SchlickFresnel(hDotV, baseRefl); // Fresnel proportion of specular reflectance
vec3 spec = (D*G*F)/(4.0*nDotV*nDotL);
// Difuse and spec light can't be above 1.0
// kD = 1.0 - kS diffuse component is equal 1.0 - spec comonent
vec3 kD = vec3(1.0) - F;
// Mult kD by the inverse of metallnes, only non-metals should have diffuse light
kD *= 1.0 - metallic;
lightAccum += ((kD*albedo.rgb/PI + spec)*radiance*nDotL)*lights[i].enabled; // Angle of light has impact on result
}
vec3 ambientFinal = (ambientColor + albedo)*ambient*0.5;
return (ambientFinal + lightAccum*ao + emissive);
}
@ -154,7 +154,7 @@ void main()
// HDR tonemapping
color = pow(color, color + vec3(1.0));
// Gamma correction
color = pow(color, vec3(1.0/2.2));

View file

@ -11,7 +11,7 @@ uniform mat4 mvp;
uniform mat4 matModel;
uniform mat4 matNormal;
uniform float time;
uniform float time;
uniform sampler2D perlinNoiseMap;