examples: created gkurve example #270

Merged
PiergiorgioZagaria merged 1 commit from main into main 2022-05-08 22:02:40 +00:00
PiergiorgioZagaria commented 2022-05-08 17:18:45 +00:00 (Migrated from github.com)
  • By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.

There is still much missing, like textures, correct matrices for positioning and some form of dynamic arrays in wgsl, but it's a start

- [X] By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right. There is still much missing, like textures, correct matrices for positioning and some form of dynamic arrays in wgsl, but it's a start
emidoots (Migrated from github.com) reviewed 2022-05-08 22:01:47 +00:00
@ -0,0 +85,4 @@
@stage(fragment) fn main(
@location(0) uv : vec2<f32>,
@interpolate(flat) @location(1) instance_index: u32,
) -> @location(0) vec4<f32> {
emidoots (Migrated from github.com) commented 2022-05-08 22:01:46 +00:00

Interesting how (relatively) complex this frag shader is. If my reading is correct, it's calculating barycentric coordinates for each fragment in the shader.

I think we can simplify this a lot (at least in terms of code, maybe with better perf too) by passing the barycentric coordinates of the triangle vertices as attributes to the vertex shade (simply (1, 0, 0), (0, 1, 0), and (0, 0, 1) for the 3 vertices of the triangle, as described e.g. here) and then have the vertex shader pass them to the fragment shader as varying - doing the interpolation for us so we have barycentric coordinates per fragment - and then use a rather simple shader to discard fragments on the side of a quadratic curve that we don't want

Interesting how (relatively) complex this frag shader is. If my reading is correct, it's calculating barycentric coordinates for each fragment in the shader. I think we can simplify this a lot (at least in terms of code, maybe with better perf too) by passing the barycentric coordinates of the triangle vertices as attributes to the vertex shade (simply `(1, 0, 0)`, `(0, 1, 0)`, and `(0, 0, 1)` for the 3 vertices of the triangle, as described e.g. [here](https://stackoverflow.com/a/25415763)) and then have the vertex shader pass them to the fragment shader as varying - doing the interpolation for us so we have barycentric coordinates per fragment - and then use a rather simple shader to discard fragments on the side of a quadratic curve that we don't want
emidoots (Migrated from github.com) approved these changes 2022-05-08 22:02:32 +00:00
emidoots (Migrated from github.com) left a comment

nice work, great starting point!

I'll look into if I can simplify this a bit. let's keeping discussing in the Matrix chat to see where we can bring this

nice work, great starting point! I'll look into if I can simplify this a bit. let's keeping discussing in the Matrix chat to see where we can bring this
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach!270
No description provided.