diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/new_render/pbr.c | 2 | ||||
-rw-r--r-- | src/new_render/render.c | 23 | ||||
-rw-r--r-- | src/new_render/render.h | 3 |
3 files changed, 25 insertions, 3 deletions
diff --git a/src/new_render/pbr.c b/src/new_render/pbr.c index 4a91080..0581f4a 100644 --- a/src/new_render/pbr.c +++ b/src/new_render/pbr.c @@ -94,7 +94,7 @@ void PBR_Execute(PBR_Storage* storage, Camera camera, TextureHandle shadowmap_te lights_data = { .pointLights = { // FIXME: add lights to our RenderScene structure. for now these are // hardcoded - (pbr_point_light){ .pos = vec3(0.0, 2.0, 2.0), .color = light_color }, + (pbr_point_light){ .pos = vec3(0.0, 6.0, 6.0), .color = light_color }, (pbr_point_light){ .pos = vec3(-10, 10, 10), .color = light_color }, (pbr_point_light){ .pos = vec3(10, -10, 10), .color = light_color }, (pbr_point_light){ .pos = vec3(-10, -10, 10), .color = light_color }, diff --git a/src/new_render/render.c b/src/new_render/render.c index 77a3269..96ab0d1 100644 --- a/src/new_render/render.c +++ b/src/new_render/render.c @@ -9,6 +9,7 @@ #include "core.h" #include "log.h" #include "maths.h" +#include "maths_types.h" #include "mem.h" #include "pbr.h" #include "ral_common.h" @@ -185,12 +186,14 @@ void Render_RenderEntities(RenderEnt* entities, size_t entity_count) { Renderer* ren = get_renderer(); RenderScene scene = ren->scene; + // FUTURE: Depth pre-pass + Shadow_Storage* shadow_storage = Render_GetShadowStorage(); shadow_storage->enabled = false; - TextureHandle depthmap = + TextureHandle sun_shadowmap = shadow_storage->enabled ? Shadow_GetShadowMapTexture(shadow_storage) : INVALID_TEX_HANDLE; - PBR_Execute(ren->pbr, scene.camera, depthmap, entities, entity_count); + PBR_Execute(ren->pbr, scene.camera, sun_shadowmap, entities, entity_count); } TextureData TextureDataLoad(const char* path, bool invert_y) { @@ -270,6 +273,22 @@ void Geometry_Destroy(Geometry* geometry) { } } +size_t ModelExtractRenderEnts(RenderEnt_darray* entities, ModelHandle model_handle, Mat4 affine, RenderEntityFlags flags) { + Model* model = MODEL_GET(model_handle); + for (u32 i = 0; i < model->mesh_count; i++) { + Mesh* m = Mesh_pool_get(Render_GetMeshPool(), model->meshes[i]); + RenderEnt data = { + .mesh = model->meshes[i], + .material = m->material, + .affine = affine, + // .bounding_box + .flags = flags + }; + RenderEnt_darray_push(entities, data); + } + return model->mesh_count; // how many RenderEnts we pushed +} + void SetCamera(Camera camera) { g_core.renderer->scene.camera = camera; } void SetMainLight(DirectionalLight light) { g_core.renderer->scene.sun = light; } diff --git a/src/new_render/render.h b/src/new_render/render.h index b7af7cb..dad3026 100644 --- a/src/new_render/render.h +++ b/src/new_render/render.h @@ -62,6 +62,9 @@ PUB Mesh Mesh_Create(Geometry* geometry, bool free_on_upload); PUB void Mesh_Delete(Mesh* mesh); void Geometry_Destroy(Geometry* geometry); +/** @brief gets render entities from a model and pushes them into a dynamic array for rendering */ +size_t ModelExtractRenderEnts(RenderEnt_darray* entities, ModelHandle model_handle, Mat4 affine, RenderEntityFlags flags); + // --- Drawing // NOTE: These functions use the globally bound camera in RenderScene |