Skip to content

Conversation

@Miou-zora
Copy link
Contributor

No description provided.

ripel2 pushed a commit to EngineSquared/EngineSquared that referenced this pull request Jan 30, 2026
This pull request introduces support for GPU-side directional light
handling and shadow mapping in the default rendering pipeline. The
changes add a new `GPUDirectionalLight` component, associated buffer and
resource management, and a shadow rendering pass. This lays the
groundwork for rendering shadows from directional lights, such as
sunlight, in the engine.

You can check usage on real use here:
EngineSquared/ES-RS#13

<img width="868" height="900" alt="Capture d’écran 2026-01-26 à 16 57
04"
src="https://github.com/user-attachments/assets/6d69dd56-7288-4169-b07a-d6480389a559"
/>

The most important changes are:

**Directional Light GPU Component and Management:**
* Added the `GPUDirectionalLight` component, which stores GPU-relevant
data for directional lights, including the view-projection matrix,
buffer, shadow texture, and bind group. (`GPUDirectionalLight.hpp`)
* Implemented creation and destruction systems for
`GPUDirectionalLight`, handling buffer, texture, and bind group
allocation and cleanup. (`OnDirectionalLightCreation.cpp`,
`OnDirectionalLightDestruction.cpp`, `OnDirectionalLightCreation.hpp`,
`OnDirectionalLightDestruction.hpp`)
[[1]](diffhunk://#diff-5d0a6063bb7649ec340d09807afce2e061e34a13b06585c486f61c66bf27f390R1-R61)
[[2]](diffhunk://#diff-57d864a8615a29c3fe0c363c6dadbfa185893b2e770283c81365a8f292655fc2R1-R24)
[[3]](diffhunk://#diff-264692a007da51ce92c5cac2ec09edad2cdc1f65f87075c21e4912a06edead6bR1-R10)
[[4]](diffhunk://#diff-c17bfad50510ee119721937ffa70e90ead9f8c190a46a75ba526ce1047a759beR1-R10)

**Resource and Buffer Management:**
* Introduced `DirectionalLightBuffer`, a GPU buffer for storing
directional light data, with methods for creation, update, and
destruction. (`DirectionalLightBuffer.hpp`)
* Registered the new buffer and component in the default pipeline setup,
ensuring proper lifecycle management. (`DefaultPipeline.hpp`,
`PluginDefaultPipeline.cpp`)
[[1]](diffhunk://#diff-2f985c1642a674e1748a3014d2641fe5d3d3b50cf7376fd16f0e968820b4f065R4)
[[2]](diffhunk://#diff-2f985c1642a674e1748a3014d2641fe5d3d3b50cf7376fd16f0e968820b4f065R15)
[[3]](diffhunk://#diff-2f985c1642a674e1748a3014d2641fe5d3d3b50cf7376fd16f0e968820b4f065R33-R34)
[[4]](diffhunk://#diff-e86556a74811ae3ebc0edb2b22497eae17e44fd96aefc063788e79add62a00a0R41-R49)

**Shadow Pass Integration:**
* Added a `Shadow` render pass, including a WGSL shader for shadow map
generation, and integrated it into the pipeline's initialization.
(`Shadow.hpp`, `Create3DGraph.cpp`, `DefaultPipeline.hpp`)
[[1]](diffhunk://#diff-06c721a198c60119d31208bc995262717dc0f8b79c80aeb67707f75772d5ba1eR1-R200)
[[2]](diffhunk://#diff-553e5465e59320e32552b7e5104d600be7eb8304bbb77cce5b4560c2aa4088c3R11)
[[3]](diffhunk://#diff-2f985c1642a674e1748a3014d2641fe5d3d3b50cf7376fd16f0e968820b4f065R24)
[[4]](diffhunk://#diff-2f985c1642a674e1748a3014d2641fe5d3d3b50cf7376fd16f0e968820b4f065R44)

These changes collectively enable the rendering pipeline to support
directional lights and generate shadow maps, enhancing lighting realism
in 3D scenes.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added directional lighting with real-time shadow mapping and a
dedicated shadow pass; deferred renderer now accounts for directional
lights and shadow sampling.
* Multi-pass render support and explicit texture-view handling to enable
per-pass shadows.

* **Chores**
  * Minor material default value tweaks.

* **Tests**
* Rendering tests and expected outputs updated to include directional
shadow results.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@Miou-zora Miou-zora merged commit 564c118 into v2 Jan 30, 2026
@Miou-zora Miou-zora deleted the add_sunset branch January 30, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants