Reestructura carpetes: src->source, third_party->source/external, shaders->data/shaders
This commit is contained in:
2
data/shaders/octograms/meta.txt
Normal file
2
data/shaders/octograms/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Octograms
|
||||
Author: whisky_shusuky
|
||||
95
data/shaders/octograms/octograms.frag.msl
Normal file
95
data/shaders/octograms/octograms.frag.msl
Normal file
@@ -0,0 +1,95 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
// Octograms — whisky_shusuky
|
||||
// MSL port of octograms.vk.glsl. The Shadertoy original uses a mutable
|
||||
// file-scope `gTime`; in MSL we pass it as a parameter through the chain.
|
||||
|
||||
struct ShadertoyUBO {
|
||||
float iTime;
|
||||
float2 iResolution;
|
||||
};
|
||||
|
||||
struct PassthroughVOut {
|
||||
float4 pos [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
static float2x2 rot(float a) {
|
||||
float c = cos(a), s = sin(a);
|
||||
return float2x2(c, s, -s, c);
|
||||
}
|
||||
|
||||
static float sdBox(float3 p, float3 b) {
|
||||
float3 q = abs(p) - b;
|
||||
return length(max(q, float3(0.0))) + min(max(q.x, max(q.y, q.z)), 0.0);
|
||||
}
|
||||
|
||||
static float boxGeom(float3 pos, float scale) {
|
||||
pos *= scale;
|
||||
float base = sdBox(pos, float3(0.4, 0.4, 0.1)) / 1.5;
|
||||
pos.xy = (pos.xy * 5.0 - float2(0.0, 3.5)) * rot(0.75);
|
||||
return -base;
|
||||
}
|
||||
|
||||
static float box_set(float3 pos, float gTime) {
|
||||
float3 pos_origin = pos;
|
||||
|
||||
pos = pos_origin;
|
||||
pos.y += sin(gTime * 0.4) * 2.5;
|
||||
pos.xy = pos.xy * rot(0.8);
|
||||
float box1 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.y -= sin(gTime * 0.4) * 2.5;
|
||||
pos.xy = pos.xy * rot(0.8);
|
||||
float box2 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.x += sin(gTime * 0.4) * 2.5;
|
||||
pos.xy = pos.xy * rot(0.8);
|
||||
float box3 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.x -= sin(gTime * 0.4) * 2.5;
|
||||
pos.xy = pos.xy * rot(0.8);
|
||||
float box4 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.xy = pos.xy * rot(0.8);
|
||||
float box5 = boxGeom(pos, 0.5) * 6.0;
|
||||
|
||||
pos = pos_origin;
|
||||
float box6 = boxGeom(pos, 0.5) * 6.0;
|
||||
|
||||
return max(max(max(max(max(box1, box2), box3), box4), box5), box6);
|
||||
}
|
||||
|
||||
fragment float4 octograms_fs(PassthroughVOut in [[stage_in]],
|
||||
constant ShadertoyUBO& U [[buffer(0)]]) {
|
||||
float2 fragCoord = in.uv * U.iResolution;
|
||||
float2 p = (fragCoord * 2.0 - U.iResolution) / min(U.iResolution.x, U.iResolution.y);
|
||||
|
||||
float3 ro = float3(0.0, -0.2, U.iTime * 4.0);
|
||||
float3 ray = normalize(float3(p, 1.5));
|
||||
ray.xy = ray.xy * rot(sin(U.iTime * 0.03) * 5.0);
|
||||
ray.yz = ray.yz * rot(sin(U.iTime * 0.05) * 0.2);
|
||||
float t = 0.1;
|
||||
float ac = 0.0;
|
||||
|
||||
for (int i = 0; i < 99; i++) {
|
||||
float3 pos = ro + ray * t;
|
||||
pos = fract((pos - 2.0) / 4.0) * 4.0 - 2.0;
|
||||
float gTime = U.iTime - float(i) * 0.01;
|
||||
|
||||
float d = box_set(pos, gTime);
|
||||
d = max(abs(d), 0.01);
|
||||
ac += exp(-d * 23.0);
|
||||
t += d * 0.55;
|
||||
}
|
||||
|
||||
float3 col = float3(ac * 0.02);
|
||||
col += float3(0.0, 0.2 * abs(sin(U.iTime)), 0.5 + sin(U.iTime) * 0.2);
|
||||
|
||||
return float4(col, 1.0 - t * (0.02 + 0.02 * sin(U.iTime)));
|
||||
}
|
||||
BIN
data/shaders/octograms/octograms.frag.spv
Normal file
BIN
data/shaders/octograms/octograms.frag.spv
Normal file
Binary file not shown.
107
data/shaders/octograms/octograms.gl.glsl
Normal file
107
data/shaders/octograms/octograms.gl.glsl
Normal file
@@ -0,0 +1,107 @@
|
||||
// Name: Octograms
|
||||
// Author: whisky_shusuky
|
||||
// URL: https://www.shadertoy.com/view/tlVGDt
|
||||
#version 330 core
|
||||
precision highp float;
|
||||
|
||||
out vec4 FragColor;
|
||||
in vec2 vUV;
|
||||
uniform vec2 iResolution;
|
||||
uniform float iTime;
|
||||
|
||||
float gTime = 0.0;
|
||||
const float REPEAT = 5.0;
|
||||
|
||||
// rotación 2D
|
||||
mat2 rot(float a) {
|
||||
float c = cos(a), s = sin(a);
|
||||
return mat2(c, s, -s, c);
|
||||
}
|
||||
|
||||
float sdBox(vec3 p, vec3 b) {
|
||||
vec3 q = abs(p) - b;
|
||||
return length(max(q, vec3(0.0))) + min(max(q.x, max(q.y, q.z)), 0.0);
|
||||
}
|
||||
|
||||
float boxGeom(vec3 pos, float scale) {
|
||||
pos *= scale;
|
||||
float base = sdBox(pos, vec3(.4, .4, .1)) / 1.5;
|
||||
pos.xy *= 5.0;
|
||||
pos.y -= 3.5;
|
||||
pos.xy *= rot(.75);
|
||||
float result = -base;
|
||||
return result;
|
||||
}
|
||||
|
||||
float box_set(vec3 pos, float iTimeLocal) {
|
||||
vec3 pos_origin = pos;
|
||||
pos = pos_origin;
|
||||
pos.y += sin(gTime * 0.4) * 2.5;
|
||||
pos.xy *= rot(.8);
|
||||
float box1 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.y -= sin(gTime * 0.4) * 2.5;
|
||||
pos.xy *= rot(.8);
|
||||
float box2 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.x += sin(gTime * 0.4) * 2.5;
|
||||
pos.xy *= rot(.8);
|
||||
float box3 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.x -= sin(gTime * 0.4) * 2.5;
|
||||
pos.xy *= rot(.8);
|
||||
float box4 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.xy *= rot(.8);
|
||||
float box5 = boxGeom(pos, .5) * 6.0;
|
||||
|
||||
pos = pos_origin;
|
||||
float box6 = boxGeom(pos, .5) * 6.0;
|
||||
|
||||
float result = max(max(max(max(max(box1, box2), box3), box4), box5), box6);
|
||||
return result;
|
||||
}
|
||||
|
||||
float mapScene(vec3 pos, float iTimeLocal) {
|
||||
return box_set(pos, iTimeLocal);
|
||||
}
|
||||
|
||||
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
||||
vec2 p = (fragCoord.xy * 2.0 - iResolution.xy) / min(iResolution.x, iResolution.y);
|
||||
vec3 ro = vec3(0.0, -0.2, iTime * 4.0);
|
||||
vec3 ray = normalize(vec3(p, 1.5));
|
||||
ray.xy = ray.xy * rot(sin(iTime * .03) * 5.0);
|
||||
ray.yz = ray.yz * rot(sin(iTime * .05) * .2);
|
||||
float t = 0.1;
|
||||
vec3 col = vec3(0.0);
|
||||
float ac = 0.0;
|
||||
|
||||
for (int i = 0; i < 99; i++) {
|
||||
vec3 pos = ro + ray * t;
|
||||
pos = mod(pos - 2.0, 4.0) - 2.0;
|
||||
gTime = iTime - float(i) * 0.01;
|
||||
|
||||
float d = mapScene(pos, iTime);
|
||||
|
||||
d = max(abs(d), 0.01);
|
||||
ac += exp(-d * 23.0);
|
||||
|
||||
t += d * 0.55;
|
||||
}
|
||||
|
||||
col = vec3(ac * 0.02);
|
||||
col += vec3(0.0, 0.2 * abs(sin(iTime)), 0.5 + sin(iTime) * 0.2);
|
||||
|
||||
fragColor = vec4(col, 1.0 - t * (0.02 + 0.02 * sin(iTime)));
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 fragCoordPixels = vUV * iResolution;
|
||||
vec4 outColor;
|
||||
mainImage(outColor, fragCoordPixels);
|
||||
FragColor = outColor;
|
||||
}
|
||||
109
data/shaders/octograms/octograms.vk.glsl
Normal file
109
data/shaders/octograms/octograms.vk.glsl
Normal file
@@ -0,0 +1,109 @@
|
||||
#version 450
|
||||
|
||||
// Name: Octograms
|
||||
// Author: whisky_shusuky
|
||||
// URL: https://www.shadertoy.com/view/tlVGDt
|
||||
|
||||
layout(location = 0) in vec2 vUV;
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
layout(set = 3, binding = 0) uniform ShadertoyUBO {
|
||||
float iTime;
|
||||
vec2 iResolution;
|
||||
};
|
||||
|
||||
float gTime = 0.0;
|
||||
const float REPEAT = 5.0;
|
||||
|
||||
mat2 rot(float a) {
|
||||
float c = cos(a), s = sin(a);
|
||||
return mat2(c, s, -s, c);
|
||||
}
|
||||
|
||||
float sdBox(vec3 p, vec3 b) {
|
||||
vec3 q = abs(p) - b;
|
||||
return length(max(q, vec3(0.0))) + min(max(q.x, max(q.y, q.z)), 0.0);
|
||||
}
|
||||
|
||||
float boxGeom(vec3 pos, float scale) {
|
||||
pos *= scale;
|
||||
float base = sdBox(pos, vec3(.4, .4, .1)) / 1.5;
|
||||
pos.xy *= 5.0;
|
||||
pos.y -= 3.5;
|
||||
pos.xy *= rot(.75);
|
||||
float result = -base;
|
||||
return result;
|
||||
}
|
||||
|
||||
float box_set(vec3 pos, float iTimeLocal) {
|
||||
vec3 pos_origin = pos;
|
||||
pos = pos_origin;
|
||||
pos.y += sin(gTime * 0.4) * 2.5;
|
||||
pos.xy *= rot(.8);
|
||||
float box1 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.y -= sin(gTime * 0.4) * 2.5;
|
||||
pos.xy *= rot(.8);
|
||||
float box2 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.x += sin(gTime * 0.4) * 2.5;
|
||||
pos.xy *= rot(.8);
|
||||
float box3 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.x -= sin(gTime * 0.4) * 2.5;
|
||||
pos.xy *= rot(.8);
|
||||
float box4 = boxGeom(pos, 2.0 - abs(sin(gTime * 0.4)) * 1.5);
|
||||
|
||||
pos = pos_origin;
|
||||
pos.xy *= rot(.8);
|
||||
float box5 = boxGeom(pos, .5) * 6.0;
|
||||
|
||||
pos = pos_origin;
|
||||
float box6 = boxGeom(pos, .5) * 6.0;
|
||||
|
||||
float result = max(max(max(max(max(box1, box2), box3), box4), box5), box6);
|
||||
return result;
|
||||
}
|
||||
|
||||
float mapScene(vec3 pos, float iTimeLocal) {
|
||||
return box_set(pos, iTimeLocal);
|
||||
}
|
||||
|
||||
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
||||
vec2 p = (fragCoord.xy * 2.0 - iResolution.xy) / min(iResolution.x, iResolution.y);
|
||||
vec3 ro = vec3(0.0, -0.2, iTime * 4.0);
|
||||
vec3 ray = normalize(vec3(p, 1.5));
|
||||
ray.xy = ray.xy * rot(sin(iTime * .03) * 5.0);
|
||||
ray.yz = ray.yz * rot(sin(iTime * .05) * .2);
|
||||
float t = 0.1;
|
||||
vec3 col = vec3(0.0);
|
||||
float ac = 0.0;
|
||||
|
||||
for (int i = 0; i < 99; i++) {
|
||||
vec3 pos = ro + ray * t;
|
||||
pos = mod(pos - 2.0, 4.0) - 2.0;
|
||||
gTime = iTime - float(i) * 0.01;
|
||||
|
||||
float d = mapScene(pos, iTime);
|
||||
|
||||
d = max(abs(d), 0.01);
|
||||
ac += exp(-d * 23.0);
|
||||
|
||||
t += d * 0.55;
|
||||
}
|
||||
|
||||
col = vec3(ac * 0.02);
|
||||
col += vec3(0.0, 0.2 * abs(sin(iTime)), 0.5 + sin(iTime) * 0.2);
|
||||
|
||||
fragColor = vec4(col, 1.0 - t * (0.02 + 0.02 * sin(iTime)));
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 fragCoordPixels = vUV * iResolution;
|
||||
vec4 outColor;
|
||||
mainImage(outColor, fragCoordPixels);
|
||||
FragColor = outColor;
|
||||
}
|
||||
Reference in New Issue
Block a user