Horrific & Open_file
Hey, I’ve been tinkering with a framework for procedural horror textures—thought you’d love to see how code can make fear feel more alive.
Sounds deliciously twisted. Show me the raw shadows—I'm itching to see how your algorithm drips dread onto the surface.
Sure thing, here’s a stripped‑down fragment shader that pulls a nasty shadow map from a 2D noise texture and then modulates it with a black‑hole‑style falloff. Copy this into a WebGL or Unity shader and watch the dread grow.
```
uniform sampler2D uNoiseTex;
uniform float uTime;
uniform vec2 uResolution;
vec2 cellUV(vec2 uv) {
return floor(uv * 8.0) / 8.0;
}
float hash(vec2 p) {
return fract(sin(dot(p, vec2(12.9898,78.233))) * 43758.5453);
}
float noise(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
float a = hash(i);
float b = hash(i + vec2(1.0, 0.0));
float c = hash(i + vec2(0.0, 1.0));
float d = hash(i + vec2(1.0, 1.0));
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
}
float shadowDrop(vec2 uv) {
float n = noise(uv * 4.0 + uTime * 0.1);
float depth = pow(n, 4.0); // darken low noise, keep peaks
float falloff = smoothstep(0.0, 1.0, length(uv - 0.5) * 2.0);
return depth * falloff;
}
void main() {
vec2 uv = gl_FragCoord.xy / uResolution;
float rawShadow = shadowDrop(uv);
vec3 col = vec3(rawShadow);
gl_FragColor = vec4(col, 1.0);
}
```
Drop the `uResolution`, `uTime`, and a simple white noise texture into your renderer, hit play, and let the shadows creep. The `smoothstep` term makes the dark areas grow as you move away from the center—perfect for a creepy vignette. Happy spooking!
Nice little wormhole—darkening those low‑noise spots like a secret hand. Maybe add a flicker or a slow rotation to keep the edge of terror fresh. Keep the shadows hunting; they'll never stop.
Here’s a quick tweak that adds a slow rotation and a jittery flicker to keep the horror alive. Just drop this into your fragment shader and keep the rest as before.
// rotate uv coordinates slowly around the center
vec2 rotateUV(vec2 uv, float angle) {
vec2 p = uv - 0.5;
float s = sin(angle);
float c = cos(angle);
mat2 rot = mat2(c, -s, s, c);
return rot * p + 0.5;
}
// flicker by mixing two noise octaves with a sine offset
float flickerNoise(vec2 p, float time) {
float n1 = noise(p * 4.0 + time * 0.05);
float n2 = noise(p * 8.0 + time * 0.07);
float mixVal = 0.5 + 0.5 * sin(time * 5.0);
return mix(n1, n2, mixVal);
}
// main
void main() {
vec2 uv = gl_FragCoord.xy / uResolution;
float rot = time * 0.01; // slow rotation
uv = rotateUV(uv, rot);
float n = flickerNoise(uv, time);
float depth = pow(n, 4.0);
float falloff = smoothstep(0.0, 1.0, length(uv - 0.5) * 2.0);
float rawShadow = depth * falloff;
vec3 col = vec3(rawShadow);
gl_FragColor = vec4(col, 1.0);
}
The `rotateUV` makes the pattern slowly spin, and `flickerNoise` swaps between two octaves in a sine‑driven way, so the darkness keeps twitching. Try it out and watch those shadows keep hunting.
That spin is like a slow heartbeat in the void. The flicker will keep anyone who watches feeling unsettled. Drop it in and let the darkness shuffle.