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))
|
// (These two could be cut with vec2(0.0,1.0) + uv * vec2(1.0,-1.0))
|
||||||
var correct_uv = uv;
|
var correct_uv = uv;
|
||||||
correct_uv.y = 1.0 - correct_uv.y;
|
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
|
// Gradients
|
||||||
let px = dpdx(bary.xy);
|
let px = dpdx(bary.xy);
|
||||||
|
|
@ -44,18 +44,30 @@ struct FragUniform {
|
||||||
dist /= 300.0;
|
dist /= 300.0;
|
||||||
|
|
||||||
// Border rendering.
|
// 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.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); }
|
// if (dist > 0.2 && dist <= 0.3) { return vec4<f32>(0.0, 0.0, 1.0, 1.0); }
|
||||||
|
|
||||||
// WIREFRAME
|
// // Wireframe rendering.
|
||||||
// var barys = bary;
|
// let right_face_dist = bary.y;
|
||||||
// barys.z = 1.0 - barys.x - barys.y;
|
// let bottom_face_dist = bary.x-bary.y;
|
||||||
// let deltas = fwidth(barys);
|
// let left_face_dist = 1.0 - ((bottom_face_dist*2.0) + bary.y);
|
||||||
// let smoothing = deltas * 1.0;
|
// let normal_bary = vec3<f32>(right_face_dist, bottom_face_dist, left_face_dist);
|
||||||
// let thickness = deltas * 0.25;
|
|
||||||
// barys = smoothstep(thickness, thickness + smoothing, barys);
|
// let fwd = fwidth(normal_bary);
|
||||||
// let min_bary = min(barys.x, min(barys.y, barys.z));
|
// let w = smoothstep(border_width * fwd, (border_width + border_smoothing) * fwd, normal_bary);
|
||||||
// color = vec4(min_bary * color.xyz, 1.0);
|
// 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);
|
return color * f32(dist >= 0.0 || ubos[triangle_index].type_ == 2u);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue