Skip to content

Commit 5e38540

Browse files
committed
committing requested changes in stages.
1 parent acfbd6e commit 5e38540

File tree

7 files changed

+666
-343
lines changed

7 files changed

+666
-343
lines changed

en/Building_a_Simple_Engine/Lighting_Materials/01_introduction.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
In this chapter, we'll explore the fundamentals of lighting and materials in 3D rendering, with a focus on Physically Based Rendering (PBR). Lighting is a crucial aspect of creating realistic and visually appealing 3D scenes. Without proper lighting, even the most detailed models can appear flat and lifeless.
44

5+
image:../../../images/bistro.png[Bistro scene with PBR, width=600, alt=Rendering the Bistro scene at night with PBR pass]
6+
7+
58
[NOTE]
69
====
710
*About PBR References*: Throughout this tutorial, you may encounter references to PBR (Physically Based Rendering) before reaching this chapter. PBR is a modern rendering approach that simulates how light interacts with surfaces based on physical principles. We'll cover PBR in detail in the sections that follow, so don't worry if you're not familiar with these concepts yet.

en/Building_a_Simple_Engine/Lighting_Materials/03_push_constants.adoc

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,15 @@
22

33
In this section, we'll explore push constants, a powerful feature in Vulkan that allows us to efficiently pass small amounts of data to shaders without the overhead of descriptor sets.
44

5-
Throughout our engine implementation, we're using vk::raii dynamic rendering and C++20 modules. The vk::raii namespace provides Resource Acquisition Is Initialization (RAII) wrappers for Vulkan objects, which helps with resource management and makes the code cleaner. Dynamic rendering simplifies the rendering process by eliminating the need for explicit render passes and framebuffers. C++20 modules improve code organization, compilation times, and encapsulation compared to traditional header files.
6-
75
== What Are Push Constants?
86

97
Push constants are a way to send a small amount of data directly to shaders. Unlike uniform buffers, which require descriptor sets and memory allocation, push constants are part of the command buffer itself. This makes them ideal for small, frequently changing data.
108

11-
Some key characteristics of push constants:
12-
13-
1. *Size Limitations*: Push constants have a limited size (typically 128 bytes, but this can vary depending on the device).
14-
2. *Efficiency*: They're more efficient than uniform buffers for small, frequently changing data.
15-
3. *Simplicity*: They don't require descriptor sets or memory allocation.
16-
4. *Scope*: They're available to all shader stages in a pipeline.
9+
Some key characteristics of push constants: they are tiny (typically up to 128 bytes, device dependent), fast to update per draw, and require no descriptor sets or allocations because they live on the command buffer. They can be read by any shader stage you enable in the pipeline.
1710

1811
== When to Use Push Constants
1912

20-
Push constants are particularly useful for:
21-
22-
1. *Per-Draw Data*: Data that changes for each draw call, such as material properties.
23-
2. *Small Data Sets*: Data that fits within the size limitations of push constants.
24-
3. *Frequently Changing Data*: Data that changes often, where the overhead of updating a uniform buffer would be significant.
25-
26-
For our PBR implementation, push constants are perfect for storing material properties like base color, metallic factor, and roughness factor.
13+
Use push constants for tiny, per‑draw parameters that change frequently—exactly the kind of material knobs (base color, metallic, roughness) we tweak per object. If the data is larger than the device’s push‑constant limit or doesn’t change often, prefer a uniform buffer instead.
2714

2815
== Defining Push Constants in Shaders
2916

0 commit comments

Comments
 (0)