examples/gkurve: update wireframe rendering to 2 barycentric coordinates
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
38091d0d1b
commit
8d067b62c2
1 changed files with 22 additions and 10 deletions
|
|
@ -27,7 +27,7 @@ struct FragUniform {
|
|||
// (These two could be cut with vec2(0.0,1.0) + uv * vec2(1.0,-1.0))
|
||||
var correct_uv = uv;
|
||||
correct_uv.y = 1.0 - correct_uv.y;
|
||||
let color = textureSample(myTexture, mySampler, correct_uv) * ubos[triangle_index].blend_color;
|
||||
var color = textureSample(myTexture, mySampler, correct_uv) * ubos[triangle_index].blend_color;
|
||||
|
||||
// Gradients
|
||||
let px = dpdx(bary.xy);
|
||||
|
|
@ -44,18 +44,30 @@ struct FragUniform {
|
|||
dist /= 300.0;
|
||||
|
||||
// Border rendering.
|
||||
let border_color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
let border_width = 3.0;
|
||||
let border_smoothing = 1.0;
|
||||
// if (dist > 0.0 && dist <= 0.1) { return vec4<f32>(1.0, 0.0, 0.0, 1.0); }
|
||||
// if (dist > 0.2 && dist <= 0.3) { return vec4<f32>(0.0, 0.0, 1.0, 1.0); }
|
||||
|
||||
// WIREFRAME
|
||||
// var barys = bary;
|
||||
// barys.z = 1.0 - barys.x - barys.y;
|
||||
// let deltas = fwidth(barys);
|
||||
// let smoothing = deltas * 1.0;
|
||||
// let thickness = deltas * 0.25;
|
||||
// barys = smoothstep(thickness, thickness + smoothing, barys);
|
||||
// let min_bary = min(barys.x, min(barys.y, barys.z));
|
||||
// color = vec4(min_bary * color.xyz, 1.0);
|
||||
// // Wireframe rendering.
|
||||
// let right_face_dist = bary.y;
|
||||
// let bottom_face_dist = bary.x-bary.y;
|
||||
// let left_face_dist = 1.0 - ((bottom_face_dist*2.0) + bary.y);
|
||||
// let normal_bary = vec3<f32>(right_face_dist, bottom_face_dist, left_face_dist);
|
||||
|
||||
// let fwd = fwidth(normal_bary);
|
||||
// let w = smoothstep(border_width * fwd, (border_width + border_smoothing) * fwd, normal_bary);
|
||||
// let width = 1.0 - min(min(w.x, w.y), w.z);
|
||||
// let epsilon = 0.001;
|
||||
// if (right_face_dist >= -epsilon && right_face_dist <= width
|
||||
// || left_face_dist >= -epsilon && left_face_dist <= width
|
||||
// || bottom_face_dist >= -epsilon && bottom_face_dist <= width) {
|
||||
// color = mix(color, border_color, width);
|
||||
// if (dist < 0.0 && ubos[triangle_index].type_ != 2u) {
|
||||
// return vec4<f32>(border_color.rgb, width);
|
||||
// }
|
||||
// }
|
||||
|
||||
return color * f32(dist >= 0.0 || ubos[triangle_index].type_ == 2u);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue