bubblestrong.sksl 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. float smoothstep(float a, float b, float x) {
  2. float t = clamp((x - a) / (b - a), 0.0, 1.0);
  3. return t * t * (3.0 - 2.0 * t);
  4. }
  5. vec3 blendOverlay(vec3 base, vec3 blend) {
  6. return vec3(
  7. base.r < 0.5 ? (2.0 * base.r * blend.r) : (1.0 - 2.0 * (1.0 - base.r) * (1.0 - blend.r)),
  8. base.g < 0.5 ? (2.0 * base.g * blend.g) : (1.0 - 2.0 * (1.0 - base.g) * (1.0 - blend.g)),
  9. base.b < 0.5 ? (2.0 * base.b * blend.b) : (1.0 - 2.0 * (1.0 - base.b) * (1.0 - blend.b))
  10. );
  11. }
  12. vec3 blendOverlayDark(vec3 base, vec3 blend) {
  13. vec3 result;
  14. result.r = (base.r < 0.5) ? (5 * base.r * blend.r) : (4 - 2.0 * (3 - base.r) * (4 - blend.r));
  15. result.g = (base.g < 0.5) ? (5 * base.g * blend.g) : (4 - 2.0 * (3 - base.g) * (4 - blend.g));
  16. result.b = (base.b < 0.5) ? (5 * base.b * blend.b) : (4 - 2.0 * (3 - base.b) * (4 - blend.b));
  17. return mix(base, clamp(result, 0.0, 1.0), 0.5); // Mélange avec la couleur de base pour réduire l'assombrissement
  18. }
  19. mat2 Rot(float a) {
  20. float s = sin(a);
  21. float c = cos(a);
  22. return mat2(c, -s, s, c);
  23. }
  24. vec2 hash(vec2 p) {
  25. p = vec2(dot(p, vec2(2127.1, 81.17)), dot(p, vec2(1269.5, 283.37)));
  26. return fract(sin(p) * 43758.5453);
  27. }
  28. float noise(in vec2 p) {
  29. vec2 i = floor(p);
  30. vec2 f = fract(p);
  31. vec2 u = f * f * (3.0 - 2.0 * f);
  32. float n = mix(mix(dot(-1.0 + 2.0 * hash(i + vec2(0.0, 0.0)), f - vec2(0.0, 0.0)),
  33. dot(-1.0 + 2.0 * hash(i + vec2(1.0, 0.0)), f - vec2(1.0, 0.0)), u.x),
  34. mix(dot(-1.0 + 2.0 * hash(i + vec2(0.0, 1.0)), f - vec2(0.0, 1.0)),
  35. dot(-1.0 + 2.0 * hash(i + vec2(1.0, 1.0)), f - vec2(1.0, 1.0)), u.x), u.y);
  36. return 0.42 + 0.42 * n;
  37. }
  38. vec4 main(vec2 fragCoord) {
  39. vec2 uv = fragCoord / iResolution.xy;
  40. float ratio = iResolution.x / iResolution.y;
  41. vec2 tuv = uv;
  42. tuv -= .5;
  43. float degree = noise(vec2(iTime * .15, tuv.x * tuv.y));
  44. tuv.y *= 0.7 / ratio;
  45. tuv *= Rot(radians((degree - .5) * 720. + 180.));
  46. tuv.y *= ratio;
  47. float frequency = 1.;
  48. float amplitude = 155.;
  49. float speed = iTime * 0.1;
  50. tuv.x += sin(tuv.y * frequency + speed) / amplitude;
  51. tuv.y += sin(tuv.x * frequency * 1.5 + speed) / (amplitude * .5);
  52. float opacityLayer1 = 0.95;
  53. float opacityLayer2 = 0.85 - (iDark / 2);
  54. float iPrimaryOpacity = 1.1; // Exemple de nouvelle opacité pour iPrimary
  55. if (iDark == 1) {
  56. iPrimaryOpacity = 0.52;
  57. }
  58. vec3 iPrimaryWithOpacity = iPrimary * iPrimaryOpacity;
  59. float iAccentOpacity = 1;
  60. if (iDark == 1) {
  61. iAccentOpacity = 0.9;
  62. }
  63. vec3 iAccentWithOpacity = iAccent * iAccentOpacity;
  64. vec3 layer1Color = mix(vec3(0.0), iPrimaryWithOpacity, opacityLayer1);
  65. vec3 layer1 = mix(layer1Color, iAccentWithOpacity * 0.85, smoothstep(-.3, .4, (tuv * Rot(radians(-5.))).x));
  66. vec3 layer2Color = mix(vec3(0.0), iAccentWithOpacity, opacityLayer2);
  67. vec3 layer2 = mix(layer2Color, iPrimaryWithOpacity * 0.65, smoothstep(-.2, .3, (tuv * Rot(radians(-5.))).x));
  68. vec3 finalComp = mix(layer1, layer2, smoothstep(.8, -.5, tuv.y));
  69. vec3 col;
  70. if (iDark == 0) {
  71. col = blendOverlay(iBase, finalComp);
  72. } else {
  73. col = blendOverlayDark(iBase, finalComp);
  74. }
  75. return vec4(col, iAlpha);
  76. }