2#include <engine/engine_export.h>
14#include <hpp/small_vector.hpp>
200 u_params0 = bgfx::createUniform(
"u_params0", bgfx::UniformType::Vec4);
201 u_params1 = bgfx::createUniform(
"u_params1", bgfx::UniformType::Vec4);
202 u_params2 = bgfx::createUniform(
"u_params2", bgfx::UniformType::Vec4);
203 u_color = bgfx::createUniform(
"u_color", bgfx::UniformType::Vec4);
204 u_smSamplingParams = bgfx::createUniform(
"u_smSamplingParams", bgfx::UniformType::Vec4);
205 u_csmFarDistances = bgfx::createUniform(
"u_csmFarDistances", bgfx::UniformType::Vec4);
206 u_lightMtx = bgfx::createUniform(
"u_lightMtx", bgfx::UniformType::Mat4);
208 u_tetraNormalGreen = bgfx::createUniform(
"u_tetraNormalGreen", bgfx::UniformType::Vec4);
209 u_tetraNormalYellow = bgfx::createUniform(
"u_tetraNormalYellow", bgfx::UniformType::Vec4);
210 u_tetraNormalBlue = bgfx::createUniform(
"u_tetraNormalBlue", bgfx::UniformType::Vec4);
211 u_tetraNormalRed = bgfx::createUniform(
"u_tetraNormalRed", bgfx::UniformType::Vec4);
213 u_shadowMapMtx0 = bgfx::createUniform(
"u_shadowMapMtx0", bgfx::UniformType::Mat4);
214 u_shadowMapMtx1 = bgfx::createUniform(
"u_shadowMapMtx1", bgfx::UniformType::Mat4);
215 u_shadowMapMtx2 = bgfx::createUniform(
"u_shadowMapMtx2", bgfx::UniformType::Mat4);
216 u_shadowMapMtx3 = bgfx::createUniform(
"u_shadowMapMtx3", bgfx::UniformType::Mat4);
222 float* _shadowMapMtx0,
223 float* _shadowMapMtx1,
224 float* _shadowMapMtx2,
225 float* _shadowMapMtx3)
270 bgfx::destroy(u_params0);
271 bgfx::destroy(u_params1);
272 bgfx::destroy(u_params2);
273 bgfx::destroy(u_color);
274 bgfx::destroy(u_smSamplingParams);
275 bgfx::destroy(u_csmFarDistances);
277 bgfx::destroy(u_tetraNormalGreen);
278 bgfx::destroy(u_tetraNormalYellow);
279 bgfx::destroy(u_tetraNormalBlue);
280 bgfx::destroy(u_tetraNormalRed);
282 bgfx::destroy(u_shadowMapMtx0);
283 bgfx::destroy(u_shadowMapMtx1);
284 bgfx::destroy(u_shadowMapMtx2);
285 bgfx::destroy(u_shadowMapMtx3);
287 bgfx::destroy(u_lightMtx);
357 bgfx::UniformHandle u_params0;
358 bgfx::UniformHandle u_params1;
359 bgfx::UniformHandle u_params2;
360 bgfx::UniformHandle u_color;
361 bgfx::UniformHandle u_smSamplingParams;
362 bgfx::UniformHandle u_csmFarDistances;
364 bgfx::UniformHandle u_tetraNormalGreen;
365 bgfx::UniformHandle u_tetraNormalYellow;
366 bgfx::UniformHandle u_tetraNormalBlue;
367 bgfx::UniformHandle u_tetraNormalRed;
369 bgfx::UniformHandle u_shadowMapMtx0;
370 bgfx::UniformHandle u_shadowMapMtx1;
371 bgfx::UniformHandle u_shadowMapMtx2;
372 bgfx::UniformHandle u_shadowMapMtx3;
374 bgfx::UniformHandle u_lightMtx;
411 .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
412 .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8,
true)
413 .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
425 decl.begin().add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float).end();
476#define SHADOW_FLOAT_PARAM(_name) \
477 float _name{}, _name##Min{}, _name##Max{}, _name##Step \
495#undef SHADOW_FLOAT_PARAM
520 ClearValues(uint32_t _clearRgba = 0x30303000,
float _clearDepth = 1.0f, uint8_t _clearStencil = 0)
650 auto render_scene_into_shadowmap(uint8_t shadowmap_1_id,
659 Light directional_light_;
661 float light_mtx_[16];
667 uint16_t current_shadow_map_size_{};
668 uint8_t current_num_splits_{};
678 bgfx::UniformHandle tex_color_{bgfx::kInvalidHandle};
681 bgfx::FrameBufferHandle rt_blur_{bgfx::kInvalidHandle};
685 uint64_t last_update_ = -1;
686 std::shared_ptr<int> sentinel_ = std::make_shared<int>(0);
693 adaptive_shadow_params adaptive_params_;
Storage for frustum planes / values and wraps up common functionality.
Class representing a camera. Contains functionality for manipulating and updating a camera....
Class representing a GPU program.
std::shared_ptr< gpu_program > ptr
Structure describing a LOD group (set of meshes), LOD transitions, and their materials.
Shadow mapping generator with improved algorithms for high-altitude cameras.
void set_adaptive_params(const adaptive_shadow_params ¶ms)
auto get_csm_optimization_flags() const -> uint32_t
void generate_shadowmaps(const shadow_map_models_t &model)
auto get_frustum_calculation_method() const -> frustum_calculation_method::Enum
auto get_adaptive_params() const -> const adaptive_shadow_params &
auto get_min_altitude_boost() const -> float
auto get_depth_type() const -> PackDepth::Enum
void submit_uniforms(uint8_t stage) const
auto get_rt_texture(uint8_t split) const -> bgfx::TextureHandle
auto get_max_altitude_boost() const -> float
void set_altitude_boost_range(float min_boost, float max_boost)
void update(const camera &cam, const light &l, const math::transform <rans, bool is_active)
void init(rtti::context &ctx)
void set_csm_optimization_flags(uint32_t flags)
auto already_updated() const -> bool
void set_altitude_scale_factor(float factor)
auto get_depth_render_program(PackDepth::Enum depth) const -> gpu_program::ptr
void set_frustum_calculation_method(frustum_calculation_method::Enum method)
auto get_altitude_scale_factor() const -> float
void enable_adaptive_shadows(bool enable)
bgfx::VertexLayout vertex_layout
hpp::small_vector< entt::handle > shadow_map_models_t
Struct representing a light.
ClearValues(uint32_t _clearRgba=0x30303000, float _clearDepth=1.0f, uint8_t _clearStencil=0)
SpotDirectionInner m_spotDirectionInner
static void init(gfx::vertex_layout &decl)
static void init(gfx::vertex_layout &decl)
gpu_program::ptr m_packDepthSkinned[DepthImpl::Count][PackDepth::Count]
gpu_program::ptr m_hBlur[PackDepth::Count]
gpu_program::ptr m_packDepth[DepthImpl::Count][PackDepth::Count]
void init(rtti::context &ctx)
gpu_program::ptr m_drawDepth[PackDepth::Count]
gpu_program::ptr m_vBlur[PackDepth::Count]
uint32_t m_blendFactorRgba
@ ShadowMap_PackDepthHoriz
@ Custom_BlendLightTexture
@ ShadowMap_PackDepthVert
float m_splitDistribution
DepthImpl::Enum m_depthImpl
LightType::Enum m_lightType
SHADOW_FLOAT_PARAM(m_yNum)
SHADOW_FLOAT_PARAM(m_customParam1)
SHADOW_FLOAT_PARAM(m_xNum)
SHADOW_FLOAT_PARAM(m_sizePwrTwo)
SHADOW_FLOAT_PARAM(m_bias)
SHADOW_FLOAT_PARAM(m_yOffset)
SHADOW_FLOAT_PARAM(m_far)
SHADOW_FLOAT_PARAM(m_depthValuePow)
SHADOW_FLOAT_PARAM(m_xOffset)
gpu_program * m_progPackSkinned
SHADOW_FLOAT_PARAM(m_normalOffset)
SHADOW_FLOAT_PARAM(m_near)
SHADOW_FLOAT_PARAM(m_customParam0)
float scene_bounds_margin
float altitude_scale_factor
@ stabilized_light_matrix