forked from 1b-agent/opencadstudio-upstream
Blend gradient backgrounds linearly; two colours over twice the view
Measured against the reference: a two-colour gradient reaches its end colours a viewport beyond the edges, and the bands blend linearly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46daf03bc9
commit
bd4029fb50
1 file changed
+6
-4
@@ -120,11 +120,13 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
|||||||
let horizon = clamp(u.background_params.y, 0.0, 1.0);
|
let horizon = clamp(u.background_params.y, 0.0, 1.0);
|
||||||
let half_height = abs(u.background_params.z) * 0.5;
|
let half_height = abs(u.background_params.z) * 0.5;
|
||||||
if half_height <= 1e-6 {
|
if half_height <= 1e-6 {
|
||||||
// Two colours: one blend from the bottom to the top.
|
// Two colours: one blend from the bottom to the top, over twice
|
||||||
color = mix(u.background_bottom.rgb, u.background_top.rgb, coordinate);
|
// the viewport (the reference's two-colour gradient reaches the
|
||||||
|
// end colours a viewport beyond the edges).
|
||||||
|
color = mix(u.background_bottom.rgb, u.background_top.rgb, 0.25 + 0.5 * coordinate);
|
||||||
} else {
|
} else {
|
||||||
let lower = smoothstep(horizon - half_height, horizon, coordinate);
|
let lower = clamp((coordinate - (horizon - half_height)) / half_height, 0.0, 1.0);
|
||||||
let upper = smoothstep(horizon, horizon + half_height, coordinate);
|
let upper = clamp((coordinate - horizon) / half_height, 0.0, 1.0);
|
||||||
let low_color = mix(u.background_bottom.rgb, u.background_middle.rgb, lower);
|
let low_color = mix(u.background_bottom.rgb, u.background_middle.rgb, lower);
|
||||||
color = mix(low_color, u.background_top.rgb, upper);
|
color = mix(low_color, u.background_top.rgb, upper);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user