Skip to content

Commit fc6800f

Browse files
committed
Trailer progress
1 parent 90d08e0 commit fc6800f

6 files changed

Lines changed: 480 additions & 0 deletions

File tree

resources/trailer/PufferNet.png

19.7 KB
Loading

resources/trailer/glow_330.fs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#version 330
2+
3+
in vec2 fragTexCoord;
4+
out vec4 finalColor;
5+
6+
uniform sampler2D texture0;
7+
uniform vec2 texelSize; // 1.0 / vec2(textureWidth, textureHeight)
8+
uniform float glowStrength; // driven by cos in time
9+
uniform float fadeAlpha; // 0..1 fade-in multiplier
10+
11+
void main()
12+
{
13+
vec2 uv = fragTexCoord;
14+
float c = texture(texture0, uv).a;
15+
16+
// Solid pixels stay fully opaque — no shader math needed
17+
if (c > 0.5) {
18+
vec3 color = vec3(0.0, 0.87, 0.87);
19+
finalColor = vec4(color * fadeAlpha, fadeAlpha);
20+
return;
21+
}
22+
23+
// Find the distance to the nearest solid pixel, then apply a smooth
24+
// exponential falloff on that distance. This gives a proper gradient
25+
// rather than a flat accumulated plateau.
26+
float min_dist = 32.0;
27+
int R = 32;
28+
for (int dx = -R; dx <= R; dx++) {
29+
for (int dy = -R; dy <= R; dy++) {
30+
float s = texture(texture0, uv + texelSize * vec2(dx, dy)).a;
31+
if (s > 0.5) {
32+
min_dist = min(min_dist, length(vec2(dx, dy)));
33+
}
34+
}
35+
}
36+
37+
float glow = exp(-0.12 * min_dist); // bright at d=1, fades over ~20px
38+
float halo = glow * (0.4 + glowStrength * 0.6) * fadeAlpha;
39+
vec3 color = vec3(0.0, 0.87, 0.87);
40+
finalColor = vec4(color * halo, halo);
41+
}

resources/trailer/glow_330.vs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#version 330
2+
3+
in vec3 vertexPosition;
4+
in vec2 vertexTexCoord;
5+
6+
uniform mat4 mvp;
7+
8+
out vec2 fragTexCoord;
9+
10+
void main()
11+
{
12+
fragTexCoord = vertexTexCoord;
13+
gl_Position = mvp * vec4(vertexPosition, 1.0);
14+
}

resources/trailer/star_330.fs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#version 330
2+
3+
in vec4 fragColor;
4+
out vec4 finalColor;
5+
6+
void main()
7+
{
8+
vec2 uv = gl_PointCoord - vec2(0.5);
9+
float r = length(uv);
10+
float angle = atan(uv.y, uv.x);
11+
12+
// Multi-lobe Gaussian core (tight + medium + wide)
13+
float core = exp(-120.0 * r * r);
14+
float mid = exp(- 30.0 * r * r) * 0.5;
15+
float corona = exp(- 3.5 * r * r) * 0.35;
16+
17+
// Diffraction spikes: 4-point cross, sharp along axes
18+
// pow(abs(cos(angle*2)), p) peaks at 0, 90, 180, 270 degrees
19+
float spike_mask = pow(abs(cos(angle * 2.0)), 24.0);
20+
float spike = spike_mask * exp(-18.0 * r * r) * exp(-r * 4.0) * 1.2;
21+
22+
float brightness = core + mid + corona + spike;
23+
24+
if (brightness < 0.01)
25+
discard;
26+
27+
// Slight chromatic shift on spikes/corona toward cool blue
28+
vec3 color = fragColor.rgb * brightness;
29+
color += vec3(0.0, 0.05, 0.15) * spike;
30+
color += vec3(0.0, 0.02, 0.08) * corona;
31+
32+
finalColor = vec4(color, clamp(brightness, 0.0, 1.0));
33+
}

resources/trailer/star_330.vs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#version 330
2+
3+
in vec3 vertexPosition;
4+
in vec4 vertexColor;
5+
6+
uniform mat4 mvp;
7+
uniform float currentTime;
8+
9+
out vec4 fragColor;
10+
11+
float twinkle(float seed, float t) {
12+
// Stable per-star seed passed via vertexColor.a from CPU
13+
float phase = mod(seed * 137.5, 360.0);
14+
float frequency = 1.2 + mod(seed * 0.317, 3.0) * 0.9;
15+
float amplitude = 7.0;
16+
float base_size = 20.0;
17+
float size_variation = amplitude * sin(frequency * t + radians(phase));
18+
return max(1.0, base_size + size_variation);
19+
}
20+
21+
void main()
22+
{
23+
vec2 pos = vertexPosition.xy;
24+
float size_scale = vertexPosition.z;
25+
float seed = vertexColor.a; // stable per-star identity, not alpha
26+
27+
gl_Position = mvp * vec4(pos, 0.0, 1.0);
28+
gl_PointSize = twinkle(seed, currentTime) * size_scale;
29+
30+
fragColor = vertexColor;
31+
}

0 commit comments

Comments
 (0)