Skip to content

Commit

Permalink
prep for 0.9 release
Browse files Browse the repository at this point in the history
  • Loading branch information
aevyrie committed Nov 13, 2022
1 parent 28705ba commit 8e67c6c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 45 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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",
] }
Expand All @@ -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",
] }
44 changes: 2 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,56 +21,16 @@ 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<Assets<PolylineMaterial>>,
mut polylines: ResMut<Assets<Polyline>>,
) {
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.

### 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.

Expand Down
Binary file removed nbody.gif
Binary file not shown.

0 comments on commit 8e67c6c

Please sign in to comment.