 |
Blamite Game Engine - blam!
00453.06.08.26.0624.blamite
The core library for the Blamite Game Engine.
|
Go to the documentation of this file.
19 #define BLAM_SHADOW_VIEW_IDS_TOTAL ( \
20 BLAM_SHADOW_MAX_DIRECTIONAL_CASTERS * BLAM_SHADOW_CASCADE_COUNT + \
21 BLAM_SHADOW_MAX_SPOT_CASTERS + \
22 BLAM_SHADOW_MAX_POINT_CASTERS * 6)
24 #define BLAM_SHADOW_VIEW_IDS_TO_RESERVE (BLAM_SHADOW_VIEW_IDS_TOTAL - 1)
50 bool operator==(
const group_key& other)
const
52 return submesh == other.submesh && baked_state == other.baked_state;
58 size_t operator()(
const group_key& k)
const
61 size_t h1 = std::hash<void*>()((
void*)k.submesh);
62 size_t h2 = std::hash<void*>()((
void*)k.baked_state);
63 return h1 ^ (h2 + 0x9e3779b9 + (h1 << 6) + (h1 >> 2));
78 std::string material_tag_path;
79 std::vector<float> packed_transforms;
85 void AppendTransformRowMajor(std::vector<float>& packed,
const float* srt_matrix);
89 void SubmitNonInstanced(
mesh::submesh* submesh,
const std::string& material_tag_path,
const float* srt_matrix,
90 bgfx::ProgramHandle program, bgfx::ViewId view_id,
uint64_t state_flags, BlamVector4 render_params);
94 void SubmitInstancedGroup(group_data& group, bgfx::ProgramHandle program,
95 bgfx::ViewId view_id,
uint64_t state_flags, BlamVector4 render_params);
99 std::unordered_map<group_key, group_data, group_key_hash> g_groups;
100 bgfx::UniformHandle u_renderParams = BGFX_INVALID_HANDLE;
103 void _Execute(
float delta)
override;
106 bgfx::TextureHandle
albedo = BGFX_INVALID_HANDLE;
107 bgfx::TextureHandle
normal = BGFX_INVALID_HANDLE;
108 bgfx::TextureHandle
pbr = BGFX_INVALID_HANDLE;
109 bgfx::TextureHandle
emissive = BGFX_INVALID_HANDLE;
110 bgfx::TextureHandle
depth = BGFX_INVALID_HANDLE;
111 bgfx::TextureHandle
worldpos = BGFX_INVALID_HANDLE;
112 bgfx::TextureHandle
coverage = BGFX_INVALID_HANDLE;
113 bgfx::FrameBufferHandle
gbuffer = BGFX_INVALID_HANDLE;
129 void _Execute(
float delta)
override;
141 void _Execute(
float delta)
override;
153 void _Execute(
float delta)
override;
165 void _Execute(
float delta)
override;
183 bgfx::ViewId blur_view_id = 0;
186 void _Execute(
float delta)
override;
211 #define BLAM_SHADOW_CASCADE_COUNT 8
217 #define BLAM_SHADOW_SPOT_COUNT 4
219 #define BLAM_SHADOW_POINT_COUNT 4
220 #define BLAM_SHADOW_CUBE_FACE_COUNT 6
225 #define BLAM_SHADOW_VIEW_IDS_TO_RESERVE \
226 ((BLAM_SHADOW_CASCADE_COUNT + BLAM_SHADOW_SPOT_COUNT + \
227 (BLAM_SHADOW_POINT_COUNT * BLAM_SHADOW_CUBE_FACE_COUNT)) - 1)
232 #define BLAM_SHADOW_CASCADE_LAMBDA 0.75f
240 struct shadow_instance
243 BlamVector3 world_aabb_min;
244 BlamVector3 world_aabb_max;
245 BlamVector3 world_sphere_center;
246 float world_sphere_radius;
247 bool infinite_bounds;
252 struct shadow_group_data
255 std::vector<shadow_instance> instances;
261 bgfx::TextureHandle shadow_texture_array;
262 bgfx::TextureHandle shadow_depth_renderbuffer;
267 int cascade_resolution;
271 bgfx::TextureHandle spot_texture_array;
272 bgfx::TextureHandle spot_depth_renderbuffer;
276 int active_spot_count;
292 bgfx::TextureHandle point_depth_renderbuffer;
299 int point_resolution;
300 int active_point_count;
304 std::unordered_map<mesh::submesh*, shadow_group_data> g_shadow_groups;
307 bgfx::ViewId base_view_id;
308 bool resources_initialized;
310 void InitializeResources();
311 void DestroyResources();
312 void SubmitShadowGeometry(bgfx::ViewId view_id, bgfx::ProgramHandle program,
bool flip_cull,
const BlamFrustum* frustum);
315 void RenderDirectionalCascades(bgfx::ProgramHandle shadow_program);
316 void RenderSpotShadows(bgfx::ProgramHandle shadow_program);
317 void RenderPointShadows(bgfx::ProgramHandle point_shadow_program);
319 void CollectShadowGeometry();
321 void ComputePointFaceMatrix(BlamVector3 light_pos,
int face,
float near_plane,
float far_plane,
float* out_matrix);
323 void ComputeCascadeMatrix(BlamVector3 light_dir,
float split_near,
float split_far,
int cascade_resolution,
float* out_matrix);
324 void ComputeCascadeSplits(
float near_plane,
float far_plane,
float* out_splits);
325 int GatherShadowCasters(
BlamWorldObject_Tag** out_points,
int max_count, light::shape_enum shape);
330 void _Execute(
float delta)
override;
bgfx::TextureHandle ssao_result
Definition: passes.h:189
BLAM BlamDirector * GetCamera()
Retrieves the director instance.
Definition: director.cpp:36
BLAM BlamWorldState * GetWorldState()
Retrieves the current world state.
Definition: world.cpp:56
#define SHADER_DEFAULT_SSAO
Definition: rendering.h:37
void _Execute(float delta) override
Definition: BlamGBufferPass.cpp:140
float * GetCascadeSplits()
Definition: BlamShadowPass.cpp:1223
void GenerateNoiseTexture()
Definition: BlamSSAOPass.cpp:57
bool has_multiple_views
Definition: types.h:110
BLAM void SubmitLightUniforms(BlamVector3 cameraPos, BlamVector3 ambientColor)
Definition: lights.cpp:79
#define BLAM_SHADOW_MAX_POINT_CASTERS
Definition: types.h:15
#define PASS_SHADOW
Definition: rendering.h:45
if(WIN32) set(OGRE_MEDIA_PATH "Media") elseif(APPLE) set(OGRE_MEDIA_PATH "Media") elseif(UNIX) set(OGRE_MEDIA_PATH "share/$
Definition: CMakeLists.txt:15
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
void RenderObjects(float delta)
Definition: BlamWorldState.cpp:240
bgfx::FrameBufferHandle ssao_buffer
Definition: passes.h:193
bgfx::TextureHandle noise_texture
Definition: passes.h:191
float far_clip_plane_distance
Definition: director.h:118
void RecreateBuffers(BlamVector2 size) override
Definition: BlamSSAOPass.cpp:82
#define PASS_POSTPROCESS
Definition: rendering.h:49
bgfx::VertexBufferHandle vertex_buffer
Definition: types.h:31
BlamVector3 aabb_min
Definition: types.h:45
BlamLightingPass()
Definition: BlamLightingPass.cpp:9
#define PASS_LIGHTING
Definition: rendering.h:48
bgfx::FrameBufferHandle gbuffer
Definition: passes.h:113
BlamVector3 GetPosition()
Definition: BlamWorldObject.cpp:222
void _Execute(float delta) override
Definition: BlamShadowPass.cpp:623
#define BLAM_SHADOW_CUBE_FACE_COUNT
Definition: passes.h:220
#define SHADER_DEFAULT_SHADOW_POINT_INSTANCED
Definition: rendering.h:42
char path[256]
The tag's path.
Definition: tags.h:145
bgfx::TextureHandle GetSpotShadowTextureArray()
Definition: BlamShadowPass.cpp:1238
int view_id_count
Definition: types.h:111
bgfx::TextureHandle ssao_blurred
Definition: passes.h:190
BLAM int GetRenderHeight()
Retrieves the current height of the viewport.
Definition: bgfx.cpp:428
BlamSSAOPass()
Definition: BlamSSAOPass.cpp:9
int GetSpotShadowLayerFor(class BlamWorldObject_Tag *spot_object)
Definition: BlamShadowPass.cpp:1258
#define SHADER_DEFAULT_SHADOW_INSTANCED
Definition: rendering.h:41
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:403
unsigned char uint8_t
Definition: stdint.h:15
real bounding_sphere_radius
Definition: render_model.h:51
float near_clip_plane_distance
Definition: director.h:117
BLAM bgfx::ProgramHandle GetProgram(std::string name)
Definition: shaders.cpp:100
float * GetSpotShadowMatrices()
Definition: BlamShadowPass.cpp:1243
#define SHADER_DEFAULT_SHADOW
Definition: rendering.h:39
int GetObjectCount()
Definition: BlamWorldState.cpp:157
BlamGBufferPass()
Definition: BlamGBufferPass.cpp:12
#define PASS_SSAO
Definition: rendering.h:50
bgfx::TextureHandle emissive
Definition: passes.h:109
void _Execute(float delta) override
Definition: BlamPostprocessPass.cpp:29
#define BLAM_SHADOW_MAX_SPOT_CASTERS
Definition: types.h:14
BlamPostprocessPass()
Definition: BlamPostprocessPass.cpp:6
BlamTagData * tag_data
Pointer to the tag data associated with this object.
Definition: world_objects.h:304
BLAM BlamColor * GetGlobalAsColor(std::string name)
Retrieves a global's value as a BlamColor.
Definition: globals.cpp:415
void RecreateBuffers(BlamVector2 size) override
Definition: BlamGBufferPass.cpp:22
bgfx::TextureHandle normal
Definition: passes.h:107
bitfield16_flags flags
Bitfield data for flags. See #bitfield16_flags for details.
Definition: render_model.h:50
Class representing a tag-based world object.
Definition: world_objects.h:278
unsigned long long uint64_t
Definition: stdint.h:18
bgfx::FrameBufferHandle ssao_blur_buffer
Definition: passes.h:194
int GetPointResolution()
Definition: BlamShadowPass.cpp:1291
void mtxOrtho(float *_result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _homogeneousNdc)
Definition: ogre.cpp:117
bgfx::TextureHandle hdr_color
Definition: passes.h:169
bgfx::TextureHandle GetPointShadowCube(int index)
Definition: BlamShadowPass.cpp:1276
float * GetCascadeMatrices()
Definition: BlamShadowPass.cpp:1218
#define tag_ligh
Definition: light.h:22
std::vector< submesh * > submeshes
Definition: types.h:55
bool use_bounding_sphere
Definition: render_model.h:32
bgfx::IndexBufferHandle index_buffer
Definition: types.h:32
float * GetPointShadowData()
Definition: BlamShadowPass.cpp:1286
std::string material_tag_path
Definition: types.h:33
float * GetCascadeSplitsPacked()
Definition: BlamShadowPass.cpp:1228
BlamWorldObject * GetObjectAtIndex(int index)
Definition: BlamWorldState.cpp:178
font DisplayOffset y
Definition: README.txt:68
BLAM void Render()
Renders all UI to the screen.
Definition: ui.cpp:64
Add a fourth parameter to bake specific font ranges NULL
Definition: README.txt:57
int GetPointShadowLayerFor(class BlamWorldObject_Tag *point_object)
Definition: BlamShadowPass.cpp:1301
GBuffer Pass.
Definition: passes.h:33
void _Execute(float delta) override
Definition: BlamForwardPass.cpp:11
int GetCascadeResolution()
Definition: BlamShadowPass.cpp:1233
bitfield16_flags flags
Bitfield data for flags. See #bitfield16_flags for details.
Definition: light.h:49
render_model * tag
Definition: types.h:54
void ExtractFrustum(BlamFrustum *out_frustum, const float *vp_matrix)
Definition: culling.cpp:36
BlamUIPass()
Definition: BlamUIPass.cpp:8
#define PASS_FORWARD
Definition: rendering.h:47
BLAM bgfx::UniformHandle GetUniform(std::string id)
Definition: shader_uniforms.cpp:174
~BlamGBufferPass()
Definition: BlamGBufferPass.cpp:17
void TransformAABB(BlamVector3 model_min, BlamVector3 model_max, const float *world_matrix, BlamVector3 *out_world_min, BlamVector3 *out_world_max)
Definition: culling.cpp:151
int max_2d_z_depth
Definition: ogre.cpp:89
bool override_priority
Definition: world_objects.h:353
BlamVector3 GetRotation()
Definition: BlamWorldObject.cpp:172
unsigned int uint32_t
Definition: stdint.h:17
#define BLAM_SHADOW_VIEW_IDS_TO_RESERVE
Definition: passes.h:225
BlamVector3 GetAbsolutePosition()
Definition: BlamWorldObject.cpp:209
BLAM void PrepareScreenQuad()
Definition: bgfx.cpp:515
#define SHADER_DEFAULT_DEFERRED_GBUFFER_INSTANCED
Definition: rendering.h:34
#define PASS_GBUFFER
Definition: rendering.h:46
uint16_t render_clear_flags
Definition: passes.h:115
BLAM mesh * GetModelFromTagPath(std::string tag_path)
Definition: models.cpp:220
void _Execute(float delta) override
Definition: BlamSSAOPass.cpp:118
void TransformSphere(BlamVector3 model_center, float model_radius, const float *world_matrix, BlamVector3 *out_world_center, float *out_world_radius)
Definition: culling.cpp:206
Definition: world_objects.h:337
BlamVector3 aabb_max
Definition: types.h:46
#define BLAM_SHADOW_CASCADE_LAMBDA
Definition: passes.h:232
#define BLAM_SHADOW_CASCADE_COUNT
Definition: passes.h:211
#define PASS_UI
Definition: rendering.h:51
void GenerateKernel()
Definition: BlamSSAOPass.cpp:20
Class representing a world object.
Definition: world_objects.h:138
BlamMaterialBakedState * baked_state
Definition: types.h:35
bool SphereInFrustum(const BlamFrustum *frustum, BlamVector3 center, float radius)
Definition: culling.cpp:132
int priority
Definition: world_objects.h:354
#define SHADER_DEFAULT_DEFERRED_GBUFFER
Definition: rendering.h:33
BlamVector2 viewport_size
Definition: bgfx.cpp:37
The original diffuse textures are from the NVIDIA texture with other maps generated from them by Steve Streeting The following license applies to all textures Single Product or Project Use of NVSDK Art Imagery THIS IS A LEGAL immediately delete the NVSDK Art Imagery from your hard disk If you proceed to use any of the you thereby signify that you have agreed to all of the terms and conditions set forth below You may not copy
Definition: TextureUsageAgreement.txt:6
bgfx::TextureHandle pbr
Definition: passes.h:108
#define SHADER_DEFAULT_SHADOW_POINT
Definition: rendering.h:40
BlamShadowPass()
Definition: BlamShadowPass.cpp:14
BLAM void ApplyMaterialParameters(mesh::submesh *submesh, std::string material_tag_path)
Definition: materials.cpp:772
bgfx::TextureHandle worldpos
Definition: passes.h:111
BLAM float * GetCameraProjectionMatrix()
Definition: bgfx.cpp:458
BlamVector3 GetScale()
Definition: BlamWorldObject.cpp:244
void RecreateBuffers(BlamVector2 size) override
Definition: BlamPostprocessPass.cpp:11
void _Execute(float delta) override
Definition: BlamLightingPass.cpp:14
Lighting Pass.
Definition: passes.h:138
BLAM float * GetCameraViewMatrix()
Definition: bgfx.cpp:453
UI/2D Pass.
Definition: passes.h:150
bgfx::TextureHandle depth
Definition: passes.h:110
bool casts_shadows
Definition: light.h:31
#define SHADER_DEFAULT_SSAO_BLUR
Definition: rendering.h:38
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:132
Forward Pass.
Definition: passes.h:126
#define BLAM_SHADOW_POINT_COUNT
Definition: passes.h:219
bool AABBInFrustum(const BlamFrustum *frustum, BlamVector3 aabb_min, BlamVector3 aabb_max)
Definition: culling.cpp:99
BlamForwardPass()
Definition: BlamForwardPass.cpp:6
SSAO Pass.
Definition: passes.h:180
config GlyphExtraSpacing x
Definition: README.txt:30
BLAM bgfx::ViewId ReserveViewID()
Definition: bgfx.cpp:520
void _Execute(float delta) override
Definition: BlamUIPass.cpp:13
#define SHADER_DEFAULT_DEFERRED_POSTPROCESS
Definition: rendering.h:36
BLAM BlamWorldObject_Tag * GetLightCacheAt(int index)
Definition: lights.cpp:239
bool infinite_bounds
Definition: render_model.h:35
#define BLAM_SHADOW_SPOT_COUNT
Definition: passes.h:217
unsigned short uint16_t
Definition: stdint.h:16
BLAM int GetRenderWidth()
Retrieves the current width of the viewport.
Definition: bgfx.cpp:423
Postprocess Pass.
Definition: passes.h:162
#define MAX_LIGHTS
Definition: passes.h:26
int32_t priority
Definition: light.h:50
bgfx::TextureHandle coverage
Definition: passes.h:112
bgfx::FrameBufferHandle hdr_buffer
Definition: passes.h:170
#define SHADER_DEFAULT_DEFERRED_LIGHT_PASS
Definition: rendering.h:35
BlamVector3 camera_pos
The current position of the camera.
Definition: director.h:84
bool disable_culling
Definition: world_objects.h:163
Class representing a world state.
Definition: world_objects.h:715
BLAM bool * GetGlobalAsBoolean(std::string name)
Retrieves a global's value as a boolean.
Definition: globals.cpp:343
BLAM int GetLightCacheCount()
Definition: lights.cpp:234
int GetSpotResolution()
Definition: BlamShadowPass.cpp:1248
bgfx::ViewId GetViewID()
Definition: BlamRenderPass.cpp:44
bgfx::TextureHandle albedo
Definition: passes.h:106
#define tag_mode
Definition: render_model.h:22
int GetPointShadowCount()
Definition: BlamShadowPass.cpp:1296
int GetSpotShadowCount()
Definition: BlamShadowPass.cpp:1253
BLAM BlamRenderPass * GetPass(std::string id)
Definition: bgfx.cpp:502
bool bounds_valid
Definition: types.h:51
bgfx::TextureHandle GetShadowTextureArray()
Definition: BlamShadowPass.cpp:1213
std::string tag_class
The tag's short class name.
Definition: tags.h:146
BLAM int * GetGlobalAsInteger(std::string name)
Retrieves a global's value as an int.
Definition: globals.cpp:391