Last active
June 10, 2024 09:28
-
-
Save cecilemuller/0e21b2455d40bf9c3d057c4ab55498a6 to your computer and use it in GitHub Desktop.
Neuro shader for Marmoset Toolbag 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "data/shader/mat/state.frag" | |
#include "data/shader/mat/other/customExtras.sh" | |
uniform int uIterations; //name "Iterations" default 15 min 5 max 30 | |
uniform float uSpeed; //name "Speed" default 1.0 min 0.0 max 10.0 | |
uniform float uFactor; //name "Factor" default 8.0 min 4.0 max 10.0 | |
// Based on https://codepen.io/wildpeaks/pen/gOJmzdo | |
float neuro(float ratio, vec2 uv, float t) { | |
mat2 rotate = mat2(0.540302, 0.841470, -0.841470, 0.540302); | |
vec2 p = vec2(uv.x * ratio, uv.y); | |
vec2 n = vec2(0.0, 0.0); | |
vec2 N = vec2(0.0, 0.0); | |
float S = uFactor; | |
for (int i = 0; i < uIterations; i++) { | |
p = mul(p, rotate); | |
n = mul(n, rotate); | |
vec2 q = p * S + float(i) + n + t; | |
n += sin(q); | |
N += (0.5 + 0.5 * cos(q)) / S; | |
S *= 1.2; | |
} | |
float o = N.x + N.y; | |
o = max(0.0, 1.2 * pow(o, 3.0) + pow(o, 10.0) - 0.5) * (1.0 - length(N - 0.5)); | |
return o; | |
} | |
void NeuroEmissive( inout FragmentState s ) | |
{ | |
#ifdef Emissive | |
Emissive(s); | |
#endif | |
float ratio = uCustomScreenSize.x / uCustomScreenSize.y; | |
vec2 uv = s.vertexTexCoord.xy; | |
float t = uCustomAnimationTime * uSpeed; | |
float fraction = neuro(ratio, uv, t); | |
s.albedo.a = fraction; | |
} | |
#ifdef Emissive | |
#undef Emissive | |
#endif | |
#define Emissive NeuroEmissive |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment