42static constexpr size_t kNumLights = 4;
50 SDL_GPUDevice *_device =
nullptr;
80 SDL_GPUTexture *depth_texture, SDL_GPUTextureFormat format,
81 const Config &config = {});
93 :
DepthPass(device, layout, texture, texture.format(), config) {}
101 std::span<const OpaqueCastable> castables);
128 SDL_GPUDevice *m_device =
nullptr;
129 Uint32 m_numLights = 0;
146 std::array<Camera, kNumLights>
cam;
153 SDL_GPUTextureFormat format,
const Config &config);
156 SDL_GPUTextureFormat format)
195 std::span<const DirectionalLight> dirLight,
196 std::span<const OpaqueCastable> castables,
197 const AABB &worldAABB);
208 std::span<const DirectionalLight> dirLight,
209 std::span<const OpaqueCastable> castables,
230 const float sx = 2.f / sizes.x();
231 const float sy = 2.f / sizes.y();
232 const float sz = 1.f / (zMin - zMax);
233 const float pz = 0.5f * (zMin + zMax) * sz;
235 Mat4f proj = Mat4f::Zero();
Definition CommandBuffer.h:16
Helper struct for depth or light pre-passes.
Definition DepthAndShadowPass.h:49
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:67
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:64
GraphicsPipeline pipeline
Definition DepthAndShadowPass.h:65
static constexpr Uint32 TRANSFORM_SLOT
Definition DepthAndShadowPass.h:53
DepthPass(const Device &device, const MeshLayout &layout, const Texture &texture, const Config &config={})
Create DepthPass (e.g. for a depth pre-pass) from a Device, specified mesh layout,...
Definition DepthAndShadowPass.h:91
Class representing a graphics pipeline.
Definition GraphicsPipeline.h:15
This class defines the layout of a mesh's vertices.
Definition MeshLayout.h:122
Class for defining the shadow maps (as an atlas) and rendering into it.
Definition DepthAndShadowPass.h:127
auto numLights() const noexcept
Definition DepthAndShadowPass.h:173
ShadowMapPass & operator=(const ShadowMapPass &)=delete
ShadowMapPass(ShadowMapPass &&other) noexcept
ShadowPassConfig Config
Definition DepthAndShadowPass.h:134
ShadowMapPass(const Device &device, const MeshLayout &layout, SDL_GPUTextureFormat format, const Config &config)
ShadowMapPass(NoInitT)
Definition DepthAndShadowPass.h:150
bool initialized() const
Definition DepthAndShadowPass.h:164
GraphicsPipeline pipeline
Definition DepthAndShadowPass.h:144
ShadowMapPass(const ShadowMapPass &)=delete
Texture shadowMap
actually a texture atlas
Definition DepthAndShadowPass.h:143
SDL_GPUSampler * sampler
Definition DepthAndShadowPass.h:145
ShadowMapPass(const Device &device, const MeshLayout &layout, SDL_GPUTextureFormat format)
Definition DepthAndShadowPass.h:155
std::array< Camera, kNumLights > cam
Definition DepthAndShadowPass.h:146
ShadowMapPass & operator=(ShadowMapPass &&other) noexcept
void render(CommandBuffer &cmdBuf, std::span< const OpaqueCastable > castables)
std::array< AtlasRegion, kNumLights > regions
regions of the atlas
Definition DepthAndShadowPass.h:148
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:228
std::tuple< const Mesh &, Mat4f > OpaqueCastable
Intermediary argument type for shadow-casting or opaque objects. For use in depth or light pre-passes...
Definition DepthAndShadowPass.h:39
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:54
bool enable_depth_bias
Definition DepthAndShadowPass.h:58
const char * pipeline_name
Definition DepthAndShadowPass.h:60
SDL_GPUCullMode cull_mode
Definition DepthAndShadowPass.h:55
float depth_bias_constant_factor
Definition DepthAndShadowPass.h:56
bool enable_depth_clip
Definition DepthAndShadowPass.h:59
float depth_bias_slope_factor
Definition DepthAndShadowPass.h:57
SDL_GPUSampleCount sample_count
Definition DepthAndShadowPass.h:61
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:136
Uint32 x
Definition DepthAndShadowPass.h:137
Uint32 y
Definition DepthAndShadowPass.h:138
Uint32 w
Definition DepthAndShadowPass.h:139
Uint32 h
Definition DepthAndShadowPass.h:140
Definition DepthAndShadowPass.h:110
bool enable_depth_clip
Definition DepthAndShadowPass.h:117
bool enable_depth_bias
Definition DepthAndShadowPass.h:116
Uint32 width
Definition DepthAndShadowPass.h:112
Uint32 height
Definition DepthAndShadowPass.h:113
Uint32 numLights
Definition DepthAndShadowPass.h:118
float depth_bias_slope_factor
Definition DepthAndShadowPass.h:115
float depth_bias_constant_factor
Definition DepthAndShadowPass.h:114