Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
WIP 0

WIP 1

WIP

WIP cleanup
WIP cleanup

WIP

WIP

WIP

WIP

WIP cube

WIP cube 2

WIP

WIP
  • Loading branch information
hoffstadt committed Jan 23, 2025
1 parent e5cc75b commit 14534ba
Show file tree
Hide file tree
Showing 42 changed files with 4,318 additions and 2,779 deletions.
74 changes: 72 additions & 2 deletions docs/features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,84 @@ Reference Renderer:
* Edge outline (Jump flood with compute shaders)
* Pixel perfect picking
* Directional lights + cascaded shadow maps
* Point lights
* Point lights + cubemap shadows
* Spot lights + shadows
* Soft shadows (PCF)
* Gamma correct, HDR rendering
* Deferred + forward rendering
* Reversed Z-buffer
* Vertex skinning (compute shaders)
* Panorama to cubemap calculations (compute shaders)
* Environment filtering (compute shaders)
* Parallax-corrected environment maps
* Dynamic environment mapping
* Cube map reflections (static and real time)
* Tonemapping
* gltf model loading
* stl model loading

Wishlist (from Wicked Engine):
* Morph target animation (with sparse accessor)
* Animated texturing
* Displacement mapping
* Parallax occlusion mapping
* Real time planar reflections
* Refractions (screen space, blurred)
* Interactive Water
* Bloom
* Motion Blur
* Lens Flare
* Light shafts
* Bokeh Depth of Field
* Chromatic aberration
* Multithreaded rendering
* Tessellation (silhouette smoothing, displacement mapping)
* GPU-based particles (emit from point, mesh, animated mesh)
* Soft particles
* Hair particle systems (grass/vegetation)
* Instanced rendering
* MSAA
* FXAA
* TAA (Temporal Antialiasing)
* Supersampling
* Physics: rigid body, soft body, ragdoll
* 3D Audio
* Input: keyboard, mouse, controller (rawinput, xinput), touch
* Controller feedback (vibration, LED)
* Backlog: log,input,scripting
* Gamma correct, HDR rendering
* Screen Space Ambient Occlusion (SSAO, HBAO, MSAO)
* Stochastic Screen Space Reflections
* Color Grading
* Sharpen filter
* Eye adaption
* Lua Scripting
* Impostor system
* Tiled forward (Forward+) rendering (+2.5D culling)
* Occlusion culling with gpu queries
* Tiled decals
* Frame Profiler
* Voxel Global Illumination
* Force Fields GPU simulation
* Particle - Depth Buffer collisions
* Ocean simulation (FFT)
* Translucent colored shadows
* Refraction caustics
* Volumetric light scattering
* Smooth Particle Hydrodynamics (SPH) Fluid Simulation
* Ray tracing, path tracing (on GPU)
* Lightmap baking (with GPU path tracing)
* Springs, Colliders
* Variable Rate Shading
* Real time ray tracing: ambient occlusion, shadows, reflections (DXR and Vulkan raytracing)
* Screen Space Contact Shadows
* Stochastic alphatest transparency
* Surfel GI
* HDR display output
* Dynamic Diffuse Global Illumination (DDGI)
* Procedural terrain generator
* Virtual textures
* Animation retargeting
* Video decoding: H264
* 3D path finding
* Screen Space Global Illumination (SSGI)
* Texture streaming
6 changes: 4 additions & 2 deletions extensions/pl_debug_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Index of this file:
// core
#include <float.h>
#include "pl.h"
#include "pl_ds.h"

#include "pl_debug_ext.h"
#define PL_MATH_INCLUDE_FUNCTIONS
#include "pl_math.h"
Expand Down Expand Up @@ -103,6 +103,8 @@ static plDebugContext* gptDebugCtx = NULL;

#endif

#include "pl_ds.h"

//-----------------------------------------------------------------------------
// [SECTION] internal api
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -883,7 +885,7 @@ pl__show_device_memory(bool* bValue)
const char* apcAllocatorNames[] = {
"Device Memory: Local Buddy",
"Device Memory: Local Dedicated",
"Device Memory: Staging Uncached",
"Device Memory: Staging Uncached Buddy",
"Device Memory: Staging Cached"
};

Expand Down
31 changes: 18 additions & 13 deletions extensions/pl_draw_backend_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Index of this file:
#include <float.h>
#include "pl.h"
#include "pl_memory.h"
#include "pl_ds.h"
#define PL_MATH_INCLUDE_FUNCTIONS
#include "pl_math.h"

