Skip to content

Commit

Permalink
[shaders] Add 'evolutes' macro to defines
Browse files Browse the repository at this point in the history
  • Loading branch information
armansito committed Jun 10, 2024
1 parent d6e07ef commit d8ced35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
7 changes: 3 additions & 4 deletions vello_shaders/shader/flatten.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions vello_shaders/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit d8ced35

Please sign in to comment.