32#include <SDL3/SDL_gpu.h>
43 SDL_GPUDevice *_device =
nullptr;
71 SDL_GPUTexture *depth_texture, SDL_GPUTextureFormat format,
72 const Config &config = {});
91 std::span<const OpaqueCastable> castables);
98static constexpr size_t kNumLights = 4;
119 SDL_GPUDevice *_device =
nullptr;
120 Uint32 _numLights = 0;
137 std::array<Camera, kNumLights>
cam;
144 SDL_GPUTextureFormat format,
const Config &config);
147 SDL_GPUTextureFormat format)
182 std::span<const DirectionalLight> dirLight,
183 std::span<const OpaqueCastable> castables,
184 const AABB &worldAABB);
195 std::span<const DirectionalLight> dirLight,
196 std::span<const OpaqueCastable> castables,
217 const float sx = 2.f / sizes.x();
218 const float sy = 2.f / sizes.y();
219 const float sz = 1.f / (zMin - zMax);
220 const float pz = 0.5f * (zMin + zMax) * sz;
222 Mat4f proj = Mat4f::Zero();
Definition CommandBuffer.h:17
DepthPass(const Device &device, const MeshLayout &layout, const Texture &depth_texture, const Config &config={})
Create DepthPass (e.g. for a depth pre-pass) from a Device, specified mesh layout,...
SDL_GPUGraphicsPipeline * pipeline
Definition DepthAndShadowPass.h:56
DepthPass(const DepthPass &)=delete
DepthPass & operator=(DepthPass &&other) noexcept
DepthPass & operator=(const DepthPass &)=delete
DepthPass(DepthPass &&other) noexcept
DepthPass(const Device &device, const MeshLayout &layout, SDL_GPUTexture *depth_texture, SDL_GPUTextureFormat format, const Config &config={})
Create DepthPass (e.g. for a depth pre-pass) from a Device, specified mesh layout,...
DepthPass(NoInitT)
Definition DepthAndShadowPass.h:58
void release() noexcept
Release the pass resources.
void render(CommandBuffer &cmdBuf, const Mat4f &viewProj, std::span< const OpaqueCastable > castables)
SDL_GPUTexture * depthTexture
Definition DepthAndShadowPass.h:55
static constexpr Uint32 TRANSFORM_SLOT
Definition DepthAndShadowPass.h:46
This class defines the layout of a mesh's vertices.
Definition MeshLayout.h:98
Class for defining the shadow maps (as an atlas) and rendering into it.
Definition DepthAndShadowPass.h:118
auto numLights() const noexcept
Definition DepthAndShadowPass.h:160
ShadowMapPass & operator=(const ShadowMapPass &)=delete
ShadowMapPass(ShadowMapPass &&other) noexcept
ShadowPassConfig Config
Definition DepthAndShadowPass.h:125
ShadowMapPass(const Device &device, const MeshLayout &layout, SDL_GPUTextureFormat format, const Config &config)
ShadowMapPass(NoInitT)
Definition DepthAndShadowPass.h:141
ShadowMapPass(const ShadowMapPass &)=delete
Texture shadowMap
actually a texture atlas
Definition DepthAndShadowPass.h:134
SDL_GPUSampler * sampler
Definition DepthAndShadowPass.h:136
ShadowMapPass(const Device &device, const MeshLayout &layout, SDL_GPUTextureFormat format)
Definition DepthAndShadowPass.h:146
std::array< Camera, kNumLights > cam
Definition DepthAndShadowPass.h:137
ShadowMapPass & operator=(ShadowMapPass &&other) noexcept
SDL_GPUGraphicsPipeline * pipeline
Definition DepthAndShadowPass.h:135
void render(CommandBuffer &cmdBuf, std::span< const OpaqueCastable > castables)
std::array< AtlasRegion, kNumLights > regions
regions of the atlas
Definition DepthAndShadowPass.h:139
void renderShadowPassFromAABB(CommandBuffer &cmdBuf, ShadowMapPass &passInfo, std::span< const DirectionalLight > dirLight, std::span< const OpaqueCastable > castables, const AABB &worldAABB)
Render shadow pass, using provided scene bounds.
void renderShadowPassFromFrustum(CommandBuffer &cmdBuf, ShadowMapPass &passInfo, std::span< const DirectionalLight > dirLight, std::span< const OpaqueCastable > castables, const FrustumCornersType &worldSpaceCorners)
Render shadow pass, using a provided world-space frustum.
Mat4f shadowOrthographicMatrix(const Float2 &sizes, float zMin, float zMax)
Orthographic matrix which maps to the negative-Z half-volume of the NDC cube, for depth-testing/shado...
Definition DepthAndShadowPass.h:215
std::array< Float3, 8ul > FrustumCornersType
Definition math_types.h:15
Eigen::Vector2f Float2
Definition math_types.h:7
Eigen::Matrix4f Mat4f
Definition math_types.h:11
constexpr NoInitT NoInit
Definition Tags.h:9
Definition DepthAndShadowPass.h:47
bool enable_depth_bias
Definition DepthAndShadowPass.h:51
SDL_GPUCullMode cull_mode
Definition DepthAndShadowPass.h:48
float depth_bias_constant_factor
Definition DepthAndShadowPass.h:49
bool enable_depth_clip
Definition DepthAndShadowPass.h:52
float depth_bias_slope_factor
Definition DepthAndShadowPass.h:50
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17
Tag type for non-initializing constructors (for e.g. RAII classes)
Definition Tags.h:6
Texture atlas region, implicitly converts to an SDLGPU viewport.
Definition DepthAndShadowPass.h:127
Uint32 x
Definition DepthAndShadowPass.h:128
Uint32 y
Definition DepthAndShadowPass.h:129
Uint32 w
Definition DepthAndShadowPass.h:130
Uint32 h
Definition DepthAndShadowPass.h:131
Definition DepthAndShadowPass.h:101
bool enable_depth_clip
Definition DepthAndShadowPass.h:108
bool enable_depth_bias
Definition DepthAndShadowPass.h:107
Uint32 width
Definition DepthAndShadowPass.h:103
Uint32 height
Definition DepthAndShadowPass.h:104
Uint32 numLights
Definition DepthAndShadowPass.h:109
float depth_bias_slope_factor
Definition DepthAndShadowPass.h:106
float depth_bias_constant_factor
Definition DepthAndShadowPass.h:105