Skip to content

Commit b644ee1

Browse files
committed
Add SVG diagrams and introduction chapter for Opacity Micromaps course
Add four SVG diagrams illustrating shadow concepts (hard shadows, soft shadows, foliage alpha-testing problem, shadow ray lifecycle, and triangle subdivision) and create the introduction chapter for the Opacity Micromaps course explaining the performance problem with alpha-tested geometry in ray-traced shadows.
1 parent bc6f001 commit b644ee1

32 files changed

Lines changed: 3145 additions & 37 deletions

antora/modules/ROOT/nav.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@
128128
*** xref:Building_a_Simple_Engine/Mobile_Development/04_rendering_approaches.adoc[Rendering approaches]
129129
*** xref:Building_a_Simple_Engine/Mobile_Development/05_vulkan_extensions.adoc[Vulkan extensions]
130130
*** xref:Building_a_Simple_Engine/Mobile_Development/06_conclusion.adoc[Conclusion]
131+
** Extra Courses
132+
*** Opacity Micromaps
133+
**** xref:Building_a_Simple_Engine/Courses/Opacity_Micromaps/00_introduction.adoc[Introduction]
134+
**** xref:Building_a_Simple_Engine/Courses/Opacity_Micromaps/01_the_shadow_problem.adoc[The shadow problem]
135+
**** xref:Building_a_Simple_Engine/Courses/Opacity_Micromaps/02_why_alpha_testing_is_expensive.adoc[Why alpha testing is expensive]
136+
**** xref:Building_a_Simple_Engine/Courses/Opacity_Micromaps/03_what_are_micromaps.adoc[What are micromaps]
137+
**** xref:Building_a_Simple_Engine/Courses/Opacity_Micromaps/04_hardware_traversal_with_omm.adoc[Hardware traversal with OMM]
138+
**** xref:Building_a_Simple_Engine/Courses/Opacity_Micromaps/05_implementation_overview.adoc[Implementation overview]
139+
**** xref:Building_a_Simple_Engine/Courses/Opacity_Micromaps/06_results_guidance_and_tradeoffs.adoc[Results, guidance and tradeoffs]
140+
**** xref:Building_a_Simple_Engine/Courses/Opacity_Micromaps/07_conclusion.adoc[Conclusion]
131141
** Advanced Topics
132142
*** xref:Building_a_Simple_Engine/Advanced_Topics/01_introduction.adoc[Introduction]
133143
*** xref:Building_a_Simple_Engine/Advanced_Topics/Rendering_Pipeline_Overview.adoc[Rendering pipeline overview]

attachments/simple_engine/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ cmake_minimum_required(VERSION 3.29)
22

33
project(SimpleEngine VERSION 1.0.0 LANGUAGES CXX C)
44

5+
# ─────────────────────────────────────────────────────────────────────────────
6+
# Course modules — optional self-contained feature extensions
7+
# Each course lives entirely in Courses/ and is linked into the engine target.
8+
# Disable globally with: cmake -DENABLE_COURSES=OFF ..
9+
# ─────────────────────────────────────────────────────────────────────────────
10+
option(ENABLE_COURSES "Build the Simple Engine course modules" OFF)
11+
512
# Option to enable/disable Vulkan C++20 module support for this standalone project
613
option(ENABLE_CPP20_MODULE "Enable C++ 20 module support for Vulkan in SimpleEngine" OFF)
714

@@ -168,6 +175,19 @@ endif ()
168175
add_dependencies(SimpleEngine shaders)
169176
set_target_properties (SimpleEngine PROPERTIES CXX_STANDARD 20)
170177

