Skip to content

Commit cfc9566

Browse files
committed
fix stacking gradients
1 parent f0a4760 commit cfc9566

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

examples/tests/dynamic-shader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default async function ({ renderer }: ExampleSettings) {
4040
angle: 220,
4141
colors: [
4242
0xff0000ff, 0x00ff00ff, 0xff0000ff, 0x0000ffff, 0xffff00ff,
43-
0xff0000ff,
43+
0xff000000,
4444
],
4545
},
4646
},
@@ -210,7 +210,7 @@ export default async function ({ renderer }: ExampleSettings) {
210210
{
211211
type: 'radialGradient',
212212
props: {
213-
colors: [0xff0000ff, 0x00ff00ff, 0x0000ffff],
213+
colors: [0xff0000ff, 0x00ff00ff, 0x00000000],
214214
stops: [0.1, 0.4, 1.0],
215215
height: 200,
216216
width: 1000,

src/core/renderers/webgl/shaders/effects/LinearGradientEffect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class LinearGradientEffect extends ShaderEffect {
176176
stopCalc = (dist - stops[i]) / (stops[i + 1] - stops[i]);
177177
colorOut = mix(colorOut, colors[i + 1], clamp(stopCalc, 0.0, 1.0));
178178
}
179-
return colorOut;
179+
return mix(maskColor, colorOut, colorOut.a);
180180
`;
181181
};
182182
}

src/core/renderers/webgl/shaders/effects/RadialGradientEffect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class RadialGradientEffect extends ShaderEffect {
153153
stopCalc = (dist - stops[i]) / (stops[i + 1] - stops[i]);
154154
colorOut = mix(colorOut, colors[i + 1], clamp(stopCalc, 0.0, 1.0));
155155
}
156-
return colorOut;
156+
return mix(maskColor, colorOut, colorOut.a);
157157
`;
158158
};
159159
}

0 commit comments

Comments
 (0)