diff --git a/render/wgpu/shaders/gradient/common.wgsl b/render/wgpu/shaders/gradient/common.wgsl index e3af71a03..90e72a398 100644 --- a/render/wgpu/shaders/gradient/common.wgsl +++ b/render/wgpu/shaders/gradient/common.wgsl @@ -92,26 +92,6 @@ fn main_fragment(in: VertexOutput) -> @location(0) vec4 { // Calculate normalized `t` position in gradient, [0.0, 1.0] being the bounds of the ratios. var t: f32 = find_t(gradient.focal_point, in.uv); - #if gradient_repeat_mode == 1 - // Mirror - if( t < 0.0 ) { - t = -t; - } - if ( (i32(t) & 1) == 0 ) { - t = fract(t); - } else { - t = 1.0 - fract(t); - } - #endif - #if gradient_repeat_mode == 2 - // Repeat - t = fract(t); - #endif - #if gradient_repeat_mode == 3 - // Clamp - t = clamp(t, 0.0, 1.0); - #endif - t = clamp(t, ratio(0u), ratio(last)); // Find the two gradient colors bordering our position. diff --git a/render/wgpu/shaders/gradient/mode/focal.wgsl b/render/wgpu/shaders/gradient/mode/focal.wgsl index 820e92846..d44e13dce 100644 --- a/render/wgpu/shaders/gradient/mode/focal.wgsl +++ b/render/wgpu/shaders/gradient/mode/focal.wgsl @@ -5,7 +5,27 @@ override fn gradient::find_t(focal_point: f32, uv: vec2) -> f32 { var d: vec2 = vec2(focal_point, 0.0) - uv; let l = length(d); d = d / l; - return l / (sqrt(1.0 - focal_point * focal_point * d.y * d.y) + focal_point * d.x); + var t = l / (sqrt(1.0 - focal_point * focal_point * d.y * d.y) + focal_point * d.x); + #if gradient_repeat_mode == 1 + // Mirror + if( t < 0.0 ) { + t = -t; + } + if ( (i32(t) & 1) == 0 ) { + t = fract(t); + } else { + t = 1.0 - fract(t); + } + #endif + #if gradient_repeat_mode == 2 + // Repeat + t = fract(t); + #endif + #if gradient_repeat_mode == 3 + // Clamp + t = clamp(t, 0.0, 1.0); + #endif + return t; } @vertex diff --git a/render/wgpu/shaders/gradient/mode/linear.wgsl b/render/wgpu/shaders/gradient/mode/linear.wgsl index bf865cac9..94655b644 100644 --- a/render/wgpu/shaders/gradient/mode/linear.wgsl +++ b/render/wgpu/shaders/gradient/mode/linear.wgsl @@ -1,7 +1,27 @@ #import gradient override fn gradient::find_t(focal_point: f32, uv: vec2) -> f32 { - return uv.x; + var t = uv.x; + #if gradient_repeat_mode == 1 + // Mirror + if( t < 0.0 ) { + t = -t; + } + if ( (i32(t) & 1) == 0 ) { + t = fract(t); + } else { + t = 1.0 - fract(t); + } + #endif + #if gradient_repeat_mode == 2 + // Repeat + t = fract(t); + #endif + #if gradient_repeat_mode == 3 + // Clamp + t = clamp(t, 0.0, 1.0); + #endif + return t; } @vertex diff --git a/render/wgpu/shaders/gradient/mode/radial.wgsl b/render/wgpu/shaders/gradient/mode/radial.wgsl index c6ee119c4..1ef871703 100644 --- a/render/wgpu/shaders/gradient/mode/radial.wgsl +++ b/render/wgpu/shaders/gradient/mode/radial.wgsl @@ -1,7 +1,27 @@ #import gradient override fn gradient::find_t(focal_point: f32, uv: vec2) -> f32 { - return length(uv * 2.0 - 1.0); + var t = length(uv * 2.0 - 1.0); + #if gradient_repeat_mode == 1 + // Mirror + if( t < 0.0 ) { + t = -t; + } + if ( (i32(t) & 1) == 0 ) { + t = fract(t); + } else { + t = 1.0 - fract(t); + } + #endif + #if gradient_repeat_mode == 2 + // Repeat + t = fract(t); + #endif + #if gradient_repeat_mode == 3 + // Clamp + t = clamp(t, 0.0, 1.0); + #endif + return t; } @vertex diff --git a/tests/tests/swfs/avm1/color_matrix_filter/test.swf b/tests/tests/swfs/avm1/color_matrix_filter/test.swf index 9976a1035..ea842aa9d 100644 Binary files a/tests/tests/swfs/avm1/color_matrix_filter/test.swf and b/tests/tests/swfs/avm1/color_matrix_filter/test.swf differ diff --git a/tests/tests/swfs/avm2/textformat/test.swf b/tests/tests/swfs/avm2/textformat/test.swf index c361432db..3094ce422 100644 Binary files a/tests/tests/swfs/avm2/textformat/test.swf and b/tests/tests/swfs/avm2/textformat/test.swf differ diff --git a/tests/tests/swfs/visual/drawing_api/fills_and_lines/expected.png b/tests/tests/swfs/visual/drawing_api/fills_and_lines/expected.png index f6b998815..228212768 100644 Binary files a/tests/tests/swfs/visual/drawing_api/fills_and_lines/expected.png and b/tests/tests/swfs/visual/drawing_api/fills_and_lines/expected.png differ diff --git a/tests/tests/swfs/visual/drawing_api/fills_and_lines/test.toml b/tests/tests/swfs/visual/drawing_api/fills_and_lines/test.toml index f4264f815..459c55fbe 100644 --- a/tests/tests/swfs/visual/drawing_api/fills_and_lines/test.toml +++ b/tests/tests/swfs/visual/drawing_api/fills_and_lines/test.toml @@ -1,8 +1,7 @@ num_frames = 1 -ignore = true [image_comparison] -tolerance = 0 +tolerance = 2 [player_options] with_renderer = { optional = true, sample_count = 1 } \ No newline at end of file diff --git a/tests/tests/swfs/visual/simple_shapes/gradients/gradients/expected.png b/tests/tests/swfs/visual/simple_shapes/gradients/gradients/expected.png index 511283344..85d7535ad 100644 Binary files a/tests/tests/swfs/visual/simple_shapes/gradients/gradients/expected.png and b/tests/tests/swfs/visual/simple_shapes/gradients/gradients/expected.png differ diff --git a/tests/tests/swfs/visual/simple_shapes/gradients/gradients/test.toml b/tests/tests/swfs/visual/simple_shapes/gradients/gradients/test.toml index f4264f815..b4e1595ae 100644 --- a/tests/tests/swfs/visual/simple_shapes/gradients/gradients/test.toml +++ b/tests/tests/swfs/visual/simple_shapes/gradients/gradients/test.toml @@ -1,8 +1,7 @@ num_frames = 1 -ignore = true [image_comparison] -tolerance = 0 +tolerance = 1 [player_options] with_renderer = { optional = true, sample_count = 1 } \ No newline at end of file diff --git a/tests/tests/swfs/visual/simple_shapes/gradients/reflect/expected.png b/tests/tests/swfs/visual/simple_shapes/gradients/reflect/expected.png index bcfc315ac..fa0ff5e00 100644 Binary files a/tests/tests/swfs/visual/simple_shapes/gradients/reflect/expected.png and b/tests/tests/swfs/visual/simple_shapes/gradients/reflect/expected.png differ diff --git a/tests/tests/swfs/visual/simple_shapes/gradients/reflect/test.toml b/tests/tests/swfs/visual/simple_shapes/gradients/reflect/test.toml index f4264f815..b4e1595ae 100644 --- a/tests/tests/swfs/visual/simple_shapes/gradients/reflect/test.toml +++ b/tests/tests/swfs/visual/simple_shapes/gradients/reflect/test.toml @@ -1,8 +1,7 @@ num_frames = 1 -ignore = true [image_comparison] -tolerance = 0 +tolerance = 1 [player_options] with_renderer = { optional = true, sample_count = 1 } \ No newline at end of file diff --git a/tests/tests/swfs/visual/simple_shapes/gradients/repeat/expected.png b/tests/tests/swfs/visual/simple_shapes/gradients/repeat/expected.png index c736a97e3..87ec306fb 100644 Binary files a/tests/tests/swfs/visual/simple_shapes/gradients/repeat/expected.png and b/tests/tests/swfs/visual/simple_shapes/gradients/repeat/expected.png differ diff --git a/tests/tests/swfs/visual/simple_shapes/gradients/repeat/test.toml b/tests/tests/swfs/visual/simple_shapes/gradients/repeat/test.toml index f4264f815..b4e1595ae 100644 --- a/tests/tests/swfs/visual/simple_shapes/gradients/repeat/test.toml +++ b/tests/tests/swfs/visual/simple_shapes/gradients/repeat/test.toml @@ -1,8 +1,7 @@ num_frames = 1 -ignore = true [image_comparison] -tolerance = 0 +tolerance = 1 [player_options] with_renderer = { optional = true, sample_count = 1 } \ No newline at end of file