The fourth major refactor of how we're approaching rendering with bevy. To recap:
First, we simply ran nannou's existing pipeline in a bevy render node. This represented minimal changes but was barely integrated with bevy.
Second, we attempted to use bevy's mid level render APIs in order to use Bevy's meshes, but manage our own shader lifecycle.
Third (and the current state of bevy-refactor, we used bevy mesh-material API to avoid needing much custom rendering code.
While the material approach was great, it introduced a few problems, namely that it leaked a lot of details of the bevy pbr pipeline into nannou. While this was cool in some cases (emissives!), it also was potentially confusing to users. Additionally, it prevented us from having a simple way to implement additional render commands, i.e. explicit instancing or indirect draw, as bevy's material system doesn't support these.
This PR returns to a solution that is largely based around the mid-level APIs. The intention here is to decouple nannou from bevy's material system, while still using a similar kind of pattern.
As such, we want to lean on the ShaderModel trait, and use that as the core "material" for our rendering, and avoid exposing users to any details about bevy's pbr shaders.
Implementation
Much of the new rendering code is similar to code found in bevy's material pipeline, with a few primary differences:
When queueing materials, we are generic over the bevy "draw function", which allows us to implement different draw strategies for things like instancing and indirect draw. These are triggered by spawning a mesh with a different market component, e.g. InstancedMesh, as managed by our draw render commands.
Nannou meshes now only run in the transparent phase, which forces them to be sorted according to their draw order.
We are using a default shader that is similar to nannou's roots, but takes a lot of inspiration from the bevy 2d shader.
Nannous "default" shader model is now just a simple model that provides a base color and texture field.
How to review
The bulk of the changes are located in bevy_nannou_draw, but likely require familiarity with bevy's mid-level. Pay attention to the ways in which indirect and instanced drawing are implemented now.
ShaderModel
based renderingThe fourth major refactor of how we're approaching rendering with bevy. To recap:
bevy-refactor
, we used bevy mesh-material API to avoid needing much custom rendering code.While the material approach was great, it introduced a few problems, namely that it leaked a lot of details of the bevy pbr pipeline into nannou. While this was cool in some cases (emissives!), it also was potentially confusing to users. Additionally, it prevented us from having a simple way to implement additional render commands, i.e. explicit instancing or indirect draw, as bevy's material system doesn't support these.
This PR returns to a solution that is largely based around the mid-level APIs. The intention here is to decouple nannou from bevy's material system, while still using a similar kind of pattern.
As such, we want to lean on the
ShaderModel
trait, and use that as the core "material" for our rendering, and avoid exposing users to any details about bevy's pbr shaders.Implementation
Much of the new rendering code is similar to code found in bevy's material pipeline, with a few primary differences:
InstancedMesh
, as managed by our draw render commands.How to review
The bulk of the changes are located in
bevy_nannou_draw
, but likely require familiarity with bevy's mid-level. Pay attention to the ways in which indirect and instanced drawing are implemented now.