Skip to content

Commit 28c5d16

Browse files
committed
Update shaders_shadowmap_rendering.c
1 parent 811ec4f commit 28c5d16

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

examples/shaders/shaders_shadowmap_rendering.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ int main(void)
4242
const int screenWidth = 800;
4343
const int screenHeight = 450;
4444

45-
SetConfigFlags(FLAG_MSAA_4X_HINT);
4645
// Shadows are a HUGE topic, and this example shows an extremely simple implementation of the shadowmapping algorithm,
4746
// which is the industry standard for shadows. This algorithm can be extended in a ridiculous number of ways to improve
4847
// realism and also adapt it for different scenes. This is pretty much the simplest possible implementation
48+
49+
SetConfigFlags(FLAG_MSAA_4X_HINT);
4950
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shadowmap rendering");
5051

5152
Camera3D camera = (Camera3D){ 0 };
@@ -143,8 +144,8 @@ int main(void)
143144

144145
// Draw
145146
//----------------------------------------------------------------------------------
146-
// First, render all objects into the shadowmap
147-
// The idea is, we record all the objects' depths (as rendered from the light source's point of view) in a buffer
147+
// PASS 01: Render all objects into the shadowmap render texture
148+
// We record all the objects' depths (as rendered from the light source's point of view) in a buffer
148149
// Anything that is "visible" to the light is in light, anything that isn't is in shadow
149150
// We can later use the depth buffer when rendering everything from the player's point of view
150151
// to determine whether a given point is "visible" to the light
@@ -160,7 +161,7 @@ int main(void)
160161
EndTextureMode();
161162
lightViewProj = MatrixMultiply(lightView, lightProj);
162163

163-
// Draw the scene using the generated shadowmap
164+
// PASS 02: Draw the scene into main framebuffer, using the generated shadowmap
164165
BeginDrawing();
165166
ClearBackground(RAYWHITE);
166167

@@ -199,7 +200,7 @@ int main(void)
199200
}
200201

201202
// Load render texture for shadowmap projection
202-
// NOTE: Load frmaebuffer with only a texture depth attachment,
203+
// NOTE: Load framebuffer with only a texture depth attachment,
203204
// no color attachment required for shadowmap
204205
static RenderTexture2D LoadShadowmapRenderTexture(int width, int height)
205206
{
@@ -214,11 +215,11 @@ static RenderTexture2D LoadShadowmapRenderTexture(int width, int height)
214215
rlEnableFramebuffer(target.id);
215216

216217
// Create depth texture
217-
// We don't need a color texture for the shadowmap
218+
// NOTE: No need a color texture attachment for the shadowmap
218219
target.depth.id = rlLoadTextureDepth(width, height, false);
219220
target.depth.width = width;
220221
target.depth.height = height;
221-
target.depth.format = 19; //DEPTH_COMPONENT_24BIT?
222+
target.depth.format = 19; // DEPTH_COMPONENT_24BIT?
222223
target.depth.mipmaps = 1;
223224

224225
// Attach depth texture to FBO
@@ -245,8 +246,8 @@ static void UnloadShadowmapRenderTexture(RenderTexture2D target)
245246
}
246247
}
247248

248-
// Draw scene
249-
// NOTE: Required several calls to generate shadowmap
249+
// Draw full scene projecting shadows
250+
// NOTE: Required to be called several time to generate shadowmap
250251
static void DrawScene(Model cube, Model robot)
251252
{
252253
DrawModelEx(cube, Vector3Zero(), (Vector3) { 0.0f, 1.0f, 0.0f }, 0.0f, (Vector3) { 10.0f, 1.0f, 10.0f }, BLUE);

0 commit comments

Comments
 (0)