prettier: ignore shaders
parent
244e7266a1
commit
3a17ac48cf
|
|
@ -10,3 +10,6 @@ macos/
|
|||
|
||||
# website dev run
|
||||
website/.next
|
||||
|
||||
# shaders
|
||||
*.frag
|
||||
|
|
|
|||
|
|
@ -1,116 +0,0 @@
|
|||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
|
||||
template<typename Tx, typename Ty>
|
||||
inline Tx mod(Tx x, Ty y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
struct Globals
|
||||
{
|
||||
float3 iResolution;
|
||||
float iTime;
|
||||
float iTimeDelta;
|
||||
float iFrameRate;
|
||||
int iFrame;
|
||||
float4 iChannelTime[4];
|
||||
float3 iChannelResolution[4];
|
||||
float4 iMouse;
|
||||
float4 iDate;
|
||||
float iSampleRate;
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 _fragColor [[color(0)]];
|
||||
};
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
float2 curve(thread float2& uv)
|
||||
{
|
||||
uv = (uv - float2(0.5)) * 2.0;
|
||||
uv *= 1.10000002384185791015625;
|
||||
uv.x *= (1.0 + pow(abs(uv.y) / 5.0, 2.0));
|
||||
uv.y *= (1.0 + pow(abs(uv.x) / 4.0, 2.0));
|
||||
uv = (uv / float2(2.0)) + float2(0.5);
|
||||
uv = (uv * 0.920000016689300537109375) + float2(0.039999999105930328369140625);
|
||||
return uv;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
void mainImage(thread float4& fragColor, thread const float2& fragCoord, constant Globals& _89, texture2d<float> iChannel0, sampler iChannel0Smplr)
|
||||
{
|
||||
float2 q = fragCoord / float2(_89.iResolution[0], _89.iResolution[1]);
|
||||
float2 uv = q;
|
||||
float2 param = uv;
|
||||
float2 _100 = curve(param);
|
||||
uv = _100;
|
||||
float3 oricol = iChannel0.sample(iChannel0Smplr, float2(q.x, q.y)).xyz;
|
||||
float x = ((sin((0.300000011920928955078125 * _89.iTime) + (uv.y * 21.0)) * sin((0.699999988079071044921875 * _89.iTime) + (uv.y * 29.0))) * sin((0.300000011920928955078125 + (0.3300000131130218505859375 * _89.iTime)) + (uv.y * 31.0))) * 0.001700000022538006305694580078125;
|
||||
float3 col;
|
||||
col.x = iChannel0.sample(iChannel0Smplr, float2((x + uv.x) + 0.001000000047497451305389404296875, uv.y + 0.001000000047497451305389404296875)).x + 0.0500000007450580596923828125;
|
||||
col.y = iChannel0.sample(iChannel0Smplr, float2((x + uv.x) + 0.0, uv.y - 0.00200000009499490261077880859375)).y + 0.0500000007450580596923828125;
|
||||
col.z = iChannel0.sample(iChannel0Smplr, float2((x + uv.x) - 0.00200000009499490261077880859375, uv.y + 0.0)).z + 0.0500000007450580596923828125;
|
||||
col.x += (0.07999999821186065673828125 * iChannel0.sample(iChannel0Smplr, ((float2(x + 0.02500000037252902984619140625, -0.02700000070035457611083984375) * 0.75) + float2(uv.x + 0.001000000047497451305389404296875, uv.y + 0.001000000047497451305389404296875))).x);
|
||||
col.y += (0.0500000007450580596923828125 * iChannel0.sample(iChannel0Smplr, ((float2(x + (-0.02199999988079071044921875), -0.0199999995529651641845703125) * 0.75) + float2(uv.x + 0.0, uv.y - 0.00200000009499490261077880859375))).y);
|
||||
col.z += (0.07999999821186065673828125 * iChannel0.sample(iChannel0Smplr, ((float2(x + (-0.0199999995529651641845703125), -0.017999999225139617919921875) * 0.75) + float2(uv.x - 0.00200000009499490261077880859375, uv.y + 0.0))).z);
|
||||
col = fast::clamp((col * 0.60000002384185791015625) + (((col * 0.4000000059604644775390625) * col) * 1.0), float3(0.0), float3(1.0));
|
||||
float vig = 0.0 + ((((16.0 * uv.x) * uv.y) * (1.0 - uv.x)) * (1.0 - uv.y));
|
||||
col *= float3(pow(vig, 0.300000011920928955078125));
|
||||
col *= float3(0.949999988079071044921875, 1.0499999523162841796875, 0.949999988079071044921875);
|
||||
col *= 2.7999999523162841796875;
|
||||
float scans = fast::clamp(0.3499999940395355224609375 + (0.3499999940395355224609375 * sin((3.5 * _89.iTime) + ((uv.y * _89.iResolution[1u]) * 1.5))), 0.0, 1.0);
|
||||
float s = pow(scans, 1.7000000476837158203125);
|
||||
col *= float3(0.4000000059604644775390625 + (0.699999988079071044921875 * s));
|
||||
col *= (1.0 + (0.00999999977648258209228515625 * sin(110.0 * _89.iTime)));
|
||||
bool _352 = uv.x < 0.0;
|
||||
bool _359;
|
||||
if (!_352)
|
||||
{
|
||||
_359 = uv.x > 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_359 = _352;
|
||||
}
|
||||
if (_359)
|
||||
{
|
||||
col *= 0.0;
|
||||
}
|
||||
bool _366 = uv.y < 0.0;
|
||||
bool _373;
|
||||
if (!_366)
|
||||
{
|
||||
_373 = uv.y > 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_373 = _366;
|
||||
}
|
||||
if (_373)
|
||||
{
|
||||
col *= 0.0;
|
||||
}
|
||||
col *= (float3(1.0) - (float3(fast::clamp((mod(fragCoord.x, 2.0) - 1.0) * 2.0, 0.0, 1.0)) * 0.64999997615814208984375));
|
||||
float comp = smoothstep(0.100000001490116119384765625, 0.89999997615814208984375, sin(_89.iTime));
|
||||
fragColor = float4(col, 1.0);
|
||||
}
|
||||
|
||||
fragment main0_out main0(constant Globals& _89 [[buffer(0)]], texture2d<float> iChannel0 [[texture(0)]], sampler iChannel0Smplr [[sampler(0)]], float4 gl_FragCoord [[position]])
|
||||
{
|
||||
constexpr sampler iChannel0Smplr(address::clamp_to_edge, filter::linear);
|
||||
|
||||
main0_out out = {};
|
||||
float2 param_1 = gl_FragCoord.xy;
|
||||
float4 param;
|
||||
mainImage(param, param_1, _89, iChannel0, iChannel0Smplr);
|
||||
out._fragColor = param;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
#version 430 core
|
||||
|
||||
layout(binding = 0) uniform Globals {
|
||||
uniform vec3 iResolution;
|
||||
uniform float iTime;
|
||||
uniform float iTimeDelta;
|
||||
uniform float iFrameRate;
|
||||
uniform int iFrame;
|
||||
uniform float iChannelTime[4];
|
||||
uniform vec3 iChannelResolution[4];
|
||||
uniform vec4 iMouse;
|
||||
uniform vec4 iDate;
|
||||
uniform float iSampleRate;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform sampler2D iChannel0;
|
||||
layout(binding = 1) uniform sampler2D iChannel1;
|
||||
layout(binding = 2) uniform sampler2D iChannel2;
|
||||
layout(binding = 3) uniform sampler2D iChannel3;
|
||||
|
||||
layout(location = 0) in vec4 gl_FragCoord;
|
||||
layout(location = 0) out vec4 _fragColor;
|
||||
|
||||
#define texture2D texture
|
||||
|
||||
void mainImage( out vec4 fragColor, in vec2 fragCoord );
|
||||
void main() { mainImage (_fragColor, gl_FragCoord.xy); }
|
||||
|
||||
// Loosely based on postprocessing shader by inigo quilez, License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||
|
||||
vec2 curve(vec2 uv)
|
||||
{
|
||||
uv = (uv - 0.5) * 2.0;
|
||||
uv *= 1.1;
|
||||
uv.x *= 1.0 + pow((abs(uv.y) / 5.0), 2.0);
|
||||
uv.y *= 1.0 + pow((abs(uv.x) / 4.0), 2.0);
|
||||
uv = (uv / 2.0) + 0.5;
|
||||
uv = uv *0.92 + 0.04;
|
||||
return uv;
|
||||
}
|
||||
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||
{
|
||||
vec2 q = fragCoord.xy / iResolution.xy;
|
||||
vec2 uv = q;
|
||||
uv = curve( uv );
|
||||
vec3 oricol = texture( iChannel0, vec2(q.x,q.y) ).xyz;
|
||||
vec3 col;
|
||||
float x = sin(0.3*iTime+uv.y*21.0)*sin(0.7*iTime+uv.y*29.0)*sin(0.3+0.33*iTime+uv.y*31.0)*0.0017;
|
||||
|
||||
col.r = texture(iChannel0,vec2(x+uv.x+0.001,uv.y+0.001)).x+0.05;
|
||||
col.g = texture(iChannel0,vec2(x+uv.x+0.000,uv.y-0.002)).y+0.05;
|
||||
col.b = texture(iChannel0,vec2(x+uv.x-0.002,uv.y+0.000)).z+0.05;
|
||||
col.r += 0.08*texture(iChannel0,0.75*vec2(x+0.025, -0.027)+vec2(uv.x+0.001,uv.y+0.001)).x;
|
||||
col.g += 0.05*texture(iChannel0,0.75*vec2(x+-0.022, -0.02)+vec2(uv.x+0.000,uv.y-0.002)).y;
|
||||
col.b += 0.08*texture(iChannel0,0.75*vec2(x+-0.02, -0.018)+vec2(uv.x-0.002,uv.y+0.000)).z;
|
||||
|
||||
col = clamp(col*0.6+0.4*col*col*1.0,0.0,1.0);
|
||||
|
||||
float vig = (0.0 + 1.0*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y));
|
||||
col *= vec3(pow(vig,0.3));
|
||||
|
||||
col *= vec3(0.95,1.05,0.95);
|
||||
col *= 2.8;
|
||||
|
||||
float scans = clamp( 0.35+0.35*sin(3.5*iTime+uv.y*iResolution.y*1.5), 0.0, 1.0);
|
||||
|
||||
float s = pow(scans,1.7);
|
||||
col = col*vec3( 0.4+0.7*s) ;
|
||||
|
||||
col *= 1.0+0.01*sin(110.0*iTime);
|
||||
if (uv.x < 0.0 || uv.x > 1.0)
|
||||
col *= 0.0;
|
||||
if (uv.y < 0.0 || uv.y > 1.0)
|
||||
col *= 0.0;
|
||||
|
||||
col*=1.0-0.65*vec3(clamp((mod(fragCoord.x, 2.0)-1.0)*2.0,0.0,1.0));
|
||||
|
||||
float comp = smoothstep( 0.1, 0.9, sin(iTime) );
|
||||
|
||||
// Remove the next line to stop cross-fade between original and postprocess
|
||||
// col = mix( col, oricol, comp );
|
||||
|
||||
fragColor = vec4(col,1.0);
|
||||
}
|
||||
Loading…
Reference in New Issue