From 7b68630d6a8ce672aa38dbd2c3a3c677d0748458 Mon Sep 17 00:00:00 2001 From: Chad Brokaw Date: Mon, 15 May 2023 14:54:44 -0400 Subject: [PATCH] refactor common scale ratio code --- shader/draw_leaf.wgsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shader/draw_leaf.wgsl b/shader/draw_leaf.wgsl index 9845fdd..59e9e97 100644 --- a/shader/draw_leaf.wgsl +++ b/shader/draw_leaf.wgsl @@ -201,9 +201,9 @@ fn main( ); } else { let a = radius * radius - 1.0; - let a_recip = 1.0 / a; - let scale_x = radius * a_recip * abs(1.0 - focal_x); - let scale_y = sqrt(abs(a)) * a_recip * abs(1.0 - focal_x); + let scale_ratio = abs(1.0 - focal_x) / a; + let scale_x = radius * scale_ratio; + let scale_y = sqrt(abs(a)) * scale_ratio; user_to_scaled = transform_mul( Transform(vec4(scale_x, 0.0, 0.0, scale_y), vec2(0.0)), user_to_unit_line