Remove trailing spaces on shaders
This commit is contained in:
parent
29ded51ea4
commit
fb0f83bc91
37 changed files with 137 additions and 137 deletions
|
|
@ -23,15 +23,15 @@ void main()
|
||||||
float localX = mod(fragCoord.x, cellWidth);
|
float localX = mod(fragCoord.x, cellWidth);
|
||||||
float barWidth = cellWidth - 1.0;
|
float barWidth = cellWidth - 1.0;
|
||||||
vec4 color = WHITE;
|
vec4 color = WHITE;
|
||||||
|
|
||||||
if (localX <= barWidth)
|
if (localX <= barWidth)
|
||||||
{
|
{
|
||||||
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
|
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
|
||||||
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
|
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
|
||||||
float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
|
float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
|
||||||
|
|
||||||
if (fragTexCoord.y < amplitude) color = BLACK;
|
if (fragTexCoord.y < amplitude) color = BLACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,15 +21,15 @@ void main()
|
||||||
float localX = mod(fragCoord.x, cellWidth);
|
float localX = mod(fragCoord.x, cellWidth);
|
||||||
float barWidth = cellWidth - 1.0;
|
float barWidth = cellWidth - 1.0;
|
||||||
vec4 color = WHITE;
|
vec4 color = WHITE;
|
||||||
|
|
||||||
if (localX <= barWidth)
|
if (localX <= barWidth)
|
||||||
{
|
{
|
||||||
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
|
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
|
||||||
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
|
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
|
||||||
float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
|
float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
|
||||||
|
|
||||||
if (fragTexCoord.y < amplitude) color = BLACK;
|
if (fragTexCoord.y < amplitude) color = BLACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,15 +21,15 @@ void main()
|
||||||
float localX = mod(fragCoord.x, cellWidth);
|
float localX = mod(fragCoord.x, cellWidth);
|
||||||
float barWidth = cellWidth - 1.0;
|
float barWidth = cellWidth - 1.0;
|
||||||
vec4 color = WHITE;
|
vec4 color = WHITE;
|
||||||
|
|
||||||
if (localX <= barWidth)
|
if (localX <= barWidth)
|
||||||
{
|
{
|
||||||
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
|
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
|
||||||
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
|
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
|
||||||
float amplitude = texture(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
|
float amplitude = texture(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
|
||||||
|
|
||||||
if (fragTexCoord.y < amplitude) color = BLACK;
|
if (fragTexCoord.y < amplitude) color = BLACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
finalColor = color;
|
finalColor = color;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ void main()
|
||||||
{
|
{
|
||||||
// Fetch color from texture sampler
|
// Fetch color from texture sampler
|
||||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||||
|
|
||||||
// Calculate final fragment color
|
// Calculate final fragment color
|
||||||
gl_FragColor = texelColor*colDiffuse*fragColor;
|
gl_FragColor = texelColor*colDiffuse*fragColor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ void main()
|
||||||
int boneIndex1 = int(vertexBoneIndices.y);
|
int boneIndex1 = int(vertexBoneIndices.y);
|
||||||
int boneIndex2 = int(vertexBoneIndices.z);
|
int boneIndex2 = int(vertexBoneIndices.z);
|
||||||
int boneIndex3 = int(vertexBoneIndices.w);
|
int boneIndex3 = int(vertexBoneIndices.w);
|
||||||
|
|
||||||
// WARNING: OpenGL ES 2.0 does not support automatic matrix transposing, neither transpose() function
|
// WARNING: OpenGL ES 2.0 does not support automatic matrix transposing, neither transpose() function
|
||||||
mat4 boneMatrixTransposed0 = mat4(
|
mat4 boneMatrixTransposed0 = mat4(
|
||||||
vec4(boneMatrices[boneIndex0][0].x, boneMatrices[boneIndex0][1].x, boneMatrices[boneIndex0][2].x, boneMatrices[boneIndex0][3].x),
|
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].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].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(boneMatrices[boneIndex3][0].w, boneMatrices[boneIndex3][1].w, boneMatrices[boneIndex3][2].w, boneMatrices[boneIndex3][3].w));
|
||||||
|
|
||||||
vec4 skinnedPosition =
|
vec4 skinnedPosition =
|
||||||
vertexBoneWeights.x*(boneMatrixTransposed0*vec4(vertexPosition, 1.0)) +
|
vertexBoneWeights.x*(boneMatrixTransposed0*vec4(vertexPosition, 1.0)) +
|
||||||
vertexBoneWeights.y*(boneMatrixTransposed1*vec4(vertexPosition, 1.0)) +
|
vertexBoneWeights.y*(boneMatrixTransposed1*vec4(vertexPosition, 1.0)) +
|
||||||
vertexBoneWeights.z*(boneMatrixTransposed2*vec4(vertexPosition, 1.0)) +
|
vertexBoneWeights.z*(boneMatrixTransposed2*vec4(vertexPosition, 1.0)) +
|
||||||
vertexBoneWeights.w*(boneMatrixTransposed3*vec4(vertexPosition, 1.0));
|
vertexBoneWeights.w*(boneMatrixTransposed3*vec4(vertexPosition, 1.0));
|
||||||
|
|
||||||
fragTexCoord = vertexTexCoord;
|
fragTexCoord = vertexTexCoord;
|
||||||
fragColor = vertexColor;
|
fragColor = vertexColor;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ void main()
|
||||||
{
|
{
|
||||||
// Fetch color from texture sampler
|
// Fetch color from texture sampler
|
||||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||||
|
|
||||||
// Calculate final fragment color
|
// Calculate final fragment color
|
||||||
gl_FragColor = texelColor*colDiffuse*fragColor;
|
gl_FragColor = texelColor*colDiffuse*fragColor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ void main()
|
||||||
int boneIndex1 = int(vertexBoneIndices.y);
|
int boneIndex1 = int(vertexBoneIndices.y);
|
||||||
int boneIndex2 = int(vertexBoneIndices.z);
|
int boneIndex2 = int(vertexBoneIndices.z);
|
||||||
int boneIndex3 = int(vertexBoneIndices.w);
|
int boneIndex3 = int(vertexBoneIndices.w);
|
||||||
|
|
||||||
// WARNING: OpenGL ES 2.0 does not support automatic matrix transposing, neither transpose() function
|
// WARNING: OpenGL ES 2.0 does not support automatic matrix transposing, neither transpose() function
|
||||||
mat4 boneMatrixTransposed0 = mat4(
|
mat4 boneMatrixTransposed0 = mat4(
|
||||||
vec4(boneMatrices[boneIndex0][0].x, boneMatrices[boneIndex0][1].x, boneMatrices[boneIndex0][2].x, boneMatrices[boneIndex0][3].x),
|
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].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].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(boneMatrices[boneIndex3][0].w, boneMatrices[boneIndex3][1].w, boneMatrices[boneIndex3][2].w, boneMatrices[boneIndex3][3].w));
|
||||||
|
|
||||||
vec4 skinnedPosition =
|
vec4 skinnedPosition =
|
||||||
vertexBoneWeights.x*(boneMatrixTransposed0*vec4(vertexPosition, 1.0)) +
|
vertexBoneWeights.x*(boneMatrixTransposed0*vec4(vertexPosition, 1.0)) +
|
||||||
vertexBoneWeights.y*(boneMatrixTransposed1*vec4(vertexPosition, 1.0)) +
|
vertexBoneWeights.y*(boneMatrixTransposed1*vec4(vertexPosition, 1.0)) +
|
||||||
vertexBoneWeights.z*(boneMatrixTransposed2*vec4(vertexPosition, 1.0)) +
|
vertexBoneWeights.z*(boneMatrixTransposed2*vec4(vertexPosition, 1.0)) +
|
||||||
vertexBoneWeights.w*(boneMatrixTransposed3*vec4(vertexPosition, 1.0));
|
vertexBoneWeights.w*(boneMatrixTransposed3*vec4(vertexPosition, 1.0));
|
||||||
|
|
||||||
fragTexCoord = vertexTexCoord;
|
fragTexCoord = vertexTexCoord;
|
||||||
fragColor = vertexColor;
|
fragColor = vertexColor;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,17 +26,17 @@ void main()
|
||||||
int boneIndex1 = int(vertexBoneIndices.y);
|
int boneIndex1 = int(vertexBoneIndices.y);
|
||||||
int boneIndex2 = int(vertexBoneIndices.z);
|
int boneIndex2 = int(vertexBoneIndices.z);
|
||||||
int boneIndex3 = int(vertexBoneIndices.w);
|
int boneIndex3 = int(vertexBoneIndices.w);
|
||||||
|
|
||||||
vec4 skinnedPosition =
|
vec4 skinnedPosition =
|
||||||
vertexBoneWeights.x*(boneMatrices[boneIndex0]*vec4(vertexPosition, 1.0)) +
|
vertexBoneWeights.x*(boneMatrices[boneIndex0]*vec4(vertexPosition, 1.0)) +
|
||||||
vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexPosition, 1.0)) +
|
vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexPosition, 1.0)) +
|
||||||
vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexPosition, 1.0)) +
|
vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexPosition, 1.0)) +
|
||||||
vertexBoneWeights.w*(boneMatrices[boneIndex3]*vec4(vertexPosition, 1.0));
|
vertexBoneWeights.w*(boneMatrices[boneIndex3]*vec4(vertexPosition, 1.0));
|
||||||
|
|
||||||
vec4 skinnedNormal =
|
vec4 skinnedNormal =
|
||||||
vertexBoneWeights.x*(boneMatrices[boneIndex0]*vec4(vertexNormal, 0.0)) +
|
vertexBoneWeights.x*(boneMatrices[boneIndex0]*vec4(vertexNormal, 0.0)) +
|
||||||
vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexNormal, 0.0)) +
|
vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexNormal, 0.0)) +
|
||||||
vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexNormal, 0.0)) +
|
vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexNormal, 0.0)) +
|
||||||
vertexBoneWeights.w*(boneMatrices[boneIndex3]*vec4(vertexNormal, 0.0));
|
vertexBoneWeights.w*(boneMatrices[boneIndex3]*vec4(vertexNormal, 0.0));
|
||||||
skinnedNormal.w = 0.0;
|
skinnedNormal.w = 0.0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,12 +58,12 @@ void main()
|
||||||
float gray = GreyScale(cellColor);
|
float gray = GreyScale(cellColor);
|
||||||
|
|
||||||
float n = 4096.0;
|
float n = 4096.0;
|
||||||
|
|
||||||
// Character set from https://www.shadertoy.com/view/lssGDj
|
// Character set from https://www.shadertoy.com/view/lssGDj
|
||||||
// Create new bitmaps https://thrill-project.com/archiv/coding/bitmap/
|
// Create new bitmaps https://thrill-project.com/archiv/coding/bitmap/
|
||||||
if (gray > 0.2) n = 65600.0; // :
|
if (gray > 0.2) n = 65600.0; // :
|
||||||
if (gray > 0.3) n = 18725316.0; // v
|
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.5) n = 13121101.0; // &
|
||||||
if (gray > 0.6) n = 15252014.0; // 8
|
if (gray > 0.6) n = 15252014.0; // 8
|
||||||
if (gray > 0.7) n = 13195790.0; // @
|
if (gray > 0.7) n = 13195790.0; // @
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,5 @@ void main()
|
||||||
fragTexCoord = vertexTexCoord;
|
fragTexCoord = vertexTexCoord;
|
||||||
|
|
||||||
// Calculate final vertex position
|
// Calculate final vertex position
|
||||||
gl_Position = vec4(vertexPosition, 1.0);
|
gl_Position = vec4(vertexPosition, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#version 100
|
#version 100
|
||||||
#extension GL_EXT_frag_depth : enable
|
#extension GL_EXT_frag_depth : enable
|
||||||
|
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ uniform vec4 colDiffuse;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||||
|
|
||||||
gl_FragColor = texelColor*colDiffuse*fragColor;
|
gl_FragColor = texelColor*colDiffuse*fragColor;
|
||||||
gl_FragDepthEXT = 1.0 - gl_FragCoord.z;
|
gl_FragDepthEXT = 1.0 - gl_FragCoord.z;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@ void main()
|
||||||
{
|
{
|
||||||
// Store the fragment position vector in the first gbuffer texture
|
// Store the fragment position vector in the first gbuffer texture
|
||||||
//gPosition = fragPosition;
|
//gPosition = fragPosition;
|
||||||
|
|
||||||
// Store the per-fragment normals into the gbuffer
|
// Store the per-fragment normals into the gbuffer
|
||||||
//gNormal = normalize(fragNormal);
|
//gNormal = normalize(fragNormal);
|
||||||
|
|
||||||
// Store the diffuse per-fragment color
|
// Store the diffuse per-fragment color
|
||||||
gl_FragColor.rgb = texture2D(texture0, fragTexCoord).rgb;
|
gl_FragColor.rgb = texture2D(texture0, fragTexCoord).rgb;
|
||||||
|
|
||||||
// Store specular intensity in gAlbedoSpec's alpha component
|
// Store specular intensity in gAlbedoSpec's alpha component
|
||||||
gl_FragColor.a = texture2D(specularTexture, fragTexCoord).r;
|
gl_FragColor.a = texture2D(specularTexture, fragTexCoord).r;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ void main()
|
||||||
{
|
{
|
||||||
// Calculate vertex attributes for fragment shader
|
// Calculate vertex attributes for fragment shader
|
||||||
vec4 worldPos = matModel*vec4(vertexPosition, 1.0);
|
vec4 worldPos = matModel*vec4(vertexPosition, 1.0);
|
||||||
fragPosition = worldPos.xyz;
|
fragPosition = worldPos.xyz;
|
||||||
fragTexCoord = vertexTexCoord;
|
fragTexCoord = vertexTexCoord;
|
||||||
fragColor = vertexColor;
|
fragColor = vertexColor;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#version 100
|
#version 100
|
||||||
|
|
||||||
#extension GL_EXT_frag_depth : enable // Extension required for writing depth
|
#extension GL_EXT_frag_depth : enable // Extension required for writing depth
|
||||||
|
|
||||||
precision mediump float; // Precision required for OpenGL ES2 (WebGL)
|
precision mediump float; // Precision required for OpenGL ES2 (WebGL)
|
||||||
|
|
||||||
varying vec2 fragTexCoord;
|
varying vec2 fragTexCoord;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
p.x = abs(p.x);
|
||||||
float l = length(p.xy);
|
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;
|
c.y, c.x)*p.xy;
|
||||||
p.xy = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x),
|
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.x>0.0)?p.y:l);
|
||||||
p.xy = vec2(p.x,abs(p.y-r))-vec2(le,0.0);
|
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 q = vec2(length(max(p.xy,0.0)) + min(0.0,max(p.x,p.y)),p.z);
|
||||||
vec2 d = abs(q) - w;
|
vec2 d = abs(q) - w;
|
||||||
return min(max(d.x,d.y),0.0) + length(max(d,0.0));
|
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);
|
vec2 q = vec2(length(ap.yz), ap.x);
|
||||||
|
|
||||||
float w = sqrt(r*r-h*h);
|
float w = sqrt(r*r-h*h);
|
||||||
|
|
||||||
return ((h*q.x<w*q.y) ? length(q-vec2(w,h)) : abs(length(q)-r)) - t;
|
return ((h*q.x<w*q.y) ? length(q-vec2(w,h)) : abs(length(q)-r)) - t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,8 +110,8 @@ vec2 raycast(in vec3 ro, in vec3 rd)
|
||||||
if (t>tmax) break;
|
if (t>tmax) break;
|
||||||
vec2 h = map(ro+rd*t);
|
vec2 h = map(ro+rd*t);
|
||||||
if (abs(h.x) < (0.0001*t))
|
if (abs(h.x) < (0.0001*t))
|
||||||
{
|
{
|
||||||
res = vec2(t,h.y);
|
res = vec2(t,h.y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
t += h.x;
|
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)
|
vec3 calcNormal(in vec3 pos)
|
||||||
{
|
{
|
||||||
vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
|
vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
|
||||||
return normalize(e.xyy*map(pos + e.xyy).x +
|
return normalize(e.xyy*map(pos + e.xyy).x +
|
||||||
e.yyx*map(pos + e.yyx).x +
|
e.yyx*map(pos + e.yyx).x +
|
||||||
e.yxy*map(pos + e.yxy).x +
|
e.yxy*map(pos + e.yxy).x +
|
||||||
e.xxx*map(pos + e.xxx).x);
|
e.xxx*map(pos + e.xxx).x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,15 +176,15 @@ float checkersGradBox(in vec2 p)
|
||||||
// analytical integral (box filter)
|
// 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;
|
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
|
// 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
|
// https://www.shadertoy.com/view/tdS3DG
|
||||||
vec4 render(in vec3 ro, in vec3 rd)
|
vec4 render(in vec3 ro, in vec3 rd)
|
||||||
{
|
{
|
||||||
// background
|
// background
|
||||||
vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
|
vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
|
||||||
|
|
||||||
// raycast scene
|
// raycast scene
|
||||||
vec2 res = raycast(ro,rd);
|
vec2 res = raycast(ro,rd);
|
||||||
float t = res.x;
|
float t = res.x;
|
||||||
|
|
@ -194,11 +194,11 @@ vec4 render(in vec3 ro, in vec3 rd)
|
||||||
vec3 pos = ro + t*rd;
|
vec3 pos = ro + t*rd;
|
||||||
vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal(pos);
|
vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal(pos);
|
||||||
vec3 ref = reflect(rd, nor);
|
vec3 ref = reflect(rd, nor);
|
||||||
|
|
||||||
// material
|
// material
|
||||||
col = 0.2 + 0.2*sin(m*2.0 + vec3(0.0,1.0,2.0));
|
col = 0.2 + 0.2*sin(m*2.0 + vec3(0.0,1.0,2.0));
|
||||||
float ks = 1.0;
|
float ks = 1.0;
|
||||||
|
|
||||||
if (m<1.5)
|
if (m<1.5)
|
||||||
{
|
{
|
||||||
float f = checkersGradBox(3.0*pos.xz);
|
float f = checkersGradBox(3.0*pos.xz);
|
||||||
|
|
@ -208,7 +208,7 @@ vec4 render(in vec3 ro, in vec3 rd)
|
||||||
|
|
||||||
// lighting
|
// lighting
|
||||||
float occ = calcAO(pos, nor);
|
float occ = calcAO(pos, nor);
|
||||||
|
|
||||||
vec3 lin = vec3(0.0);
|
vec3 lin = vec3(0.0);
|
||||||
|
|
||||||
// sun
|
// sun
|
||||||
|
|
@ -249,7 +249,7 @@ vec4 render(in vec3 ro, in vec3 rd)
|
||||||
dif *= occ;
|
dif *= occ;
|
||||||
lin += col*0.25*dif*vec3(1.00,1.00,1.00);
|
lin += col*0.25*dif*vec3(1.00,1.00,1.00);
|
||||||
}
|
}
|
||||||
|
|
||||||
col = lin;
|
col = lin;
|
||||||
|
|
||||||
col = mix(col, vec3(0.7,0.7,0.9), 1.0-exp(-0.0001*t*t*t));
|
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;
|
color = res.xyz;
|
||||||
depth = CalcDepth(rd,res.w);
|
depth = CalcDepth(rd,res.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragColor = vec4(color , 1.0);
|
gl_FragColor = vec4(color , 1.0);
|
||||||
gl_FragDepthEXT = depth;
|
gl_FragDepthEXT = depth;
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ void main()
|
||||||
float normR = float(iter - (iter/55)*55)/55.0;
|
float normR = float(iter - (iter/55)*55)/55.0;
|
||||||
float normG = float(iter - (iter/69)*69)/69.0;
|
float normG = float(iter - (iter/69)*69)/69.0;
|
||||||
float normB = float(iter - (iter/40)*40)/40.0;
|
float normB = float(iter - (iter/40)*40)/40.0;
|
||||||
|
|
||||||
gl_FragColor = vec4(sin(normR*PI), sin(normG*PI), sin(normB*PI), 1.0);
|
gl_FragColor = vec4(sin(normR*PI), sin(normG*PI), sin(normB*PI), 1.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ void main()
|
||||||
// Convert the (normalized) texel color RED component (GB would work, too)
|
// Convert the (normalized) texel color RED component (GB would work, too)
|
||||||
// to the palette index by scaling up from [0..1] to [0..255]
|
// to the palette index by scaling up from [0..1] to [0..255]
|
||||||
int index = int(texelColor.r*255.0);
|
int index = int(texelColor.r*255.0);
|
||||||
|
|
||||||
ivec3 color = ivec3(0);
|
ivec3 color = ivec3(0);
|
||||||
|
|
||||||
// NOTE: On GLSL 100 we are not allowed to index a uniform array by a variable value,
|
// 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 == 5) color = palette[5];
|
||||||
else if (index == 6) color = palette[6];
|
else if (index == 6) color = palette[6];
|
||||||
else if (index == 7) color = palette[7];
|
else if (index == 7) color = palette[7];
|
||||||
|
|
||||||
//gl_FragColor = texture2D(palette, texelColor.xy); // Alternative to ivec3
|
//gl_FragColor = texture2D(palette, texelColor.xy); // Alternative to ivec3
|
||||||
|
|
||||||
// Calculate final fragment color. Note that the palette color components
|
// Calculate final fragment color. Note that the palette color components
|
||||||
|
|
|
||||||
|
|
@ -83,11 +83,11 @@ vec3 ComputePBR()
|
||||||
{
|
{
|
||||||
vec3 albedo = texture2D(albedoMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb;
|
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);
|
albedo = vec3(albedoColor.x*albedo.x, albedoColor.y*albedo.y, albedoColor.z*albedo.z);
|
||||||
|
|
||||||
float metallic = clamp(metallicValue, 0.0, 1.0);
|
float metallic = clamp(metallicValue, 0.0, 1.0);
|
||||||
float roughness = clamp(roughnessValue, 0.0, 1.0);
|
float roughness = clamp(roughnessValue, 0.0, 1.0);
|
||||||
float ao = clamp(aoValue, 0.0, 1.0);
|
float ao = clamp(aoValue, 0.0, 1.0);
|
||||||
|
|
||||||
if (useTexMRA == 1)
|
if (useTexMRA == 1)
|
||||||
{
|
{
|
||||||
vec4 mra = texture2D(mraMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y));
|
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 F = SchlickFresnel(hDotV, baseRefl); // Fresnel proportion of specular reflectance
|
||||||
|
|
||||||
vec3 spec = (D*G*F)/(4.0*nDotV*nDotL);
|
vec3 spec = (D*G*F)/(4.0*nDotV*nDotL);
|
||||||
|
|
||||||
// Difuse and spec light can't be above 1.0
|
// Difuse and spec light can't be above 1.0
|
||||||
// kD = 1.0 - kS diffuse component is equal 1.0 - spec comonent
|
// kD = 1.0 - kS diffuse component is equal 1.0 - spec comonent
|
||||||
vec3 kD = vec3(1.0) - F;
|
vec3 kD = vec3(1.0) - F;
|
||||||
|
|
||||||
// Mult kD by the inverse of metallnes, only non-metals should have diffuse light
|
// Mult kD by the inverse of metallnes, only non-metals should have diffuse light
|
||||||
kD *= 1.0 - metallic;
|
kD *= 1.0 - metallic;
|
||||||
lightAccum += ((kD*albedo.rgb/PI + spec)*radiance*nDotL)*float(lights[i].enabled); // Angle of light has impact on result
|
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;
|
vec3 ambientFinal = (ambientColor + albedo)*ambient*0.5;
|
||||||
|
|
||||||
return (ambientFinal + lightAccum*ao + emissive);
|
return (ambientFinal + lightAccum*ao + emissive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ void main()
|
||||||
|
|
||||||
// HDR tonemapping
|
// HDR tonemapping
|
||||||
color = pow(color, color + vec3(1.0));
|
color = pow(color, color + vec3(1.0));
|
||||||
|
|
||||||
// Gamma correction
|
// Gamma correction
|
||||||
color = pow(color, vec3(1.0/2.2));
|
color = pow(color, vec3(1.0/2.2));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ void main()
|
||||||
float bias = max(0.0008*(1.0 - dot(normal, l)), 0.00008);
|
float bias = max(0.0008*(1.0 - dot(normal, l)), 0.00008);
|
||||||
int shadowCounter = 0;
|
int shadowCounter = 0;
|
||||||
const int numSamples = 9;
|
const int numSamples = 9;
|
||||||
|
|
||||||
// PCF (percentage-closer filtering) algorithm:
|
// PCF (percentage-closer filtering) algorithm:
|
||||||
// Instead of testing if just one point is closer to the current point,
|
// Instead of testing if just one point is closer to the current point,
|
||||||
// we test the surrounding points as well
|
// we test the surrounding points as well
|
||||||
|
|
@ -74,7 +74,7 @@ void main()
|
||||||
if (curDepth - bias > sampleDepth) shadowCounter++;
|
if (curDepth - bias > sampleDepth) shadowCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finalColor = mix(finalColor, vec4(0, 0, 0, 1), float(shadowCounter)/float(numSamples));
|
finalColor = mix(finalColor, vec4(0, 0, 0, 1), float(shadowCounter)/float(numSamples));
|
||||||
|
|
||||||
// Add ambient lighting whether in shadow or not
|
// Add ambient lighting whether in shadow or not
|
||||||
|
|
|
||||||
|
|
@ -56,12 +56,12 @@ void main()
|
||||||
float gray = GreyScale(cellColor);
|
float gray = GreyScale(cellColor);
|
||||||
|
|
||||||
float n = 4096.0;
|
float n = 4096.0;
|
||||||
|
|
||||||
// Character set from https://www.shadertoy.com/view/lssGDj
|
// Character set from https://www.shadertoy.com/view/lssGDj
|
||||||
// Create new bitmaps https://thrill-project.com/archiv/coding/bitmap/
|
// Create new bitmaps https://thrill-project.com/archiv/coding/bitmap/
|
||||||
if (gray > 0.2) n = 65600.0; // :
|
if (gray > 0.2) n = 65600.0; // :
|
||||||
if (gray > 0.3) n = 18725316.0; // v
|
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.5) n = 13121101.0; // &
|
||||||
if (gray > 0.6) n = 15252014.0; // 8
|
if (gray > 0.6) n = 15252014.0; // 8
|
||||||
if (gray > 0.7) n = 13195790.0; // @
|
if (gray > 0.7) n = 13195790.0; // @
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue