Reestructura carpetes: src->source, third_party->source/external, shaders->data/shaders
This commit is contained in:
2
data/shaders/remember/meta.txt
Normal file
2
data/shaders/remember/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Remember
|
||||
Author: diatribes
|
||||
64
data/shaders/remember/remember.frag.msl
Normal file
64
data/shaders/remember/remember.frag.msl
Normal file
@@ -0,0 +1,64 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
// Remember — diatribes
|
||||
// MSL port of remember.vk.glsl.
|
||||
|
||||
struct ShadertoyUBO {
|
||||
float iTime;
|
||||
float2 iResolution;
|
||||
};
|
||||
|
||||
struct PassthroughVOut {
|
||||
float4 pos [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
static float hash12(float2 p) {
|
||||
float3 p3 = fract(float3(p.xyx) * 0.1031);
|
||||
p3 += dot(p3, p3.yzx + 33.33);
|
||||
return fract((p3.x + p3.y) * p3.z);
|
||||
}
|
||||
|
||||
fragment float4 remember_fs(PassthroughVOut in [[stage_in]],
|
||||
constant ShadertoyUBO& U [[buffer(0)]]) {
|
||||
float2 fragCoord = in.uv * U.iResolution;
|
||||
float2 u = fragCoord;
|
||||
|
||||
float3 q, p = float3(U.iResolution, U.iResolution.x / U.iResolution.y);
|
||||
|
||||
float i = 0.0, s = 0.0;
|
||||
float d = 0.125 * hash12(u);
|
||||
float t = U.iTime * 0.1;
|
||||
|
||||
u = (u + u - p.xy) / p.y;
|
||||
if (abs(u.y) > 0.8) { return float4(0); }
|
||||
|
||||
float4 o = float4(0.0);
|
||||
|
||||
for (; i < 64.0; i++) {
|
||||
|
||||
q = p = float3(u * d, d + t * 5.0);
|
||||
// mat2(cos(.1*p.z+.1*t+vec4(0,33,11,0))) — column-major: (m00,m10,m01,m11)
|
||||
float4 cs = cos(0.1 * p.z + 0.1 * t + float4(0, 33, 11, 0));
|
||||
float2x2 m = float2x2(cs.x, cs.y, cs.z, cs.w);
|
||||
p.xy = p.xy * m;
|
||||
|
||||
q.xz = cos(q.xz);
|
||||
p.z = cos(p.z);
|
||||
|
||||
for (s = 1.0; s++ < 6.0;) {
|
||||
q += sin(0.6 * t + p.zxy * 0.6);
|
||||
p += sin(t + t + p.yzx * s) * 0.6;
|
||||
}
|
||||
|
||||
s = 0.02 + abs(min(length(p + 3.0 * sin(p.z * 0.5)) - 4.0, length(q - 2.0 * sin(p.z * 0.4)) - 6.0)) * 0.2;
|
||||
d += s;
|
||||
|
||||
float4 brightTerm = min(0.01 * float4(6, 2, 1, 0) / max(length(u * sin(t + t + t)), 0.001), float4(50.0));
|
||||
o += brightTerm + 1.0 / s * length(u);
|
||||
}
|
||||
|
||||
o = tanh(max(o / 6e2 + dot(u, u) * 0.35, 0.0));
|
||||
return o;
|
||||
}
|
||||
BIN
data/shaders/remember/remember.frag.spv
Normal file
BIN
data/shaders/remember/remember.frag.spv
Normal file
Binary file not shown.
73
data/shaders/remember/remember.gl.glsl
Normal file
73
data/shaders/remember/remember.gl.glsl
Normal file
@@ -0,0 +1,73 @@
|
||||
// Name: Remember
|
||||
// Author: diatribes
|
||||
// URL: https://www.shadertoy.com/view/tXSBDK
|
||||
#version 330 core
|
||||
precision highp float;
|
||||
|
||||
out vec4 FragColor;
|
||||
in vec2 vUV;
|
||||
uniform vec2 iResolution;
|
||||
uniform float iTime;
|
||||
|
||||
// fuzzy brain
|
||||
|
||||
// Hash function to replace iChannel0 texture noise
|
||||
float hash12(vec2 p) {
|
||||
vec3 p3 = fract(vec3(p.xyx) * .1031);
|
||||
p3 += dot(p3, p3.yzx + 33.33);
|
||||
return fract((p3.x + p3.y) * p3.z);
|
||||
}
|
||||
|
||||
void mainImage(out vec4 o, vec2 u) {
|
||||
|
||||
vec3 q,p = vec3(iResolution.xy, iResolution.x / iResolution.y);
|
||||
|
||||
float i = 0.0, s,
|
||||
// start the ray at a small random distance,
|
||||
// this will reduce banding
|
||||
// Replaced texelFetch(iChannel0, ...) with hash function
|
||||
d = .125 * hash12(u),
|
||||
t = iTime * .1;
|
||||
|
||||
// scale coords
|
||||
u = (u+u-p.xy)/p.y;
|
||||
if (abs(u.y) > .8) { o = vec4(0); return; }
|
||||
|
||||
// Initialize output color (out parameter must be initialized before use)
|
||||
o = vec4(0.0);
|
||||
|
||||
for(; i<64.; i++) {
|
||||
|
||||
// shorthand for standard raymarch sample, then move forward:
|
||||
// p = ro + rd * d, p.z + t
|
||||
q = p = vec3(u * d, d + t*5.);
|
||||
p.xy *= mat2(cos(.1*p.z+.1*t+vec4(0,33,11,0)));
|
||||
|
||||
q.xz = cos(q.xz);
|
||||
p.z = cos(p.z) ;
|
||||
// turbulence
|
||||
for (s = 1.; s++ <6.;
|
||||
q += sin(.6*t+p.zxy*.6),
|
||||
p += sin(t+t+p.yzx*s)*.6);
|
||||
|
||||
// distance to spheres
|
||||
d += s = .02 + abs(min(length(p+3.*sin(p.z*.5))-4., length(q-2.*sin(p.z*.4))-6.))*.2;
|
||||
|
||||
// color: 1.+cos so we don't go negative, cos(d+vec4(6,4,2,0)) samples from the palette
|
||||
// divide by s for form and distance
|
||||
// Clamp only the first term to prevent extreme overflow, leave second term free
|
||||
vec4 brightTerm = min(.01*vec4(6,2,1,0)/max(length(u*sin(t+t+t)), 0.001), vec4(50.0));
|
||||
o += brightTerm + 1. / s * length(u);
|
||||
|
||||
}
|
||||
|
||||
// tonemap and divide brightness
|
||||
o = tanh(max(o /6e2 + dot(u,u)*.35, 0.));
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 fragCoordPixels = vUV * iResolution;
|
||||
vec4 outColor;
|
||||
mainImage(outColor, fragCoordPixels);
|
||||
FragColor = outColor;
|
||||
}
|
||||
61
data/shaders/remember/remember.vk.glsl
Normal file
61
data/shaders/remember/remember.vk.glsl
Normal file
@@ -0,0 +1,61 @@
|
||||
#version 450
|
||||
|
||||
// Name: Remember
|
||||
// Author: diatribes
|
||||
// URL: https://www.shadertoy.com/view/tXSBDK
|
||||
|
||||
layout(location = 0) in vec2 vUV;
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
layout(set = 3, binding = 0) uniform ShadertoyUBO {
|
||||
float iTime;
|
||||
vec2 iResolution;
|
||||
};
|
||||
|
||||
// fuzzy brain — Hash function to replace iChannel0 texture noise
|
||||
float hash12(vec2 p) {
|
||||
vec3 p3 = fract(vec3(p.xyx) * .1031);
|
||||
p3 += dot(p3, p3.yzx + 33.33);
|
||||
return fract((p3.x + p3.y) * p3.z);
|
||||
}
|
||||
|
||||
void mainImage(out vec4 o, vec2 u) {
|
||||
|
||||
vec3 q, p = vec3(iResolution.xy, iResolution.x / iResolution.y);
|
||||
|
||||
float i = 0.0, s,
|
||||
d = .125 * hash12(u),
|
||||
t = iTime * .1;
|
||||
|
||||
u = (u + u - p.xy) / p.y;
|
||||
if (abs(u.y) > .8) { o = vec4(0); return; }
|
||||
|
||||
o = vec4(0.0);
|
||||
|
||||
for (; i < 64.; i++) {
|
||||
|
||||
q = p = vec3(u * d, d + t * 5.);
|
||||
p.xy *= mat2(cos(.1 * p.z + .1 * t + vec4(0, 33, 11, 0)));
|
||||
|
||||
q.xz = cos(q.xz);
|
||||
p.z = cos(p.z);
|
||||
for (s = 1.; s++ < 6.;
|
||||
q += sin(.6 * t + p.zxy * .6),
|
||||
p += sin(t + t + p.yzx * s) * .6);
|
||||
|
||||
d += s = .02 + abs(min(length(p + 3. * sin(p.z * .5)) - 4., length(q - 2. * sin(p.z * .4)) - 6.)) * .2;
|
||||
|
||||
vec4 brightTerm = min(.01 * vec4(6, 2, 1, 0) / max(length(u * sin(t + t + t)), 0.001), vec4(50.0));
|
||||
o += brightTerm + 1. / s * length(u);
|
||||
|
||||
}
|
||||
|
||||
o = tanh(max(o / 6e2 + dot(u, u) * .35, 0.));
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 fragCoordPixels = vUV * iResolution;
|
||||
vec4 outColor;
|
||||
mainImage(outColor, fragCoordPixels);
|
||||
FragColor = outColor;
|
||||
}
|
||||
Reference in New Issue
Block a user