Skip to content

Commit 04b7632

Browse files
committed
Display visualizer name in Track Info and enhance 3D visualizer cameras, grid jitter, and Retro Fire soft bezel
1 parent cffb154 commit 04b7632

6 files changed

Lines changed: 52 additions & 15 deletions

File tree

src/engine.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3892,6 +3892,12 @@ impl VulkanEngine {
38923892
// 4. Type
38933893
ui.horizontal(|ui| { ui.label("Type"); ui.label(&state.module_type); });
38943894

3895+
// 4b. Visualization
3896+
let vis_name = crate::state::VISUALIZERS.get(state.current_visualizer_idx)
3897+
.map(|v| v.name)
3898+
.unwrap_or("Unknown");
3899+
ui.horizontal(|ui| { ui.label("Visualization"); ui.label(vis_name); });
3900+
38953901
// 5. Video
38963902
if let Some(video) = &state.video_info {
38973903
if video == "Unsupported Codec" {

src/shaders/vis_3doscilloscope.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
5858
// Subtly rotate camera around center
5959
let rot_angle = sin(audio.time * 0.2) * 0.15;
6060
let cam_dist = 3.2;
61-
let cam_height = 1.8; // Higher up to look down at the grid
61+
let cam_height = 1.7; // Adjusted camera height
6262

6363
let ro = vec3<f32>(sin(rot_angle) * cam_dist, -cos(rot_angle) * cam_dist, cam_height);
64-
let cam_target = vec3<f32>(0.0, 0.0, 0.0);
64+
let cam_target = vec3<f32>(0.0, 0.8, 0.0); // Target adjusted to push the far edge higher up in the frame
6565

6666
let w = normalize(cam_target - ro);
6767
let u = normalize(cross(w, vec3<f32>(0.0, 0.0, 1.0)));

src/shaders/vis_3doscilloscope_freq.wgsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
5959
// Subtly rotate camera around center
6060
let rot_angle = sin(audio.time * 0.2) * 0.15;
6161
let cam_dist = 3.2;
62-
let cam_height = 1.8; // Higher up to look down at the grid
62+
let cam_height = 1.7; // Adjusted camera height
6363

6464
let ro = vec3<f32>(sin(rot_angle) * cam_dist, -cos(rot_angle) * cam_dist, cam_height);
65-
let cam_target = vec3<f32>(0.0, 0.0, 0.0);
65+
let cam_target = vec3<f32>(0.0, 0.8, 0.0); // Target adjusted to push the far edge higher up in the frame
6666

6767
let w = normalize(cam_target - ro);
6868
let u = normalize(cross(w, vec3<f32>(0.0, 0.0, 1.0)));
@@ -81,7 +81,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
8181
for (var i = 0u; i < num_lines; i = i + 1u) {
8282
// Z layout: back to front. i=0 is back (low freq), i=31 is front (high freq).
8383
let i_f = f32(i);
84-
let y_line = mix(5.64, -1.8, i_f / 31.0);
84+
let y_line = mix(9.48, -1.8, i_f / 31.0);
8585

8686
let t = (y_line - ro.y) / rd.y;
8787

src/shaders/vis_3doscilloscope_raster.wgsl

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ fn vs_main_3d(in: VertexInput) -> VertexOutput3D {
7474
// Camera rotation matches the original 3D CRT Oscilloscope
7575
let rot_angle = sin(audio.time * 0.2) * 0.15;
7676
let cam_dist_val = 3.2;
77-
let cam_height = 1.8;
77+
let cam_height = 1.7; // Adjusted camera height to match others
7878
let ro = vec3<f32>(sin(rot_angle) * cam_dist_val, cam_height, -cos(rot_angle) * cam_dist_val);
79-
let cam_target = vec3<f32>(0.0, 0.0, 0.0);
79+
let cam_target = vec3<f32>(0.0, 0.0, 0.8); // Target adjusted to match others (Depth Z = 0.8, Height Y = 0.0)
8080

8181
let f = normalize(cam_target - ro);
8282
let s = normalize(cross(f, vec3<f32>(0.0, 1.0, 0.0)));
@@ -89,7 +89,18 @@ fn vs_main_3d(in: VertexInput) -> VertexOutput3D {
8989
vec4<f32>(-dot(s, ro), -dot(u, ro), dot(f, ro), 1.0)
9090
);
9191

92-
let clip_pos = camera.proj_matrix * view_matrix * vec4<f32>(p3, 1.0);
92+
let view_pos = view_matrix * vec4<f32>(p3, 1.0);
93+
// Custom projection matrix to match the 116 degree horizontal / 84 degree vertical FOV of the raymarched versions
94+
let p_00 = 1.0 / (0.9 * audio.aspect_ratio);
95+
let p_11 = 1.11111111;
96+
let p_22 = -1.0001;
97+
let p_32 = -0.10001;
98+
let clip_pos = vec4<f32>(
99+
view_pos.x * p_00,
100+
view_pos.y * p_11,
101+
view_pos.z * p_22 + p_32,
102+
-view_pos.z
103+
);
93104

94105
// Apply barrel distortion in clip space (NDC) to match the curved CRT glass
95106
let ndc = clip_pos.xy / max(clip_pos.w, 0.0001);
@@ -124,8 +135,10 @@ fn fs_main(in: VertexOutput3D) -> @location(0) vec4<f32> {
124135
// UV derivative-based wireframe grid shader
125136
// Width has 128 lines, depth has 72 lines
126137
let grid_res = vec2<f32>(128.0, 72.0);
127-
let fwidth_uv = fwidth(in.uv * grid_res) + 0.0001;
128-
138+
139+
// Use the continuous world-space Z for the vertical grid coordinate to eliminate temporal jitter
140+
let uv_g = vec2<f32>(in.uv.x, (in.world_pos.z + 1.8) / 10.8);
141+
129142
// Amplitude-reactive bloom width and brightness
130143
let wave_height = clamp(abs(in.hit_val) * 2.0, 0.0, 1.0);
131144
let bloom_boost = 1.0 + wave_height * 0.8;
@@ -134,22 +147,23 @@ fn fs_main(in: VertexOutput3D) -> @location(0) vec4<f32> {
134147
let offset_r = vec2<f32>(0.0005, 0.0003);
135148
let offset_b = vec2<f32>(-0.0005, -0.0003);
136149

150+
let fwidth_uv = fwidth(uv_g * grid_res) + 0.0001;
151+
137152
// Red Channel Grid
138-
let uv_r = in.uv + offset_r;
153+
let uv_r = uv_g + offset_r;
139154
let grid_r = abs(fract(uv_r * grid_res - 0.5) - 0.5) / fwidth_uv;
140155
let line_r = min(grid_r.x, grid_r.y) / (1.0 + total_coc);
141156
let wire_r = exp(-line_r * 1.8) / (1.0 + total_coc * 0.5) +
142157
(exp(-line_r * 0.15) * 0.45 / (1.0 + total_coc * 0.2) + exp(-line_r * 0.04) * 0.2 / (1.0 + total_coc * 0.1)) * bloom_boost;
143158

144159
// Green/Amber Channel Grid (center)
145-
let uv_g = in.uv;
146160
let grid_g = abs(fract(uv_g * grid_res - 0.5) - 0.5) / fwidth_uv;
147161
let line_g = min(grid_g.x, grid_g.y) / (1.0 + total_coc);
148162
let wire_g = exp(-line_g * 1.8) / (1.0 + total_coc * 0.5) +
149163
(exp(-line_g * 0.15) * 0.45 / (1.0 + total_coc * 0.2) + exp(-line_g * 0.04) * 0.2 / (1.0 + total_coc * 0.1)) * bloom_boost;
150164

151165
// Blue Channel Grid
152-
let uv_b = in.uv + offset_b;
166+
let uv_b = uv_g + offset_b;
153167
let grid_b = abs(fract(uv_b * grid_res - 0.5) - 0.5) / fwidth_uv;
154168
let line_b = min(grid_b.x, grid_b.y) / (1.0 + total_coc);
155169
let wire_b = exp(-line_b * 1.8) / (1.0 + total_coc * 0.5) +

src/shaders/vis_flame.wgsl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
3333
// --- CRT barrel distortion ---
3434
let uv = crt_distort_uv(in.uv, 0.03);
3535

36-
// Outside the CRT tube → pure black
37-
if uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 {
36+
// Hard check slightly outside the tube to save performance
37+
if uv.x < -0.015 || uv.x > 1.015 || uv.y < -0.015 || uv.y > 1.015 {
3838
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
3939
}
4040

41+
// Soft bezel/vignette boundary fade (blends/blurs the hard edges nicely)
42+
let bezel_fade_x = smoothstep(0.0, 0.015, uv.x) * smoothstep(1.0, 0.985, uv.x);
43+
let bezel_fade_y = smoothstep(0.0, 0.015, uv.y) * smoothstep(1.0, 0.985, uv.y);
44+
let bezel = bezel_fade_x * bezel_fade_y;
45+
4146
// --- Pixelate to virtual resolution (nearest-neighbor, chunky pixels) ---
4247
let virt_res = vec2<f32>(256.0, 144.0);
4348
let pixel_coord = floor(uv * virt_res);
@@ -91,5 +96,8 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
9196
crt_settings.flicker_intensity = 0.03;
9297
color = apply_crt_effects(color, in.uv, in.clip_position.xy, audio.smooth_time, crt_settings);
9398

99+
// Apply soft bezel edge fade
100+
color *= bezel;
101+
94102
return vec4<f32>(color, 1.0);
95103
}

src/ui.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ pub fn draw(f: &mut Frame, state: &AppState) {
252252
Span::raw(&state.module_type)
253253
]));
254254

255+
// 4b. Visualization
256+
let vis_name = crate::state::VISUALIZERS.get(state.current_visualizer_idx)
257+
.map(|v| v.name)
258+
.unwrap_or("Unknown");
259+
lines.push(Line::from(vec![
260+
Span::raw("Vis: "),
261+
Span::raw(vis_name)
262+
]));
263+
255264
// 5. BPM (if available)
256265
if state.bpm > 0 {
257266
lines.push(Line::from(vec![

0 commit comments

Comments
 (0)