Expand All @@ -33,8 +32,26 @@ Index of this file:

#ifdef PL_UNITY_BUILD
#include "pl_unity_ext.inc"
#else
static const plMemoryI* gptMemory = NULL;
#define PL_ALLOC(x) gptMemory->tracked_realloc(NULL, (x), __FILE__, __LINE__)
#define PL_REALLOC(x, y) gptMemory->tracked_realloc((x), (y), __FILE__, __LINE__)
#define PL_FREE(x) gptMemory->tracked_realloc((x), 0, __FILE__, __LINE__)

#ifndef PL_DS_ALLOC
#define PL_DS_ALLOC(x) gptMemory->tracked_realloc(NULL, (x), __FILE__, __LINE__)
#define PL_DS_ALLOC_INDIRECT(x, FILE, LINE) gptMemory->tracked_realloc(NULL, (x), FILE, LINE)
#define PL_DS_FREE(x) gptMemory->tracked_realloc((x), 0, __FILE__, __LINE__)
#endif

static const plGraphicsI* gptGfx = NULL;
static const plStatsI* gptStats = NULL;
static const plDrawI* gptDraw = NULL;
static const plShaderI* gptShader = NULL;
#endif

#include "pl_ds.h"

//-----------------------------------------------------------------------------
// [SECTION] internal structs
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -85,18 +102,6 @@ typedef struct _plDrawBackendContext

static plDrawBackendContext* gptDrawBackendCtx = NULL;

#ifndef PL_UNITY_BUILD
static const plMemoryI* gptMemory = NULL;
#define PL_ALLOC(x) gptMemory->tracked_realloc(NULL, (x), __FILE__, __LINE__)
#define PL_REALLOC(x, y) gptMemory->tracked_realloc((x), (y), __FILE__, __LINE__)
#define PL_FREE(x) gptMemory->tracked_realloc((x), 0, __FILE__, __LINE__)

static const plGraphicsI* gptGfx = NULL;
static const plStatsI* gptStats = NULL;
static const plDrawI* gptDraw = NULL;
static const plShaderI* gptShader = NULL;
#endif

//-----------------------------------------------------------------------------
// [SECTION] internal api
//-----------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion extensions/pl_draw_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Index of this file:
//-----------------------------------------------------------------------------

#include <float.h>
#include <stdlib.h>
#include "pl.h"
#define PL_MATH_INCLUDE_FUNCTIONS
#include "pl_draw_ext.h"
#include "pl_ds.h"
#include "pl_memory.h"
#include "pl_string.h"

Expand Down Expand Up @@ -140,6 +140,8 @@ static unsigned char* ptrDOut_ = NULL;
static const plFileI* gptFile = NULL;
#endif

#include "pl_ds.h"

//-----------------------------------------------------------------------------
// [SECTION] internal api
//-----------------------------------------------------------------------------
Expand Down
107 changes: 93 additions & 14 deletions extensions/pl_ecs_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Index of this file:
#define PL_MATH_INCLUDE_FUNCTIONS
#include "pl.h"
#include "pl_ecs_ext.h"
#include "pl_ds.h"
#include "pl_math.h"

// extensions
Expand Down Expand Up @@ -51,6 +50,8 @@ Index of this file:
static const plLogI* gptLog = NULL;
#endif

#include "pl_ds.h"

