61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
![]() |
#pragma once
|
||
|
|
||
|
#include "math.hpp"
|
||
|
#include "object.hpp"
|
||
|
#include "components.hpp"
|
||
|
|
||
|
class GFX;
|
||
|
class GFXCommandBuffer;
|
||
|
class GFXFramebuffer;
|
||
|
class GFXPipeline;
|
||
|
class GFXRenderPass;
|
||
|
class GFXTexture;
|
||
|
class GFXSampler;
|
||
|
class Scene;
|
||
|
struct CameraFrustum;
|
||
|
|
||
|
class ShadowPass {
|
||
|
public:
|
||
|
ShadowPass(GFX* gfx);
|
||
|
|
||
|
void create_scene_resources(Scene& scene);
|
||
|
|
||
|
void render(GFXCommandBuffer* command_buffer, Scene& scene);
|
||
|
|
||
|
GFXSampler* shadow_sampler = nullptr;
|
||
|
GFXSampler* pcf_sampler = nullptr;
|
||
|
|
||
|
private:
|
||
|
void render_meshes(GFXCommandBuffer* command_buffer, Scene& scene, const Matrix4x4 light_matrix, const Matrix4x4 model, const Vector3 light_position, const Light::Type type, const CameraFrustum& frustum);
|
||
|
|
||
|
void render_sun(GFXCommandBuffer* command_buffer, Scene& scene, Object light_object, Light& light);
|
||
|
void render_spot(GFXCommandBuffer* command_buffer, Scene& scene, Object light_object, Light& light);
|
||
|
void render_point(GFXCommandBuffer* command_buffer, Scene& scene, Object light_object, Light& light);
|
||
|
|
||
|
int last_point_light = 0;
|
||
|
int last_spot_light = 0;
|
||
|
|
||
|
void create_render_passes();
|
||
|
void create_pipelines();
|
||
|
void create_offscreen_resources();
|
||
|
|
||
|
GFXRenderPass* render_pass = nullptr;
|
||
|
GFXRenderPass* cube_render_pass = nullptr;
|
||
|
|
||
|
GFXTexture* offscreen_color_texture = nullptr;
|
||
|
GFXTexture* offscreen_depth = nullptr;
|
||
|
GFXFramebuffer* offscreen_framebuffer = nullptr;
|
||
|
|
||
|
// sun
|
||
|
GFXPipeline* static_sun_pipeline = nullptr;
|
||
|
GFXPipeline* skinned_sun_pipeline = nullptr;
|
||
|
|
||
|
// spot
|
||
|
GFXPipeline* static_spot_pipeline = nullptr;
|
||
|
GFXPipeline* skinned_spot_pipeline = nullptr;
|
||
|
|
||
|
// point
|
||
|
GFXPipeline* static_point_pipeline = nullptr;
|
||
|
GFXPipeline* skinned_point_pipeline = nullptr;
|
||
|
};
|