#Custom Render Pipeline Documentation

18 messages · Page 1 of 1 (latest)

hard pumice
#

Does anyone know of any resources (other than the source code), that shows a custom render pipeline being integrated into Bevy?

dense laurel
#

Depends. What are you trying to achieve?

#

What kind of rendering do you want to do?

hard pumice
#

I'm looking to do a few things:

  • Custom shaders with optimisations for specific use-cases.
  • Custom render passes.
  • Some compute shaders.
  • Learn some more WGPU.

I'm not looking to use the bevy_pbr pipeline, so I've been reading through how it integrates into bevy_render. I was hoping there might be some up-to-date resources that I could use to figure out how to do this correctly.

hard pumice
#

I did have a look at bevy-hikari but it's a fair bit behind version wise on Bevy so I can't rely on that for some pointers.

dense laurel
#

It really depends... If you want like customer object rendering, there's a variety of ways to do things. You could reuse bevy's gbuffer for lighting and just have a custom draw call to write the gbuffer, or do fully custom, etc

#

Or if you just want some post processing or certain effects you can do that and reuse the rest of bevy

#

It kinda heavily depends on what you want to do

#

If you have some more concrete use cases I'd be happy to show you where to get started

hard pumice
#

Initially what I'm looking to do is:
[x] Create a custom Cuboid component with a size field.
[x] Extract the cuboid in the ExtractSchedule set.
[x] Prepare the cuboid (create or retrieve WGPU buffers for vertices, indices) based on the extracted data.
[x] Prepare bind groups.
[ ] Figure out how to integrate in to the render graph.
[ ] Figure out how to issue draw calls while incorporating the views/camera stuff Bevy has.

#

Are there any resources that breakdown how the current bevy_render crate works in detail? I'm just guessing based on the bevy_pbr crate.

dense laurel
#
  1. Just create a bevy component
  2. Derive ExtractComponent, add ExtractComponentPlugin<Cuboid> to the main render world. You might also need SyncComponentPlugin or something? Idr tbh
    3/4. Setup prepare systems in the render world. Or do this whenever you want really, but prepare is the typical RenderSet.
  3. Add a custom render node to the render graph. Lots of examples of this>
  4. Make a draw call in your render node
#

If you want to reuse the existing render passes, you need a custom draw/phase item thing, I'm less familiar with the details of that, but there's an example for it

hard pumice
#

Right, so the impls of RenderCommand for unit structs like DrawMesh are for the draw/phase stuff?

dense laurel
#

Yeah

#

The main/prepass/etc nodes all have corresponding render phases. Each phase is a list of items to draw, where the RenderCommand draw stuff is how it knows what commands to do for each item.

hard pumice
#

Right okay I see.

#

Thanks for your help, that should be plenty to help me understand what I'm looking at.