//-----------------------------------------------------------------------------
// [SECTION] structs
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -114,6 +115,9 @@ static void pl_run_hierarchy_update_system (plComponentLibrary* ptLibrar
static void pl_run_animation_update_system (plComponentLibrary* ptLibrary, float fDeltaTime);
static void pl_run_inverse_kinematics_update_system(plComponentLibrary* ptLibrary);
static void pl_run_script_update_system (plComponentLibrary* ptLibrary);
static void pl_run_camera_update_system (plComponentLibrary* ptLibrary);
static void pl_run_light_update_system (plComponentLibrary* ptLibrary);
static void pl_run_probe_update_system (plComponentLibrary* ptLibrary);

// misc.
static void pl_calculate_normals (plMeshComponent* atMeshes, uint32_t uComponentCount);
Expand Down Expand Up @@ -590,7 +594,7 @@ pl_ecs_add_component(plComponentLibrary* ptLibrary, plComponentType tType, plEnt
ptManager->pComponents = sbComponents;
sbComponents[uComponentIndex] = (plMaterialComponent){
.tBlendMode = PL_BLEND_MODE_OPAQUE,
.tFlags = PL_MATERIAL_FLAG_NONE,
.tFlags = PL_MATERIAL_FLAG_CAST_SHADOW | PL_MATERIAL_FLAG_CAST_RECEIVE_SHADOW,
.tShaderType = PL_SHADER_TYPE_PBR,
.tBaseColor = {1.0f, 1.0f, 1.0f, 1.0f},
.tEmissiveColor = {0.0f, 0.0f, 0.0f, 0.0f},
Expand Down Expand Up @@ -724,7 +728,10 @@ pl_ecs_add_component(plComponentLibrary* ptLibrary, plComponentType tType, plEnt
ptManager->pComponents = sbComponents;
sbComponents[uComponentIndex] = (plEnvironmentProbeComponent){
.fRange = 10.0f,
.uResolution = 128
.uResolution = 128,
.uSamples = 128,
.uInterval = 1,
.tFlags = PL_ENVIRONMENT_PROBE_FLAGS_DIRTY
};
return &sbComponents[uComponentIndex];
}
Expand Down Expand Up @@ -890,8 +897,8 @@ pl_ecs_create_object(plComponentLibrary* ptLibrary, const char* pcName, plObject
plEntity tNewEntity = pl_ecs_create_tag(ptLibrary, pcName);

plObjectComponent* ptObject = pl_ecs_add_component(ptLibrary, PL_COMPONENT_TYPE_OBJECT, tNewEntity);
pl_ecs_add_component(ptLibrary, PL_COMPONENT_TYPE_TRANSFORM, tNewEntity);
pl_ecs_add_component(ptLibrary, PL_COMPONENT_TYPE_MESH, tNewEntity);
(void)pl_ecs_add_component(ptLibrary, PL_COMPONENT_TYPE_TRANSFORM, tNewEntity);
(void)pl_ecs_add_component(ptLibrary, PL_COMPONENT_TYPE_MESH, tNewEntity);

ptObject->tTransform = tNewEntity;
ptObject->tMesh = tNewEntity;
Expand Down Expand Up @@ -1130,17 +1137,17 @@ pl__object_update_job(plInvocationData tInvoData, void* pData)
};

// calculate AABB
ptMesh->tAABBFinal.tMax = (plVec3){-FLT_MAX, -FLT_MAX, -FLT_MAX};
ptMesh->tAABBFinal.tMin = (plVec3){FLT_MAX, FLT_MAX, FLT_MAX};
ptObject->tAABB.tMax = (plVec3){-FLT_MAX, -FLT_MAX, -FLT_MAX};
ptObject->tAABB.tMin = (plVec3){FLT_MAX, FLT_MAX, FLT_MAX};

for(uint32_t i = 0; i < 8; i++)
{
if(tVerticies[i].x > ptMesh->tAABBFinal.tMax.x) ptMesh->tAABBFinal.tMax.x = tVerticies[i].x;
if(tVerticies[i].y > ptMesh->tAABBFinal.tMax.y) ptMesh->tAABBFinal.tMax.y = tVerticies[i].y;
if(tVerticies[i].z > ptMesh->tAABBFinal.tMax.z) ptMesh->tAABBFinal.tMax.z = tVerticies[i].z;
if(tVerticies[i].x < ptMesh->tAABBFinal.tMin.x) ptMesh->tAABBFinal.tMin.x = tVerticies[i].x;
if(tVerticies[i].y < ptMesh->tAABBFinal.tMin.y) ptMesh->tAABBFinal.tMin.y = tVerticies[i].y;
if(tVerticies[i].z < ptMesh->tAABBFinal.tMin.z) ptMesh->tAABBFinal.tMin.z = tVerticies[i].z;
if(tVerticies[i].x > ptObject->tAABB.tMax.x) ptObject->tAABB.tMax.x = tVerticies[i].x;
if(tVerticies[i].y > ptObject->tAABB.tMax.y) ptObject->tAABB.tMax.y = tVerticies[i].y;
if(tVerticies[i].z > ptObject->tAABB.tMax.z) ptObject->tAABB.tMax.z = tVerticies[i].z;
if(tVerticies[i].x < ptObject->tAABB.tMin.x) ptObject->tAABB.tMin.x = tVerticies[i].x;
if(tVerticies[i].y < ptObject->tAABB.tMin.y) ptObject->tAABB.tMin.y = tVerticies[i].y;
if(tVerticies[i].z < ptObject->tAABB.tMin.z) ptObject->tAABB.tMin.z = tVerticies[i].z;
}
}

Expand Down Expand Up @@ -1220,6 +1227,75 @@ pl_run_script_update_system(plComponentLibrary* ptLibrary)
pl_end_cpu_sample(gptProfile, 0);
}

static void
pl_run_camera_update_system(plComponentLibrary* ptLibrary)
{
pl_begin_cpu_sample(gptProfile, 0, __FUNCTION__);

plCameraComponent* sbtComponents = ptLibrary->tCameraComponentManager.pComponents;

const uint32_t uComponentCount = pl_sb_size(sbtComponents);
for(uint32_t i = 0; i < uComponentCount; i++)
{
plEntity tEntity = ptLibrary->tCameraComponentManager.sbtEntities[i];
if(pl_ecs_has_entity(&ptLibrary->tTransformComponentManager, tEntity))
{
plCameraComponent* ptCamera = &sbtComponents[i];
plTransformComponent* ptTransform = pl_ecs_get_component(ptLibrary, PL_COMPONENT_TYPE_TRANSFORM, tEntity);
ptCamera->tPos = ptTransform->tWorld.col[3].xyz;
pl_camera_update(ptCamera);
}
}
pl_end_cpu_sample(gptProfile, 0);
}

static void
pl_run_light_update_system(plComponentLibrary* ptLibrary)
{
pl_begin_cpu_sample(gptProfile, 0, __FUNCTION__);

plLightComponent* sbtComponents = ptLibrary->tLightComponentManager.pComponents;

const uint32_t uComponentCount = pl_sb_size(sbtComponents);
for(uint32_t i = 0; i < uComponentCount; i++)
{
plEntity tEntity = ptLibrary->tLightComponentManager.sbtEntities[i];
if(pl_ecs_has_entity(&ptLibrary->tTransformComponentManager, tEntity))
{
plLightComponent* ptLight = &sbtComponents[i];
plTransformComponent* ptTransform = pl_ecs_get_component(ptLibrary, PL_COMPONENT_TYPE_TRANSFORM, tEntity);
ptLight->tPosition = ptTransform->tWorld.col[3].xyz;

// TODO: direction
}
}
pl_end_cpu_sample(gptProfile, 0);
}

static void
pl_run_probe_update_system(plComponentLibrary* ptLibrary)
{
pl_begin_cpu_sample(gptProfile, 0, __FUNCTION__);

plEnvironmentProbeComponent* sbtComponents = ptLibrary->tEnvironmentProbeCompManager.pComponents;

const uint32_t uComponentCount = pl_sb_size(sbtComponents);
for(uint32_t i = 0; i < uComponentCount; i++)
{
plEntity tEntity = ptLibrary->tEnvironmentProbeCompManager.sbtEntities[i];
if(pl_ecs_has_entity(&ptLibrary->tTransformComponentManager, tEntity))
{
plEnvironmentProbeComponent* ptProbe = &sbtComponents[i];
plTransformComponent* ptTransform = pl_ecs_get_component(ptLibrary, PL_COMPONENT_TYPE_TRANSFORM, tEntity);
ptProbe->tPosition = ptTransform->tWorld.col[3].xyz;
ptTransform->tWorld = pl_mat4_translate_vec3(ptProbe->tPosition);

// TODO: direction
}
}
pl_end_cpu_sample(gptProfile, 0);
}

static void
pl_run_animation_update_system(plComponentLibrary* ptLibrary, float fDeltaTime)
{
Expand Down Expand Up @@ -1851,7 +1927,10 @@ pl_load_ecs_ext(plApiRegistryI* ptApiRegistry, bool bReload)
.run_skin_update_system = pl_run_skin_update_system,
.run_animation_update_system = pl_run_animation_update_system,
.run_inverse_kinematics_update_system = pl_run_inverse_kinematics_update_system,
.run_script_update_system = pl_run_script_update_system
.run_script_update_system = pl_run_script_update_system,
.run_camera_update_system = pl_run_camera_update_system,
.run_light_update_system = pl_run_light_update_system,
.run_environment_probe_update_system = pl_run_probe_update_system
};
pl_set_api(ptApiRegistry, plEcsI, &tApi0);

Expand Down
Loading

0 comments on commit 14534ba

Please sign in to comment.