41static constexpr size_t kNumLights = 4;
49 SDL_GPUDevice *_device =
nullptr;
77 SDL_GPUTexture *depth_texture, SDL_GPUTextureFormat format,
78 const Config &config = {});
97 std::span<const OpaqueCastable> castables);
123 SDL_GPUDevice *_device =
nullptr;
124 Uint32 _numLights = 0;
141 std::array<Camera, kNumLights>
cam;
148 SDL_GPUTextureFormat format,
const Config &config);
151 SDL_GPUTextureFormat format)
190 std::span<const DirectionalLight> dirLight,
191 std::span<const OpaqueCastable> castables,
192 const AABB &worldAABB);
203 std::span<const DirectionalLight> dirLight,
204 std::span<const OpaqueCastable> castables,
225 const float sx = 2.f / sizes.x();
226 const float sy = 2.f / sizes.y();
227 const float sz = 1.f / (zMin - zMax);
228 const float pz = 0.5f * (zMin + zMax) * sz;
230 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:62
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:64
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:61
static constexpr Uint32 TRANSFORM_SLOT
Definition DepthAndShadowPass.h:52
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:122
auto numLights() const noexcept
Definition DepthAndShadowPass.h:168
ShadowMapPass & operator=(const ShadowMapPass &)=delete
ShadowMapPass(ShadowMapPass &&other) noexcept
ShadowPassConfig Config
Definition DepthAndShadowPass.h:129
ShadowMapPass(const Device &device, const MeshLayout &layout, SDL_GPUTextureFormat format, const Config &config)
ShadowMapPass(NoInitT)
Definition DepthAndShadowPass.h:145
bool initialized() const
Definition DepthAndShadowPass.h:159
ShadowMapPass(const ShadowMapPass &)=delete
Texture shadowMap
actually a texture atlas
Definition DepthAndShadowPass.h:138
SDL_GPUSampler * sampler
Definition DepthAndShadowPass.h:140
ShadowMapPass(const Device &device, const MeshLayout &layout, SDL_GPUTextureFormat format)
Definition DepthAndShadowPass.h:150
std::array< Camera, kNumLights > cam
Definition DepthAndShadowPass.h:141
ShadowMapPass & operator=(ShadowMapPass &&other) noexcept
SDL_GPUGraphicsPipeline * pipeline
Definition DepthAndShadowPass.h:139
void render(CommandBuffer &cmdBuf, std::span< const OpaqueCastable > castables)
std::array< AtlasRegion, kNumLights > regions
regions of the atlas
Definition DepthAndShadowPass.h:143
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:223
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:38
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:53
bool enable_depth_bias
Definition DepthAndShadowPass.h:57
SDL_GPUCullMode cull_mode
Definition DepthAndShadowPass.h:54
float depth_bias_constant_factor
Definition DepthAndShadowPass.h:55
bool enable_depth_clip
Definition DepthAndShadowPass.h:58
float depth_bias_slope_factor
Definition DepthAndShadowPass.h:56
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:131
Uint32 x
Definition DepthAndShadowPass.h:132
Uint32 y
Definition DepthAndShadowPass.h:133
Uint32 w
Definition DepthAndShadowPass.h:134
Uint32 h
Definition DepthAndShadowPass.h:135
Definition DepthAndShadowPass.h:105
bool enable_depth_clip
Definition DepthAndShadowPass.h:112
bool enable_depth_bias
Definition DepthAndShadowPass.h:111
Uint32 width
Definition DepthAndShadowPass.h:107
Uint32 height
Definition DepthAndShadowPass.h:108
Uint32 numLights
Definition DepthAndShadowPass.h:113
float depth_bias_slope_factor
Definition DepthAndShadowPass.h:110
float depth_bias_constant_factor
Definition DepthAndShadowPass.h:109