diff --git a/Cargo.toml b/Cargo.toml index 1d5bea1..b63421b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "bevy_polyline" -version = "0.3.0" +version = "0.4.0" description = "Polyline Rendering for Bevy" license = "MIT OR Apache-2.0" repository = "https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline" @@ -18,7 +18,7 @@ authors = [ [dependencies] bitflags = "1.3" -bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", default-features = false, features = [ +bevy = { version = "0.9", default-features = false, features = [ "render", "bevy_asset", ] } @@ -31,7 +31,7 @@ version = "0.10" lazy_static = "1.4.0" rand = "0.8.4" ringbuffer = "0.10" -bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", default-features = false, features = [ +bevy = { version = "0.9", default-features = false, features = [ "bevy_winit", "x11", ] } diff --git a/README.md b/README.md index b5b5c52..0a98b01 100644 --- a/README.md +++ b/README.md @@ -21,44 +21,9 @@ Bevy Polyline is a plugin for [Bevy Engine](https://bevyengine.org/) that adds i Bevy Polyline closely mimics the way `Mesh`es are rendered in Bevy. It works internally by passing a minimal Instance Buffer to the GPU, containing only the line segment endpoints and then completely determines all vertex positions within the vertex shader, such that the triangles form a line that is rotated around it's longitudinal axis to face towards the camera. The shader code is based on [this great tutorial by Rye Terrell](https://wwwtyro.net/2019/11/18/instanced-lines.html). -### Examples -There are two examples, linestrip demonstrates how to make a very basic static Polyline. nbody (shown in the above demo) demonstrates how to do updateable `Polyline`s, by changing the vertices of a `Polyline`. - ## Usage -Usage of Bevy Polyline is quite simple. First add it to your `Cargo.toml`: - -```toml -[dependencies] -bevy_polyline = "0.4" -``` - -You add it as a plugin to your app: -```rs -app.add_plugin(PolylinePlugin); -``` - -And then you can add some Polylines through PolylineBundle -```rs -fn setup( - mut commands: Commands, - mut polyline_materials: ResMut>, - mut polylines: ResMut>, -) { - commands.spawn(PolylineBundle { - polyline: polylines.add(Polyline { - vertices: vec![-Vec3::ONE, Vec3::ONE], - ..default() - }), - material: polyline_materials.add(PolylineMaterial { - width: 3.0, - color: Color::RED, - perspective: true, - ..default() - }), - ..default() - }); -} -``` + +See the `minimal` example for basic usage. ### Transform `Polyline`s respect positioning through `GlobalTransform`, so you can position them directly, or through the use of a `Transform` hierarchy. @@ -66,11 +31,6 @@ fn setup( ### PolylineMaterial Currently the main way of customizing a `Polyline` is by changing the `PolylineMaterial`, which, as can be seen above, has fields for `width`, `color` and `perspective`. `width` directly correlates to screen pixels in non-perspective mode. In `perspective` mode `width` gets divided by the w component of the homogeneous coordinate, meaning it corresponds to screen pixels at the near plane and becomes progressively smaller further away. -### Shaders -For more significant customization, you have to make a custom shader, although it's likely we'll add more shaders in the future. The current version only implements line strips (i.e. `PolyLine`s rendered as connected line segments) with no caps. - -Due to the nature of its instanced rendering, Bevy Polyline comes with fairly specific shaders. You can still replace these with custom ones, but you will have to keep a good chunk of the shader in tact if you want to use Bevy Polyline's way of creating the line triangles. - ### Aliasing/shimmering Bevy Polyline does some work to reduce aliasing, by implementing the line thinness fade from https://acegikmo.com/shapes/docs/#anti-aliasing. But if your line segments are very short, you will still see shimmering, caused by triangles < 1 pixel in size. This can be reduced by only adding segments of a minimum length. diff --git a/nbody.gif b/nbody.gif deleted file mode 100644 index ed85ad0..0000000 Binary files a/nbody.gif and /dev/null differ