add LICENSE, shaders, Cargo.lock, and AUR package

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 21:00:34 +02:00
parent a35a741b07
commit 1f9f01a238
39 changed files with 6078 additions and 2 deletions
-2
View File
@@ -1,3 +1 @@
target
Cargo.lock
shaders
Generated
+1788
View File
File diff suppressed because it is too large Load Diff
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Bendik Aagaard Lynghaug
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+21
View File
@@ -0,0 +1,21 @@
pkgbase = gpupaper-git
pkgdesc = Wayland layer-surface wallpaper runner powered by GLSL/WGSL fragment shaders (wgpu)
pkgver = r1.f53340a
pkgrel = 1
url = https://prosjekt.klingenbergbygg.no/bl/gpupaper
arch = x86_64
arch = aarch64
license = MIT
makedepends = rust
makedepends = cargo
depends = wayland
depends = libglvnd
optdepends = vulkan-icd-loader: Vulkan backend (generic loader)
optdepends = mesa: open-source Vulkan/OpenGL for AMD, Intel, and Raspberry Pi
optdepends = nvidia-utils: NVIDIA Vulkan/OpenGL support
provides = gpupaper
conflicts = gpupaper
source = gpupaper::git+https://prosjekt.klingenbergbygg.no/bl/gpupaper.git
sha256sums = SKIP
pkgname = gpupaper-git
+55
View File
@@ -0,0 +1,55 @@
# Maintainer: Bendik Aagaard Lynghaug <bendik.lynghaug@gmail.com>
pkgname=gpupaper-git
pkgver=r1.f53340a
pkgrel=1
pkgdesc="Wayland layer-surface wallpaper runner powered by GLSL/WGSL fragment shaders (wgpu)"
arch=('x86_64' 'aarch64')
url="https://prosjekt.klingenbergbygg.no/bl/gpupaper"
license=('MIT')
depends=('wayland' 'libglvnd')
makedepends=('rust' 'cargo')
optdepends=(
'vulkan-icd-loader: Vulkan backend (generic loader)'
'mesa: open-source Vulkan/OpenGL for AMD, Intel, and Raspberry Pi'
'nvidia-utils: NVIDIA Vulkan/OpenGL support'
)
provides=('gpupaper')
conflicts=('gpupaper')
source=("gpupaper::git+https://prosjekt.klingenbergbygg.no/bl/gpupaper.git")
sha256sums=('SKIP')
pkgver() {
cd "$srcdir/gpupaper"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
prepare() {
cd "$srcdir/gpupaper"
export RUSTUP_TOOLCHAIN=stable
cargo fetch --target "$(rustc -vV | sed -n 's/host: //p')"
}
build() {
cd "$srcdir/gpupaper"
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --offline --release
}
check() {
cd "$srcdir/gpupaper"
export RUSTUP_TOOLCHAIN=stable
cargo test --offline
}
package() {
cd "$srcdir/gpupaper"
install -Dm755 "target/release/gpupaper" "$pkgdir/usr/bin/gpupaper"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
# Example shaders
install -dm755 "$pkgdir/usr/share/gpupaper/shaders"
install -Dm644 shaders/*.frag "$pkgdir/usr/share/gpupaper/shaders/"
}
+47
View File
@@ -0,0 +1,47 @@
//#ifdef GL_ES -- Nice little tunnel... any idea ? -Harley
precision mediump float;
//#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float pi = 3.1415926;
vec2 Offset;
vec2 Scale=vec2(0.002,0.002);
float Saturation = 0.9; // 0 - 1;
vec3 lungth(vec2 x,vec3 c){
return vec3(length(x+c.r),length(x+c.g),length(c.b));
}
void main( void ) {
vec2 R = resolution;
vec2 position = (gl_FragCoord.xy - resolution * 0.5) / resolution.yy;
float th = atan(position.y, position.x) / (1.0 * pi);
float dd = length(position) + 0.00005;
float d = 0.5 / dd + time;
vec2 x = gl_FragCoord.xy;
vec3 c2=vec3(0,0,0);
x=R*x*Scale*R/R.x;
x*x+sin(x.yx*sqrt(vec2(7,9)))/1.;
c2=lungth(sin(x*sqrt(vec2(3,43))),vec3(5,6,7)*Saturation * d);
x+=sin(x.yx*sqrt(vec2(73,5)))/5.;
c2=2.*lungth(sin(time+x*sqrt(vec2(33.,23.))),c2/9.);
x+=sin(x.yx*sqrt(vec2(93,7)))/3.;
c2=lungth(sin(x*sqrt(vec2(3.,1.))),c2/2.0);
c2=.5+.5*sin(c2*8.);
vec3 uv = vec3(th + d, th - d, th + sin(d) * 0.45);
float a = 0.5 + cos(uv.x * pi * 2.0) * 0.5;
float b = 0.5 + cos(uv.y * pi * 2.0) * 0.5;
float c = 0.5 + cos(uv.z * pi * 6.0) * 0.5;
vec3 color = mix(vec3(0.5, 0.5, 0.5), vec3(0.1, 0.1, 0.2), pow(a, 0.2)) * 3.;
color += mix(vec3(1.0, 0.2, 1.0), vec3(0.1, 0.1, 0.2), pow(b, 0.1)) * 0.75;
color += mix(c2, vec3(0.1, 0.2, 0.2), pow(c, 0.1)) * 0.75;
gl_FragColor = vec4( (color * dd), 1.0);
}
+719
View File
@@ -0,0 +1,719 @@
/*
* Original shader from: https://www.shadertoy.com/view/ltBczc
*/
#ifdef GL_ES
precision mediump float;
#endif
// glslsandbox uniforms
uniform float time;
uniform vec2 resolution;
// shadertoy globals
float iTime = 0.0;
vec3 iResolution = vec3(0.0);
const vec4 iMouse = vec4(0.0);
// --------[ Original ShaderToy begins here ]---------- //
// "Ocean Structure" by dr2 - 2017
// License: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
#define REAL_WAVE 0 // real (=1) or fake (=0, less work) water waves
#define N_REFL 3 // number of reflections (1-4, 0 = none)
float PrBoxDf (vec3 p, vec3 b);
float PrSphDf (vec3 p, float s);
float PrSphAnDf (vec3 p, float r, float w);
float PrCylDf (vec3 p, float r, float h);
float PrTorusDf (vec3 p, float ri, float rc);
float PrCapsDf (vec3 p, float r, float h);
float PrCapsAnDf (vec3 p, float r, float w, float h);
float PrFlatCylDf (vec3 p, float rhi, float rlo, float h);
float Noisefv2 (vec2 p);
float Noisefv3 (vec3 p);
float Fbm1 (float p);
float Fbm2 (vec2 p);
float Fbm3 (vec3 p);
vec3 VaryNf (vec3 p, vec3 n, float f);
vec3 HsvToRgb (vec3 c);
vec2 Rot2D (vec2 q, float a);
vec3 qHit = vec3(0.), sunDir = vec3(0.), smkPos = vec3(0.);
float dstFar = 0., tCur = 0., smkRadEx = 0., smkRadIn = 0., smkPhs = 0., smkHt = 0., tWav = 0.;
int idObj = 0;
bool isNite = false;
const int idBase = 1, idPlat = 2, isShel = 3, idFrm = 4, idDway = 5,
idTwr = 6, idBrg = 7, idBrCab = 8, idRdw = 9;
const float pi = 3.14159;
float BridgeDf (vec3 p, float dMin)
{
float cbRad = 0.06;
vec3 q, qq;
float d, cLen, wRd;
wRd = 1.;
q = p; q.x = abs (q.x) - wRd; q.y -= -0.3;
d = PrBoxDf (q, vec3 (0.15, 5., 0.15));
q = p; q.y -= 4.85;
d = min (d, PrBoxDf (q, vec3 (wRd + 0.15, 0.15, 0.15)));
if (d < dMin) { dMin = d; qHit = q; idObj = idBrg; }
qq = p; qq.x = abs (qq.x) - wRd + 0.07; qq.z = abs (qq.z);
q = qq; q.y -= 4.92;
q.yz = Rot2D (q.yz, -0.1 * pi);
q.z -= 9.5;
d = PrCylDf (q, cbRad, 9.5);
q = qq; q.y -= 4.82;
q.yz = Rot2D (q.yz, -0.15 * pi);
q.z -= 6.4;
d = min (d, PrCylDf (q, cbRad, 6.4));
q = qq; q.y -= 4.77;
q.yz = Rot2D (q.yz, -0.26 * pi);
q.z -= 4.;
d = min (d, PrCylDf (q, cbRad, 4.));
if (d < dMin) { dMin = d; qHit = q; idObj = idBrCab; }
return dMin;
}
float CentStrucDf (vec3 p, float dMin, float ar)
{
float cRad = 6., cLen = 8., ww = 0.03, wThk = 0.05,
doorHt = 1.6, doorWd = 1.4;
vec3 q;
vec2 qo;
float d, dd;
q = p; q.y -= -1.05;
d = PrCylDf (q.xzy, 8.5, 0.15);
if (d < dMin) { dMin = d; qHit = q; idObj = idPlat; }
d = PrTorusDf (vec3 (q.xz, abs (abs (q.y - 1.1) - 0.4) - 0.2), 0.03, 8.5);
q.xz = Rot2D (q.xz, 2. * pi * (floor (16. * ar) + 0.5) / 16.);
q.xy -= vec2 (-8.5, 0.9);
d = min (d, PrCylDf (q.xzy, 0.05, 0.82));
if (d < dMin) { dMin = d; qHit = q; idObj = idBrCab; }
q = p;
qo = Rot2D (q.xz, 2. * pi * (floor (4. * ar) + 0.5) / 4.);
q.xz = qo; q.y -= cLen + 1.2 * doorHt - 9.;
dd = PrFlatCylDf (q.yzx, doorHt, doorWd, 0.);
q = p; q.y -= cLen - 9.;
d = max (max (max (PrCapsAnDf (q.xzy, cRad, wThk, cLen), - q.y), q.y - 1.635 * cLen), - dd);
if (d < dMin) { dMin = d; qHit = q; idObj = isShel; }
q.xz = Rot2D (q.xz, 2. * pi * (floor (8. * ar) + 0.5) / 8.);
d = max (max (max (PrCapsAnDf (q.xzy, cRad, 0.2, cLen),
min (abs (mod (q.y, 2.) - 1.) - 0.1,
dot (vec2 (q.x, abs (q.z)), vec2 (sin (0.04 * 2. * pi / 16.), cos (0.04 * 2. * pi / 16.))))),
- q.y), - dd);
if (d < dMin) { dMin = d; qHit = q; idObj = idFrm; }
q = p; q.xz = qo; q.xy -= vec2 (-0.98 * cRad, cLen + 1.2 * doorHt - 9.);
d = max (max (max (PrFlatCylDf (q.yzx, doorHt, doorWd, 0.1 * cRad),
- PrFlatCylDf (q.yzx, doorHt - ww, doorWd - ww, 0.)),
- (q.y + 2. * doorHt - ww - wThk)), - (q.y + 1.2 * doorHt));
if (d < dMin) { dMin = d; qHit = q; idObj = idDway; }
return dMin;
}
float CornStrucDf (vec3 p, float dMin)
{
vec3 q;
float d, a;
q = p; q.y -= -1.2;
d = PrCylDf (q.xzy, 3.2, 0.15);
if (d < dMin) { dMin = d; qHit = q; idObj = idPlat; }
q = p; q.y -= 1.;
d = max (PrCapsAnDf (q.xzy, 2.5, 0.1, 3.), -2.2 - q.y);
q = p; q.y -= 7.;
d = min (d, max (PrCapsDf (q.xzy, 0.7, 2.), -1. - q.y));
q = p;
a = (length (q.xz) > 0.) ? atan (q.z, - q.x) / (2. * pi) : 0.;
q.xz = Rot2D (q.xz, 2. * pi * (floor (4. * a + 0.5) / 4.));
d = max (d, - PrFlatCylDf (q.yzx, 1.5, 1., 0.));
q = p;
q.xz = Rot2D (q.xz, 2. * pi * (floor (16. * a) + 0.5) / 16.);
q.y -= 4.3;
d = max (d, - (length (max (abs (q.yz) - vec2 (0.6, 0.08), 0.)) - 0.2));
if (d < dMin) { dMin = d; qHit = q; idObj = idTwr; }
return dMin;
}
float ObjDf (vec3 p)
{
vec3 q;
float d, dMin, hs, wRd, ar;
dMin = dstFar;
hs = 5.;
q = p; q.xz = abs (q.xz) - 4.;
d = max (PrSphAnDf (q, 4.85, 0.15), - min (3.9 - q.y, q.y));
q.y -= 0.5;
d = max (d, 2.2 - min (length (q.yz), length (q.xy)));
if (d < dMin) { dMin = d; qHit = q; idObj = idBase; }
q = p; q.xz = abs (q.xz) - 20.;
d = max (PrSphAnDf (q, 4.85, 0.15), - min (3.9 - q.y, q.y));
q.y -= 0.5;
d = max (d, 2.2 - min (length (q.yz), length (q.xy)));
if (d < dMin) { dMin = d; qHit = q; idObj = idBase; }
wRd = 1.;
q = p; q.xz = abs (q.xz) - 20.7 + wRd;
d = max (max (length (max (q.xz - wRd, 0.)) - 0.3,
- (length (max (q.xz + wRd, 0.)) - 0.3)), abs (q.y - hs + 1.) - 0.1);
if (d < dMin) { dMin = d; qHit = q; idObj = idRdw; }
q = p;
ar = (length (p.xz) > 0.) ? atan (p.z, - p.x) / (2. * pi) : 0.;
q.y -= hs;
dMin = CentStrucDf (q, dMin, ar);
q = p; q.y -= hs; q.xz = abs (q.xz) - vec2 (20.);
dMin = CornStrucDf (q, dMin);
q = p; q.y -= hs;
q.xz = Rot2D (q.xz, 2. * pi * (floor (4. * ar + 0.5) / 4.));
q.x += 20.;
dMin = BridgeDf (q, dMin);
return dMin;
}
float ObjRay (vec3 ro, vec3 rd)
{
float dHit, d;
dHit = 0.;
for (int j = 0; j < 120; j ++) {
d = ObjDf (ro + dHit * rd);
dHit += d;
if (d < 0.001 || dHit > dstFar) break;
}
return dHit;
}
vec3 ObjNf (vec3 p)
{
vec4 v;
vec3 e = vec3 (0.001, -0.001, 0.);
v = vec4 (ObjDf (p + e.xxx), ObjDf (p + e.xyy), ObjDf (p + e.yxy), ObjDf (p + e.yyx));
return normalize (vec3 (v.x - v.y - v.z - v.w) + 2. * v.yzw);
}
float WaveHt (vec2 p)
{
mat2 qRot = mat2 (0.8, -0.6, 0.6, 0.8);
vec4 t4, v4;
vec2 t;
float wFreq, wAmp, ht;
wFreq = 1.;
wAmp = 1.;
ht = 0.;
for (int j = 0; j < 3; j ++) {
p *= qRot;
t = tWav * vec2 (1., -1.);
t4 = (p.xyxy + t.xxyy) * wFreq;
t = vec2 (Noisefv2 (t4.xy), Noisefv2 (t4.zw));
t4 += 2. * t.xxyy - 1.;
v4 = (1. - abs (sin (t4))) * (abs (sin (t4)) + abs (cos (t4)));
ht += wAmp * dot (pow (1. - sqrt (v4.xz * v4.yw), vec2 (8.)), vec2 (1.));
wFreq *= 2.;
wAmp *= 0.5;
}
return ht;
}
vec3 WaveNf (vec3 p, float d)
{
vec3 vn;
vec2 e;
e = vec2 (max (0.01, 0.005 * d * d), 0.);
p *= 0.3;
vn.xz = 0.4 * (WaveHt (p.xz) - vec2 (WaveHt (p.xz + e.xy), WaveHt (p.xz + e.yx)));
vn.y = e.x;
return normalize (vn);
}
#if REAL_WAVE
float WaveRay (vec3 ro, vec3 rd)
{
vec3 p;
float dHit, h, s, sLo, sHi, f1, f2;
dHit = dstFar;
f1 = 0.4;
f2 = 0.3;
s = max (- (ro.y - 1.2 * f1) / rd.y, 0.);
sLo = s;
for (int j = 0; j < 80; j ++) {
p = ro + s * rd;
h = p.y - f1 * WaveHt (f2 * p.xz);
if (h < 0.) break;
sLo = s;
s += max (0.3, h) + 0.005 * s;
if (s >= dstFar) break;
}
if (h < 0.) {
sHi = s;
for (int j = 0; j < 5; j ++) {
s = 0.5 * (sLo + sHi);
p = ro + s * rd;
h = step (0., p.y - f1 * WaveHt (f2 * p.xz));
sLo += h * (s - sLo);
sHi += (1. - h) * (s - sHi);
}
dHit = sHi;
}
return dHit;
}
#endif
float SmokeDens (vec3 p)
{
mat2 rMat;
vec3 q, u;
float f;
f = PrTorusDf (p.xzy, smkRadIn, smkRadEx);
if (f < 0.) {
q = p.xzy / smkRadEx;
u = normalize (vec3 (q.xy, 0.));
q -= u;
rMat = mat2 (vec2 (u.x, - u.y), u.yx);
q.xy = rMat * q.xy;
q.xz = Rot2D (q.xz, 2.5 * tCur);
q.xy = q.xy * rMat;
q += u;
q.xy = Rot2D (q.xy, 0.1 * tCur);
f = smoothstep (0., smkRadIn, - f) * Fbm3 (10. * q);
} else f = 0.;
return f;
}
vec4 SmokeCol (vec3 ro, vec3 rd, float dstObj)
{
vec4 col4;
vec3 q;
float densFac, dens, d, h, sh;
d = 0.;
for (int j = 0; j < 150; j ++) {
q = ro + d * rd;
q.xz = abs (q.xz);
q -= smkPos;
h = PrTorusDf (q.xzy, smkRadIn, smkRadEx);
d += h;
if (h < 0.001 || d > dstFar) break;
}
col4 = vec4 (0.);
if (d < min (dstObj, dstFar)) {
densFac = 1.45 * (1.08 - pow (smkPhs, 1.5));
for (int j = 0; j < 150; j ++) {
q = ro + d * rd;
q.xz = abs (q.xz);
q -= smkPos;
dens = SmokeDens (q);
sh = 0.3 + 0.7 * smoothstep (-0.3, 0.1, dens - SmokeDens (q + 0.1 * sunDir));
col4 += densFac * dens * (1. - col4.w) * vec4 (sh * vec3 (0.9) - col4.rgb, 0.3);
d += 2.2 * smkRadEx / 150.;
if (col4.w > 0.99 || d > dstFar) break;
}
}
if (isNite) col4.rgb *= vec3 (0.3, 0.4, 0.3);
return col4;
}
vec4 ObjCol (vec3 n)
{
vec4 col;
if (idObj == idBase) col = vec4 (0.3, 0.4, 0.1, 0.1);
else if (idObj == idPlat) col = vec4 (0.4, 0.4, 0.3, 0.1);
else if (idObj == isShel) col = vec4 (0.5, 0.5, 0.5, 0.3);
else if (idObj == idFrm) col = vec4 (0.8, 0.8, 0.9, 0.5);
else if (idObj == idDway) col = vec4 (0.7, 0.8, 0.7, 0.3);
else if (idObj == idTwr) col = vec4 (0.7, 0.7, 0.6, 0.3);
else if (idObj == idBrg) col = vec4 (1., 0.3, 0.3, 0.3);
else if (idObj == idBrCab) col = vec4 (0.9, 0.9, 1., 0.5);
else if (idObj == idRdw) col = vec4 (0.4, 0.3, 0.3, 0.1);
return col;
}
vec4 AurCol (vec3 ro, vec3 rd)
{
vec4 col, mCol;
vec3 p, dp;
float ar;
dp = rd / rd.y;
p = ro + (40. - ro.y) * dp;
col = vec4 (0.);
mCol = vec4 (0.);
tWav = 0.05 * tCur;
for (float ns = 0.; ns < 50.; ns ++) {
p += dp;
ar = 0.05 - clamp (0.06 * WaveHt (0.01 * p.xz), 0., 0.04);
mCol = mix (mCol, ar * vec4 (HsvToRgb (vec3 (0.34 + 0.007 * ns, 1., 1. - 0.02 * ns)), 1.), 0.5);
col += mCol;
}
return col;
}
vec3 NtSkyCol (vec3 rd)
{
vec3 rds;
rds = floor (2000. * rd);
rds = 0.00015 * rds + 0.1 * Noisefv3 (0.0005 * rds.yzx);
for (int j = 0; j < 19; j ++) rds = abs (rds) / dot (rds, rds) - 0.9;
return 0.3 * vec3 (1., 1., 0.9) * min (1., 0.5e-3 * pow (min (6., length (rds)), 5.));
}
vec3 BgCol (vec3 ro, vec3 rd)
{
vec3 col;
float f, a;
if (rd.y > 0.) {
a = atan (rd.x, - rd.z);
if (rd.y < 0.03 * Fbm1 (32. * a) + 0.005)
col = (isNite ? vec3 (0.07, 0.1, 0.07) : vec3 (0.4, 0.5, 0.7)) * (1. - 0.3 * Fbm2 (128. * vec2 (a, rd.y)));
else {
if (isNite) {
vec4 aCol = AurCol (ro, rd);
col = (1. - 0.5 * aCol.a) * NtSkyCol (rd) + 0.6 * aCol.rgb;
} else {
ro.xz += 2. * tCur;
col = vec3 (0.2, 0.3, 0.6) + 0.2 * (1. - max (rd.y, 0.)) +
0.1 * pow (max (dot (rd, sunDir), 0.), 16.);
f = Fbm2 (0.02 * (ro.xz + rd.xz * (100. - ro.y) / max (rd.y, 0.01)));
col = mix (col, vec3 (1.), 0.2 + 0.8 * f * rd.y);
}
}
} else {
col = vec3 (0.6, 0.5, 0.3);
if (- ro.y / rd.y < dstFar) {
ro += - (ro.y / rd.y) * rd;
col *= 1.1 - 0.2 * Noisefv2 (30. * ro.xz);
}
col = mix (col, 0.9 * (vec3 (0.4, 0.2, 0.1) + 0.2) + 0.1, pow (1. + rd.y, 5.));
}
return col;
}
vec4 GlowCol (vec3 ro, vec3 rd, float dstObj)
{
vec3 gloDir;
float gloDist, wGlow, s;
wGlow = 0.;
for (float j = 0.; j < 4.; j ++) {
gloDir = vec3 (20., 9.3, 20.) * (1. - 2. * vec3 (floor (j / 2.), 0., mod (j, 2.))) - ro;
gloDist = length (gloDir);
s = dot (rd, normalize (gloDir));
if (s > 0. && gloDist < dstObj) wGlow += 1. - smoothstep (1., 2., sqrt (1. - s * s) * gloDist);
}
gloDir = vec3 (0., 15.5, 0.) - ro;
gloDist = length (gloDir);
s = dot (rd, normalize (gloDir));
if (s > 0. && gloDist < dstObj) wGlow += 1. - smoothstep (2., 3., sqrt (1. - s * s) * gloDist);
return (0.6 + 0.4 * sin (0.3 * 2. * pi * tCur)) * clamp (wGlow, 0., 1.) * vec4 (1., 0.5, 0.3, 1.);
}
vec3 ShowScene (vec3 ro, vec3 rd)
{
vec4 objCol, smkCol, smkColR, smkColW, glwCol, glwColR, glwColW;
vec3 col, vn;
float dstObj, dstWat, reflCol;
bool wRefl;
col = vec3 (0.2, 0.2, 0.);
wRefl = false;
dstObj = ObjRay (ro, rd);
smkCol = SmokeCol (ro, rd, dstObj);
glwCol = GlowCol (ro, rd, dstObj);
glwColR = vec4 (0.);
glwColW = vec4 (0.);
smkColR = vec4 (0.);
smkColW = vec4 (0.);
tWav = 0.4 * tCur;
reflCol = 1.;
if (N_REFL >= 2 && dstObj < dstFar && idObj == isShel) {
if (length (qHit.xz) > 6. || qHit.y >= 8.8) {
ro += dstObj * rd;
vn = ObjNf (ro);
rd = reflect (rd, vn);
ro += 0.01 * rd;
dstObj = ObjRay (ro, rd);
smkColR = SmokeCol (ro, rd, dstObj);
glwColR = GlowCol (ro, rd, dstObj);
reflCol *= 0.9;
}
}
if (N_REFL >= 1 && rd.y < 0.) {
#if REAL_WAVE
dstWat = WaveRay (ro, rd);
#else
dstWat = - ro.y / rd.y;
#endif
if (dstWat < min (dstObj, dstFar)) {
wRefl = true;
ro += dstWat * rd;
vn = WaveNf (ro, dstWat);
rd = reflect (rd, vn);
ro += 0.01 * rd;
dstObj = ObjRay (ro, rd);
smkColW = SmokeCol (ro, rd, dstObj);
glwColW = GlowCol (ro, rd, dstObj);
if (N_REFL >= 3 && dstObj < dstFar && idObj == isShel) {
ro += dstObj * rd;
vn = ObjNf (ro);
rd = reflect (rd, vn);
if (N_REFL == 4) {
ro += 0.01 * rd;
dstObj = ObjRay (ro, rd);
} else {
dstObj = dstFar;
}
}
reflCol *= 0.7;
}
}
if (dstObj < dstFar) {
ro += dstObj * rd;
vn = ObjNf (ro);
if (idObj == idRdw) vn = VaryNf (5. * qHit, vn, 1.);
else if (idObj == idBase) vn = VaryNf (2. * floor (16. * qHit), vn, 2.);
objCol = ObjCol (vn);
if (isNite) col = objCol.rgb * vec3 (0.3, 0.35, 0.3) * (0.2 + 0.8 * max (0.,vn.y));
else col = objCol.rgb * (0.2 + 0.8 * max (0., max (dot (vn, sunDir), 0.))) +
objCol.a * pow (max (dot (normalize (sunDir - rd), vn), 0.), 64.);
} else if (rd.y > 0.) {
col = BgCol (ro, rd);
} else {
#if N_REFL == 0
dstWat = - ro.y / rd.y;
#endif
col = BgCol (ro + dstWat * rd, reflect (rd, vec3 (0., 1., 0.)));
reflCol = 0.7;
}
col = clamp (reflCol * col, 0., 1.);
col = mix (col, glwCol.rgb, glwCol.a);
col = mix (col, glwColR.rgb, glwColR.a);
col = mix (col, smkCol.rgb, smkCol.a);
col = mix (col, smkColR.rgb, smkColR.a);
if (wRefl) {
col = mix (col, reflCol * glwColW.rgb, glwColW.a);
col = mix (col, reflCol * smkColW.rgb, smkColW.a);
col = mix (mix (vec3 (0., 0.1, 0.), vec3 (0., 0.05, 0.05),
smoothstep (0.4, 0.6, Fbm2 (0.5 * ro.xz))), col, 1. - pow (abs (rd.y), 4.));
}
return clamp (col, 0., 1.);
}
void mainImage (out vec4 fragColor, in vec2 fragCoord)
{
mat3 vuMat;
vec4 mPtr;
vec3 ro, rd;
vec2 uv, ori, ca, sa;
float el, az;
uv = 2. * fragCoord.xy / iResolution.xy - 1.;
uv.x *= iResolution.x / iResolution.y;
tCur = iTime;
mPtr = iMouse;
mPtr.xy = mPtr.xy / iResolution.xy - 0.5;
smkPhs = mod (0.15 * tCur + 0.3, 1.);
smkPos = vec3 (20., 9. + 10. * smkPhs, 20.);
smkRadIn = 0.6 * (0.1 + 0.9 * smoothstep (0.01, 0.1, smkPhs));
smkRadEx = smkRadIn + 2.5;
dstFar = 140.;
isNite = true;
az = 0.33 * pi;
el = -0.016 * pi;
if (mPtr.z > 0.) {
if (mPtr.x > 0.45 && mPtr.y < -0.45) isNite = false;
else {
az += pi * mPtr.x;
el += 0.05 * pi * mPtr.y;
}
} else {
az += 0.002 * pi * tCur;
el += 0.01 * pi * sin (0.01 * pi * tCur);
}
el = clamp (el, -0.4 * pi, -0.01 * pi);
ori = vec2 (el, az);
ca = cos (ori);
sa = sin (ori);
vuMat = mat3 (ca.y, 0., - sa.y, 0., 1., 0., sa.y, 0., ca.y) *
mat3 (1., 0., 0., 0., ca.x, - sa.x, 0., sa.x, ca.x);
ro = vuMat * vec3 (0., 10., -100.);
rd = vuMat * normalize (vec3 (uv, 4.2));
sunDir = vuMat * normalize (vec3 (1., 1., -1.));
fragColor = vec4 (ShowScene (ro, rd), 1.);
}
float PrBoxDf (vec3 p, vec3 b)
{
vec3 d;
d = abs (p) - b;
return min (max (d.x, max (d.y, d.z)), 0.) + length (max (d, 0.));
}
float PrSphDf (vec3 p, float s)
{
return length (p) - s;
}
float PrSphAnDf (vec3 p, float r, float w)
{
return abs (length (p) - r) - w;
}
float PrCylDf (vec3 p, float r, float h)
{
return max (length (p.xy) - r, abs (p.z) - h);
}
float PrCapsDf (vec3 p, float r, float h)
{
return length (p - vec3 (0., 0., h * clamp (p.z / h, -1., 1.))) - r;
}
float PrCapsAnDf (vec3 p, float r, float w, float h)
{
p.z = abs (p.z);
return max (length (p - vec3 (0., 0., min (p.z, h + w))) - r,
- length (p - vec3 (0., 0., min (p.z, h - w))) + r) - w;
}
float PrFlatCylDf (vec3 p, float rhi, float rlo, float h)
{
float d;
d = length (p.xy - vec2 (rhi * clamp (p.x / rhi, -1., 1.), 0.)) - rlo;
if (h > 0.) d = max (d, abs (p.z) - h);
return d;
}
float PrTorusDf (vec3 p, float ri, float rc)
{
return length (vec2 (length (p.xy) - rc, p.z)) - ri;
}
const float cHashM = 43758.54;
vec2 Hashv2f (float p)
{
return fract (sin (p + vec2 (0., 1.)) * cHashM);
}
vec2 Hashv2v2 (vec2 p)
{
vec2 cHashVA2 = vec2 (37., 39.);
return fract (sin (vec2 (dot (p, cHashVA2), dot (p + vec2 (1., 0.), cHashVA2))) * cHashM);
}
vec4 Hashv4v3 (vec3 p)
{
vec3 cHashVA3 = vec3 (37., 39., 41.);
vec2 e = vec2 (1., 0.);
return fract (sin (vec4 (dot (p + e.yyy, cHashVA3), dot (p + e.xyy, cHashVA3),
dot (p + e.yxy, cHashVA3), dot (p + e.xxy, cHashVA3))) * cHashM);
}
float Noiseff (float p)
{
vec2 t;
float ip, fp;
ip = floor (p);
fp = fract (p);
fp = fp * fp * (3. - 2. * fp);
t = Hashv2f (ip);
return mix (t.x, t.y, fp);
}
float Noisefv2 (vec2 p)
{
vec2 t, ip, fp;
ip = floor (p);
fp = fract (p);
fp = fp * fp * (3. - 2. * fp);
t = mix (Hashv2v2 (ip), Hashv2v2 (ip + vec2 (0., 1.)), fp.y);
return mix (t.x, t.y, fp.x);
}
float Noisefv3 (vec3 p)
{
vec4 t;
vec3 ip, fp;
ip = floor (p);
fp = fract (p);
fp *= fp * (3. - 2. * fp);
t = mix (Hashv4v3 (ip), Hashv4v3 (ip + vec3 (0., 0., 1.)), fp.z);
return mix (mix (t.x, t.y, fp.x), mix (t.z, t.w, fp.x), fp.y);
}
float Fbm1 (float p)
{
float f, a;
f = 0.;
a = 1.;
for (int i = 0; i < 5; i ++) {
f += a * Noiseff (p);
a *= 0.5;
p *= 2.;
}
return f * (1. / 1.9375);
}
float Fbm2 (vec2 p)
{
float f, a;
f = 0.;
a = 1.;
for (int i = 0; i < 5; i ++) {
f += a * Noisefv2 (p);
a *= 0.5;
p *= 2.;
}
return f * (1. / 1.9375);
}
float Fbm3 (vec3 p)
{
float f, a;
f = 0.;
a = 1.;
for (int i = 0; i < 5; i ++) {
f += a * Noisefv3 (p);
a *= 0.5;
p *= 2.;
}
return f * (1. / 1.9375);
}
float Fbmn (vec3 p, vec3 n)
{
vec3 s;
float a;
s = vec3 (0.);
a = 1.;
for (int i = 0; i < 5; i ++) {
s += a * vec3 (Noisefv2 (p.yz), Noisefv2 (p.zx), Noisefv2 (p.xy));
a *= 0.5;
p *= 2.;
}
return dot (s, abs (n));
}
vec3 VaryNf (vec3 p, vec3 n, float f)
{
vec3 g;
vec2 e = vec2 (0.1, 0.);
g = vec3 (Fbmn (p + e.xyy, n), Fbmn (p + e.yxy, n), Fbmn (p + e.yyx, n)) - Fbmn (p, n);
return normalize (n + f * (g - n * dot (n, g)));
}
vec3 HsvToRgb (vec3 c)
{
vec3 p;
p = abs (fract (c.xxx + vec3 (1., 2./3., 1./3.)) * 6. - 3.);
return c.z * mix (vec3 (1.), clamp (p - 1., 0., 1.), c.y);
}
vec2 Rot2D (vec2 q, float a)
{
return q * cos (a) + q.yx * sin (a) * vec2 (-1., 1.);
}
// --------[ Original ShaderToy ends here ]---------- //
void main(void)
{
iTime = time;
iResolution = vec3(resolution, 0.0);
mainImage(gl_FragColor, gl_FragCoord.xy);
gl_FragColor.a = 1.0;
}
+213
View File
@@ -0,0 +1,213 @@
#ifdef GL_ES
precision highp float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
#define CHAR_SIZE vec2(6, 7)
#define CHAR_SPACING vec2(6, 9)
#define DOWN_SCALE 2.0
vec2 res;
vec2 start_pos = vec2(0);
vec2 print_pos = vec2(0);
vec2 print_pos_pre_move = vec2(0);
vec3 text_color = vec3(1);
/*
Top left pixel is the most significant bit.
Bottom right pixel is the least significant bit.
███ |
█ █ |
█ █ |
█ █ |
█████ |
█ █ |
█ █ |
000000
100010
100010
100010
111110
100010
100010
011100 (upper 21 bits)
100010 -> 011100 100010 100010 100 -> 935188
100010
100
010 (lower 21 bits)
111110 -> 010 111110 100010 100010 -> 780450
100010
100010
vec2(935188.0,780450.0)
*/
//Text coloring
#define HEX(i) text_color = mod(vec3(i / 65536,i / 256,i),vec3(256.0))/255.0;
#define RGB(r,g,b) text_color = vec3(r,g,b);
#define STRWIDTH(c) (c * CHAR_SPACING.x)
#define STRHEIGHT(c) (c * CHAR_SPACING.y)
#define BEGIN_TEXT(x,y) print_pos = floor(vec2(x,y)); start_pos = floor(vec2(x,y));
//Automatically generated from the sprite sheet here: http://uzebox.org/wiki/index.php?title=File:Font6x8.png
#define _ col+=char(vec2(0.0,0.0),uv);
#define _spc col+=char(vec2(0.0,0.0),uv)*text_color;
#define _exc col+=char(vec2(276705.0,32776.0),uv)*text_color;
#define _quo col+=char(vec2(1797408.0,0.0),uv)*text_color;
#define _hsh col+=char(vec2(10738.0,1134484.0),uv)*text_color;
#define _dol col+=char(vec2(538883.0,19976.0),uv)*text_color;
#define _pct col+=char(vec2(1664033.0,68006.0),uv)*text_color;
#define _amp col+=char(vec2(545090.0,174362.0),uv)*text_color;
#define _apo col+=char(vec2(798848.0,0.0),uv)*text_color;
#define _lbr col+=char(vec2(270466.0,66568.0),uv)*text_color;
#define _rbr col+=char(vec2(528449.0,33296.0),uv)*text_color;
#define _ast col+=char(vec2(10471.0,1688832.0),uv)*text_color;
#define _crs col+=char(vec2(4167.0,1606144.0),uv)*text_color;
#define _per col+=char(vec2(0.0,1560.0),uv)*text_color;
#define _dsh col+=char(vec2(7.0,1572864.0),uv)*text_color;
#define _com col+=char(vec2(0.0,1544.0),uv)*text_color;
#define _lsl col+=char(vec2(1057.0,67584.0),uv)*text_color;
#define _0 col+=char(vec2(935221.0,731292.0),uv)*text_color;
#define _1 col+=char(vec2(274497.0,33308.0),uv)*text_color;
#define _2 col+=char(vec2(934929.0,1116222.0),uv)*text_color;
#define _3 col+=char(vec2(934931.0,1058972.0),uv)*text_color;
#define _4 col+=char(vec2(137380.0,1302788.0),uv)*text_color;
#define _5 col+=char(vec2(2048263.0,1058972.0),uv)*text_color;
#define _6 col+=char(vec2(401671.0,1190044.0),uv)*text_color;
#define _7 col+=char(vec2(2032673.0,66576.0),uv)*text_color;
#define _8 col+=char(vec2(935187.0,1190044.0),uv)*text_color;
#define _9 col+=char(vec2(935187.0,1581336.0),uv)*text_color;
#define _col col+=char(vec2(195.0,1560.0),uv)*text_color;
#define _scl col+=char(vec2(195.0,1544.0),uv)*text_color;
#define _les col+=char(vec2(135300.0,66052.0),uv)*text_color;
#define _equ col+=char(vec2(496.0,3968.0),uv)*text_color;
#define _grt col+=char(vec2(528416.0,541200.0),uv)*text_color;
#define _que col+=char(vec2(934929.0,1081352.0),uv)*text_color;
#define _ats col+=char(vec2(935285.0,714780.0),uv)*text_color;
#define _A col+=char(vec2(935188.0,780450.0),uv)*text_color;
#define _B col+=char(vec2(1983767.0,1190076.0),uv)*text_color;
#define _C col+=char(vec2(935172.0,133276.0),uv)*text_color;
#define _D col+=char(vec2(1983764.0,665788.0),uv)*text_color;
#define _E col+=char(vec2(2048263.0,1181758.0),uv)*text_color;
#define _F col+=char(vec2(2048263.0,1181728.0),uv)*text_color;
#define _G col+=char(vec2(935173.0,1714334.0),uv)*text_color;
#define _H col+=char(vec2(1131799.0,1714338.0),uv)*text_color;
#define _I col+=char(vec2(921665.0,33308.0),uv)*text_color;
#define _J col+=char(vec2(66576.0,665756.0),uv)*text_color;
#define _K col+=char(vec2(1132870.0,166178.0),uv)*text_color;
#define _L col+=char(vec2(1065220.0,133182.0),uv)*text_color;
#define _M col+=char(vec2(1142100.0,665762.0),uv)*text_color;
#define _N col+=char(vec2(1140052.0,1714338.0),uv)*text_color;
#define _O col+=char(vec2(935188.0,665756.0),uv)*text_color;
#define _P col+=char(vec2(1983767.0,1181728.0),uv)*text_color;
#define _Q col+=char(vec2(935188.0,698650.0),uv)*text_color;
#define _R col+=char(vec2(1983767.0,1198242.0),uv)*text_color;
#define _S col+=char(vec2(935171.0,1058972.0),uv)*text_color;
#define _T col+=char(vec2(2035777.0,33288.0),uv)*text_color;
#define _U col+=char(vec2(1131796.0,665756.0),uv)*text_color;
#define _V col+=char(vec2(1131796.0,664840.0),uv)*text_color;
#define _W col+=char(vec2(1131861.0,699028.0),uv)*text_color;
#define _X col+=char(vec2(1131681.0,84130.0),uv)*text_color;
#define _Y col+=char(vec2(1131794.0,1081864.0),uv)*text_color;
#define _Z col+=char(vec2(1968194.0,133180.0),uv)*text_color;
#define _lsb col+=char(vec2(925826.0,66588.0),uv)*text_color;
#define _rsl col+=char(vec2(16513.0,16512.0),uv)*text_color;
#define _rsb col+=char(vec2(919584.0,1065244.0),uv)*text_color;
#define _pow col+=char(vec2(272656.0,0.0),uv)*text_color;
#define _usc col+=char(vec2(0.0,62.0),uv)*text_color;
#define _a col+=char(vec2(224.0,649374.0),uv)*text_color;
#define _b col+=char(vec2(1065444.0,665788.0),uv)*text_color;
#define _c col+=char(vec2(228.0,657564.0),uv)*text_color;
#define _d col+=char(vec2(66804.0,665758.0),uv)*text_color;
#define _e col+=char(vec2(228.0,772124.0),uv)*text_color;
#define _f col+=char(vec2(401543.0,1115152.0),uv)*text_color;
#define _g col+=char(vec2(244.0,665474.0),uv)*text_color;
#define _h col+=char(vec2(1065444.0,665762.0),uv)*text_color;
#define _i col+=char(vec2(262209.0,33292.0),uv)*text_color;
#define _j col+=char(vec2(131168.0,1066252.0),uv)*text_color;
#define _k col+=char(vec2(1065253.0,199204.0),uv)*text_color;
#define _l col+=char(vec2(266305.0,33292.0),uv)*text_color;
#define _m col+=char(vec2(421.0,698530.0),uv)*text_color;
#define _n col+=char(vec2(452.0,1198372.0),uv)*text_color;
#define _o col+=char(vec2(228.0,665756.0),uv)*text_color;
#define _p col+=char(vec2(484.0,667424.0),uv)*text_color;
#define _q col+=char(vec2(244.0,665474.0),uv)*text_color;
#define _r col+=char(vec2(354.0,590904.0),uv)*text_color;
#define _s col+=char(vec2(228.0,114844.0),uv)*text_color;
#define _t col+=char(vec2(8674.0,66824.0),uv)*text_color;
#define _u col+=char(vec2(292.0,1198868.0),uv)*text_color;
#define _v col+=char(vec2(276.0,664840.0),uv)*text_color;
#define _w col+=char(vec2(276.0,700308.0),uv)*text_color;
#define _x col+=char(vec2(292.0,1149220.0),uv)*text_color;
#define _y col+=char(vec2(292.0,1163824.0),uv)*text_color;
#define _z col+=char(vec2(480.0,1148988.0),uv)*text_color;
#define _lpa col+=char(vec2(401542.0,66572.0),uv)*text_color;
#define _bar col+=char(vec2(266304.0,33288.0),uv)*text_color;
#define _rpa col+=char(vec2(788512.0,1589528.0),uv)*text_color;
#define _tid col+=char(vec2(675840.0,0.0),uv)*text_color;
#define _lar col+=char(vec2(8387.0,1147904.0),uv)*text_color;
#define _nl print_pos = start_pos - vec2(0,CHAR_SPACING.y);
//Extracts bit b from the given number.
float extract_bit(float n, float b)
{
b = clamp(b,-1.0,22.0);
return floor(mod(floor(n / pow(2.0,floor(b))),2.0));
}
//Returns the pixel at uv in the given bit-packed sprite.
float sprite(vec2 spr, vec2 size, vec2 uv)
{
uv = floor(uv);
float bit = (size.x-uv.x-1.0) + uv.y * size.x;
bool bounds = all(greaterThanEqual(uv,vec2(0)))&& all(lessThan(uv,size));
return bounds ? extract_bit(spr.x, bit - 21.0) + extract_bit(spr.y, bit) : 0.0;
}
//Prints a character and moves the print position forward by 1 character width.
vec3 char(vec2 ch, vec2 uv)
{
float px = sprite(ch, CHAR_SIZE, uv - print_pos);
print_pos.x += CHAR_SPACING.x;
print_pos.y += sin(4.*print_pos.x-time*10.);
return vec3(px);
}
vec3 Text(vec2 uv)
{
vec3 col = vec3(0.0);
vec2 center_pos = vec2(res.x/2.0 - STRWIDTH(20.0)/2.0,res.y/2.0 - STRHEIGHT(1.0)/2.0);
BEGIN_TEXT(center_pos.x,center_pos.y)
HEX(0x00ffFF) _ _ _C _L _O _U _D _ _N _I _N _J _A;
BEGIN_TEXT(res.x/2.0-STRWIDTH(11.0)/2.0,res.y/2.0)
print_pos += vec2(cos(time)*96.,sin(time)*96.);
// RGB(1,0,0) _M RGB(1,.5,0)_o RGB(1,1,0)_v RGB(0,1,0)_i RGB(0,.5,1)_n RGB(0.5,0,1)_g _ RGB(1,0,0)_T RGB(1,.5,0)_e RGB(1,1,0)_x RGB(0,1,0)_t
return col;
}
void main( void )
{
res = resolution.xy / DOWN_SCALE;
vec2 uv = gl_FragCoord.xy / DOWN_SCALE;
vec2 duv = floor(gl_FragCoord.xy / DOWN_SCALE);
vec3 pixel = Text(duv);
vec3 col = pixel*0.9+0.1;
col *= (1.-distance(mod(uv,vec2(1.0)),vec2(0.65)))*1.2;
gl_FragColor = vec4(vec3(col), 1.0);
}
+155
View File
@@ -0,0 +1,155 @@
#ifdef GL_ES
precision highp float;
#endif
vec2 uv;
uniform float time;
uniform vec2 resolution;
const vec2 ch_size = vec2(1.0, 2.0) * 0.6; // character size (X,Y)
const vec2 ch_space = ch_size + vec2(1.0, 1.0); // character distance Vector(X,Y)
const vec2 ch_start = vec2 (ch_space.x * -5., 1.); // start position
vec2 ch_pos = vec2 (0.0, 0.0); // character position(X,Y)
// vec3 ch_color = vec3 (1.5, 0.75, 0.5); // character color (R,G,B)
//const vec3 bg_color = vec3 (0.2, 0.2, 0.2); // background color (R,G,B)
#define REPEAT_SIGN false // True/False; True=Multiple, False=Single
/* 16 segment display...Akin to LED Display.
Segment bit positions:
binary to hex -> 0x119F
*/
#define n0 ddigit(0x22FF);
#define n1 ddigit(0x0281);
#define n2 ddigit(0x1177);
#define n3 ddigit(0x11E7);
#define n4 ddigit(0x5508);
#define n5 ddigit(0x11EE);
#define n6 ddigit(0x11FE);
#define n7 ddigit(0x2206);
#define n8 ddigit(0x11FF);
#define n9 ddigit(0x11EF);
#define A ddigit(0x119F);
#define B ddigit(0x927E);
#define C ddigit(0x007E);
#define D ddigit(0x44E7);
#define E ddigit(0x107E);
#define F ddigit(0x101E);
#define G ddigit(0x807E);
#define H ddigit(0x1199);
#define I ddigit(0x4466);
#define J ddigit(0x4436);
#define K ddigit(0x9218);
#define L ddigit(0x0078);
#define M ddigit(0x0A99);
#define N ddigit(0x8899);
#define O ddigit(0x00FF);
#define P ddigit(0x111F);
#define Q ddigit(0x80FF);
#define R ddigit(0x911F);
#define S ddigit(0x8866);
#define T ddigit(0x4406);
#define U ddigit(0x00F9);
#define V ddigit(0x2218);
#define W ddigit(0xA099);
#define X ddigit(0xAA00);
#define Y ddigit(0x4A00);
#define Z ddigit(0x2266);
#define _ ch_pos.x += ch_space.x;
#define s_dot ddigit(0);
#define s_minus ddigit(0x1100);
#define s_plus ddigit(0x5500);
#define s_greater ddigit(0x2800);
#define s_less ddigit(0x8200);
#define s_sqrt ddigit(0x0C02);
#define nl1 ch_pos = ch_start; ch_pos.y -= 3.0;
#define nl2 ch_pos = ch_start; ch_pos.y -= 6.0;
#define nl3 ch_pos = ch_start; ch_pos.y -= 9.0;
float dseg(vec2 p0, vec2 p1)
{
vec2 dir = normalize(p1 - p0);
vec2 cp = (uv - ch_pos - p0) * mat2(dir.x, dir.y,-dir.y, dir.x);
return distance(cp, clamp(cp, vec2(0), vec2(distance(p0, p1), 0)));
}
bool bit(int n, int b)
{
return mod(floor(float(n) / exp2(floor(float(b)))), 2.0) != 0.0;
}
float d = 1e6;
void ddigit(int n)
{
float v = 1e6;
vec2 cp = uv - ch_pos;
if (n == 0) v = min(v, dseg(vec2(-0.405, -1.000), vec2(-0.500, -1.000)));
if (bit(n, 0)) v = min(v, dseg(vec2( 0.500, 0.063), vec2( 0.500, 0.937)));
if (bit(n, 1)) v = min(v, dseg(vec2( 0.438, 1.000), vec2( 0.063, 1.000000000)));
if (bit(n, 2)) v = min(v, dseg(vec2(-0.063, 1.000), vec2(-0.438, 1.000)));
if (bit(n, 3)) v = min(v, dseg(vec2(-0.500, 0.937), vec2(-0.500, 0.062)));
if (bit(n, 4)) v = min(v, dseg(vec2(-0.500, -0.063), vec2(-0.500, -0.938)));
if (bit(n, 5)) v = min(v, dseg(vec2(-0.438, -1.000), vec2(-0.063, -1.000)));
if (bit(n, 6)) v = min(v, dseg(vec2( 0.063, -1.000), vec2( 0.438, -1.000)));
if (bit(n, 7)) v = min(v, dseg(vec2( 0.500, -0.938), vec2( 0.500, -0.063)));
if (bit(n, 8)) v = min(v, dseg(vec2( 0.063, 0.000), vec2( 0.438, -0.000)));
if (bit(n, 9)) v = min(v, dseg(vec2( 0.063, 0.063), vec2( 0.438, 0.938)));
if (bit(n, 10)) v = min(v, dseg(vec2( 0.000, 0.063), vec2( 0.000, 0.937)));
if (bit(n, 11)) v = min(v, dseg(vec2(-0.063, 0.063), vec2(-0.438, 0.938)));
if (bit(n, 12)) v = min(v, dseg(vec2(-0.438, 0.000), vec2(-0.063, -0.000)));
if (bit(n, 13)) v = min(v, dseg(vec2(-0.063, -0.063), vec2(-0.438, -0.938)));
if (bit(n, 14)) v = min(v, dseg(vec2( 0.000, -0.938), vec2( 0.000, -0.063)));
if (bit(n, 15)) v = min(v, dseg(vec2( 0.063, -0.063), vec2( 0.438, -0.938)));
ch_pos.x += ch_space.x;
d = min(d, v);
}
mat2 rotate(float a)
{
float c = cos(a);
float s = sin(a);
return mat2(c, s, -s, c);
}
vec3 hsv2rgb_smooth( in vec3 c )
{
vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
rgb = rgb*rgb*(3.0-2.0*rgb); // cubic smoothing
return c.z * mix( vec3(1.0), rgb, c.y);
}
void main( void )
{
vec2 aspect = resolution.xy / resolution.y;
uv = ( gl_FragCoord.xy / resolution.y ) - aspect / 2.0;
float _d = 1.0-length(uv);
uv *= 18.0 ;
uv.y -= 3.;
//uv *= rotate(time+uv.x*0.05);
vec3 ch_color = hsv2rgb_smooth(vec3(time*0.4+uv.y*0.1,0.5,1.0));
vec3 bg_color = vec3(_d*0.4, _d*0.2, _d*0.1);
uv.x += -1.+sin(time+uv.y*0.7)*0.5;
ch_pos = ch_start;
_ C L O U D N I N J A
vec3 color = mix(ch_color, bg_color, 1.0- (0.08 / d*2.0)); // shading
gl_FragColor = vec4(color, 1.0);
}
+79
View File
@@ -0,0 +1,79 @@
// Inspired from: https://www.shadertoy.com/view/3dBGWG
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 resolution;
vec3 rotate(vec3 p,vec3 axis,float theta)
{
vec3 v = cross(p, axis), u = cross(v, axis);
return u * cos(theta) + v * sin(theta) + axis * dot(p, axis);
}
vec2 rotate(vec2 p, float theta)
{
return p * cos(theta) + vec2(-p.y, p.x) * sin(theta);
}
float deLineBox(vec3 p)
{
p=mod(p,4.0)-2.0;
float de = 1e5;
for(float j=1.0; j<4.0;j++)
{
p = abs(p)-1.0;
for(int i=0; i<3;i++)
{
vec3 q =p;
q[i]=max(0.0,q[i]);
de= min(de,length(q)-0.03*j);
}
p*=2.0;
}
return de;
}
float dstepf = 0.0;
float map(vec3 p)
{
dstepf += 0.003;
float t = floor(time/5.5)*3.5 + min(8.0, mod(time,10.0));
p = rotate(p,normalize(vec3(rotate(vec2(1,2),sin(t/3.)),3)),t*0.35);
return deLineBox(p);
}
void main()
{
vec2 uv = (gl_FragCoord.xy*2.0-resolution.xy)/resolution.y;
vec3 ro = vec3(3.5)*sin(time*0.02+ 0.2*sin(time*0.1));
vec3 rd0 = normalize(vec3(uv, -1.0));
vec3 rd1 = normalize(vec3(uv, (1.0-dot(uv, uv)*0.5)*0.5));
vec3 rd = mix(rd0, rd1, step(6.0,mod(time,12.0)));
vec3 col = vec3(0);
float t=0.1, layers=0.0, d, aD;
float thD = 0.03;
for(float i=0.; i<80.; i++)
{
if(layers>10. || col.x > 1.0 || t>6.0) break;
vec3 p = ro + rd*t;
d = map(p);
aD = (thD-abs(d))/thD;
if(aD>0.)
{
col += aD*aD*(3.0-2.0*aD)/(1.0 + t*t*0.5)*0.15;
layers++;
}
t += max(d, thD*1.5) * dstepf;
}
col = mix(col, vec3(min(col.x*1.5, 1.), pow(col.x, 2.5), pow(col.x, 12.)),
dot(sin(rd.yzx*8. + sin(rd.zxy*8.)), vec3(.1666))+0.4);
col = mix(col, vec3(col.x*col.x*.85, col.x, col.x*col.x*0.3),
dot(sin(rd.yzx*4. + sin(rd.zxy*4.)), vec3(.1666))+0.25);
gl_FragColor = vec4( clamp(col, 0., 1.), 1.0 );
}
+23
View File
@@ -0,0 +1,23 @@
// Example Shadertoy-style fragment shader for gpupaper.
// Demonstrates use of 'time' and 'resolution' uniforms.
//
// Usage: gpupaper HDMI-A-1 shaders/example.frag
uniform vec2 resolution;
uniform float time;
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord / resolution;
// Animated gradient
float r = 0.5 + 0.5 * sin(time * 0.7 + uv.x * 3.0);
float g = 0.5 + 0.5 * sin(time * 0.5 + uv.y * 3.0 + 2.094);
float b = 0.5 + 0.5 * sin(time * 0.3 + (uv.x + uv.y) * 3.0 + 4.189);
// Vignette
vec2 centered = uv - 0.5;
float vignette = 1.0 - dot(centered, centered) * 2.0;
vignette = clamp(vignette, 0.0, 1.0);
fragColor = vec4(vec3(r, g, b) * vignette, 1.0);
}
+75
View File
@@ -0,0 +1,75 @@
#ifdef GL_ES
precision mediump float;
#endif
//dashxdr
// showing the points while performing the mandelbrot function
uniform float time;
uniform vec2 resolution;
uniform vec2 mouse;
uniform sampler2D bb;
void main( void )
{
float sum = 0.0;
float size = .0025;
vec2 tpos = gl_FragCoord.xy / resolution;
float px,py;
float scale = 1.0;
float basex = -1.0;
float basey = 0.0;
float x = basex + (mouse.x-.5)*scale;
float y = basey + (mouse.y-.5)*scale;
float t;
if(true) // change to false to control with mouse
{
t = time;
float t1 = t;
float scale1 = .3;
float t2 = t *.61223;
float scale2 = .5;
x = basex + scale1*cos(t1) + scale2*cos(t2);
y = basey + scale1*sin(t1) + scale2*sin(t2);
}
vec2 position = 2.0*(tpos + vec2(-0.75, -0.5));
#define NUM 30
float u, v;
u = v = .317;
for(int j=0;j<4;++j)
{
px = py = 0.0;
float x0, y0;
x0 = x + u;
y0 = y + v;
for (int i=0; i < NUM; ++i) {
t = (px*px-py*py)+x0;
py = (2.0*px*py) + y0;
px = t;
float dist = length(vec2(px, py) - position);
if(dist > .0001)
sum += size/dist;
else break;
}
t = u;
u = -v;
v = t;
}
float val = sum;
vec3 color;
color = vec3(val, val*0.66666, 0.0);
tpos = .5 + 1.2 * (tpos - .5);
#define INDENT .02
vec3 tcolor;
if(tpos.x>INDENT && tpos.y>INDENT &&
tpos.x < 1.0-INDENT && tpos.y < 1.0-INDENT)
tcolor = .9*texture2D(bb, tpos).rgb;
else tcolor = vec3(0.0);
gl_FragColor = vec4(max(color,tcolor), 1.0);
}
+138
View File
@@ -0,0 +1,138 @@
/*
* License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
* Created by bal-khan
*/
precision highp float;
uniform float time;
uniform vec2 resolution;
vec2 iResolution;
float iTime;
vec2 march(vec3 pos, vec3 dir);
vec3 camera(vec2 uv);
void rotate(inout vec2 v, float angle);
float t; // time
vec3 ret_col; // torus color
vec3 h; // light amount
#define I_MAX 400.
#define E 0.00001
#define FAR 50.
#define PI 3.14
// blackbody by aiekick : https://www.shadertoy.com/view/lttXDn
// -------------blackbody----------------- //
// return color from temperature
//http://www.physics.sfasu.edu/astro/color/blackbody.html
//http://www.vendian.org/mncharity/dir3/blackbody/
//http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html
vec3 blackbody(float Temp)
{
vec3 col = vec3(255.);
col.x = 56100000. * pow(Temp,(-3. / 2.)) + 148.;
col.y = 100.04 * log(Temp) - 623.6;
if (Temp > 6500.) col.y = 35200000. * pow(Temp,(-3. / 2.)) + 184.;
col.z = 194.18 * log(Temp) - 1448.6;
col = clamp(col, 0., 255.)/255.;
if (Temp < 1000.) col *= Temp/1000.;
return col;
}
// -------------blackbody----------------- //
void mainImage(out vec4 c_out, in vec2 f)
{
t = iTime*.125;
vec3 col = vec3(0., 0., 0.);
vec2 R = iResolution.xy,
uv = vec2(f-R/2.) / R.y;
vec3 dir = camera(uv);
vec3 pos = vec3(.0, .0, 0.0);
pos.z = 4.5+1.5*sin(t*10.);
h*=0.;
vec2 inter = (march(pos, dir));
col.xyz = ret_col*(1.-inter.x*.0125);
col += h * .4;
c_out = vec4(col,1.0);
}
float scene(vec3 p)
{
float var;
float mind = 1e5;
p.z += 10.;
rotate(p.xz, 1.57-.5*iTime );
rotate(p.yz, 1.57-.5*iTime );
var = atan(p.x,p.y);
vec2 q = vec2( ( length(p.xy) )-6.,p.z);
rotate(q, var*.25+iTime*2.*0.);
vec2 oq = q ;
q = abs(q)-2.5;
if (oq.x < q.x && oq.y > q.y)
rotate(q, ( (var*1.)+iTime*0.)*3.14+iTime*0.);
else
rotate(q, ( .28-(var*1.)+iTime*0.)*3.14+iTime*0.);
float oldvar = var;
ret_col = 1.-vec3(.350, .2, .3);
mind = length(q)+.5+1.05*(length(fract(q*.5*(3.+3.*sin(oldvar*1. - iTime*2.)) )-.5)-1.215);
h -= vec3(-3.20,.20,1.0)*vec3(1.)*.0025/(.051+(mind-sin(oldvar*1. - iTime*2. + 3.14)*.125 )*(mind-sin(oldvar*1. - iTime*2. + 3.14)*.125 ) );
h -= vec3(1.20,-.50,-.50)*vec3(1.)*.025/(.501+(mind-sin(oldvar*1. - iTime*2.)*.5 )*(mind-sin(oldvar*1. - iTime*2.)*.5 ) );
h += vec3(.25, .4, .5)*.0025/(.021+mind*mind);
return (mind);
}
vec2 march(vec3 pos, vec3 dir)
{
vec2 dist = vec2(0.0, 0.0);
vec3 p = vec3(0.0, 0.0, 0.0);
vec2 s = vec2(0.0, 0.0);
for (float i = -1.; i < I_MAX; ++i)
{
p = pos + dir * dist.y;
dist.x = scene(p);
dist.y += dist.x*.2; // makes artefacts disappear
// log trick by aiekick
if (log(dist.y*dist.y/dist.x/1e5) > .0 || dist.x < E || dist.y > FAR)
{
break;
}
s.x++;
}
s.y = dist.y;
return (s);
}
// Utilities
void rotate(inout vec2 v, float angle)
{
v = vec2(cos(angle)*v.x+sin(angle)*v.y,-sin(angle)*v.x+cos(angle)*v.y);
}
vec3 camera(vec2 uv)
{
float fov = 1.;
vec3 forw = vec3(0.0, 0.0, -1.0);
vec3 right = vec3(1.0, 0.0, 0.0);
vec3 up = vec3(0.0, 1.0, 0.0);
return (normalize((uv.x) * right + (uv.y) * up + fov * forw));
}
void main() {
iTime = time;
iResolution = resolution;
mainImage(gl_FragColor, gl_FragCoord.xy);
}
+441
View File
@@ -0,0 +1,441 @@
#ifdef GL_ES
precision mediump float;
#endif
// Community flags
// Individual flags taken from other shaders
//
// enhanced edition, best viewed at 1
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
#define WAVE
float kFlagCount = 15.0; // +1 to add new flag
vec3 Flag0( vec2 p )
{
// http://glsl.heroku.com/e#2701.0
vec3 c = vec3(1.0, 0.48, 0.15);
if((p.y > 0.6 && p.y < 0.7) || (p.x > 0.7 && p.x < 0.76)) c = vec3(1.0, 0.9, 0.3);
return c;
}
vec3 Flag1( vec2 p )
{
// http://glsl.heroku.com/e#2703.0
// Czech Republic
vec3 c = vec3(1, 1, 1);
if (-p.x + 1.0 > p.y) c = vec3(0, 0, 1);
if (p.y < 0.5) {
c = vec3(1, 0, 0);
if (p.x < p.y) c = vec3(0, 0, 1);
}
return c;
}
vec3 Flag2orig( vec2 p )
{
// http://glsl.heroku.com/e#2724.0
// Germany
vec3 c = vec3(0.0);
if(p.y < 0.333)
c = vec3(1.0, 0.8, 0.0);
else if(p.y > 0.333 && p.y < 0.666)
c = vec3(1.0, 0.0, 0.0);
else
c = vec3(0.0);
return c;
}
vec3 Flag2enh( vec2 p)
{
// "Germany"
float r = -2.0*time;
vec3 c = vec3(1.0);
p -= 0.5;
p.x *= resolution.x / resolution.y;
p /= 0.43;
if(length(p) >= 1.0)
return vec3(1.0,0.0,0.0);
p = vec2(p.x*cos(r)+p.y*sin(r), -p.x*sin(r)+p.y*cos(r))/0.67 /*should be r*/;
if(abs(p.x) > 1.0 || abs(p.y) > 1.0)
return c;
if(p.y < 0.0) p = vec2(-p.x, -p.y);
if(p.x < 0.0) p = vec2(p.y, -p.x);
if(p.y > 0.2 && p.y < 0.6 && p.x > 0.2)
return c;
return vec3(0.0);
}
vec3 noise( vec3 p)
{
return vec3(0.5 + 0.5 * fract(sin(dot(p.xyz, vec3(7.791,12.9898, 78.233)))* 43758.5453));
}
vec3 Flag2( vec2 p)
{
if(mod(time,2.0) >= 1.7)
return noise(vec3(time,p.xy));
if(mod(time,4.0) >= 2.0)
return Flag2orig(p);
return Flag2enh(p);
}
vec3 Flag3( vec2 p )
{
// http://glsl.heroku.com/e#2727.0
// Poland
float gb = 1.0;
if (p.y < 0.5)
gb = 0.0;
return vec3( 1.0, gb, gb);
}
vec3 Flag4( vec2 p )
{
// http://glsl.heroku.com/e#2766.0
// Japan
p -= 0.5;
p.y *= resolution.y / resolution.x;
float col = clamp((length(p) - 0.12) * 1000.0, 0.0, 1.0);
return vec3(1.0, col, col);
}
vec3 Flag5( vec2 p )
{
// http://glsl.heroku.com/e#2731.1
// United Kingdom
vec3 kRed = vec3( 204.0 / 255.0, 0.0, 0.0 );
vec3 kWhite = vec3( 1.0, 1.0, 1.0 );
vec3 kBlue = vec3( 0.0, 0.0, 102.0 / 255.0 );
vec3 c = kBlue;
p = p * 2.0 - 1.0;
float d = -p.x * sign(p.y) + p.y * sign(p.x);
if((abs(p.x) < (6.0/60.0)) || (abs(p.y) < (6.0/30.0)))
{
c = kRed;
}
else
if((abs(p.x) < (10.0/60.0)) || (abs(p.y) < (10.0/30.0)))
{
c = kWhite;
}
else
if( (d > 0.0) && (d < 0.15))
{
c = kRed;
}
else
if( (d > -0.15 * 3.0 / 2.0) && (d < 0.15 * 3.0 /2.0))
{
c = kWhite;
}
return c;
}
vec3 Flag6( vec2 p )
{
// http://glsl.heroku.com/e#2737.0
// Serbia and Montenegro
vec3 c = vec3(0.0);
if(p.y < 0.3333333333333333333333)
c = vec3(0.2, 0.2, 1.0);
else if(p.y > 0.3333333333333333 && p.y < 0.666666666666666666666666)
c = vec3(1.0, 1.0, 1.0);
else
c = vec3(1.0, 0.2, 0.2);
return c;
}
vec3 Flag7( vec2 p )
{
// http://glsl.heroku.com/e#2739.0
// Italy
vec3 c = vec3(0.807, 0.168, 0.215);
if(p.x < 0.333)
c = vec3(0, 0.572, 0.274);
else if(p.x > 0.333 && p.x < 0.666)
c = vec3(1.0, 1.0, 1.0);
return c;
}
vec3 Flag8( vec2 p )
{
// http://glsl.heroku.com/e#2740.0
// Spain
vec3 c = vec3(0.666, 0.082, 0.098);
if(p.y > 0.25 && p.y < 0.75)
c = vec3(0.945, 0.749, 0.0);
return c;
}
vec3 Flag9( vec2 p )
{
// http://glsl.heroku.com/e#2770.4
// Hungary
/*
* Author: Yours3!f
* Ripple effect taken from here (glsl.heroku.com/e#2757)
* This flag has proper colors (not just r = 1, b = 1)
*/
vec3 red = vec3(206, 17, 38) / vec3(255);
vec3 green = vec3(0, 135, 81) / vec3(255);
vec3 c = vec3(1);
if(p.y > 0.66)
c.xyz = red;
else if(p.y < 0.33)
c.xyz = green;
return c;
}
vec3 Flag10( vec2 p )
{
// http://glsl.heroku.com/e#2752.0
// Greek Flag by Optimus
// I am not sure about the color or dimensions but one can fork this
//Added proper color, by Yours3!f
vec3 blue = vec3(13, 94, 175) / vec3(255);
vec3 white = vec3(1.0, 1.0, 1.0);
vec3 finalcolor = vec3(0.0);
float stripes = mod(p.y * 4.5, 1.0);
vec3 stripecol = vec3(0.0);
if (stripes < 0.5)
{
stripecol = blue;
}
else
{
stripecol = white;
}
vec3 crosscol = vec3(0.0);
if (p.x < 0.4 && p.y > 0.444)
{
crosscol = blue;
if (p.x > 0.15 && p.x < 0.25) crosscol = white;
if (p.y > 0.666 && p.y < 0.778) crosscol = white;
finalcolor = crosscol;
}
else
{
finalcolor = stripecol;
}
return finalcolor;
}
vec3 Flag11( vec2 p )
{
// http://glsl.heroku.com/e#2758.0
// France
vec3 c = vec3(0.0);
if(p.x < 0.3333333333333333333333)
c = vec3(0.2, 0.2, 1.0);
else if(p.x > 0.3333333333333333 && p.x < 0.666666666666666666666666)
c = vec3(1.0, 1.0, 1.0);
else
c = vec3(1.0, 0.2, 0.2);
return c;
}
vec3 Flag12( vec2 p )
{
// http://glsl.heroku.com/e#2772.4
// Denmark!
// by @dennishjorth
//
// Please! Set the precision to 0.5!
// otherwise it hurts your eyes...
vec3 kRed = vec3( 255.0 / 255.0, 0.0, 0.0 );
vec3 kWhite = vec3( 1.0, 1.0, 1.0 );
vec3 c;
p = p * 2.0 - 1.0;
if((abs(p.x+0.3) < (6.0/60.0)) || (abs(p.y) < (6.0/30.0)))
{
c = kWhite;
}
else
{
c = kRed;
}
return c;
}
vec3 Flag13( vec2 p )
{
// England
vec3 kRed = vec3( 204.0 / 255.0, 0.0, 0.0 );
vec3 kWhite = vec3( 1.0, 1.0, 1.0 );
vec3 c = kWhite;
p = p * 2.0 - 1.0;
if((abs(p.x) < (6.0/60.0)) || (abs(p.y) < (6.0/30.0)))
{
c = kRed;
}
return c;
}
vec3 Flag14( vec2 p )
{
// Russia
vec3 c = vec3(0.0);
if(p.y > 0.666)
c = vec3(1.0);
else if(p.y < 0.666 && p.y > 0.333)
c = vec3(0.0, 0.0, 1.0);
else
c = vec3(1.0, 0.0, 0.0);
return c;
}
vec3 Flag15( vec2 p )
{
vec3 c = vec3(0.0); // add new flag code here
return c;
}
vec3 GetFlagCol(vec2 p, float index)
{
index = mod(index, kFlagCount);
if(index < 0.5) {
return Flag0(p);
}
else if(index < 1.5) {
return Flag1(p);
}
else if(index < 2.5) {
return Flag2(p);
}
else if(index < 3.5) {
return Flag3(p);
}
else if(index < 4.5) {
return Flag4(p);
}
else if(index < 5.5) {
return Flag5(p);
}
else if(index < 6.5) {
return Flag6(p);
}
else if(index < 7.5) {
return Flag7(p);
}
else if(index < 8.5) {
return Flag8(p);
}
else if(index < 9.5) {
return Flag9(p);
}
else if(index < 10.5) {
return Flag10(p);
}
else if(index < 11.5) {
return Flag11(p);
}
else if(index < 12.5) {
return Flag12(p);
}
else if(index < 13.5) {
return Flag13(p);
}
else if(index < 14.5) {
return Flag14(p);
}
else if(index < 15.5) {
return Flag15(p);
}
return vec3(0.0);
}
void main( void )
{
vec2 p = gl_FragCoord.xy / resolution.xy;
// apply movement
vec2 p2 = p * 8.0;
p2.y += time * 0.2;
float shade = 1.0;
#ifdef WAVE
float nx =0.0;
float k_freq = 100.0;
float k_x_movement = 0.025;
float k_y_movement = 0.05;
float k_scroll_speed = 4.0;
float mag = 1.0;
float freq = 1.0;
float scroll_speed = 1.0;
for(int i=0; i<3; i++)
{
// move more near the right
float movement_amount = fract(p2.x);
if(movement_amount > 0.9) movement_amount = 0.0;
// wibble
float f = (p.x) * freq * k_freq - time * scroll_speed * k_scroll_speed;
float dx = cos( f ) * mag * movement_amount;
float dy = (sin( f ) ) * mag * movement_amount;
p2.x += dx * k_x_movement;
p2.y += dy * k_y_movement;
// accumulate dx movement for shading
nx += dx;
freq *= 2.0;
mag *= 0.5;
scroll_speed *= 2.5;
}
shade = clamp(0.8 - nx * 0.2, 0.0, 1.0);
#endif // WAVE
float index = floor(p2.x) + floor(p2.y) * 5.0;
vec2 vFlagCoord = fract(p2) * 1.25;
// default background
vec3 vCol = vec3(0.0, 0.2, 0.0);
// get flag col
if((vFlagCoord.x <= 1.0) && (vFlagCoord.y <= 1.0))
{
vCol = GetFlagCol( vFlagCoord, index ) * shade;
}
//vCol = GetFlagCol( p, kFlagCount ); // uncomment to show flag full screen
gl_FragColor = vec4( vCol, 1.0 );
}
+225
View File
@@ -0,0 +1,225 @@
#ifdef GL_ES
precision lowp float;
#endif
// ***********************************************************
// Alcatraz / Rhodium 4k Intro liquid carbon
// by Jochen "Virgill" Feldkötter
//
// 4kb executable: http://www.pouet.net/prod.php?which=68239
// Youtube: https://www.youtube.com/watch?v=YK7fbtQw3ZU
// ***********************************************************
// PORTED to GLSLHeroku/Sandbox by JaK^threepixels
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
uniform sampler2D optTex;
uniform sampler2D backbuffer;
float lowFreq;
float midFreq;
float highFreq;
//#define time iTime
const float GA =2.399;
mat2 rot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA));
float bounce = 0.0f;
// signed box
float sdBox(vec3 p,vec3 b)
{
vec3 d=abs(p)-b;
return min(max(d.x,max(d.y,d.z)),0.)+length(max(d,0.));
}
// rotation
void pR(inout vec2 p,float a)
{
p=cos(a)*p+sin(a)*vec2(p.y,-p.x);
}
// 3D noise function (IQ)
float noise(vec3 p)
{
vec3 ip=floor(p);
p-=ip;
vec3 s=vec3(7,875,113);
vec4 h=vec4(0.,s.yz,s.y+s.z)+dot(ip,s);
p=p*p*(3.-2.*p);
h=mix(fract(sin(h)*43758.5),fract(sin(h+s.x)*43758.5),p.x);
h.xy=mix(h.xz,h.yw,p.y);
return mix(h.x,h.y,p.z);
}
float map(vec3 p)
{
p.z-=1.0;
p*=0.9;
pR(p.yz,bounce*1.+0.4*p.x);
return sdBox(p+vec3(0,sin(1.6*time),0),vec3(20.0, 0.05, 1.2))-.4*noise(8.*p+3.*bounce);
}
// normal calculation
vec3 calcNormal(vec3 pos)
{
float eps=0.0001;
float d=map(pos);
return normalize(vec3(map(pos+vec3(eps,0,0))-d,map(pos+vec3(0,eps,0))-d,map(pos+vec3(0,0,eps))-d));
}
// standard sphere tracing inside and outside
float castRayx(vec3 ro,vec3 rd)
{
float function_sign=(map(ro)<0.)?-1.:1.;
float precis=.0001;
float h=precis*2.;
float t=0.;
for(int i=0;i<120;i++)
{
if(abs(h)<precis||t>12.)break;
h=function_sign*map(ro+rd*t);
t+=h;
}
return t;
}
// refraction
float refr(vec3 pos,vec3 lig,vec3 dir,vec3 nor,float angle,out float t2, out vec3 nor2)
{
float h=0.;
t2=2.;
vec3 dir2=refract(dir,nor,angle);
for(int i=0;i<50;i++)
{
if(abs(h)>3.) break;
h=map(pos+dir2*t2);
t2-=h;
}
nor2=calcNormal(pos+dir2*t2);
return(.5*clamp(dot(-lig,nor2),0.,1.)+pow(max(dot(reflect(dir2,nor2),lig),0.),8.));
}
// softshadow
float softshadow(vec3 ro,vec3 rd)
{
float sh=1.;
float t=.02;
float h=.0;
for(int i=0;i<22;i++)
{
if(t>20.)continue;
h=map(ro+rd*t);
sh=min(sh,4.*h/t);
t+=h;
}
return sh;
}
// main function
vec4 mainScene(vec2 fragCoord)
{
bounce=abs(fract(0.05*time)-.5)*20.; // triangle function
vec2 uv=gl_FragCoord.xy/resolution.xy;
vec2 p=uv*2.-1.;
// bouncy cam every 10 seconds
float wobble=(fract(.1*(time-1.))>=0.9)?fract(-time)*0.1*sin(30.*time):0.;
// camera
vec3 dir = normalize(vec3(2.*gl_FragCoord.xy -resolution.xy, resolution.y));
vec3 org = vec3(0,2.*wobble,-3.);
// standard sphere tracing:
vec3 color = vec3(0.);
vec3 color2 =vec3(0.);
float t=castRayx(org,dir);
vec3 pos=org+dir*t;
vec3 nor=calcNormal(pos);
// lighting:
vec3 lig=normalize(vec3(.2,6.,.5));
// scene depth
float depth=clamp((1.-0.09*t),0.,1.);
vec3 pos2 = vec3(0.);
vec3 nor2 = vec3(0.);
if(t<12.0)
{
color2 = vec3(max(dot(lig,nor),0.) + pow(max(dot(reflect(dir,nor),lig),0.),16.));
color2 *=clamp(softshadow(pos,lig),0.,1.); // shadow
float t2;
color2.rgb +=refr(pos,lig,dir,nor,0.9, t2, nor2)*depth;
color2-=clamp(.1*t2,0.,1.); // inner intensity loss
}
float tmp = 0.;
float T = 1.;
// animation of glow intensity
float intensity = 0.1*-sin(.209*time+1.)+0.05;
for(int i=0; i<128; i++)
{
float density = 0.; float nebula = noise(org+bounce);
density=intensity-map(org+.5*nor2)*nebula;
if(density>0.)
{
tmp = density / 128.;
T *= 1. -tmp * 100.;
if( T <= 0.) break;
}
org += dir*0.078;
}
vec3 basecol=vec3(1./1. , 1./4. , 1./16.);
T=clamp(T,0.,1.5);
color += basecol* exp(4.*(0.5-T) - 0.8);
color2*=depth;
color2+= (1.-depth)*noise(6.*dir+0.3*time)*.1; // subtle mist
// scene depth included in alpha channel
vec4 finalRGB = vec4(vec3(1.*color+0.8*color2)*1.3,abs(0.67-depth)*2.+4.*wobble);
return finalRGB;
}
// simplyfied version of Dave Hoskins blur
vec3 dof(sampler2D tex,vec2 uv,float rad)
//vec3 dof(vec3 Coltex,vec2 uv,float rad)
{
vec3 acc=vec3(0);
vec2 pixel=vec2(.002*resolution.y/resolution.x,.002),angle=vec2(0,rad);;
rad=1.;
for (int j=0;j<80;j++)
{
rad += 1./rad;
angle*=rot;
vec4 col=texture2D(tex,uv+pixel*(rad-1.)*angle);
acc+=col.xyz;
}
return acc/80.;
}
//-------------------------------------------------------------------------------------------
//void mainImage(out vec4 fragColor,in vec2 fragCoord)
//{
uniform sampler2D mainRender;
void main() {
// sampler2D mainRender;
vec2 uv = gl_FragCoord.xy / resolution.xy; //Condensing this into one line
vec4 mainPixels=mainScene(uv);
mainPixels.w=1.0;
//Can't use an alternate buffer to write in glslsandbox?
//texture2D(backbuffer,uv)=mainPixels;
//gl_FragColor=vec4(dof(backbuffer,uv,texture2D(backbuffer,uv).w),1.);
gl_FragColor=mainPixels;
//vec4(dof(mainRender,uv,mainPixels.w),1.);
}
+47
View File
@@ -0,0 +1,47 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
//uniform vec2 mouse;
uniform vec2 resolution;
// bonniemathew@gmail.com
//vec3 COLOR1 = vec3(0.0, 0.0, 0.50);
//vec3 COLOR2 = vec3(0.30, .0, 0.0);
const vec3 COLOR1 = vec3(0.0, 0.0, 0.0);
vec3 COLOR2 = COLOR1;
float BLOCK_WIDTH = 0.01;
void main() {
vec2 position = ( gl_FragCoord.xy / resolution.xy );
vec3 final_color = vec3(1.0);
// For creating the BG pattern
float c1 = mod(position.x, 2.0 * BLOCK_WIDTH);
c1 = step(position.x*0.01, c1);
float c2 = mod(position.y, 2.0 * BLOCK_WIDTH);
c2 = step(BLOCK_WIDTH, c2);
final_color = mix( position.x * COLOR1, position.y * COLOR2, c1 * c2);
// creating the wave
position = -1.0 + 2.0 * position;
float lineWidth = 10.0;
vec2 sPos = position ;
for( float i = 0.0; i < 13.; i++) {
sPos.y += ((0.07*cos(time)) * tan(position.x + i/5.0+ sin(time*0.5)));
lineWidth = abs(1.0 / (750.0 * sPos.y));
final_color = final_color + vec3(lineWidth * 0.9, lineWidth*1.9, lineWidth * 0.);
}
gl_FragColor = vec4(final_color, 1.0);
}
+63
View File
@@ -0,0 +1,63 @@
// Lightning
// By: Brandon Fogerty
// bfogerty at gmail dot com
// xdpixel.com
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float Hash( vec2 p)
{
vec3 p2 = vec3(p.xy,2.0);
return fract(sin(dot(p2,vec3(27.1,20.7, 2.4)))*0.5453123);
}
float noise(in vec2 p)
{
vec2 i = floor(p);
vec2 f = fract(p);
f *= f * (3.0-2.0*f);
return mix(mix(Hash(i + vec2(0.,0.)), Hash(i + vec2(1.,0.)),f.x),
mix(Hash(i + vec2(0.,1.)), Hash(i + vec2(1.,1.)),f.x),
f.y);
}
float fbm(vec2 p)
{
float v = 0.0;
v += noise(p*1.0) * .5;
v += noise(p*2.) * .25;
v += noise(p*4.) * .15;
return v;
}
void main( void )
{
vec2 uv = ( gl_FragCoord.xy / resolution.xy ) * 2.0 - 1.0;
vec2 center = vec2(0.0, 0.0);
float angle = time * 0.4;
//uv.x = cos(angle) * (uv.x - center.x) - sin(angle) * (uv.y - center.y) + center.x;
//uv.y = sin(angle) * (uv.x - center.y) + cos(angle) * (uv.y - center.y) + center.y;
vec3 finalColor = vec3( 0.0 );
for( int i=0; i < 3; ++i )
{
float t = abs( 1.4 / (sin(uv.y + fbm( uv + time * 0.04 )) * 100.0) );
finalColor += t * vec3( 2.9, 1.5, .25 );
finalColor = vec3(t);
}
gl_FragColor = vec4( finalColor, 1.0 );
}
+26
View File
@@ -0,0 +1,26 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 resolution;
#define PI 30
void main( void ) {
vec2 p = ( gl_FragCoord.xy / resolution.xy ) -0.5;
float sx = 0.3 * (p.x*p.x*5.0 - 0.7) * cos( 45.0 * p.x - 15. * pow(time*0.03, 0.7)*9.);
float dy = 9./ ( 423. * abs(p.y - sx));
dy += 11./ (200. * length(p - vec2(p.x, 0.0
)));
gl_FragColor = vec4( (p.x + 0.2
) * dy, 0.3 * dy, dy, 6.1 );
}
+98
View File
@@ -0,0 +1,98 @@
#define RAIN_SPEED 0.75 // Speed of rain droplets
#define DROP_SIZE 15.0 // Higher value lowers, the size of individual droplets
precision highp float;
uniform float time;
uniform vec2 resolution;
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
float rchar(vec2 outer, vec2 inner, float globalTime) {
//return float(rand(floor(inner * 2.0) + outer) > 0.9);
vec2 seed = floor(inner * 4.0) + outer.y;
if (rand(vec2(outer.y, 23.0)) > 0.98) {
seed += floor((globalTime + rand(vec2(outer.y, 49.0))) * 3.0);
}
return float(rand(seed) > 0.5);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 position = fragCoord.xy / resolution.xy;
vec2 uv = vec2(position.x, position.y);
position.x /= resolution.x / resolution.y;
float globalTime = time * RAIN_SPEED;
float scaledown = DROP_SIZE;
float rx = fragCoord.x / (40.0 * scaledown);
float mx = 40.0*scaledown*fract(position.x * 30.0 * scaledown);
vec4 result;
if (mx > 12.0 * scaledown) {
result = vec4(0.0);
} else
{
float x = floor(rx);
float r1x = floor(fragCoord.x / (15.0));
float ry = position.y*600.0 + rand(vec2(x, x * 3.0)) * 100000.0 + globalTime* rand(vec2(r1x, 23.0)) * 120.0;
float my = mod(ry, 15.0);
if (my > 12.0 * scaledown) {
result = vec4(0.0);
} else {
float y = floor(ry / 15.0);
float b = rchar(vec2(rx, floor((ry) / 15.0)), vec2(mx, my) / 12.0, globalTime);
float col = max(mod(-y, 24.0) - 4.0, 0.0) / 20.0;
vec3 c = col < 0.8 ? vec3(0.0, col / 0.8, 0.0) : mix(vec3(0.0, 1.0, 0.0), vec3(1.0), (col - 0.8) / 0.2);
result = vec4(c * b, 1.0) ;
}
}
position.x += 0.05;
scaledown = DROP_SIZE;
rx = fragCoord.x / (40.0 * scaledown);
mx = 40.0*scaledown*fract(position.x * 30.0 * scaledown);
if (mx > 12.0 * scaledown) {
result += vec4(0.0);
} else
{
float x = floor(rx);
float r1x = floor(fragCoord.x / (12.0));
float ry = position.y*700.0 + rand(vec2(x, x * 3.0)) * 100000.0 + globalTime* rand(vec2(r1x, 23.0)) * 120.0;
float my = mod(ry, 15.0);
if (my > 12.0 * scaledown) {
result += vec4(0.0);
} else {
float y = floor(ry / 15.0);
float b = rchar(vec2(rx, floor((ry) / 15.0)), vec2(mx, my) / 12.0, globalTime);
float col = max(mod(-y, 24.0) - 4.0, 0.0) / 20.0;
vec3 c = col < 0.8 ? vec3(0.0, col / 0.8, 0.0) : mix(vec3(0.0, 1.0, 0.0), vec3(1.0), (col - 0.8) / 0.2);
result += vec4(c * b, 1.0) ;
}
}
result = result * length(vec3(.2)) + 0.22 * vec4(0.,0.5,0.,1.);
if(result.b < 0.5)
result.b = result.g * 0.5 ;
fragColor = result;
}
void main() {
mainImage(gl_FragColor, gl_FragCoord.xy);
}
+67
View File
@@ -0,0 +1,67 @@
/*
* Original shader from: https://www.shadertoy.com/view/4dGfDy
*/
#ifdef GL_ES
precision mediump float;
#endif
// glslsandbox uniforms
uniform float time;
uniform vec2 resolution;
// shadertoy globals
#define iTime time
#define iResolution resolution
// --------[ Original ShaderToy begins here ]---------- //
float circle(vec2 uv, vec2 position, float radius, float blur) {
uv -=0.5; // position of the circle || to make (0,0) center of the screen
uv.y*=iResolution.y/iResolution.x; //to make it a circle
float d = length(uv-position);
float c = smoothstep(radius,radius-blur,d); //if(d<radius){d=1} else{d=0} and also adds blur on the edges
return c;
}
float oval(vec2 uv, vec2 position, float radius, float blur) {
uv -=0.5; // position of the circle || to make (0,0) center of the screen
float d = length(uv-position);
float c = smoothstep(radius,radius-blur,d); //if(d<radius){d=1} else{d=0} and also adds blur on the edges
return c;
}
float verticalOval(vec2 uv, vec2 position, float radius, float blur, float thickness) {
uv -=0.5;
uv.x*= uv.y+thickness;
uv.y*=iResolution.y/iResolution.x; // position of the circle || to make (0,0) center of the screen
float d = length(uv-position);
float c = smoothstep(radius,radius-blur,d); //if(d<radius){d=1} else{d=0} and also adds blur on the edges
return c;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord/iResolution.xy;
float c = circle(uv,vec2(0.),.1,.003);
float c2 = circle(uv,vec2(.1),.06,.003);
float c3 = circle(uv,vec2(-.1,.1),.06,.003);
float c4 = oval(uv,vec2(0.,-.08),.04,.005);
float c5 = oval(uv,vec2(0.025,-0.06),.04,.05);
float c6 = verticalOval(uv,vec2(-0.1,.025),.04,.005,2.5);
float c7 = verticalOval(uv,vec2(0.1,.025),.04,.005,2.5);
float c8 = oval(uv,vec2(-0.05,0.07),.015,0.006);
float c9 = oval(uv,vec2(0.03,0.07),.015,.006);
vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4));
vec3 sumAppear = vec3 (c+c2+c3+c5+c8+c9-c6-c7-c4);
vec3 makeAppear = col * sumAppear ;
fragColor = vec4(makeAppear,1.0);
}
// --------[ Original ShaderToy ends here ]---------- //
void main(void)
{
mainImage(gl_FragColor, gl_FragCoord.xy);
}
+17
View File
@@ -0,0 +1,17 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 resolution;
void main()
{
vec2 r = resolution,
o = gl_FragCoord.xy - r/2.;
o = vec2(length(o) / r.y - .35, atan(o.y,o.x));
vec4 s = .1*cos(1.6*vec4(0,1,2,3) + time + o.y + asin(sin(o.x)) * sin(time)*10.);
vec4 e = s.yzwx;
vec4 f = min(o.x-s,e-o.x);
gl_FragColor = dot(clamp(f*r.y,0.,1.), 80.*(s-e)) * (s-.1) - f;
}
+28
View File
@@ -0,0 +1,28 @@
// v!
//
#extension GL_OES_standard_derivatives : enable
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 resolution;
#define r resolution
#define t time*2.0
void main( void ) {
vec2 p= gl_FragCoord.xy/resolution.xy*2.-1.0;
vec3 n = normalize(vec3(p,p.y));
vec3 c=vec3(-cos(t)*2.*n.y, 3.*sin(t+(cos(4.*p.y))), 1.-cos(t+sin(4.*n.z)));
c.y += n.z- length(2.5*n.y*n.z)*tan(sin(50.0*n.z+n.x));
c.x -= -c.y-length(2.5*n.y*n.z)*tan(sin(50.0*n.z+n.x));
c.z *= -c.x*length(2.5*n.y*n.z)*tan(sin(50.0*n.z+n.x));
gl_FragColor=vec4(c*0.8, 1.0);
}
+50
View File
@@ -0,0 +1,50 @@
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.14159265359
#define TWO_PI 6.28318530718
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
vec3 hsb2rgb( in vec3 c ){
vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),
6.0)-3.0)-1.0,
0.0,
1.0 );
rgb = rgb*rgb*(3.0-2.0*rgb);
return c.z * mix(vec3(1.0), rgb, c.y);
}
vec3 rgb2hsb( in vec3 c ){
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz),
vec4(c.gb, K.xy),
step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r),
vec4(c.r, p.yzx),
step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)),
d / (q.x + e),
q.x);
}
void main() {
vec2 st = (gl_FragCoord.xy*2.0-resolution)/min(resolution.x,resolution.y);
vec2 pq = gl_FragCoord.xy/resolution;
vec3 color=vec3(1.);
vec2 toCenter=st;
float angle=atan(toCenter.y,toCenter.x)/TWO_PI;
float radius=length(toCenter);
//color=hsb2rgb(vec3((angle/TWO_PI)+.5,1.,1.));
color = hsb2rgb(vec3((angle)+fract(time*2.),radius,1.0));
float circle = (0.03) / abs(0.6 - length(st));
color = color * circle;
gl_FragColor = vec4(color,1.0);
}
+24
View File
@@ -0,0 +1,24 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main()
{
vec2 r = resolution,o = gl_FragCoord.xy - r / 2.00;
o = vec2(max(abs(o.x) * 0.8996 + o.y * 0.5, -o.y) * 2.0 / r.y - 0.25, atan(o.y,o.x));
vec4 s = 0.07 * sin(1.5 * vec4(1,2,3,4) + 2.0 * time / 90.0 + o.y + sin(time) * 1.75),
e = s.yzwx,
f = max(o.x - s-0.1, e-o.x);
gl_FragColor = dot(clamp(f*r.y,0.,1.), 82.*(s-e)) * (s-.1)*1.5 ;
}
+47
View File
@@ -0,0 +1,47 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
//uniform vec2 mouse;
uniform vec2 resolution;
// bonniemathew@gmail.com
//vec3 COLOR1 = vec3(0.0, 0.0, 0.50);
//vec3 COLOR2 = vec3(0.30, .0, 0.0);
const vec3 COLOR1 = vec3(0.0, 0.0, 0.0);
vec3 COLOR2 = COLOR1;
float BLOCK_WIDTH = 0.01;
void main( void ) {
vec2 position = ( gl_FragCoord.xy / resolution.xy );
vec3 final_color = vec3(1.0);
// For creating the BG pattern
float c1 = mod(position.x, 2.0 * BLOCK_WIDTH);
c1 = step(position.x*0.01, c1);
float c2 = mod(position.y, 2.0 * BLOCK_WIDTH);
c2 = step(BLOCK_WIDTH, c2);
final_color = mix( position.x * COLOR1, position.y * COLOR2, c1 * c2);
// creating the wave
position = -1.0 + 2.0 * position;
float lineWidth = 10.0;
vec2 sPos = position ;
for( float i = 0.0; i < 13.; i++) {
sPos.y += ((0.07*cos(time)) * tan(position.x + i/5.0+ sin(time*0.5)));
lineWidth = abs(1.0 / (750.0 * sPos.y));
final_color = final_color + vec3(lineWidth * 1.9f, lineWidth*0.0f, lineWidth * 0.);
}
gl_FragColor = vec4(final_color, 1.0);
}
+90
View File
@@ -0,0 +1,90 @@
//pastel psx/dreamcast thingy
// @samloeschen
#ifdef GL_ES
precision mediump float;
#endif
#define M_PI 3.1415926535897932384626433832795
uniform float time;
uniform vec2 resolution;
// 2D Random
float random (in vec2 st) {
return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);
}
// 2D Noise based on Morgan McGuire @morgan3d
// https://www.shadertoy.com/view/4dS3Wd
float noise (in vec2 st) {
vec2 i = floor(st);
vec2 f = fract(st);
// Four corners in 2D of a tile
float a = random(i);
float b = random(i + vec2(1.0, 0.0));
float c = random(i + vec2(0.0, 1.0));
float d = random(i + vec2(1.0, 1.0));
// Smooth Interpolation
// Cubic Hermine Curve. Same as SmoothStep()
vec2 u = f*f*(3.0-2.0*f);
// u = smoothstep(0.,1.,f);
// Mix 4 coorners porcentages
return mix(a, b, u.x) +
(c - a)* u.y * (1.0 - u.x) +
(d - b) * u.x * u.y;
}
bool boxtest (in vec2 p, in vec2 circle, in float w) {
return p.x - w < circle.x && p.x + w > circle.x && p.y - w < circle.y && p.y + w > circle.y;
}
vec3 palette (in float t) {
vec3 a = vec3(0.93,0.43,0.76);
vec3 b = vec3(0.90,0.31,0.24);
vec3 c = vec3(0.41,0.93,1.0);
vec3 d = vec3(0,0.44,0.32);
return a + b*cos( 2.0*M_PI*(c*t+d) );
}
vec3 drawCircle (in vec2 p, in vec2 circle, in vec3 setting) {
if(boxtest(p, circle, setting.x) && !(boxtest(p, circle, setting.x - setting.y)))
return palette(setting.z / 70.0 + time * 0.1);
return vec3(0.0);
}
void main (void) {
vec2 uv = (gl_FragCoord.xy / resolution.xy);
vec2 aspect = resolution.xy / min(resolution.x, resolution.y);
vec2 center = vec2(0.5);
vec2 pos = uv - center;
float horizon = 0.03*cos(time); //lil motion here
float fov = -0.5; //if we negate fov the box has a better palette relationship with the planes
vec3 p = vec3(pos.x, fov, pos.y - horizon);
float scroll = (time * -sign(p.z));
float bump = noise((vec2(p.x + 100., p.y) * 20.)) * 0.1;
vec2 s = vec2(p.x/p.z, p.y/p.z + bump + scroll) * 0.1; //actual plane position
bool grid = (fract(s.y / 0.02) > 0.95) || (fract(s.x / 0.02) > 0.95);
vec3 gridColor = (mix(palette(s.y + bump * 0.5), vec3(1.0), float(grid)));
gridColor = mix(gridColor, vec3(1.0), 0.3); //slight desaturate and boost
float fog = pow(sin(uv.y * M_PI), 5.);
vec3 color = mix(gridColor, vec3(1.0), fog);
float a = sin(time) * 0.6; //box angle
mat2 rot = mat2(cos(a), -sin(a), sin(a), cos(a));
pos = uv * aspect * rot;
center *= aspect * rot;
for(int i = 0; i < 50; i++) {
vec3 d = drawCircle(pos, center + vec2(sin(float(i) / 10.0 + time) / 4.0, 0.0), vec3(0.0 + sin(float(i) / 200.0), 0.01 , float(i)));
if(d.x > 0.) color = mix(d, vec3(1.0), 0.3); //slight desaturate and boost
}
gl_FragColor = vec4(color, 1.0);
}
+132
View File
@@ -0,0 +1,132 @@
/*
* License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
* Created by bal-khan
*/
precision highp float;
uniform float time;
uniform vec2 resolution;
vec2 march(vec3 pos, vec3 dir);
vec3 camera(vec2 uv);
void rotate(inout vec2 v, float angle);
float t; // time
vec3 ret_col; // torus color
vec3 h; // light amount
#define I_MAX 400.
#define E 0.00001
#define FAR 50.
#define PI 3.14
// blackbody by aiekick : https://www.shadertoy.com/view/lttXDn
// -------------blackbody----------------- //
// return color from temperature
//http://www.physics.sfasu.edu/astro/color/blackbody.html
//http://www.vendian.org/mncharity/dir3/blackbody/
//http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html
vec3 blackbody(float Temp)
{
vec3 col = vec3(255.);
col.x = 56100000. * pow(Temp,(-3. / 2.)) + 148.;
col.y = 100.04 * log(Temp) - 623.6;
if (Temp > 6500.) col.y = 35200000. * pow(Temp,(-3. / 2.)) + 184.;
col.z = 194.18 * log(Temp) - 1448.6;
col = clamp(col, 0., 255.)/255.;
if (Temp < 1000.) col *= Temp/1000.;
return col;
}
// -------------blackbody----------------- //
void mainImage(out vec4 c_out, in vec2 f)
{
t = time*.125;
vec3 col = vec3(0., 0., 0.);
vec2 R = resolution.xy,
uv = vec2(f-R/2.) / R.y;
vec3 dir = camera(uv);
vec3 pos = vec3(.0, .0, 0.0);
pos.z = 4.5+1.5*sin(t*10.);
h*=0.;
vec2 inter = (march(pos, dir));
col.xyz = ret_col*(1.-inter.x*.0125);
col += h * .4;
c_out = vec4(col,1.0);
}
void main() {
mainImage(gl_FragColor, gl_FragCoord.xy);
}
float scene(vec3 p)
{
float var;
float mind = 1e5;
p.z += 10.;
rotate(p.xz, 1.57-.5*time );
rotate(p.yz, 1.57-.5*time );
var = atan(p.x,p.y);
vec2 q = vec2( ( length(p.xy) )-6.,p.z);
rotate(q, var*.25+time*2.*0.);
vec2 oq = q ;
q = abs(q)-2.5;
if (oq.x < q.x && oq.y > q.y)
rotate(q, ( (var*1.)+time*0.)*3.14+time*0.);
else
rotate(q, ( .28-(var*1.)+time*0.)*3.14+time*0.);
float oldvar = var;
ret_col = 1.-vec3(.350, .2, .3);
mind = length(q)+.5+1.05*(length(fract(q*.5*(3.+3.*sin(oldvar*1. - time*2.)) )-.5)-1.215);
h -= vec3(-3.20,.20,1.0)*vec3(1.)*.0025/(.051+(mind-sin(oldvar*1. - time*2. + 3.14)*.125 )*(mind-sin(oldvar*1. - time*2. + 3.14)*.125 ) );
h -= vec3(1.20,-.50,-.50)*vec3(1.)*.025/(.501+(mind-sin(oldvar*1. - time*2.)*.5 )*(mind-sin(oldvar*1. - time*2.)*.5 ) );
h += vec3(.25, .4, .5)*.0025/(.021+mind*mind);
return (mind);
}
vec2 march(vec3 pos, vec3 dir)
{
vec2 dist = vec2(0.0, 0.0);
vec3 p = vec3(0.0, 0.0, 0.0);
vec2 s = vec2(0.0, 0.0);
for (float i = -1.; i < I_MAX; ++i)
{
p = pos + dir * dist.y;
dist.x = scene(p);
dist.y += dist.x*.2; // makes artefacts disappear
// log trick by aiekick
if (log(dist.y*dist.y/dist.x/1e5) > .0 || dist.x < E || dist.y > FAR)
{
break;
}
s.x++;
}
s.y = dist.y;
return (s);
}
// Utilities
void rotate(inout vec2 v, float angle)
{
v = vec2(cos(angle)*v.x+sin(angle)*v.y,-sin(angle)*v.x+cos(angle)*v.y);
}
vec3 camera(vec2 uv)
{
float fov = 1.;
vec3 forw = vec3(0.0, 0.0, -1.0);
vec3 right = vec3(1.0, 0.0, 0.0);
vec3 up = vec3(0.0, 1.0, 0.0);
return (normalize((uv.x) * right + (uv.y) * up + fov * forw));
}
+132
View File
@@ -0,0 +1,132 @@
/*
* License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
* Created by bal-khan
*/
precision highp float;
uniform float time;
uniform vec2 resolution;
vec2 march(vec3 pos, vec3 dir);
vec3 camera(vec2 uv);
void rotate(inout vec2 v, float angle);
float t; // time
vec3 ret_col; // torus color
vec3 h; // light amount
#define I_MAX 30.
#define E 0.00001
#define FAR 50.
#define PI 3.14
// blackbody by aiekick : https://www.shadertoy.com/view/lttXDn
// -------------blackbody----------------- //
// return color from temperature
//http://www.physics.sfasu.edu/astro/color/blackbody.html
//http://www.vendian.org/mncharity/dir3/blackbody/
//http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html
vec3 blackbody(float Temp)
{
vec3 col = vec3(255.);
col.x = 56100000. * pow(Temp,(-3. / 2.)) + 148.;
col.y = 100.04 * log(Temp) - 623.6;
if (Temp > 6500.) col.y = 35200000. * pow(Temp,(-3. / 2.)) + 184.;
col.z = 194.18 * log(Temp) - 1448.6;
col = clamp(col, 0., 255.)/255.;
if (Temp < 1000.) col *= Temp/1000.;
return col;
}
// -------------blackbody----------------- //
void mainImage(out vec4 c_out, in vec2 f)
{
t = time*.125;
vec3 col = vec3(0., 0., 0.);
vec2 R = resolution.xy,
uv = vec2(f-R/2.) / R.y;
vec3 dir = camera(uv);
vec3 pos = vec3(.0, .0, 0.0);
pos.z = 4.5+1.5*sin(t*10.);
h*=0.;
vec2 inter = (march(pos, dir));
col.xyz = ret_col*(1.-inter.x*.0125);
col += h * .4;
c_out = vec4(col,1.0);
}
void main() {
mainImage(gl_FragColor, gl_FragCoord.xy);
}
float scene(vec3 p)
{
float var;
float mind = 1e5;
p.z += 20.;
rotate(p.xz, 1.57-.5*time );
rotate(p.yz, 1.57-.5*time );
var = atan(p.x,p.y);
vec2 q = vec2( ( length(p.xy) )-6.,p.z);
rotate(q, var*.25+time*2.*0.);
vec2 oq = q ;
q = abs(q)-2.5;
if (oq.x < q.x && oq.y > q.y)
rotate(q, ( (var*1.)+time*0.)*3.14+time*0.);
else
rotate(q, ( .28-(var*1.)+time*0.)*3.14+time*0.);
float oldvar = var;
ret_col = 1.-vec3(.350, .2, .3);
mind = length(q)+.5+1.05*(length(fract(q*.5*(3.+3.*sin(oldvar*1. - time*2.)) )-.5)-1.215);
h -= vec3(-3.20,.20,1.0)*vec3(1.)*.0025/(.051+(mind-sin(oldvar*1. - time*2. + 3.14)*.125 )*(mind-sin(oldvar*1. - time*2. + 3.14)*.125 ) );
h -= vec3(1.20,-.50,-.50)*vec3(1.)*.025/(.501+(mind-sin(oldvar*1. - time*2.)*.5 )*(mind-sin(oldvar*1. - time*2.)*.5 ) );
h += vec3(.25, .4, .5)*.0025/(.021+mind*mind);
return (mind);
}
vec2 march(vec3 pos, vec3 dir)
{
vec2 dist = vec2(0.0, 0.0);
vec3 p = vec3(0.0, 0.0, 0.0);
vec2 s = vec2(0.0, 0.0);
for (float i = -1.; i < I_MAX; ++i)
{
p = pos + dir * dist.y;
dist.x = scene(p);
dist.y += dist.x*.6; // makes artefacts disappear
// log trick by aiekick
if (log(dist.y*dist.y/dist.x/1e5) > .0 || dist.x < E || dist.y > FAR)
{
break;
}
s.x++;
}
s.y = dist.y;
return (s);
}
// Utilities
void rotate(inout vec2 v, float angle)
{
v = vec2(cos(angle)*v.x+sin(angle)*v.y,-sin(angle)*v.x+cos(angle)*v.y);
}
vec3 camera(vec2 uv)
{
float fov = 1.;
vec3 forw = vec3(0.0, 0.0, -1.0);
vec3 right = vec3(1.0, 0.0, 0.0);
vec3 up = vec3(0.0, 1.0, 0.0);
return (normalize((uv.x) * right + (uv.y) * up + fov * forw));
}
+159
View File
@@ -0,0 +1,159 @@
/*
* License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
*
* Created by wj just by playing with the formula of the original version
*
* here: https://www.shadertoy.com/view/lt2fDz created by bal-khan
*
* (and by adding some music..=
*/
precision highp float;
uniform float time;
uniform vec2 resolution;
float iTime;
vec2 iResolution;
vec2 march(vec3 pos, vec3 dir);
vec3 camera(vec2 uv);
void rotate(inout vec2 v, float angle);
float t; // time
vec3 ret_col; // torus color
vec3 h; // light amount
#define I_MAX 400.
#define E 0.00001
#define FAR 50.
#define PI 3.14
// blackbody by aiekick : https://www.shadertoy.com/view/lttXDn
// -------------blackbody----------------- //
// return color from temperature
//http://www.physics.sfasu.edu/astro/color/blackbody.html
//http://www.vendian.org/mncharity/dir3/blackbody/
//http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html
vec3 blackbody(float Temp)
{
vec3 col = vec3(255.);
col.x = 56100000. * pow(Temp,(-3. / 2.)) + 148.;
col.y = 100.04 * log(Temp) - 623.6;
if (Temp > 6500.) col.y = 35200000. * pow(Temp,(-3. / 2.)) + 184.;
col.z = 194.18 * log(Temp) - 1448.6;
col = clamp(col, 0., 255.)/255.;
if (Temp < 1000.) col *= Temp/1000.;
return col;
}
// -------------blackbody----------------- //
void mainImage(out vec4 c_out, in vec2 f)
{
t = iTime*.125;
vec3 col = vec3(0., 0., 0.);
vec2 R = iResolution.xy,
uv = vec2(f-R/2.) / R.y;
vec3 dir = camera(uv);
vec3 pos = vec3(.0, .0, 0.0);
pos.z = 4.5+1.5*sin(t*10.); // add camera movement
h*=0.;
vec2 inter = (march(pos, dir));
col.xyz = ret_col*(1.-inter.x*.0125);
col += h * .4;
c_out = vec4(col,1.0);
}
void main() {
iTime = time;
iResolution = resolution;
mainImage(gl_FragColor, gl_FragCoord.xy);
}
float scene(vec3 p)
{
float var;
float mind = 1e5;
// overall object placement
p.z += 25.;
rotate(p.xz, 1.57-.5*iTime );
rotate(p.yz, 1.57-.5*iTime );
var = atan(p.x,p.y);
vec2 q = vec2( ( length(p.xy) )-9.,p.z);
float ttwists=0.75;
rotate(q, var*ttwists+iTime*0.4);
vec2 oq = q ;
q = abs(q)-vec2(3.,3.)-sin(q)*7.; // add some twists
float twist= 3.3; // twists the "blue" strands
float s= iTime*1.; // add "movement speed" to the "blue" strands
if (oq.x < q.x && oq.y > q.y){
rotate(q, ( (var*twist)+s)*3.14+s);
}else{
rotate(q, ( 0.28-(var*twist)+s)*3.14+s);
}
float oldvar = var;
ret_col = 1.-vec3(.350, .2, .3);
q=q*0.2;
mind = length(q)+.5+1.05*(length(fract(q*.5*(3.+3.*sin(oldvar*1. - iTime*1.)) )-.5)-1.215);
// only the coloring:
h -= vec3(-3.20,.20,1.0)*vec3(1.)*.0025/(.051+(mind-sin(oldvar*1. - iTime*2. + 3.14)*.125 )*(mind-sin(oldvar*1. - iTime*2. + 3.14)*.125 ) );
h -= vec3(1.20,-.50,-.50)*vec3(1.)*.025/(.501+(mind-sin(oldvar*1. - iTime*2.)*.5 )*(mind-sin(oldvar*1. - iTime*2.)*.5 ) );
h += vec3(.25, .4, .5)*.0025/(.021+mind*mind);
// add some music feedback
return (mind);
}
vec2 march(vec3 pos, vec3 dir)
{
vec2 dist = vec2(0.0, 0.0);
vec3 p = vec3(0.0, 0.0, 0.0);
vec2 s = vec2(0.0, 0.0);
for (float i = -1.; i < I_MAX; ++i)
{
p = pos + dir * dist.y;
dist.x = scene(p);
dist.y += dist.x*.2; // makes artefacts disappear
// log trick by aiekick
if (log(dist.y*dist.y/dist.x/1e5) > .0 || dist.x < E || dist.y > FAR)
{
break;
}
s.x++;
}
s.y = dist.y;
return (s);
}
// Utilities
void rotate(inout vec2 v, float angle)
{
v = vec2(cos(angle)*v.x+sin(angle)*v.y,-sin(angle)*v.x+cos(angle)*v.y);
}
vec3 camera(vec2 uv)
{
float fov = 1.;
vec3 forw = vec3(0.0, 0.0, -1.0);
vec3 right = vec3(1.0, 0.0, 0.0);
vec3 up = vec3(0.0, 1.0, 0.0);
return (normalize((uv.x) * right + (uv.y) * up + fov * forw));
}
+177
View File
@@ -0,0 +1,177 @@
#ifdef GL_ES
precision highp float; // ios
#endif
uniform float time;
// uniform vec2 mouse;
#define mouse vec2(time* 0.0, time * 0.0)
uniform vec2 resolution;
#define iterations 12
#define formuparam2 0.79
#define volsteps 7
#define stepsize 0.290
#define zoom 1.0
#define tile 0.850
#define speed2 0.2
#define brightness 0.0015
#define darkmatter 0.100
#define distfading 0.560
#define saturation 0.90
#define transverseSpeed zoom
#define cloud 0.17
float triangle(float x, float a) {
float output2 = 2.0*abs( 3.0* ( (x/a) - floor( (x/a) + 0.5) ) ) - 1.0;
return output2;
}
float field(in vec3 p) {
float strength = 7. + .03 * log(1.e-6 + fract(sin(time) * 373.11));
float accum = 0.;
float prev = 0.;
float tw = 0.;
for (int i = 0; i < 6; ++i) {
float mag = dot(p, p);
p = abs(p) / mag + vec3(-.5, -.8 + 0.1*sin(-time*0.1 + 2.0), -1.1+0.3*cos(time*0.3));
float w = exp(-float(i) / 7.);
accum += w * exp(-strength * pow(abs(mag - prev), 2.3));
tw += w;
prev = mag;
}
return max(0., 5. * accum / tw - .7);
}
void main() {
vec2 uv2 = 2. * gl_FragCoord.xy / vec2(512) - 1.;
vec2 uvs = uv2 * vec2(512) / 512.;
float time2 = time;
float speed = -speed2;
speed = .005 * cos(time2*0.02 + 3.1415926/4.0);
//speed = 0.0;
float formuparam = formuparam2;
//get coords and direction
vec2 uv = uvs;
//mouse rotation
float a_xz = 0.9;
float a_yz = -.6;
float a_xy = 0.9 + time*0.08;
mat2 rot_xz = mat2(cos(a_xz),sin(a_xz),-sin(a_xz),cos(a_xz));
mat2 rot_yz = mat2(cos(a_yz),sin(a_yz),-sin(a_yz),cos(a_yz));
mat2 rot_xy = mat2(cos(a_xy),sin(a_xy),-sin(a_xy),cos(a_xy));
float v2 =1.0;
vec3 dir=vec3(uv*zoom,1.);
vec3 from=vec3(0.0, 0.0,0.0);
from.x -= 2.0*(mouse.x-0.5);
from.y -= 2.0*(mouse.y-0.5);
vec3 forward = vec3(0.,0.,1.);
from.x += transverseSpeed*(1.0)*cos(0.01*time) + 0.001*time;
from.y += transverseSpeed*(1.0)*sin(0.01*time) +0.001*time;
from.z += 0.003*time;
dir.xy*=rot_xy;
forward.xy *= rot_xy;
dir.xz*=rot_xz;
forward.xz *= rot_xz;
dir.yz*= rot_yz;
forward.yz *= rot_yz;
from.xy*=-rot_xy;
from.xz*=rot_xz;
from.yz*= rot_yz;
//zoom
float zooom = (time2-3311.)*speed;
from += forward* zooom;
float sampleShift = mod( zooom, stepsize );
float zoffset = -sampleShift;
sampleShift /= stepsize; // make from 0 to 1
//volumetric rendering
float s=0.24;
float s3 = s + stepsize/2.0;
vec3 v=vec3(0.);
float t3 = 0.0;
vec3 backCol2 = vec3(0.);
for (int r=0; r<volsteps; r++) {
vec3 p2=from+(s+zoffset)*dir;// + vec3(0.,0.,zoffset);
vec3 p3=from+(s3+zoffset)*dir;// + vec3(0.,0.,zoffset);
p2 = abs(vec3(tile)-mod(p2,vec3(tile*2.))); // tiling fold
p3 = abs(vec3(tile)-mod(p3,vec3(tile*2.))); // tiling fold
#ifdef cloud
t3 = field(p3);
#endif
float pa,a=pa=0.;
for (int i=0; i<iterations; i++) {
p2=abs(p2)/dot(p2,p2)-formuparam; // the magic formula
//p=abs(p)/max(dot(p,p),0.005)-formuparam; // another interesting way to reduce noise
float D = abs(length(p2)-pa); // absolute sum of average change
a += i > 7 ? min( 12., D) : D;
pa=length(p2);
}
//float dm=max(0.,darkmatter-a*a*.001); //dark matter
a*=a*a; // add contrast
//if (r>3) fade*=1.-dm; // dark matter, don't render near
// brightens stuff up a bit
float s1 = s+zoffset;
// need closed form expression for this, now that we shift samples
float fade = pow(distfading,max(0.,float(r)-sampleShift));
//t3 += fade;
v+=fade;
//backCol2 -= fade;
// fade out samples as they approach the camera
if( r == 0 )
fade *= (1. - (sampleShift));
// fade in samples as they approach from the distance
if( r == volsteps-1 )
fade *= sampleShift;
v+=vec3(s1,s1*s1,s1*s1*s1*s1)*a*brightness*fade; // coloring based on distance
backCol2 += mix(.4, 1., v2) * vec3(1.8 * t3 * t3 * t3, 1.4 * t3 * t3, t3) * fade;
s+=stepsize;
s3 += stepsize;
}//фор
v=mix(vec3(length(v)),v,saturation); //color adjust
vec4 forCol2 = vec4(v*.01,1.);
#ifdef cloud
backCol2 *= cloud;
#endif
backCol2.b *= 1.8;
backCol2.r *= 0.05;
backCol2.b = 0.5*mix(backCol2.g, backCol2.b, 0.8);
backCol2.g = 0.0;
backCol2.bg = mix(backCol2.gb, backCol2.bg, 0.5*(cos(time*0.01) + 1.0));
gl_FragColor = forCol2 + vec4(backCol2, 1.0);
}
+47
View File
@@ -0,0 +1,47 @@
/*
@machine_shaman
*/
#extension GL_OES_standard_derivatives : enable
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
mat2 rotate(float a) {
float c = cos(a);
float s = sin(a);
return mat2(c, -s, s, c);
}
void main() {
vec2 uv = (2. * gl_FragCoord.xy - resolution) / resolution.y;
vec3 col = vec3(0.);
vec3 ro = vec3(0.0, 0.0, -3.0);
vec3 rd = vec3(uv, 1.0);
vec3 p = vec3(0.0);
float t = 0.;
for (int i = 0; i < 64; i++) {
p = ro + rd * t;
p.xz *= rotate(p.y * 6.28 * 0.5 + time * 0.5);
vec2 q = vec2(length(p.xy) - 1., p.z);
float d = length(q) - .1;
d = min(d, length(p.xz) - (.3 - .2 * sin(time + p.y * 6.28 * 0.5)));
t += 0.5 * d;
col += .15 / (1. + t * t * t * 0.8);
}
gl_FragColor = vec4(col, 1.);
}
+137
View File
@@ -0,0 +1,137 @@
precision highp float;
/*
* License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
* Created by bal-khan
*/
uniform float time;
uniform vec2 resolution;
float iTime;
vec2 iResolution;
vec2 march(vec3 pos, vec3 dir);
vec3 camera(vec2 uv);
void rotate(inout vec2 v, float angle);
float t; // time
vec3 ret_col; // torus color
vec3 h; // light amount
#define I_MAX 400.
#define E 0.00001
#define FAR 50.
#define PI 3.14
// blackbody by aiekick : https://www.shadertoy.com/view/lttXDn
// -------------blackbody----------------- //
// return color from temperature
//http://www.physics.sfasu.edu/astro/color/blackbody.html
//http://www.vendian.org/mncharity/dir3/blackbody/
//http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html
vec3 blackbody(float Temp)
{
vec3 col = vec3(255.);
col.x = 56100000. * pow(Temp,(-3. / 2.)) + 148.;
col.y = 100.04 * log(Temp) - 623.6;
if (Temp > 6500.) col.y = 35200000. * pow(Temp,(-3. / 2.)) + 184.;
col.z = 194.18 * log(Temp) - 1448.6;
col = clamp(col, 0., 255.)/255.;
if (Temp < 1000.) col *= Temp/1000.;
return col;
}
// -------------blackbody----------------- //
void mainImage(out vec4 c_out, in vec2 f)
{
t = iTime*.125;
vec3 col = vec3(0., 0., 0.);
vec2 R = iResolution.xy,
uv = vec2(f-R/2.) / R.y;
vec3 dir = camera(uv);
vec3 pos = vec3(.0, .0, 0.0);
pos.z = 4.5+1.5*sin(t*10.);
h*=0.;
vec2 inter = (march(pos, dir));
col.xyz = ret_col*(1.-inter.x*.0125);
col += h * .4;
c_out = vec4(col,1.0);
}
void main() {
iTime = time;
iResolution = resolution;
mainImage(gl_FragColor, gl_FragCoord.xy);
}
float scene(vec3 p)
{
float var;
float mind = 1e5;
p.z += 10.;
rotate(p.xz, 1.57-.5*iTime );
rotate(p.yz, 1.57-.5*iTime );
var = atan(p.x,p.y);
vec2 q = vec2( ( length(p.xy) )-6.,p.z);
rotate(q, var*.25+iTime*2.*0.);
vec2 oq = q ;
q = abs(q)-2.5;
if (oq.x < q.x && oq.y > q.y)
rotate(q, ( (var*1.)+iTime*0.)*3.14+iTime*0.);
else
rotate(q, ( .28-(var*1.)+iTime*0.)*3.14+iTime*0.);
float oldvar = var;
ret_col = 1.-vec3(.350, .2, .3);
mind = length(q)+.5+1.05*(length(fract(q*.5*(3.+3.*sin(oldvar*1. - iTime*2.)) )-.5)-1.215);
h -= vec3(-3.20,.20,1.0)*vec3(1.)*.0025/(.051+(mind-sin(oldvar*1. - iTime*2. + 3.14)*.125 )*(mind-sin(oldvar*1. - iTime*2. + 3.14)*.125 ) );
h -= vec3(1.20,-.50,-.50)*vec3(1.)*.025/(.501+(mind-sin(oldvar*1. - iTime*2.)*.5 )*(mind-sin(oldvar*1. - iTime*2.)*.5 ) );
h += vec3(.25, .4, .5)*.0025/(.021+mind*mind);
return (mind);
}
vec2 march(vec3 pos, vec3 dir)
{
vec2 dist = vec2(0.0, 0.0);
vec3 p = vec3(0.0, 0.0, 0.0);
vec2 s = vec2(0.0, 0.0);
for (float i = -1.; i < I_MAX; ++i)
{
p = pos + dir * dist.y;
dist.x = scene(p);
dist.y += dist.x*.2; // makes artefacts disappear
// log trick by aiekick
if (log(dist.y*dist.y/dist.x/1e5) > .0 || dist.x < E || dist.y > FAR)
{
break;
}
s.x++;
}
s.y = dist.y;
return (s);
}
// Utilities
void rotate(inout vec2 v, float angle)
{
v = vec2(cos(angle)*v.x+sin(angle)*v.y,-sin(angle)*v.x+cos(angle)*v.y);
}
vec3 camera(vec2 uv)
{
float fov = 1.;
vec3 forw = vec3(0.0, 0.0, -1.0);
vec3 right = vec3(1.0, 0.0, 0.0);
vec3 up = vec3(0.0, 1.0, 0.0);
return (normalize((uv.x) * right + (uv.y) * up + fov * forw));
}
+121
View File
@@ -0,0 +1,121 @@
#extension GL_OES_standard_derivatives : enable
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
const float PI = 3.14159265;
mat2 rot(float a){
float c = cos(a),s = sin(a);
return mat2(c,s,-s,c);
}
mat3 rot3D(float a){
float c = cos(a),s = sin(a);
return mat3(c,-s,0.,
s,c,0.,
0.,0.,1.0);
}
float sphere(vec3 p){
return length(p)-0.5;
}
float deMengerSponge2(vec3 p, vec3 offset, float scale) {
vec4 z = vec4(p, 1.0);
for (int i = 0; i < 10; i++) {
z = abs(z);
if (z.x < z.y) z.xy = z.yx;
if (z.x < z.z) z.xz = z.zx;
if (z.y < z.z) z.yz = z.zy;
z *= scale;
z.xyz -= offset * (scale - 1.0);
if (z.z < -0.5 * offset.z * (scale - 1.0))
z.z += offset.z * (scale - 1.0);
}
return (length(max(abs(z.xyz) - vec3(1.0, 1.0, 1.0), 0.0))) / z.w;
}
float de(vec3 p) {
p.xy *= rot(time);
p.yz *= rot(time);
return deMengerSponge2(p, vec3(1.0), 3.0);
}
float dist(vec3 p){
float d = de(p);
//p.xy = vec2(0.0);
p.xyz *= rot3D(time);
p = abs(p);
for(int i = 0; i < 10; i++){
//p.xy = mod(p.xy,4.0);
p.xzy *= rot3D(0.3);
p.xyz *= rot3D(0.3);
p.yz = mod(p.yz,2.0);
}
p.xyz *= rot3D(sin(time));
d = min(d,sphere(p));
return d;
}
vec3 getnormal(vec3 p){
float d = 0.0001;
return normalize(vec3(
dist(p+vec3(d,0.,0.))-dist(p+vec3(-d,0.,0.)),
dist(p+vec3(0.,d,0.))-dist(p+vec3(0.,-d,0.)),
dist(p+vec3(0.,0.,d))-dist(p+vec3(0.,0.,-d))
));
}
void main( void ) {
vec2 p = ( gl_FragCoord.xy *2.0 -resolution ) / min(resolution.x,resolution.y);
float angle = 60.0;
float fov = angle * 0.5 * PI/180.0;
vec3 cPos = vec3(0.0,0.0,4.0);
vec3 LightDir = vec3(-0.577,0.577,0.577);
vec3 ray = normalize(vec3(sin(fov)*p.x,sin(fov)*p.y,-cos(fov)));
vec2 d = vec2(float(0.0));
float rLen = 0.0;
vec3 rPos = cPos;
for(int i = 0; i <99; i++){
d.x = dist(rPos);
d.y = de(rPos);
rLen +=d.x;
rPos = rLen*ray+cPos;
}
if(abs(d.x)<0.001){
vec3 normal = getnormal(rPos);
float diff = clamp(dot(normal,LightDir),0.2,1.0);
gl_FragColor = vec4( vec3(cos(time)*diff*cos(time)+0.5,cos(time)+0.5*diff,sin(time)*diff+0.5),1.0);
if(abs(d.y)<0.001){
gl_FragColor = vec4(vec3(diff*ray*cos(time)+0.25),1.0);
}
}else{
gl_FragColor = vec4( vec3(0.0),1.0);
}
}
+76
View File
@@ -0,0 +1,76 @@
#extension GL_OES_standard_derivatives : enable
#ifdef GL_ES
precision highp float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
const float PI = 3.141592653589793;
const float PI2 = PI* 2.;
#define saturate(x) clamp(x,0.,1.)
float tri(float x){return abs(2.*fract(x*.5-.25)-1.)*2.-1.;}
float sqr(float x){return -2.*(step(.5,fract(x*.5))-.5);}
float circuit(float x){return clamp(tri(x*4.)*.25,(sqr(x)-1.)*.5,(sqr(x+.5)+1.)*.5);}
float circuit2(float x){return clamp(tri(x*.5)*.5,0.,.25);}
float flow(float x,float d){return (1.+sin(x+d*time*5.+3.))*.3+.3;}
vec2 pp(vec2 p){float r=.5/p.y;return vec2(p.x*r, r);}
void main(void){
float t=floor(time * 0.8 *30.)/15.;
vec2 p = ( gl_FragCoord.xy - resolution.xy*.5 ) / resolution.x;
vec2 p2 = p;
vec3 color;
vec3 light_color = vec3(1,0.6,1.0);
float k = mix(fract(-p.y), 1.0, step(0., -p.y));
if (p.y > 10.0) {
} else {
float l=0.,d=sign(p.y);
vec2 r = p;
vec2 q = p;
q=pp(q);
float n = floor(q.x/.5);
q.x=mod(q.x,.5)-.25;
p=pp(p);
l+=step(abs(q.x+circuit(q.y+sign(p.y)*t+n)),.005);
l+=pow(.001/abs(p.x+circuit(p.y+d*t)),flow(p.y,d));
l+=pow(.001/abs(p.x+.75+circuit2(p.y+d*t)),(1.+sin(p.y+d*time*5.))*.3+.3);
l+=pow(.001/abs(p.x-.75+circuit2(p.y+d*t)),(1.+sin(p.y+d*time*5.))*.3+.3);
l=saturate(l);
l*=abs(r.y*2.);
l*=abs(sin(r.y*200.+sign(p.y)*time*5.))*.5+.5;
l+=pow(.001/abs(p.x+circuit(p.x+d*time)),(1.+sin(p.x+d*time*5.+3.))*.3+.3);
//l+=pow(.001/abs(p.x+circuit(p.x+d*time + 0.3)),(1.+sin(p.x+d*time*5.+3.))*.3+.3);
color = vec3(l) - vec3(.2, .4, 0.);
color *= k;
}
float angle = atan(p2.y,p2.x)/(2.*3.14159265359);
angle -= floor(angle);
float rad = length(p2);
float c = 0.1;
float brightness = 0.012;
float speed = 0.8;
for (int i = 0; i < 1; ++i){
float angleRnd = floor(angle*14.)+1.;
float angleRnd1 = fract(angleRnd*fract(angleRnd*.7235)*45.1);
float angleRnd2 = fract(angleRnd*fract(angleRnd*.82657)*13.724);
float t = t*speed + angleRnd1*10.;
float radDist = sqrt(angleRnd2+float(i));
float adist = radDist/rad*.1;
float dist = (t*.1+adist);
dist = abs(fract(dist)-.5);
c += (1.0 / (dist))*cos(0.7*(sin(t)))*adist/radDist * brightness;
}
angle = fract(angle+.161);
gl_FragColor = vec4(color + vec3(c) * light_color, 1.0);
}
+18
View File
@@ -0,0 +1,18 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main()
{
vec2 r = resolution,
o = gl_FragCoord.xy - r/2.;
o = vec2(length(o) / r.y - .2, atan(o.y,o.x));
vec4 s = .1*cos(1.6*vec4(0,1,2,3) + time + 0.5 + o.y + sin(o.y) * sin(time)*2.),
e = s.yzwx,
f = min(o.x-s,e-o.x);
gl_FragColor = dot(clamp(f*r.y,0.,1.), 40.*(s-e)) * (s-.1) - f;
}
+208
View File
@@ -0,0 +1,208 @@
#ifdef GL_ES
precision highp float;
#endif
uniform float time;
uniform vec2 resolution;
#define CHAR_SIZE vec2(6, 7)
#define CHAR_SPACING vec2(6, 9)
vec2 start_pos = vec2(0);
vec2 print_pos = vec2(0);
vec2 print_pos_pre_move = vec2(0);
vec3 text_color = vec3(1);
/*
Top left pixel is the most significant bit.
Bottom right pixel is the least significant bit.
███ |
█ █ |
█ █ |
█ █ |
█████ |
█ █ |
█ █ |
000000
100010
100010
100010
111110
100010
100010
011100 (upper 21 bits)
100010 -> 011100 100010 100010 100 -> 935188
100010
100
010 (lower 21 bits)
111110 -> 010 111110 100010 100010 -> 780450
100010
100010
vec2(935188.0,780450.0)
*/
//Text coloring
#define HEX(i) text_color = mod(vec3(i / 65536,i / 256,i),vec3(256.0))/255.0;
#define RGB(r,g,b) text_color = vec3(r,g,b);
#define STRWIDTH(c) (c * CHAR_SPACING.x)
#define STRHEIGHT(c) (c * CHAR_SPACING.y)
#define BEGIN_TEXT(x,y) print_pos = floor(vec2(x,y)); start_pos = floor(vec2(x,y));
//Automatically generated from the sprite sheet here: http://uzebox.org/wiki/index.php?title=File:Font6x8.png
#define _ col+=char(vec2(0.0,0.0),uv);
#define _spc col+=char(vec2(0.0,0.0),uv)*text_color;
#define _exc col+=char(vec2(276705.0,32776.0),uv)*text_color;
#define _quo col+=char(vec2(1797408.0,0.0),uv)*text_color;
#define _hsh col+=char(vec2(10738.0,1134484.0),uv)*text_color;
#define _dol col+=char(vec2(538883.0,19976.0),uv)*text_color;
#define _pct col+=char(vec2(1664033.0,68006.0),uv)*text_color;
#define _amp col+=char(vec2(545090.0,174362.0),uv)*text_color;
#define _apo col+=char(vec2(798848.0,0.0),uv)*text_color;
#define _lbr col+=char(vec2(270466.0,66568.0),uv)*text_color;
#define _rbr col+=char(vec2(528449.0,33296.0),uv)*text_color;
#define _ast col+=char(vec2(10471.0,1688832.0),uv)*text_color;
#define _crs col+=char(vec2(4167.0,1606144.0),uv)*text_color;
#define _per col+=char(vec2(0.0,1560.0),uv)*text_color;
#define _dsh col+=char(vec2(7.0,1572864.0),uv)*text_color;
#define _com col+=char(vec2(0.0,1544.0),uv)*text_color;
#define _lsl col+=char(vec2(1057.0,67584.0),uv)*text_color;
#define _0 col+=char(vec2(935221.0,731292.0),uv)*text_color;
#define _1 col+=char(vec2(274497.0,33308.0),uv)*text_color;
#define _2 col+=char(vec2(934929.0,1116222.0),uv)*text_color;
#define _3 col+=char(vec2(934931.0,1058972.0),uv)*text_color;
#define _4 col+=char(vec2(137380.0,1302788.0),uv)*text_color;
#define _5 col+=char(vec2(2048263.0,1058972.0),uv)*text_color;
#define _6 col+=char(vec2(401671.0,1190044.0),uv)*text_color;
#define _7 col+=char(vec2(2032673.0,66576.0),uv)*text_color;
#define _8 col+=char(vec2(935187.0,1190044.0),uv)*text_color;
#define _9 col+=char(vec2(935187.0,1581336.0),uv)*text_color;
#define _col col+=char(vec2(195.0,1560.0),uv)*text_color;
#define _scl col+=char(vec2(195.0,1544.0),uv)*text_color;
#define _les col+=char(vec2(135300.0,66052.0),uv)*text_color;
#define _equ col+=char(vec2(496.0,3968.0),uv)*text_color;
#define _grt col+=char(vec2(528416.0,541200.0),uv)*text_color;
#define _que col+=char(vec2(934929.0,1081352.0),uv)*text_color;
#define _ats col+=char(vec2(935285.0,714780.0),uv)*text_color;
#define _A col+=char(vec2(935188.0,780450.0),uv)*text_color;
#define _B col+=char(vec2(1983767.0,1190076.0),uv)*text_color;
#define _C col+=char(vec2(935172.0,133276.0),uv)*text_color;
#define _D col+=char(vec2(1983764.0,665788.0),uv)*text_color;
#define _E col+=char(vec2(2048263.0,1181758.0),uv)*text_color;
#define _F col+=char(vec2(2048263.0,1181728.0),uv)*text_color;
#define _G col+=char(vec2(935173.0,1714334.0),uv)*text_color;
#define _H col+=char(vec2(1131799.0,1714338.0),uv)*text_color;
#define _I col+=char(vec2(921665.0,33308.0),uv)*text_color;
#define _J col+=char(vec2(66576.0,665756.0),uv)*text_color;
#define _K col+=char(vec2(1132870.0,166178.0),uv)*text_color;
#define _L col+=char(vec2(1065220.0,133182.0),uv)*text_color;
#define _M col+=char(vec2(1142100.0,665762.0),uv)*text_color;
#define _N col+=char(vec2(1140052.0,1714338.0),uv)*text_color;
#define _O col+=char(vec2(935188.0,665756.0),uv)*text_color;
#define _P col+=char(vec2(1983767.0,1181728.0),uv)*text_color;
#define _Q col+=char(vec2(935188.0,698650.0),uv)*text_color;
#define _R col+=char(vec2(1983767.0,1198242.0),uv)*text_color;
#define _S col+=char(vec2(935171.0,1058972.0),uv)*text_color;
#define _T col+=char(vec2(2035777.0,33288.0),uv)*text_color;
#define _U col+=char(vec2(1131796.0,665756.0),uv)*text_color;
#define _V col+=char(vec2(1131796.0,664840.0),uv)*text_color;
#define _W col+=char(vec2(1131861.0,699028.0),uv)*text_color;
#define _X col+=char(vec2(1131681.0,84130.0),uv)*text_color;
#define _Y col+=char(vec2(1131794.0,1081864.0),uv)*text_color;
#define _Z col+=char(vec2(1968194.0,133180.0),uv)*text_color;
#define _lsb col+=char(vec2(925826.0,66588.0),uv)*text_color;
#define _rsl col+=char(vec2(16513.0,16512.0),uv)*text_color;
#define _rsb col+=char(vec2(919584.0,1065244.0),uv)*text_color;
#define _pow col+=char(vec2(272656.0,0.0),uv)*text_color;
#define _usc col+=char(vec2(0.0,62.0),uv)*text_color;
#define _a col+=char(vec2(224.0,649374.0),uv)*text_color;
#define _b col+=char(vec2(1065444.0,665788.0),uv)*text_color;
#define _c col+=char(vec2(228.0,657564.0),uv)*text_color;
#define _d col+=char(vec2(66804.0,665758.0),uv)*text_color;
#define _e col+=char(vec2(228.0,772124.0),uv)*text_color;
#define _f col+=char(vec2(401543.0,1115152.0),uv)*text_color;
#define _g col+=char(vec2(244.0,665474.0),uv)*text_color;
#define _h col+=char(vec2(1065444.0,665762.0),uv)*text_color;
#define _i col+=char(vec2(262209.0,33292.0),uv)*text_color;
#define _j col+=char(vec2(131168.0,1066252.0),uv)*text_color;
#define _k col+=char(vec2(1065253.0,199204.0),uv)*text_color;
#define _l col+=char(vec2(266305.0,33292.0),uv)*text_color;
#define _m col+=char(vec2(421.0,698530.0),uv)*text_color;
#define _n col+=char(vec2(452.0,1198372.0),uv)*text_color;
#define _o col+=char(vec2(228.0,665756.0),uv)*text_color;
#define _p col+=char(vec2(484.0,667424.0),uv)*text_color;
#define _q col+=char(vec2(244.0,665474.0),uv)*text_color;
#define _r col+=char(vec2(354.0,590904.0),uv)*text_color;
#define _s col+=char(vec2(228.0,114844.0),uv)*text_color;
#define _t col+=char(vec2(8674.0,66824.0),uv)*text_color;
#define _u col+=char(vec2(292.0,1198868.0),uv)*text_color;
#define _v col+=char(vec2(276.0,664840.0),uv)*text_color;
#define _w col+=char(vec2(276.0,700308.0),uv)*text_color;
#define _x col+=char(vec2(292.0,1149220.0),uv)*text_color;
#define _y col+=char(vec2(292.0,1163824.0),uv)*text_color;
#define _z col+=char(vec2(480.0,1148988.0),uv)*text_color;
#define _lpa col+=char(vec2(401542.0,66572.0),uv)*text_color;
#define _bar col+=char(vec2(266304.0,33288.0),uv)*text_color;
#define _rpa col+=char(vec2(788512.0,1589528.0),uv)*text_color;
#define _tid col+=char(vec2(675840.0,0.0),uv)*text_color;
#define _lar col+=char(vec2(8387.0,1147904.0),uv)*text_color;
#define _nl print_pos = start_pos - vec2(0,CHAR_SPACING.y);
//Extracts bit b from the given number.
float extract_bit(float n, float b)
{
b = clamp(b,-1.0,22.0);
return floor(mod(floor(n / pow(2.0,floor(b))),2.0));
}
//Returns the pixel at uv in the given bit-packed sprite.
float sprite(vec2 spr, vec2 size, vec2 uv)
{
uv = floor(uv);
float bit = (size.x-uv.x-1.0) + uv.y * size.x;
bool bounds = all(greaterThanEqual(uv,vec2(0)))&& all(lessThan(uv,size));
return bounds ? extract_bit(spr.x, bit - 21.0) + extract_bit(spr.y, bit) : 0.0;
}
//Prints a character and moves the print position forward by 1 character width.
vec3 char(vec2 ch, vec2 uv)
{
float px = sprite(ch, CHAR_SIZE, uv - print_pos);
print_pos.x += CHAR_SPACING.x;
print_pos.y += sin(4.*print_pos.x-time*10.);
return vec3(px);
}
vec3 Text(vec2 uv)
{
vec3 col = vec3(0.0);
vec2 center_pos = vec2(resolution.x/2.0 - STRWIDTH(20.0)/2.0,resolution.y/2.0 - STRHEIGHT(1.0)/2.0);
BEGIN_TEXT(center_pos.x,center_pos.y)
HEX(0x00ffFF) _ _ _w _ _a _ _t _ _ _e _ _r;
BEGIN_TEXT(resolution.x/2.0-STRWIDTH(11.0)/2.0,resolution.y/2.0)
print_pos += vec2(cos(time)*96.,sin(time)*96.);
// RGB(1,0,0) _M RGB(1,.5,0)_o RGB(1,1,0)_v RGB(0,1,0)_i RGB(0,.5,1)_n RGB(0.5,0,1)_g _ RGB(1,0,0)_T RGB(1,.5,0)_e RGB(1,1,0)_x RGB(0,1,0)_t
return col;
}
void main( void )
{
vec2 uv = gl_FragCoord.xy;
vec2 duv = floor(gl_FragCoord.xy);
vec3 pixel = Text(duv);
vec3 col = pixel*0.9+0.1;
col *= (1.-distance(mod(uv,vec2(1.0)),vec2(0.65)))*1.2;
gl_FragColor = vec4(vec3(col), 1.0);
}
+41
View File
@@ -0,0 +1,41 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 resolution;
// bonniemathew@gmail.com
vec3 COLOR1 = vec3(0.0, 0.0, 0.30);
vec3 COLOR2 = vec3(0.50, .0, 0.0);
float BLOCK_WIDTH = 0.01;
void main( void ) {
vec2 position = ( gl_FragCoord.xy / resolution.xy );
vec3 final_color = vec3(1.0);
// For creating the BG pattern
float c1 = mod(position.x, 2.0 * BLOCK_WIDTH);
c1 = step(BLOCK_WIDTH, c1);
float c2 = mod(position.y, 2.0 * BLOCK_WIDTH);
c2 = step(BLOCK_WIDTH, c2);
final_color = mix( position.x * COLOR1, position.y * COLOR2, c1 * c2);
// creating the wave
position = -1.0 + 2.0 * position;
float lineWidth = 10.0;
vec2 sPos = position ;
for( float i = 0.0; i < 13.; i++) {
sPos.y += (0.07 * sin(position.x + i/5.0+ time*1.));
lineWidth = abs(1.0 / (1000.0 * sPos.y));
final_color = final_color + vec3(lineWidth * 2.9, lineWidth*0., lineWidth * 1.);
}
gl_FragColor = vec4(final_color, 1.0);
}
+226
View File
@@ -0,0 +1,226 @@
/*
* Original shader from: https://www.shadertoy.com/view/wss3zB
*/
#ifdef GL_ES
precision highp float;
#endif
// glslsandbox uniforms
uniform float time;
uniform vec2 resolution;
// shadertoy globals
float iTime = 0.0;
vec3 iResolution = vec3(0.0);
// --------[ Original ShaderToy begins here ]---------- //
// Spiral Offset II - Del 06/01/2018
// watch fullscreen, params have been tweaked to overlap and never loop... :)
// keep watching... :)
#define TAU 6.283185
vec2 rot(vec2 v, float angle)
{
float c = cos(angle);
float s = sin(angle);
return mat2(c, -s, s, c)*v;
}
// IQ UnevenCapsule distance func
float cro(in vec2 a, in vec2 b ) { return a.x*b.y - a.y*b.x; }
float sdUnevenCapsule( in vec2 p, in vec2 pa, in vec2 pb, in float ra, in float rb )
{
p -= pa;
pb -= pa;
float h = dot(pb,pb);
vec2 q = vec2( dot(p,vec2(pb.y,-pb.x)), dot(p,pb) )/h;
//-----------
q.x = abs(q.x);
float b = ra-rb;
vec2 c = vec2(sqrt(h-b*b),b);
float k = cro(c,q);
float m = dot(c,q);
float n = dot(q,q);
if( k < 0.0 ) return sqrt(h*(n )) - ra;
else if( k > c.x ) return sqrt(h*(n+1.0-2.0*q.y)) - rb;
return m - ra;
}
float TimerInOut(vec4 v)
{
return smoothstep(v.y,v.y+v.w,v.x) - smoothstep(v.z-v.w,v.z,v.x);
}
float Stime(float scale)
{
return fract(iTime*scale)*TAU;
}
float Mtime(float mval)
{
return mod(iTime,mval);
}
// Trippy spiral calc - Del 06/01/2018
vec2 spiral(vec2 uv,float zoom, float len, float offset,vec2 capoff, float trip, float scount)
{
float d = length(uv) * zoom;
d=log(d*trip);
uv = rot(uv,sin(d*offset)+d*scount);
float v = 1.0-sdUnevenCapsule(uv,vec2(0.0,0.0)+capoff,vec2(0.4*len,0.0)+capoff,0.0,0.4*len)*14.0;
return vec2(v,d); // dx , dy
}
vec2 directionalWaveNormal(vec2 p, float amp, vec2 dir, float freq, float speed, float time, float k)
{
float a = dot(p, dir) * freq + time * speed;
float b = 0.5 * k * freq * amp * pow((sin(a) + 1.0) * 0.5, k) * cos(a);
return vec2(dir.x * b, dir.y * b);
}
vec3 summedWaveNormal(vec2 p)
{
float time = iTime;
vec2 sum = vec2(0.0);
sum += directionalWaveNormal(p, 0.5, normalize(vec2(1, 1)), 5.0, 1.5, time, 1.0);
sum += directionalWaveNormal(p, 0.25,normalize(vec2(1.4, 1.0)), 11.0, 2.4, time, 1.5);
sum += directionalWaveNormal(p, 0.125, normalize(vec2(-0.8, -1.0)), 10.0, 2.0, time, 2.0);
sum += directionalWaveNormal(p, 0.0625, normalize(vec2(1.3, 1.0)), 15.0, 4.0, time, 2.2);
sum += directionalWaveNormal(p, 0.03125, normalize(vec2(-1.7, -1.0)), 5.0, 1.8, time, 3.0);
return normalize(vec3(-sum.x, -sum.y, 1.0));
}
vec3 background(vec2 p)
{
vec3 normal = summedWaveNormal(p);
vec3 c = mix(vec3(0.1, 0.15, 0.1), vec3(0.2, 0.25, 0.4), dot(normal, normalize(vec3(0.2, 0.2, 0.5))) * 0.5 + 0.5);
c = mix(c, vec3(0.7, 0.9, 1.0), pow(dot(normal, normalize(vec3(-0.4, 0.1, 1.0))) * 0.5 + 0.5, 2.0));
c = mix(c, vec3(0.95, 0.98, 1.0), pow(dot(normal, normalize(vec3(-0.1, -0.3, 0.5))) * 0.5 + 0.5, 10.0));
return clamp(c,0.0,1.0);
}
float Bub(vec2 uv,float scale)
{
float time = iTime*0.75;
uv.y-=time*2./scale;
//uv.x += time*0.2;
uv.x+=sin(uv.y+time*.95)*0.025; ///scale;
uv*=scale;
vec2 s=floor(uv);
vec2 f=fract(uv);
float k=3.0;
vec2 p =.5+.35*sin(11.*fract(sin((s+scale)*mat2(7.0,3.0,6.0,5.0))*5.))-f;
float d=length(p);
k=min(d,k);
k=smoothstep(0.0,k,sin(f.x+f.y)*0.01);
return k;
}
vec3 Bubbles(vec2 uv,float head,float d)
{
float c = Bub(uv,30.)*.3;
c+=Bub(uv,20.)*.5;
c+=Bub(uv,15.)*.8;
c+=Bub(uv,10.);
c+=Bub(uv,8.);
c+=Bub(uv,6.);
c+=Bub(uv,5.);
vec3 scol = vec3(clamp(c*0.3,0.0,0.3));
return scol;
}
vec3 checks(vec2 p)
{
//p*=1.0+(sin(p.y+p.x+Stime(0.25))*0.15);
//float f = mod( floor(5.5*p.x) + floor(5.5*p.y), 2.0);
//vec3 col = 0.05 + 0.1*f+0.2*vec3(0.1,0.1,0.1);
//return col;
float d = length(p);
float head = 1.0-length(p);
d+=(0.5+sin(iTime*2.0)*0.5)*0.25;
p *= 0.25;
return Bubbles(p*(d+0.5), head,d);
}
vec3 hsv2rgb_smooth( in vec3 c )
{
vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
rgb = rgb*rgb*(3.0-2.0*rgb); // cubic smoothing
return c.z * mix( vec3(1.0), rgb, c.y);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = (fragCoord.xy - 0.5 * iResolution.xy) / iResolution.y;
// Create some blends over time...
float t1 = TimerInOut(vec4(Mtime(9.6),1.0, 7.2, 1.8));
float t2 = TimerInOut(vec4(Mtime(12.0),1.0, 9.0, 1.5));
float t3 = TimerInOut(vec4(Mtime(21.0),6.0, 14.2, 2.8));
float t4 = TimerInOut(vec4(Mtime(60.0),15.0,45.0,1.0));
float t5 = TimerInOut(vec4(Mtime(85.0),57.0, 67.0, 3.1));
float t6 = TimerInOut(vec4(Mtime(123.0),77.0,101.0,10.0));
float t7 = TimerInOut(vec4(Mtime(50.0),28.0,45.0,3.5));
float t8 = TimerInOut(vec4(Mtime(20.0),1.0,13.0,3.1));
float t9 = TimerInOut(vec4(Mtime(200.0),100.0,199.0,0.5));
float t10 = TimerInOut(vec4(Mtime(45.0),21.0,31.0,0.75));
// various spiral modifiers applied over time
float t = Stime(0.4);
float offset = 25.0 * t1;
float zoom = 1.0 + (sin(Stime(0.17))*0.5) * t2;
vec2 capoff = vec2(sin(uv.y*4.0+Stime(0.125))*0.25, sin(uv.x*2.0+Stime(0.25))*0.75) * t3;
float m = 0.48+sin(Stime(0.15)+uv.y+uv.x)*0.5;
float trip = 1.0-(m*t4);
float scmod = sin(Stime(0.176));
float scount = 5.0+((3.0+(scmod*5.0))*t5);
// debug... (disable effects)
//scount = 5.0;
//offset=0.0;
//zoom = 1.0;
//trip = 1.0;
//capoff = vec2(0.0);
vec2 dist = spiral(uv, zoom, t, offset, capoff, trip, scount);
float distmod = 0.49+sin(dist.x*0.34+dist.y*1.6+sin(Stime(.1)))*0.5;
dist.x = mix(dist.x, dist.x*distmod, t10);
float v2 = smoothstep(0.5-0.1,0.5+0.1,dist.x);
float v = mix(v2,clamp(dist.x,0.0,3.0), t6);
//vec3 col = vec3(v*1.0-l/t);
vec3 col1 = checks(uv); ////vec3(0.0,0.0,0.2);
vec3 col2 = vec3(1.0,0.6,0.5);
// rainbow flavour...
col2 = mix(col2,hsv2rgb_smooth(vec3(fract(iTime*0.1)+dist.x*0.1,1.0,v)),t9);
vec3 col3 = background(uv); //vec3(0.5,0.7,0.5);
col1 = mix(col1,col3*0.3, t7);
col2 = mix(col2,col3, t8);
vec3 col = mix(col1,col2,v*1.0-dist.y/t);
// vignette
vec2 q = fragCoord/iResolution.xy;
col *= 0.3 + 0.7*pow(16.0*q.x*q.y*(1.0-q.x)*(1.0-q.y),0.25);
fragColor = vec4(col, 1.0);
}
// --------[ Original ShaderToy ends here ]---------- //
void main(void)
{
iTime = time;
iResolution = vec3(resolution, 0.0);
mainImage(gl_FragColor, gl_FragCoord.xy);
}
+47
View File
@@ -0,0 +1,47 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
//uniform vec2 mouse;
uniform vec2 resolution;
// bonniemathew@gmail.com
//vec3 COLOR1 = vec3(0.0, 0.0, 0.50);
//vec3 COLOR2 = vec3(0.30, .0, 0.0);
const vec3 COLOR1 = vec3(0.0, 0.0, 0.0);
vec3 COLOR2 = COLOR1;
float BLOCK_WIDTH = 0.01;
void main( void ) {
vec2 position = ( gl_FragCoord.xy / resolution.xy );
vec3 final_color = vec3(1.0);
// For creating the BG pattern
float c1 = mod(position.x, 2.0 * BLOCK_WIDTH);
c1 = step(position.x*0.01, c1);
float c2 = mod(position.y, 2.0 * BLOCK_WIDTH);
c2 = step(BLOCK_WIDTH, c2);
final_color = mix( position.x * COLOR1, position.y * COLOR2, c1 * c2);
// creating the wave
position = -1.0 + 2.0 * position;
float lineWidth = 10.0;
vec2 sPos = position ;
for( float i = 0.0; i < 13.; i++) {
sPos.y += ((0.07*cos(time)) * tan(position.x + i/5.0+ sin(time*0.5)));
lineWidth = abs(1.0 / (750.0 * sPos.y));
final_color = final_color + vec3(lineWidth * 1.9f, lineWidth*1.9f, lineWidth * 0.);
}
gl_FragColor = vec4(final_color, 1.0);
}