Reestructura carpetes: src->source, third_party->source/external, shaders->data/shaders
This commit is contained in:
2
data/shaders/water/meta.txt
Normal file
2
data/shaders/water/meta.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Name: Water
|
||||
Author: diatribes
|
||||
40
data/shaders/water/water.frag.msl
Normal file
40
data/shaders/water/water.frag.msl
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
// Water — diatribes
|
||||
// MSL port of water.vk.glsl. Entry point is named after the shader (water_fs).
|
||||
|
||||
struct ShadertoyUBO {
|
||||
float iTime;
|
||||
float2 iResolution;
|
||||
};
|
||||
|
||||
struct PassthroughVOut {
|
||||
float4 pos [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
fragment float4 water_fs(PassthroughVOut in [[stage_in]],
|
||||
constant ShadertoyUBO& U [[buffer(0)]]) {
|
||||
float2 fragCoord = in.uv * U.iResolution;
|
||||
float2 u = fragCoord;
|
||||
|
||||
float s = 0.002, i = 0.0, n;
|
||||
float3 r = float3(U.iResolution, U.iResolution.x / U.iResolution.y);
|
||||
float3 p = float3(0);
|
||||
u = (u - r.xy / 2.0) / r.y - 0.3;
|
||||
|
||||
float4 o = float4(0);
|
||||
|
||||
for (; i < 32.0 && s > 0.001; i++) {
|
||||
float4 term = float4(5, 2, 1, 0) / max(length(u - 0.1), 0.001);
|
||||
o += min(term, float4(100.0));
|
||||
p += float3(u * s, s);
|
||||
s = 1.0 + p.y;
|
||||
for (n = 0.01; n < 1.0; n += n) {
|
||||
s += abs(dot(sin(p.z + U.iTime + p / n), float3(1))) * n * 0.1;
|
||||
}
|
||||
}
|
||||
o = tanh(o / 5e2);
|
||||
return o;
|
||||
}
|
||||
BIN
data/shaders/water/water.frag.spv
Normal file
BIN
data/shaders/water/water.frag.spv
Normal file
Binary file not shown.
44
data/shaders/water/water.gl.glsl
Normal file
44
data/shaders/water/water.gl.glsl
Normal file
@@ -0,0 +1,44 @@
|
||||
// Name: Water
|
||||
// Author: diatribes
|
||||
// URL: https://www.shadertoy.com/view/tXjXDy
|
||||
#version 330 core
|
||||
precision highp float;
|
||||
|
||||
out vec4 FragColor;
|
||||
in vec2 vUV;
|
||||
uniform vec2 iResolution;
|
||||
uniform float iTime;
|
||||
|
||||
/*
|
||||
-2 by @FabriceNeyret2
|
||||
|
||||
thanks!! :D
|
||||
|
||||
If it doesn't display correctly, change line 17 "r/r" to "vec3(1)"
|
||||
*/
|
||||
|
||||
void mainImage( out vec4 o, vec2 u ) {
|
||||
float s=.002, i=0., n; // FIXED: Initialize i=0
|
||||
vec3 r = vec3(iResolution.xy, iResolution.x/iResolution.y);
|
||||
vec3 p = vec3(0);
|
||||
u = (u-r.xy/2.)/r.y-.3;
|
||||
|
||||
o = vec4(0); // FIXED: Initialize output to black
|
||||
|
||||
for(; i < 32. && s > .001; i++) {
|
||||
// Clamp only extreme overflow values, let normal brightness through
|
||||
vec4 term = vec4(5,2,1,0)/max(length(u-.1), 0.001);
|
||||
o += min(term, vec4(100.0));
|
||||
for (p += vec3(u*s,s), s = 1. + p.y, n =.01; n < 1.; n+=n) {
|
||||
s += abs(dot(sin(p.z+iTime+p / n), vec3(1))) * n*.1;
|
||||
}
|
||||
}
|
||||
o = tanh(o/5e2);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 fragCoordPixels = vUV * iResolution;
|
||||
vec4 outColor;
|
||||
mainImage(outColor, fragCoordPixels);
|
||||
FragColor = outColor;
|
||||
}
|
||||
45
data/shaders/water/water.vk.glsl
Normal file
45
data/shaders/water/water.vk.glsl
Normal file
@@ -0,0 +1,45 @@
|
||||
#version 450
|
||||
|
||||
// Name: Water
|
||||
// Author: diatribes
|
||||
// URL: https://www.shadertoy.com/view/tXjXDy
|
||||
|
||||
layout(location = 0) in vec2 vUV;
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
layout(set = 3, binding = 0) uniform ShadertoyUBO {
|
||||
float iTime;
|
||||
vec2 iResolution;
|
||||
};
|
||||
|
||||
/*
|
||||
-2 by @FabriceNeyret2
|
||||
thanks!! :D
|
||||
|
||||
If it doesn't display correctly, change line "r/r" to "vec3(1)"
|
||||
*/
|
||||
|
||||
void mainImage( out vec4 o, vec2 u ) {
|
||||
float s=.002, i=0., n;
|
||||
vec3 r = vec3(iResolution.xy, iResolution.x/iResolution.y);
|
||||
vec3 p = vec3(0);
|
||||
u = (u-r.xy/2.)/r.y-.3;
|
||||
|
||||
o = vec4(0);
|
||||
|
||||
for(; i < 32. && s > .001; i++) {
|
||||
vec4 term = vec4(5,2,1,0)/max(length(u-.1), 0.001);
|
||||
o += min(term, vec4(100.0));
|
||||
for (p += vec3(u*s,s), s = 1. + p.y, n =.01; n < 1.; n+=n) {
|
||||
s += abs(dot(sin(p.z+iTime+p / n), vec3(1))) * n*.1;
|
||||
}
|
||||
}
|
||||
o = tanh(o/5e2);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 fragCoordPixels = vUV * iResolution;
|
||||
vec4 outColor;
|
||||
mainImage(outColor, fragCoordPixels);
|
||||
FragColor = outColor;
|
||||
}
|
||||
Reference in New Issue
Block a user