178+
# ── Course modules ────────────────────────────────────────────────────────────
179+
# Each course is a static library defined in Courses/CMakeLists.txt.
180+
# The SIMPLE_ENGINE_COURSES_LIB variable is set in that file; it is empty when
181+
# all course modules are disabled.
182+
if(ENABLE_COURSES)
183+
add_subdirectory(Courses)
184+
if(SIMPLE_ENGINE_COURSES_LIB)
185+
target_link_libraries(SimpleEngine PUBLIC ${SIMPLE_ENGINE_COURSES_LIB})
186+
target_include_directories(SimpleEngine PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Courses)
187+
message(STATUS "[SimpleEngine] Course modules linked: ${SIMPLE_ENGINE_COURSES_LIB}")
188+
endif()
189+
endif()
190+
171191
# Enable required defines for GLM experimental extensions and MSVC math constants
172192
target_compile_definitions(SimpleEngine PRIVATE
173193
GLM_ENABLE_EXPERIMENTAL
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# =============================================================================
2+
# Courses/CMakeLists.txt
3+
# =============================================================================
4+
#
5+
# This subdirectory contains self-contained course modules that extend the
6+
# Simple Engine with new rendering features. Each module is optional — if
7+
# the parent CMakeLists.txt includes this directory with:
8+
#
9+
# option(ENABLE_COURSES "Build the Simple Engine course modules" ON)
10+
# if(ENABLE_COURSES)
11+
# add_subdirectory(Courses)
12+
# endif()
13+
#
14+
# then all enabled courses are compiled as a STATIC library that is linked
15+
# into the SimpleEngine target. No existing engine source files are modified
16+
# by this build; the modules attach to the engine via the public extension
17+
# points added to renderer.h.
18+
#
19+
# ADDING A NEW COURSE
20+
# -------------------
21+
# 1. Create a subdirectory under Courses/ (e.g. Courses/My_New_Topic/).
22+
# 2. Add its source files to the COURSE_SOURCES list below.
23+
# 3. If the course has a Slang shader, add it to COURSE_SLANG_SHADERS below.
24+
# 4. Document the course in en/Building_a_Simple_Engine/Courses/.
25+
#
26+
# The course modules in this file:
27+
# * Opacity Micromaps — VK_EXT_opacity_micromap hardware shadow acceleration
28+
# =============================================================================
29+
30+
cmake_minimum_required(VERSION 3.29)
31+
32+
# ─────────────────────────────────────────────────────────────────────────────
33+
# Per-course opt-in options
34+
# ─────────────────────────────────────────────────────────────────────────────
35+
option(ENABLE_COURSE_OPACITY_MICROMAPS
36+
"Build the Opacity Micromaps course module (VK_EXT_opacity_micromap)"
37+
ON)
38+
39+
# ─────────────────────────────────────────────────────────────────────────────
40+
# Collect sources from enabled course modules
41+
# ─────────────────────────────────────────────────────────────────────────────
42+
set(COURSE_SOURCES "")
43+
set(COURSE_SLANG_SHADERS "")
44+
45+
if(ENABLE_COURSE_OPACITY_MICROMAPS)
46+
list(APPEND COURSE_SOURCES
47+
${CMAKE_CURRENT_SOURCE_DIR}/opacity_micromap_builder.cpp
48+
${CMAKE_CURRENT_SOURCE_DIR}/omm_integration.cpp
49+
${CMAKE_CURRENT_SOURCE_DIR}/omm_imgui_panel.cpp
50+
)
51+
# No standalone shader needed: VK_EXT_opacity_micromap is transparent to
52+
# the existing ray_query.slang shader — the hardware handles everything.
53+
message(STATUS "[Courses] Opacity Micromaps module ENABLED")
54+
else()
55+
message(STATUS "[Courses] Opacity Micromaps module disabled")
56+
endif()
57+
58+
# ─────────────────────────────────────────────────────────────────────────────
59+
# Build the course modules library (only if there are sources)
60+
# ─────────────────────────────────────────────────────────────────────────────
61+
if(COURSE_SOURCES)
62+
add_library(SimpleEngineCourses STATIC ${COURSE_SOURCES})
63+
64+
set_target_properties(SimpleEngineCourses PROPERTIES CXX_STANDARD 20)
65+
66+
if(ENABLE_COURSE_OPACITY_MICROMAPS)
67+
target_compile_definitions(SimpleEngineCourses PUBLIC ENABLE_COURSE_OPACITY_MICROMAPS)
68+
endif()
69+
70+
# The course modules include engine headers directly (../renderer.h etc.)
71+
target_include_directories(SimpleEngineCourses PUBLIC
72+
${CMAKE_CURRENT_SOURCE_DIR}/.. # engine root (renderer.h, etc.)
73+
)
74+
75+
# Inherit the same compile definitions as the main engine target so that
76+
# the Vulkan-Hpp dispatch loader and GLM settings are consistent.
77+
target_compile_definitions(SimpleEngineCourses PRIVATE
78+
GLM_ENABLE_EXPERIMENTAL
79+
_USE_MATH_DEFINES
80+
VULKAN_HPP_NO_STRUCT_CONSTRUCTORS
81+
VULKAN_HPP_DISPATCH_LOADER_DYNAMIC
82+
)
83+
84+
# MSVC portability
85+
if(MSVC)
86+
target_compile_definitions(SimpleEngineCourses PRIVATE
87+
NOMINMAX
88+
WIN32_LEAN_AND_MEAN
89+
_CRT_SECURE_NO_WARNINGS
90+
)
91+
target_compile_options(SimpleEngineCourses PRIVATE
92+
/permissive-
93+
/Zc:__cplusplus
94+
/EHsc
95+
/W3
96+
/MP
97+
)
98+
endif()
99+
100+
# Link against Vulkan (same path as the engine).
101+
if(TARGET Vulkan::cppm)
102+
target_link_libraries(SimpleEngineCourses PUBLIC Vulkan::cppm)
103+
else()
104+
target_link_libraries(SimpleEngineCourses PUBLIC Vulkan::Vulkan)
105+
endif()
106+
107+
target_link_libraries(SimpleEngineCourses PUBLIC glm::glm)
108+
109+
# Export the library name to the parent scope so CMakeLists.txt can link it.
110+
set(SIMPLE_ENGINE_COURSES_LIB SimpleEngineCourses PARENT_SCOPE)
111+
112+
# ── Shader compilation (future courses that DO add shaders) ──────────────
113+
if(COURSE_SLANG_SHADERS AND SLANGC_EXECUTABLE)
114+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/shaders)
115+
foreach(SHADER ${COURSE_SLANG_SHADERS})
116+
get_filename_component(SHADER_NAME ${SHADER} NAME)
117+
add_custom_command(
118+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/shaders/${SHADER_NAME}.spv
119+
COMMAND ${SLANGC_EXECUTABLE} ${SHADER}
120+
-target spirv -profile spirv_1_4 -emit-spirv-directly
121+
-o ${CMAKE_CURRENT_BINARY_DIR}/shaders/${SHADER_NAME}.spv
122+
DEPENDS ${SHADER}
123+
COMMENT "Compiling course shader ${SHADER_NAME}"
124+
)
125+
list(APPEND COURSE_SHADER_SPVS
126+
${CMAKE_CURRENT_BINARY_DIR}/shaders/${SHADER_NAME}.spv)
127+
endforeach()
128+
129+
if(COURSE_SHADER_SPVS)
130+
add_custom_target(CourseShaders DEPENDS ${COURSE_SHADER_SPVS})
131+
add_dependencies(SimpleEngineCourses CourseShaders)
132+
endif()
133+
endif()
134+
135+
else()
136+
# No course sources enabled — export an empty library name.
137+
set(SIMPLE_ENGINE_COURSES_LIB "" PARENT_SCOPE)
138+
message(STATUS "[Courses] No course modules enabled; skipping library build.")
139+
endif()

0 commit comments

Comments
 (0)