ForesightMiningSoftwareCorporation / bevy_polyline

Polyline Rendering for Bevy
https://crates.io/crates/bevy_polyline
Apache License 2.0
171 stars 43 forks source link

Feature request: Depth test bypass #25

Closed nicopap closed 2 years ago

nicopap commented 2 years ago

Hi. Thank for the great library.

I've been using bevy_polyline for a debugging library. And one feature I would really like is the ability to draw some polyline on top of everything else.

Given that often time, in a debugging context, you'll have your debug lines inside or very close to polygons, they are often occluded. Therefore, it would be very useful to be able to tell bevy_polyline to draw some lines on top of the rest of the geometry.

It would probably work by uploading a toggle (or a value saying how closer to the camera the line should be drawn) to the shader through a uniform (I'm very new to shader programming). On the user side, it would just be an additional field to the PolylineMaterial.

I'm going to experiment with this, see if I can come up with something clean enough to open a PR.

aevyrie commented 2 years ago

Yeah, we could maybe add a depth_bias field to the PolylineMaterial and access that in the shader. I've played around with a fixed offset to mimic the lines having thickness, and that worked okay - the only issues were that the meaning of that value was different depending on if perspective was enabled.

nicopap commented 2 years ago

the only issues were that the meaning of that value was different depending on if perspective was enabled.

Maybe an enum could solve that? I'm not sure, but I'll try that out in my experimentation.