Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions content/learn/book/rendering/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
+++
title = "Rendering"
template = "docs.html"
insert_anchor_links = "right"
[extra]
weight = 16
+++

To display stuff on screen, 3D rendering... (what about 2D?)

list of crates (pbr, core pipeline, mesh, light, anti_aliasing, etc)

Quick start example spawn mesh/camera/etc:
```rust

```

wgpu/supported platforms (webgpu, native, mobile, webgl2)

naga/wgsl/wesl

Where to stick?:
* Decals (forward, clustered) (stick with meshes?)
* OIT
* RenderLayers
* Particles (not upstreamed in bevy yet)
* Useful shader math stuff
11 changes: 11 additions & 0 deletions content/learn/book/rendering/animation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
+++
title = "TODO"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

Skinning
Morph targets
Animation controller stuff(?) (idk much about animation, and likely deserves it's own book section? Maybe dosen't belong in rendering)
11 changes: 11 additions & 0 deletions content/learn/book/rendering/anti-aliasing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
+++
title = "TODO"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

Types of aliasing: Geometric, specular, temporal

MSAA, FXAA, SMAA, TAA, DLSS, CAS sharpening
11 changes: 11 additions & 0 deletions content/learn/book/rendering/cameras.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
+++
title = "TODO"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

* Split screen / multi-camera
* Render-to-texture
* Minimap(?)
12 changes: 12 additions & 0 deletions content/learn/book/rendering/custom-materials.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
+++
title = "TODO"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

Material API
Mesh tag
Different vertex/fragment shader overrides (and how prepass/deferred/shadow mapping/virtual geometry plays with it)
PBR shader APIs
28 changes: 28 additions & 0 deletions content/learn/book/rendering/lighting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
+++
title = "TODO"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

Lighting considerations and overview:
* Direct vs indirect
* Diffuse vs specular
* Baked vs dynamic (dynamism, performance, quality, disk size, baking time)

* Direct Lighting Options
* DirectionalLight (and cascade setup)
* SpotLight
* PointLight
* Shadow mapping, PCF filtering and PCSS, shadow map resolution, NotShadowCaster/Receiver
* Indirect Lighting Options
* AmbientLight
* EnvironmentMapLight and GeneratedEnvironmentMapLight, Global camera vs LightProbe
* IrradianceVolume
* Lightmaps
* SSAO, SSR (no rough SSR yet, no SSGI yet)
* Volumetrics
* DistanceFog (non-PBR)
* FogVolume, VoumetricFog, and VolumetricLight
* Solari
20 changes: 20 additions & 0 deletions content/learn/book/rendering/low-level.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
+++
title = "TODO"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

_Not_ a tutorial for wgpu/graphics programming. Just bevy-specific concepts. Link to learn-wgpu instead.

RenderWorld, ExtractSchedule/world sync, and RenderSystems
SpecializedPipeline stuff
Render graph and nodes, add_command_buffer_generation_task()
RenderAssets
MeshAllocator
PipelineCache
GpuReadback stuff
Bind group(layout) helpers
RenderAdapter/RenderDevice/RenderQueue resources
Render-world camera stuff(?)
10 changes: 10 additions & 0 deletions content/learn/book/rendering/mesh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
+++
title = "TODO"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

Vertex attributes
Virtual geometry
25 changes: 25 additions & 0 deletions content/learn/book/rendering/performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
+++
title = "TODO"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

* Profile first! Really!! (Link to that part of the book)
* CPU vs GPU bottlenecks, render world and render commands vs GPU timeline
* Mesh/material auto-batching and pipeline/draw calls, MeshTag
* RenderDiagnostics
* Use a single-digits amount of shadow-casting lights
* Don't use more than ~10(?) lights affecting the same pixel
* Deferred vs forward vs forward with prepass
* Overdraw, culling, and wasted work
* RenderAssetUsages to save RAM
* VRAM usage in general (texture size, mesh size, etc)
* Optimize textures:
* Texture size (4k vs 1080p)
* Mipmaps (perf, not just quality)
* GPU-compressed texture formats (BC or ASTC)
* CPU-compressed files (zstd) (different than GPU-compressed _formats_)
* Give users the option to turn off more expensive features (e.g. lower SSAO quality, or adjust shadow map resolution)
* LOD/VisibilityRange/VirtualGeometry
17 changes: 17 additions & 0 deletions content/learn/book/rendering/post-processing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
+++
title = "TODO"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

Bloom
Tonemapping
Hdr component
Auto exposure
Skybox/Procedural atmosphere(?)
Motion blur
Depth of field
Chromatic abberation
Color grading
41 changes: 41 additions & 0 deletions content/learn/book/rendering/standard-material.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
+++
title = "Standard Material"
insert_anchor_links = "right"
[extra]
weight = 1
status = 'hidden'
+++

