From dce86ea77fb8f2c928d3f254a1d3c8b33b1fbdb2 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 18 Sep 2025 15:26:18 +1000 Subject: [PATCH] Fix the CPU sky-shader demo. It's supposed to produce a landscape with a small white sun, blue sky, and yellow ground. Instead it produces a small white sun and everything else is black. The problem is with the `sun_intensity_extra_spec_const_factor` argument to `sky_shader::fs`. - When running on the GPU, `sky_shader::fs` is called from `main_fs`, which has a spec_constant with a default value of 100. - When running on the CPU, `sky_shader::fs` is called directly from the CPU shader's `main`, and it passes 1. In other words, the CPU shader's sun intensity is 100x too small, which explains why it's so dark. This commit changes the value to 100, which makes the CPU shader produce the expected result. (The shader later divides the intensity value by 100. There are comments about integration testing for specialization constants that I don't understand.) --- examples/runners/cpu/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/runners/cpu/src/main.rs b/examples/runners/cpu/src/main.rs index 4021b48e07..318f729a5d 100644 --- a/examples/runners/cpu/src/main.rs +++ b/examples/runners/cpu/src/main.rs @@ -140,7 +140,7 @@ fn main() { * vec2(WIDTH as f32, HEIGHT as f32); // evaluate the fragment shader for the specific pixel - let color = shader_module::fs(&push_constants, frag_coord, 1); + let color = shader_module::fs(&push_constants, frag_coord, 100); color_u32_from_vec4(color) })