Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(rendering): reduce gradient noise intensity with 0.25 multiplier

Richie McIlroy94e10b5b0239
diff --git a/apps/desktop/src/routes/editor/GradientEditor.tsx b/apps/desktop/src/routes/editor/GradientEditor.tsx
index ac036f98b..81fad0a60 100644
--- a/apps/desktop/src/routes/editor/GradientEditor.tsx
+++ b/apps/desktop/src/routes/editor/GradientEditor.tsx
@@ -34,6 +34,9 @@ export const GRADIENT_PRESETS = [
{ from: [255, 0, 255], to: [0, 255, 0] },
] satisfies Array<{ from: RGBColor; to: RGBColor }>;
+const DEFAULT_NOISE_SCALE = 3;
+const NOISE_INTENSITY_MULTIPLIER = 0.25;
+
function randomColor(): RGBColor {
return [
Math.floor(Math.random() * 256),
@@ -53,7 +56,7 @@ export function GradientEditor() {
const angle = () => source()?.angle ?? 90;
const noiseIntensity = () => source()?.noise_intensity ?? 0;
- const noiseScale = () => source()?.noise_scale ?? 50;
+ const noiseScale = () => source()?.noise_scale ?? DEFAULT_NOISE_SCALE;
const updateGradient = (updates: Partial<GradientSourceFields>) => {
setProject("background", "source", updates as Record<string, unknown>);
@@ -72,6 +75,10 @@ export function GradientEditor() {
return (0.3 + ((100 - scale) / 100) * 1.2).toFixed(3);
});
+ const noiseOpacity = createMemo(
+ () => (noiseIntensity() / 100) * NOISE_INTENSITY_MULTIPLIER,
+ );
+
return (
<Show when={source()}>
{(src) => (
@@ -88,7 +95,7 @@ export function GradientEditor() {
<svg
class="absolute inset-0 w-full h-full pointer-events-none"
style={{
- opacity: noiseIntensity() / 100,
+ opacity: noiseOpacity(),
"mix-blend-mode": "overlay",
}}
>
diff --git a/crates/rendering/src/shaders/gradient-or-color.wgsl b/crates/rendering/src/shaders/gradient-or-color.wgsl
index cdd77ea1a..d78e8dfce 100644
--- a/crates/rendering/src/shaders/gradient-or-color.wgsl
+++ b/crates/rendering/src/shaders/gradient-or-color.wgsl
@@ -61,7 +61,7 @@ fn fs_main(@location(0) tex_coords: vec2<f32>) -> @location(0) vec4<f32> {
overlay_channel(color.b, n),
);
- let intensity = u.noise_intensity / 100.0;
+ let intensity = (u.noise_intensity / 100.0) * 0.25;
color = vec4<f32>(mix(color.rgb, blended, intensity), color.a);
}