diff --git a/examples/audio/resources/shaders/glsl100/fft.fs b/examples/audio/resources/shaders/glsl100/fft.fs index a97bf336b..15f6fef0f 100644 --- a/examples/audio/resources/shaders/glsl100/fft.fs +++ b/examples/audio/resources/shaders/glsl100/fft.fs @@ -23,15 +23,15 @@ void main() float localX = mod(fragCoord.x, cellWidth); float barWidth = cellWidth - 1.0; vec4 color = WHITE; - + if (localX <= barWidth) { float sampleX = (binIndex + 0.5)/NUM_OF_BINS; vec2 sampleCoord = vec2(sampleX, FFT_ROW); float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use - + if (fragTexCoord.y < amplitude) color = BLACK; } - + gl_FragColor = color; } diff --git a/examples/audio/resources/shaders/glsl120/fft.fs b/examples/audio/resources/shaders/glsl120/fft.fs index bab5d533b..3048d6c1f 100644 --- a/examples/audio/resources/shaders/glsl120/fft.fs +++ b/examples/audio/resources/shaders/glsl120/fft.fs @@ -21,15 +21,15 @@ void main() float localX = mod(fragCoord.x, cellWidth); float barWidth = cellWidth - 1.0; vec4 color = WHITE; - + if (localX <= barWidth) { float sampleX = (binIndex + 0.5)/NUM_OF_BINS; vec2 sampleCoord = vec2(sampleX, FFT_ROW); float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use - + if (fragTexCoord.y < amplitude) color = BLACK; } - + gl_FragColor = color; } diff --git a/examples/audio/resources/shaders/glsl330/fft.fs b/examples/audio/resources/shaders/glsl330/fft.fs index 20b2e9dfa..f355ced65 100644 --- a/examples/audio/resources/shaders/glsl330/fft.fs +++ b/examples/audio/resources/shaders/glsl330/fft.fs @@ -21,15 +21,15 @@ void main() float localX = mod(fragCoord.x, cellWidth); float barWidth = cellWidth - 1.0; vec4 color = WHITE; - + if (localX <= barWidth) { float sampleX = (binIndex + 0.5)/NUM_OF_BINS; vec2 sampleCoord = vec2(sampleX, FFT_ROW); float amplitude = texture(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use - + if (fragTexCoord.y < amplitude) color = BLACK; } - + finalColor = color; } diff --git a/examples/models/resources/shaders/glsl100/skinning.fs b/examples/models/resources/shaders/glsl100/skinning.fs index 96bcabe01..7feb097dd 100644 --- a/examples/models/resources/shaders/glsl100/skinning.fs +++ b/examples/models/resources/shaders/glsl100/skinning.fs @@ -14,7 +14,7 @@ void main() { // Fetch color from texture sampler vec4 texelColor = texture2D(texture0, fragTexCoord); - + // Calculate final fragment color gl_FragColor = texelColor*colDiffuse*fragColor; } diff --git a/examples/models/resources/shaders/glsl100/skinning.vs b/examples/models/resources/shaders/glsl100/skinning.vs index 344ad3f95..cb726eb5a 100644 --- a/examples/models/resources/shaders/glsl100/skinning.vs +++ b/examples/models/resources/shaders/glsl100/skinning.vs @@ -23,7 +23,7 @@ void main() int boneIndex1 = int(vertexBoneIndices.y); int boneIndex2 = int(vertexBoneIndices.z); int boneIndex3 = int(vertexBoneIndices.w); - + // WARNING: OpenGL ES 2.0 does not support automatic matrix transposing, neither transpose() function mat4 boneMatrixTransposed0 = mat4( vec4(boneMatrices[boneIndex0][0].x, boneMatrices[boneIndex0][1].x, boneMatrices[boneIndex0][2].x, boneMatrices[boneIndex0][3].x), @@ -45,13 +45,13 @@ void main() vec4(boneMatrices[boneIndex3][0].y, boneMatrices[boneIndex3][1].y, boneMatrices[boneIndex3][2].y, boneMatrices[boneIndex3][3].y), vec4(boneMatrices[boneIndex3][0].z, boneMatrices[boneIndex3][1].z, boneMatrices[boneIndex3][2].z, boneMatrices[boneIndex3][3].z), vec4(boneMatrices[boneIndex3][0].w, boneMatrices[boneIndex3][1].w, boneMatrices[boneIndex3][2].w, boneMatrices[boneIndex3][3].w)); - + vec4 skinnedPosition = vertexBoneWeights.x*(boneMatrixTransposed0*vec4(vertexPosition, 1.0)) + - vertexBoneWeights.y*(boneMatrixTransposed1*vec4(vertexPosition, 1.0)) + - vertexBoneWeights.z*(boneMatrixTransposed2*vec4(vertexPosition, 1.0)) + + vertexBoneWeights.y*(boneMatrixTransposed1*vec4(vertexPosition, 1.0)) + + vertexBoneWeights.z*(boneMatrixTransposed2*vec4(vertexPosition, 1.0)) + vertexBoneWeights.w*(boneMatrixTransposed3*vec4(vertexPosition, 1.0)); - + fragTexCoord = vertexTexCoord; fragColor = vertexColor; diff --git a/examples/models/resources/shaders/glsl120/skinning.fs b/examples/models/resources/shaders/glsl120/skinning.fs index 44c6314d1..5ea45cbac 100644 --- a/examples/models/resources/shaders/glsl120/skinning.fs +++ b/examples/models/resources/shaders/glsl120/skinning.fs @@ -12,7 +12,7 @@ void main() { // Fetch color from texture sampler vec4 texelColor = texture2D(texture0, fragTexCoord); - + // Calculate final fragment color gl_FragColor = texelColor*colDiffuse*fragColor; } diff --git a/examples/models/resources/shaders/glsl120/skinning.vs b/examples/models/resources/shaders/glsl120/skinning.vs index 1d9855074..02815f515 100644 --- a/examples/models/resources/shaders/glsl120/skinning.vs +++ b/examples/models/resources/shaders/glsl120/skinning.vs @@ -23,7 +23,7 @@ void main() int boneIndex1 = int(vertexBoneIndices.y); int boneIndex2 = int(vertexBoneIndices.z); int boneIndex3 = int(vertexBoneIndices.w); - + // WARNING: OpenGL ES 2.0 does not support automatic matrix transposing, neither transpose() function mat4 boneMatrixTransposed0 = mat4( vec4(boneMatrices[boneIndex0][0].x, boneMatrices[boneIndex0][1].x, boneMatrices[boneIndex0][2].x, boneMatrices[boneIndex0][3].x), @@ -45,13 +45,13 @@ void main() vec4(boneMatrices[boneIndex3][0].y, boneMatrices[boneIndex3][1].y, boneMatrices[boneIndex3][2].y, boneMatrices[boneIndex3][3].y), vec4(boneMatrices[boneIndex3][0].z, boneMatrices[boneIndex3][1].z, boneMatrices[boneIndex3][2].z, boneMatrices[boneIndex3][3].z), vec4(boneMatrices[boneIndex3][0].w, boneMatrices[boneIndex3][1].w, boneMatrices[boneIndex3][2].w, boneMatrices[boneIndex3][3].w)); - + vec4 skinnedPosition = vertexBoneWeights.x*(boneMatrixTransposed0*vec4(vertexPosition, 1.0)) + - vertexBoneWeights.y*(boneMatrixTransposed1*vec4(vertexPosition, 1.0)) + - vertexBoneWeights.z*(boneMatrixTransposed2*vec4(vertexPosition, 1.0)) + + vertexBoneWeights.y*(boneMatrixTransposed1*vec4(vertexPosition, 1.0)) + + vertexBoneWeights.z*(boneMatrixTransposed2*vec4(vertexPosition, 1.0)) + vertexBoneWeights.w*(boneMatrixTransposed3*vec4(vertexPosition, 1.0)); - + fragTexCoord = vertexTexCoord; fragColor = vertexColor; diff --git a/examples/models/resources/shaders/glsl330/skinning.vs b/examples/models/resources/shaders/glsl330/skinning.vs index 9b4ffbbfa..406d16f56 100644 --- a/examples/models/resources/shaders/glsl330/skinning.vs +++ b/examples/models/resources/shaders/glsl330/skinning.vs @@ -26,17 +26,17 @@ void main() int boneIndex1 = int(vertexBoneIndices.y); int boneIndex2 = int(vertexBoneIndices.z); int boneIndex3 = int(vertexBoneIndices.w); - + vec4 skinnedPosition = vertexBoneWeights.x*(boneMatrices[boneIndex0]*vec4(vertexPosition, 1.0)) + - vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexPosition, 1.0)) + - vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexPosition, 1.0)) + + vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexPosition, 1.0)) + + vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexPosition, 1.0)) + vertexBoneWeights.w*(boneMatrices[boneIndex3]*vec4(vertexPosition, 1.0)); vec4 skinnedNormal = vertexBoneWeights.x*(boneMatrices[boneIndex0]*vec4(vertexNormal, 0.0)) + - vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexNormal, 0.0)) + - vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexNormal, 0.0)) + + vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexNormal, 0.0)) + + vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexNormal, 0.0)) + vertexBoneWeights.w*(boneMatrices[boneIndex3]*vec4(vertexNormal, 0.0)); skinnedNormal.w = 0.0; diff --git a/examples/shaders/resources/shaders/glsl100/ascii.fs b/examples/shaders/resources/shaders/glsl100/ascii.fs index 11b46e471..2e325c0ed 100644 --- a/examples/shaders/resources/shaders/glsl100/ascii.fs +++ b/examples/shaders/resources/shaders/glsl100/ascii.fs @@ -58,12 +58,12 @@ void main() float gray = GreyScale(cellColor); float n = 4096.0; - + // 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.0; // : if (gray > 0.3) n = 18725316.0; // v - if (gray > 0.4) n = 15255086.0; // o + if (gray > 0.4) n = 15255086.0; // o if (gray > 0.5) n = 13121101.0; // & if (gray > 0.6) n = 15252014.0; // 8 if (gray > 0.7) n = 13195790.0; // @ diff --git a/examples/shaders/resources/shaders/glsl100/deferred_shading.vs b/examples/shaders/resources/shaders/glsl100/deferred_shading.vs index bb108ce09..bd5bed5b1 100644 --- a/examples/shaders/resources/shaders/glsl100/deferred_shading.vs +++ b/examples/shaders/resources/shaders/glsl100/deferred_shading.vs @@ -12,5 +12,5 @@ void main() fragTexCoord = vertexTexCoord; // Calculate final vertex position - gl_Position = vec4(vertexPosition, 1.0); + gl_Position = vec4(vertexPosition, 1.0); } diff --git a/examples/shaders/resources/shaders/glsl100/depth_write.fs b/examples/shaders/resources/shaders/glsl100/depth_write.fs index 15095db11..55d3a2d87 100644 --- a/examples/shaders/resources/shaders/glsl100/depth_write.fs +++ b/examples/shaders/resources/shaders/glsl100/depth_write.fs @@ -1,5 +1,5 @@ #version 100 -#extension GL_EXT_frag_depth : enable +#extension GL_EXT_frag_depth : enable precision mediump float; @@ -14,7 +14,7 @@ uniform vec4 colDiffuse; void main() { vec4 texelColor = texture2D(texture0, fragTexCoord); - + gl_FragColor = texelColor*colDiffuse*fragColor; gl_FragDepthEXT = 1.0 - gl_FragCoord.z; } diff --git a/examples/shaders/resources/shaders/glsl100/gbuffer.fs b/examples/shaders/resources/shaders/glsl100/gbuffer.fs index 2945c5ddd..deb3d9ff3 100644 --- a/examples/shaders/resources/shaders/glsl100/gbuffer.fs +++ b/examples/shaders/resources/shaders/glsl100/gbuffer.fs @@ -24,13 +24,13 @@ void main() { // Store the fragment position vector in the first gbuffer texture //gPosition = fragPosition; - + // Store the per-fragment normals into the gbuffer //gNormal = normalize(fragNormal); - + // Store the diffuse per-fragment color gl_FragColor.rgb = texture2D(texture0, fragTexCoord).rgb; - + // Store specular intensity in gAlbedoSpec's alpha component gl_FragColor.a = texture2D(specularTexture, fragTexCoord).r; } diff --git a/examples/shaders/resources/shaders/glsl100/gbuffer.vs b/examples/shaders/resources/shaders/glsl100/gbuffer.vs index 2791ce5ee..0df010b8c 100644 --- a/examples/shaders/resources/shaders/glsl100/gbuffer.vs +++ b/examples/shaders/resources/shaders/glsl100/gbuffer.vs @@ -48,7 +48,7 @@ void main() { // Calculate vertex attributes for fragment shader vec4 worldPos = matModel*vec4(vertexPosition, 1.0); - fragPosition = worldPos.xyz; + fragPosition = worldPos.xyz; fragTexCoord = vertexTexCoord; fragColor = vertexColor; diff --git a/examples/shaders/resources/shaders/glsl100/hybrid_raster.fs b/examples/shaders/resources/shaders/glsl100/hybrid_raster.fs index 9658b3819..4f4f4a675 100644 --- a/examples/shaders/resources/shaders/glsl100/hybrid_raster.fs +++ b/examples/shaders/resources/shaders/glsl100/hybrid_raster.fs @@ -1,7 +1,7 @@ #version 100 #extension GL_EXT_frag_depth : enable // Extension required for writing depth - + precision mediump float; // Precision required for OpenGL ES2 (WebGL) varying vec2 fragTexCoord; diff --git a/examples/shaders/resources/shaders/glsl100/hybrid_raymarch.fs b/examples/shaders/resources/shaders/glsl100/hybrid_raymarch.fs index e3287fc04..f13902d12 100644 --- a/examples/shaders/resources/shaders/glsl100/hybrid_raymarch.fs +++ b/examples/shaders/resources/shaders/glsl100/hybrid_raymarch.fs @@ -32,12 +32,12 @@ float sdHorseshoe(in vec3 p, in vec2 c, in float r, in float le, vec2 w) { p.x = abs(p.x); float l = length(p.xy); - p.xy = mat2(-c.x, c.y, + 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)); @@ -56,9 +56,9 @@ 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.xtmax) 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; @@ -146,9 +146,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); } @@ -176,15 +176,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; @@ -194,11 +194,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); @@ -208,7 +208,7 @@ vec4 render(in vec3 ro, in vec3 rd) // lighting float occ = calcAO(pos, nor); - + vec3 lin = vec3(0.0); // sun @@ -249,7 +249,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)); @@ -289,7 +289,7 @@ void main() color = res.xyz; depth = CalcDepth(rd,res.w); } - + gl_FragColor = vec4(color , 1.0); gl_FragDepthEXT = depth; } \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/mandelbrot_set.fs b/examples/shaders/resources/shaders/glsl100/mandelbrot_set.fs index 7a89e86b0..b0125a5f6 100644 --- a/examples/shaders/resources/shaders/glsl100/mandelbrot_set.fs +++ b/examples/shaders/resources/shaders/glsl100/mandelbrot_set.fs @@ -48,7 +48,7 @@ void main() float normR = float(iter - (iter/55)*55)/55.0; float normG = float(iter - (iter/69)*69)/69.0; float normB = float(iter - (iter/40)*40)/40.0; - + gl_FragColor = vec4(sin(normR*PI), sin(normG*PI), sin(normB*PI), 1.0); return; } diff --git a/examples/shaders/resources/shaders/glsl100/palette_switch.fs b/examples/shaders/resources/shaders/glsl100/palette_switch.fs index d8d696d4f..a2dcdb912 100644 --- a/examples/shaders/resources/shaders/glsl100/palette_switch.fs +++ b/examples/shaders/resources/shaders/glsl100/palette_switch.fs @@ -21,7 +21,7 @@ void main() // Convert the (normalized) texel color RED component (GB would work, too) // to the palette index by scaling up from [0..1] to [0..255] int index = int(texelColor.r*255.0); - + ivec3 color = ivec3(0); // NOTE: On GLSL 100 we are not allowed to index a uniform array by a variable value, @@ -34,7 +34,7 @@ void main() else if (index == 5) color = palette[5]; else if (index == 6) color = palette[6]; else if (index == 7) color = palette[7]; - + //gl_FragColor = texture2D(palette, texelColor.xy); // Alternative to ivec3 // Calculate final fragment color. Note that the palette color components diff --git a/examples/shaders/resources/shaders/glsl100/pbr.fs b/examples/shaders/resources/shaders/glsl100/pbr.fs index 48688ebe9..28212bf63 100644 --- a/examples/shaders/resources/shaders/glsl100/pbr.fs +++ b/examples/shaders/resources/shaders/glsl100/pbr.fs @@ -83,11 +83,11 @@ vec3 ComputePBR() { vec3 albedo = texture2D(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 = texture2D(mraMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)); @@ -132,18 +132,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)*float(lights[i].enabled); // Angle of light has impact on result } - + vec3 ambientFinal = (ambientColor + albedo)*ambient*0.5; - + return (ambientFinal + lightAccum*ao + emissive); } @@ -153,7 +153,7 @@ void main() // HDR tonemapping color = pow(color, color + vec3(1.0)); - + // Gamma correction color = pow(color, vec3(1.0/2.2)); diff --git a/examples/shaders/resources/shaders/glsl100/shadowmap.fs b/examples/shaders/resources/shaders/glsl100/shadowmap.fs index 7a0e806a5..c65d20e44 100644 --- a/examples/shaders/resources/shaders/glsl100/shadowmap.fs +++ b/examples/shaders/resources/shaders/glsl100/shadowmap.fs @@ -60,7 +60,7 @@ void main() float bias = max(0.0008*(1.0 - dot(normal, l)), 0.00008); int shadowCounter = 0; const int numSamples = 9; - + // PCF (percentage-closer filtering) algorithm: // Instead of testing if just one point is closer to the current point, // we test the surrounding points as well @@ -74,7 +74,7 @@ void main() if (curDepth - bias > sampleDepth) shadowCounter++; } } - + finalColor = mix(finalColor, vec4(0, 0, 0, 1), float(shadowCounter)/float(numSamples)); // Add ambient lighting whether in shadow or not diff --git a/examples/shaders/resources/shaders/glsl120/ascii.fs b/examples/shaders/resources/shaders/glsl120/ascii.fs index e4e9927b9..44ff399ae 100644 --- a/examples/shaders/resources/shaders/glsl120/ascii.fs +++ b/examples/shaders/resources/shaders/glsl120/ascii.fs @@ -56,12 +56,12 @@ void main() float gray = GreyScale(cellColor); float n = 4096.0; - + // 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.0; // : if (gray > 0.3) n = 18725316.0; // v - if (gray > 0.4) n = 15255086.0; // o + if (gray > 0.4) n = 15255086.0; // o if (gray > 0.5) n = 13121101.0; // & if (gray > 0.6) n = 15252014.0; // 8 if (gray > 0.7) n = 13195790.0; // @ diff --git a/examples/shaders/resources/shaders/glsl120/deferred_shading.vs b/examples/shaders/resources/shaders/glsl120/deferred_shading.vs index daece19e5..d08e909a9 100644 --- a/examples/shaders/resources/shaders/glsl120/deferred_shading.vs +++ b/examples/shaders/resources/shaders/glsl120/deferred_shading.vs @@ -12,5 +12,5 @@ void main() fragTexCoord = vertexTexCoord; // Calculate final vertex position - gl_Position = vec4(vertexPosition, 1.0); + gl_Position = vec4(vertexPosition, 1.0); } diff --git a/examples/shaders/resources/shaders/glsl120/depth_write.fs b/examples/shaders/resources/shaders/glsl120/depth_write.fs index a2bc38516..897b5ccd0 100644 --- a/examples/shaders/resources/shaders/glsl120/depth_write.fs +++ b/examples/shaders/resources/shaders/glsl120/depth_write.fs @@ -1,6 +1,6 @@ #version 120 -#extension GL_EXT_frag_depth : enable +#extension GL_EXT_frag_depth : enable varying vec2 fragTexCoord; varying vec4 fragColor; @@ -11,7 +11,7 @@ uniform vec4 colDiffuse; void main() { vec4 texelColor = texture2D(texture0, fragTexCoord); - + gl_FragColor = texelColor*colDiffuse*fragColor; gl_FragDepthEXT = 1.0 - gl_FragCoord.z; } \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/gbuffer.fs b/examples/shaders/resources/shaders/glsl120/gbuffer.fs index a826d7916..509558e24 100644 --- a/examples/shaders/resources/shaders/glsl120/gbuffer.fs +++ b/examples/shaders/resources/shaders/glsl120/gbuffer.fs @@ -22,13 +22,13 @@ void main() { // Store the fragment position vector in the first gbuffer texture //gPosition = fragPosition; - + // Store the per-fragment normals into the gbuffer //gNormal = normalize(fragNormal); - + // Store the diffuse per-fragment color gl_FragColor.rgb = texture2D(texture0, fragTexCoord).rgb; - + // Store specular intensity in gAlbedoSpec's alpha component gl_FragColor.a = texture2D(specularTexture, fragTexCoord).r; } diff --git a/examples/shaders/resources/shaders/glsl120/gbuffer.vs b/examples/shaders/resources/shaders/glsl120/gbuffer.vs index adc1dcd1a..502dc6792 100644 --- a/examples/shaders/resources/shaders/glsl120/gbuffer.vs +++ b/examples/shaders/resources/shaders/glsl120/gbuffer.vs @@ -48,7 +48,7 @@ void main() { // Calculate vertex attributes for fragment shader vec4 worldPos = matModel*vec4(vertexPosition, 1.0); - fragPosition = worldPos.xyz; + fragPosition = worldPos.xyz; fragTexCoord = vertexTexCoord; fragColor = vertexColor; diff --git a/examples/shaders/resources/shaders/glsl120/hybrid_raster.fs b/examples/shaders/resources/shaders/glsl120/hybrid_raster.fs index e4c7e2eca..74e17eee9 100644 --- a/examples/shaders/resources/shaders/glsl120/hybrid_raster.fs +++ b/examples/shaders/resources/shaders/glsl120/hybrid_raster.fs @@ -1,6 +1,6 @@ #version 120 -#extension GL_EXT_frag_depth : enable // Extension required for writing depth +#extension GL_EXT_frag_depth : enable // Extension required for writing depth varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/hybrid_raymarch.fs b/examples/shaders/resources/shaders/glsl120/hybrid_raymarch.fs index 6090df6b1..7a097feff 100644 --- a/examples/shaders/resources/shaders/glsl120/hybrid_raymarch.fs +++ b/examples/shaders/resources/shaders/glsl120/hybrid_raymarch.fs @@ -30,12 +30,12 @@ float sdHorseshoe(in vec3 p, in vec2 c, in float r, in float le, vec2 w) { p.x = abs(p.x); float l = length(p.xy); - p.xy = mat2(-c.x, c.y, + 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,9 +54,9 @@ 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.xtmax) 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; @@ -144,9 +144,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); } @@ -174,15 +174,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; @@ -192,11 +192,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); @@ -206,7 +206,7 @@ vec4 render(in vec3 ro, in vec3 rd) // lighting float occ = calcAO(pos, nor); - + vec3 lin = vec3(0.0); // sun @@ -247,7 +247,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)); diff --git a/examples/shaders/resources/shaders/glsl120/pbr.fs b/examples/shaders/resources/shaders/glsl120/pbr.fs index 63241709b..b36b76bee 100644 --- a/examples/shaders/resources/shaders/glsl120/pbr.fs +++ b/examples/shaders/resources/shaders/glsl120/pbr.fs @@ -81,11 +81,11 @@ vec3 ComputePBR() { vec3 albedo = texture2D(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 = texture2D(mraMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)); @@ -130,18 +130,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)*float(lights[i].enabled); // Angle of light has impact on result } - + vec3 ambientFinal = (ambientColor + albedo)*ambient*0.5; - + return (ambientFinal + lightAccum*ao + emissive); } @@ -151,7 +151,7 @@ void main() // HDR tonemapping color = pow(color, color + vec3(1.0)); - + // Gamma correction color = pow(color, vec3(1.0/2.2)); diff --git a/examples/shaders/resources/shaders/glsl120/shadowmap.fs b/examples/shaders/resources/shaders/glsl120/shadowmap.fs index 354c4a2c5..a0f8e9425 100644 --- a/examples/shaders/resources/shaders/glsl120/shadowmap.fs +++ b/examples/shaders/resources/shaders/glsl120/shadowmap.fs @@ -58,7 +58,7 @@ void main() float bias = max(0.0008*(1.0 - dot(normal, l)), 0.00008); int shadowCounter = 0; const int numSamples = 9; - + // PCF (percentage-closer filtering) algorithm: // Instead of testing if just one point is closer to the current point, // we test the surrounding points as well @@ -72,7 +72,7 @@ void main() if (curDepth - bias > sampleDepth) shadowCounter++; } } - + finalColor = mix(finalColor, vec4(0, 0, 0, 1), float(shadowCounter)/float(numSamples)); // Add ambient lighting whether in shadow or not diff --git a/examples/shaders/resources/shaders/glsl330/ascii.fs b/examples/shaders/resources/shaders/glsl330/ascii.fs index 3934c5dc1..8a6cc01d9 100644 --- a/examples/shaders/resources/shaders/glsl330/ascii.fs +++ b/examples/shaders/resources/shaders/glsl330/ascii.fs @@ -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; // @ diff --git a/examples/shaders/resources/shaders/glsl330/base.fs b/examples/shaders/resources/shaders/glsl330/base.fs index e8bf9e2d2..abf5dec6b 100644 --- a/examples/shaders/resources/shaders/glsl330/base.fs +++ b/examples/shaders/resources/shaders/glsl330/base.fs @@ -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; diff --git a/examples/shaders/resources/shaders/glsl330/depth_write.fs b/examples/shaders/resources/shaders/glsl330/depth_write.fs index f0e07beec..31f716784 100644 --- a/examples/shaders/resources/shaders/glsl330/depth_write.fs +++ b/examples/shaders/resources/shaders/glsl330/depth_write.fs @@ -14,7 +14,7 @@ out vec4 finalColor; void main() { vec4 texelColor = texture(texture0, fragTexCoord); - + finalColor = texelColor*colDiffuse*fragColor; gl_FragDepth = 1.0 - finalColor.z; } diff --git a/examples/shaders/resources/shaders/glsl330/gbuffer.vs b/examples/shaders/resources/shaders/glsl330/gbuffer.vs index 5af4448e6..e39779e27 100644 --- a/examples/shaders/resources/shaders/glsl330/gbuffer.vs +++ b/examples/shaders/resources/shaders/glsl330/gbuffer.vs @@ -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))); diff --git a/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs b/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs index 0b94dbdef..a31920bbf 100644 --- a/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs +++ b/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs @@ -16,7 +16,7 @@ out vec4 finalColor; void main() { vec4 texelColor = texture(texture0, fragTexCoord); - + finalColor = texelColor*colDiffuse*fragColor; gl_FragDepth = finalColor.z; } \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/hybrid_raymarch.fs b/examples/shaders/resources/shaders/glsl330/hybrid_raymarch.fs index 073fef4f1..48fba9af8 100644 --- a/examples/shaders/resources/shaders/glsl330/hybrid_raymarch.fs +++ b/examples/shaders/resources/shaders/glsl330/hybrid_raymarch.fs @@ -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; } \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/palette_switch.fs b/examples/shaders/resources/shaders/glsl330/palette_switch.fs index 2db8880d1..9bd77e863 100644 --- a/examples/shaders/resources/shaders/glsl330/palette_switch.fs +++ b/examples/shaders/resources/shaders/glsl330/palette_switch.fs @@ -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 diff --git a/examples/shaders/resources/shaders/glsl330/pbr.fs b/examples/shaders/resources/shaders/glsl330/pbr.fs index d439841df..ceaead308 100644 --- a/examples/shaders/resources/shaders/glsl330/pbr.fs +++ b/examples/shaders/resources/shaders/glsl330/pbr.fs @@ -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)); diff --git a/examples/shaders/resources/shaders/glsl330/vertex_displacement.vs b/examples/shaders/resources/shaders/glsl330/vertex_displacement.vs index 080ad473a..b324cbd57 100644 --- a/examples/shaders/resources/shaders/glsl330/vertex_displacement.vs +++ b/examples/shaders/resources/shaders/glsl330/vertex_displacement.vs @@ -11,7 +11,7 @@ uniform mat4 mvp; uniform mat4 matModel; uniform mat4 matNormal; -uniform float time; +uniform float time; uniform sampler2D perlinNoiseMap;