In Bevy, the main `Material` the engine provides is the `StandardMaterial`.

StandardMaterial, like most of the functionality in `bevy_pbr`, implements an idea called "physically based rendering", or PBR.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh not my favorite wikipedia page. It's kinda generic and not very informative. I'll see if I can find something better.


PBR is when you use formulas and units derived from real-world physics and math. PBR is oftentimes a concept more than a strict set of rules, and approximations are used in the name of performance, but where possible you try to stick to real-world physics.

Before PBR, artists designed lighting, material, and camera properties more ad-hoc. When answering the question "what color should this object be?", artists would just choose a value that they thought looked good. Properties like how shiny or smooth an object are were similiary made up by the artist.

While this process worked fine for smaller scenes, as larger movies and games got created, assets became harder to reuse. A coin that looked the correct shade of yellow, with a certain shininess in one scene, might look completely wrong when reused in another scene under different lighting conditions.

With PBR, to answer "what color should this object be?", you instead reference values from a database of real-world measurements like [Physically Based](https://physicallybased.info). Assets are more scene-independent, and behave consistently in a variety of different lighting conditions. Even if you're making a stylized game, PBR is still important.

## Theory

While `Material`s in Bevy implement fragment shaders (TODO: reference rendering stuff and the custom material chapter) that run arbitrary functions for computing the color of each pixel, `StandardMaterial` and PBR materials in general are based on the concept of a bidirectional reflectance distribution function (BRDF).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rendering noob commentary: I got a little confused here as it sounds like PBR materials do not implement fragment shaders. Is that true? I thought everything basically had a shader. I assume that BRDF is how colors are calculated? Or am I incorrect in my assumptions here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see later down this is clarified.

Copy link
Contributor Author

@JMS55 JMS55 Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback.

Your assumptions were correct - all materials have fragment shaders (well unless you're rendering depth-only but that's out of scope... anyways). You can do whatever you want in a fragment shader. Hardcode the result to blue, return a value based on the current time, etc. StandardMaterial's fragment shader implements physically based lighting. It loops over the list of lights in the scene, and multiplies the light contribution by the BRDF. The sum of these values is the final pixel color.

I'll reword the section.


In the real world, when light hits a surface, a portion of the energy is absorbed, and a portion is reflected and bounces in a different direction. Given an incoming ray of light, a BRDF is a formula that outputs the possible directions the ray can bounce, and the amount of energy reflected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a quick real world example connection up front might help my understanding while in the flow of reading, though I see its mentioned later on. It kind of sounds like the BRDF is a description of the roughness of a surface

Copy link
Contributor Author

@JMS55 JMS55 Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat. A BRDF just describes how light bounces off a surface.

StandardMaterial roughness is one property (among many) that go into building the final BRDF that StandardMaterial uses.

Tbh I debated between including the BRDF stuff or not. Is it useful? Idk.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the usefulness in building an intuition on the building blocks of PBR and breaking it down like this taught me something I didn't know that seems important to understanding the pipeline, so I think it is useful to include it in some capacity!


The `StandardMaterial`'s fragment shader loops over the light of lights in the scene, and accumulates each light's interaction with the BRDF described by the material's properties, giving the final color of the pixel.

There are different types of BRDFs. Light might bounce equally in many directions (diffuse), towards one general direction (glossy), or even a perfect reflection in one direction (mirror). The glossy and mirror cases are typically referred to as specular BRDFs, as opposed to diffuse BRDFs. Diagrams: https://en.wikipedia.org/wiki/Bidirectional_reflectance_distribution_function#Models.

Ofentimes real-world materials are not perfectly diffuse or perfectly specular, but a combination of the two. A common way to classify materials is into "metals" and "non-metals" (dielectrics). Metals are actual metals like silver, gold, copper, etc, while dielectrics are everything else including plastic, wood, stone, rubber, etc. Metals have only a specular BRDF, while dielectrics have a combination of diffuse and specular BRDFs.

Bevy's `StandardMaterial` is built to represent arbitrary real-world materials using a combination of multiple diffuse and specular BRDFs mixed together with a set of weights based on the `metallic` property. A subset of more complex materials like wax, cloth, and gemstones that have effects like subsurface scattering, sheen, and refraction, can be modelled with additional properties.

Showcase screenshots: https://bevy.org/examples/3d-rendering/pbr and other examples

## Property Reference

Each property has both a value, and an optional texture map.

TODO: Explain and showcase each StandardMaterial property
Loading