From d8ced35475ab3dd7c961f5d350455363a05798f0 Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Sun, 9 Jun 2024 19:52:30 -0700 Subject: [PATCH] [shaders] Add 'evolutes' macro to defines --- vello_shaders/shader/flatten.wgsl | 7 +++---- vello_shaders/src/compile/mod.rs | 15 ++++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/vello_shaders/shader/flatten.wgsl b/vello_shaders/shader/flatten.wgsl index 5a26f5985..938d4dd65 100644 --- a/vello_shaders/shader/flatten.wgsl +++ b/vello_shaders/shader/flatten.wgsl @@ -584,10 +584,7 @@ fn flatten_euler( let lowering = EulerSegLoweringParams( es, transform, path_ix, t1, scale, offset, cubic_params.chord_len, tol, ); -// NOTE: change this to "ifndef" to disable rendering evolutes. -#ifdef evolute - contour = es_seg_flatten_offset(lowering, contour, vec2(0., 1.), /*flip=*/false); -#else +#ifdef evolutes let chord_len = length(es.p1 - es.p0); let cusp0 = es_params_curvature(es.params, 0.) * offset + chord_len; let cusp1 = es_params_curvature(es.params, 1.) * offset + chord_len; @@ -631,6 +628,8 @@ fn flatten_euler( flatten_offset_cusp_finalize(path_ix, transform, offset, &evolute_patch, &contour); contour = es_seg_flatten_offset(lowering, contour, vec2(t, 1.), /*flip=*/false); } +#else + contour = es_seg_flatten_offset(lowering, contour, vec2(0., 1.), /*flip=*/false); #endif last_p = this_pq1.point; last_q = this_pq1.deriv; diff --git a/vello_shaders/src/compile/mod.rs b/vello_shaders/src/compile/mod.rs index ab11729b3..0e9a5629f 100644 --- a/vello_shaders/src/compile/mod.rs +++ b/vello_shaders/src/compile/mod.rs @@ -195,13 +195,14 @@ impl ShaderInfo { let imports = preprocess::get_imports(shader_dir); let mut errors = vec![]; let mut info = HashMap::default(); - let defines: HashSet<_> = if cfg!(feature = "full") { - vec!["full".to_string()] - } else { - vec![] - } - .into_iter() - .collect(); + let defines: HashSet<_> = { + let mut defines = vec![]; + if cfg!(feature = "full") { + defines.push("full"); + } + defines.push("evolutes"); + defines.into_iter().map(|s| s.to_owned()).collect() + }; for entry in shader_dir .read_dir() .expect("Can read shader import directory")