🔧 Use new global methods for shader I/O

This commit is contained in:
Simon Schneegans
2022-06-10 07:20:21 +02:00
parent 25f2261ad6
commit 0bd0fb27b9
11 changed files with 43 additions and 77 deletions
+2 -6
View File
@@ -48,12 +48,8 @@ void main() {
float c = cos(angle);
coords = vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
oColor = texture2D(uTexture, coords + center);
if (oColor.a > 0) {
oColor.rgb /= oColor.a;
}
// Fade out the window texture.
vec4 oColor = getInputColor(coords + center);
oColor.a *= 1.0 - progress;
setOutputColor(oColor);
}
+3 -6
View File
@@ -25,7 +25,7 @@ const float ACTOR_SCALE = 2.0;
const float PADDING = ACTOR_SCALE / 2.0 - 0.5;
void main() {
oColor = vec4(0, 0, 0, 0);
vec4 oColor = vec4(0, 0, 0, 0);
float progress = uForOpening ? 1.0 - uProgress : uProgress;
@@ -66,12 +66,9 @@ void main() {
float shardGroup = floor(shardMap.g * SHARD_LAYERS * 0.999);
if (shardGroup == i && (shardMap.x - pow(progress + 0.1, 2)) > 0) {
oColor = texture2D(uTexture, coords);
oColor = getInputColor(coords);
}
}
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (oColor.a > 0) {
oColor.rgb /= oColor.a;
}
setOutputColor(oColor);
}
+1 -1
View File
@@ -106,7 +106,7 @@ uniform float uTime;
uniform vec2 uSize;
uniform float uPadding;
// On GNOME, we set iTexCoord and oColor to be aliases for the cogl variables.
// On GNOME, we set iTexCoord to be an alias for the cogl variables.
#define iTexCoord cogl_tex_coord_in[0]
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
+6 -9
View File
@@ -59,17 +59,12 @@ vec2 getMasks(float progress) {
void main() {
float progress = easeOutQuad(uProgress);
vec2 masks = getMasks(progress);
vec4 windowColor = texture2D(uTexture, iTexCoord.st);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (windowColor.a > 0) {
windowColor.rgb /= windowColor.a;
}
vec2 masks = getMasks(progress);
vec4 oColor = getInputColor(iTexCoord.st);
// Dissolve window to effect color / transparency.
oColor.rgb = mix(uColor, windowColor.rgb, 0.2 * masks.y + 0.8);
oColor.a = windowColor.a * masks.y;
oColor.rgb = mix(uColor, oColor.rgb, 0.2 * masks.y + 0.8);
oColor.a = oColor.a * masks.y;
vec2 scaledUV = (iTexCoord.st - 0.5) * (1.0 + 0.1 * progress);
scaledUV /= uScale;
@@ -94,4 +89,6 @@ void main() {
// oColor = vec4(vec3(masks.x), 1.0);
// oColor = vec4(vec3(masks.y), 1.0);
// oColor = vec4(vec3(particles), 1.0);
setOutputColor(oColor);
}
+6 -9
View File
@@ -76,17 +76,12 @@ vec4 getMasks(float progress) {
void main() {
float progress = easeOutQuad(uProgress);
vec4 masks = getMasks(progress);
vec4 windowColor = texture2D(uTexture, iTexCoord.st);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (windowColor.a > 0) {
windowColor.rgb /= windowColor.a;
}
vec4 masks = getMasks(progress);
vec4 oColor = getInputColor(iTexCoord.st);
// Dissolve window to effect color / transparency.
oColor.rgb = mix(uColor, windowColor.rgb, 0.5 * masks.w + 0.5);
oColor.a = windowColor.a * masks.w;
oColor.rgb = mix(uColor, oColor.rgb, 0.5 * masks.w + 0.5);
oColor.a = oColor.a * masks.w;
// Add leading shower particles.
vec2 showerUV = iTexCoord.st + vec2(0, -0.7 * progress / SHOWER_TIME);
@@ -118,4 +113,6 @@ void main() {
// oColor = vec4(vec3(shower), 1.0);
// oColor = vec4(vec3(streaks), 1.0);
// oColor = vec4(vec3(atoms), 1.0);
setOutputColor(oColor);
}
+3 -6
View File
@@ -103,12 +103,7 @@ void main() {
vec4 fire = getFireColor(noise);
// Get the window texture.
oColor = texture2D(uTexture, iTexCoord.st);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (oColor.a > 0) {
oColor.rgb /= oColor.a;
}
vec4 oColor = getInputColor(iTexCoord.st);
// Fade the window according to the effect mask.
oColor.a *= effectMask.x;
@@ -120,4 +115,6 @@ void main() {
// oColor = vec4(vec3(noise), 1);
// oColor = vec4(vec3(effectMask.x), 1);
// oColor = vec4(vec3(effectMask.y), 1);
setOutputColor(oColor);
}
+6 -11
View File
@@ -79,22 +79,15 @@ void main() {
vec2 texScale = 0.1 * uSize / uScale;
vec4 hex = getHexagons(iTexCoord.st * texScale);
if (tileProgress > hex.z) {
vec4 oColor = vec4(0.0);
// Crop outer parts of the shrinking tiles.
oColor.a = 0.0;
} else {
// Crop outer parts of the shrinking tiles.
if (tileProgress < hex.z) {
// Make the tiles shrink by offsetting the texture lookup towards the edge
// of the cell.
vec2 lookupOffset = tileProgress * hex.xy / texScale / (1.0 - tileProgress);
oColor = texture2D(uTexture, iTexCoord.st + lookupOffset);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (oColor.a > 0) {
oColor.rgb /= oColor.a;
}
oColor = getInputColor(iTexCoord.st + lookupOffset);
vec4 glow = uGlowColor;
vec4 line = uLineColor;
@@ -122,4 +115,6 @@ void main() {
oColor.rgb = mix(oColor.rgb, line.rgb, line.a);
}
}
setOutputColor(oColor);
}
+3 -6
View File
@@ -83,12 +83,7 @@ void main() {
float textMask = getText(coords);
// Get the window texture.
oColor = texture2D(uTexture, coords);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (oColor.a > 0) {
oColor.rgb /= oColor.a;
}
vec4 oColor = getInputColor(coords);
// Fade the window according to the effect mask.
oColor.a *= rainMask.y;
@@ -107,4 +102,6 @@ void main() {
// oColor = vec4(vec3(textMask), 1);
// oColor = vec4(vec3(rainMask.x), 1);
// oColor = vec4(vec3(rainMask.y), 1);
setOutputColor(oColor);
}
+7 -11
View File
@@ -34,11 +34,7 @@ void main() {
progress = progress + 0.25 - 0.5 * simplex2D((iTexCoord.st + uSeed) * 2.0);
progress = pow(max(0, progress), 2.0);
// This may help you to understand how this effect works.
// oColor = vec4(progress, 0, 0, 0);
// return;
oColor = vec4(0, 0, 0, 0);
vec4 oColor = vec4(0.0);
for (float i = 0; i < DUST_LAYERS; ++i) {
@@ -80,12 +76,7 @@ void main() {
if (dustGroup == i) {
// Get the window color.
vec4 windowColor = texture2D(uTexture, coords + 0.5);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (windowColor.a > 0) {
windowColor.rgb /= windowColor.a;
}
vec4 windowColor = getInputColor(coords + 0.5);
// Fade the window color to uDustColor.
vec3 dustColor = mix(windowColor.rgb, uDustColor.rgb, uDustColor.a);
@@ -97,4 +88,9 @@ void main() {
}
}
}
// This may help you to understand how this effect works.
// oColor = vec4(progress, 0, 0, 0);
setOutputColor(oColor);
}
+3 -6
View File
@@ -90,12 +90,7 @@ void main() {
// Get the window texture. We shift the texture lookup by the local derivative of
// the claw texture in order to mimic some folding distortion.
vec2 offset = vec2(dFdx(scratchMap), dFdy(scratchMap)) * progress * 0.5;
oColor = texture2D(uTexture, coords + offset);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (oColor.a > 0) {
oColor.rgb /= oColor.a;
}
vec4 oColor = getInputColor(coords + offset);
// Add colorful flashes.
float flashIntensity = 1.0 / FLASH_INTENSITY * (scratchMap - progress) + 1;
@@ -120,4 +115,6 @@ void main() {
// These are pretty useful for understanding how this works.
// oColor = vec4(vec3(flashIntensity), 1);
// oColor = vec4(vec3(scratchMap), 1);
setOutputColor(oColor);
}
+3 -6
View File
@@ -71,12 +71,7 @@ void main() {
vec2 coords = iTexCoord.st * (scale + 1.0) - scale * 0.5;
// Get the color of the window.
oColor = texture2D(uTexture, coords);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (oColor.a > 0) {
oColor.rgb /= oColor.a;
}
vec4 oColor = getInputColor(coords);
// Compute several layers of moving wisps.
vec2 uv = (iTexCoord.st - 0.5) / mix(1.0, 0.5, progress) + 0.5;
@@ -110,4 +105,6 @@ void main() {
// oColor = vec4(vec3(wisps), 1.0);
// oColor = vec4(vec3(noise), 1.0);
// oColor = vec4(vec3(mask*min(wispsIn, 1.0 - wispsOut)), 1.0);
setOutputColor(oColor);
}