Skip to content

Commit 28f7d17

Browse files
committed
WIP
1 parent c9e496e commit 28f7d17

File tree

12 files changed

+1203
-1045
lines changed

12 files changed

+1203
-1045
lines changed

extensions/pl_ecs_ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ pl_ecs_add_component(plComponentLibrary* ptLibrary, plComponentType tType, plEnt
593593
ptManager->pComponents = sbComponents;
594594
sbComponents[uComponentIndex] = (plMaterialComponent){
595595
.tBlendMode = PL_BLEND_MODE_OPAQUE,
596-
.tFlags = PL_MATERIAL_FLAG_NONE,
596+
.tFlags = PL_MATERIAL_FLAG_CAST_SHADOW | PL_MATERIAL_FLAG_CAST_RECEIVE_SHADOW,
597597
.tShaderType = PL_SHADER_TYPE_PBR,
598598
.tBaseColor = {1.0f, 1.0f, 1.0f, 1.0f},
599599
.tEmissiveColor = {0.0f, 0.0f, 0.0f, 0.0f},

extensions/pl_ecs_ext.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ enum _plShaderType
221221

222222
enum _plMaterialFlags
223223
{
224-
PL_MATERIAL_FLAG_NONE = 0,
225-
PL_MATERIAL_FLAG_DOUBLE_SIDED = 1 << 0,
226-
PL_MATERIAL_FLAG_OUTLINE = 1 << 1,
224+
PL_MATERIAL_FLAG_NONE = 0,
225+
PL_MATERIAL_FLAG_DOUBLE_SIDED = 1 << 0,
226+
PL_MATERIAL_FLAG_OUTLINE = 1 << 1,
227+
PL_MATERIAL_FLAG_CAST_SHADOW = 1 << 2,
228+
PL_MATERIAL_FLAG_CAST_RECEIVE_SHADOW = 1 << 3
227229
};
228230

229231
enum _plBlendMode

extensions/pl_graphics_vulkan.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,6 @@ pl_create_shader(plDevice* ptDevice, const plShaderDesc* ptDescription)
12931293
plShaderHandle tHandle = pl__get_new_shader_handle(ptDevice);
12941294
plShader* ptShader = pl__get_shader(ptDevice, tHandle);
12951295
ptShader->tDesc = *ptDescription;
1296-
12971296
uint32_t uStageCount = 1;
12981297

12991298
plVulkanShader* ptVulkanShader = &ptDevice->sbtShadersHot[tHandle.uIndex];

extensions/pl_renderer_ext.c

Lines changed: 1002 additions & 965 deletions
Large diffs are not rendered by default.

extensions/pl_renderer_internal.c

Lines changed: 175 additions & 58 deletions
Large diffs are not rendered by default.

extensions/pl_renderer_internal.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ typedef struct _plEnvironmentProbeData
255255
plBufferHandle atGlobalBuffers[PL_MAX_FRAMES_IN_FLIGHT];
256256

257257
// submitted drawables
258-
plDrawable* sbtVisibleOpaqueDrawables;
259-
plDrawable* sbtVisibleTransparentDrawables;
258+
plDrawable* sbtVisibleOpaqueDrawables[6];
259+
plDrawable* sbtVisibleTransparentDrawables[6];
260260

261261
// shadows
262262
plDirectionLightShadowData tDirectionLightShadowData;
@@ -373,8 +373,11 @@ typedef struct _plRefScene
373373
// drawables (per scene, will be culled by views)
374374
plDrawable* sbtDeferredDrawables;
375375
plDrawable* sbtForwardDrawables;
376+
uint32_t* sbuShadowDeferredDrawables;
377+
uint32_t* sbuShadowForwardDrawables;
376378
plDrawable* sbtOutlineDrawables;
377379
plShaderHandle* sbtOutlineDrawablesOldShaders;
380+
plShaderHandle* sbtOutlineDrawablesOldEnvShaders;
378381

379382
// entity to drawable hashmaps
380383
plHashMap* ptDeferredHashmap;
@@ -513,6 +516,7 @@ typedef struct _plRefRendererData
513516
bool bShowSelectedBoundingBox;
514517
bool bMultiViewportShadows;
515518
bool bImageBasedLighting;
519+
bool bPunctualLighting;
516520
float fShadowConstantDepthBias;
517521
float fShadowSlopeDepthBias;
518522
uint32_t uOutlineWidth;
@@ -556,7 +560,8 @@ enum _plMaterialInfoFlags
556560
enum _plRenderingFlags
557561
{
558562
PL_RENDERING_FLAG_USE_PUNCTUAL = 1 << 0,
559-
PL_RENDERING_FLAG_USE_IBL = 1 << 1
563+
PL_RENDERING_FLAG_USE_IBL = 1 << 1,
564+
PL_RENDERING_FLAG_SHADOWS = 1 << 2
560565
};
561566

562567
//-----------------------------------------------------------------------------

sandbox/app.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plEditorData* ptEditorData)
207207

208208
ptEditorData->tPointLight = gptEcs->create_point_light(ptMainComponentLibrary, "point light", (plVec3){0.0f, 2.0f, 2.0f}, &ptLight);
209209
ptLight->uShadowResolution = 1024;
210-
// ptLight->tFlags |= PL_LIGHT_FLAG_CAST_SHADOW | PL_LIGHT_FLAG_VISUALIZER;
210+
ptLight->tFlags |= PL_LIGHT_FLAG_CAST_SHADOW;
211211
plTransformComponent* ptPLightTransform = gptEcs->add_component(ptMainComponentLibrary, PL_COMPONENT_TYPE_TRANSFORM, ptEditorData->tPointLight);
212212
ptPLightTransform->tTranslation = (plVec3){0.0f, 1.497f, 2.0f};
213213

@@ -216,21 +216,18 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plEditorData* ptEditorData)
216216
ptLight->fRange = 5.0f;
217217
ptLight->fRadius = 0.025f;
218218
ptLight->fIntensity = 20.0f;
219-
// ptLight->tFlags |= PL_LIGHT_FLAG_CAST_SHADOW | PL_LIGHT_FLAG_VISUALIZER;
219+
ptLight->tFlags |= PL_LIGHT_FLAG_CAST_SHADOW | PL_LIGHT_FLAG_VISUALIZER;
220220
plTransformComponent* ptSLightTransform = gptEcs->add_component(ptMainComponentLibrary, PL_COMPONENT_TYPE_TRANSFORM, ptEditorData->tSpotLight);
221221
ptSLightTransform->tTranslation = (plVec3){0.0f, 4.0f, 0.0f};
222222

223223
plEnvironmentProbeComponent* ptProbe = NULL;
224-
plEntity tProbe = gptEcs->create_environment_probe(ptMainComponentLibrary, "Main Probe", (plVec3){0.0f, 2.0f, 0.0f}, &ptProbe);
225-
ptProbe->fRange = 10.0f;
224+
gptEcs->create_environment_probe(ptMainComponentLibrary, "Main Probe", (plVec3){0.0f, 2.0f, 2.0f}, &ptProbe);
225+
ptProbe->fRange = 30.0f;
226226
ptProbe->uResolution = 128;
227-
plTransformComponent* ptProbeTransform = gptEcs->add_component(ptMainComponentLibrary, PL_COMPONENT_TYPE_TRANSFORM, tProbe);
228-
ptProbeTransform->tTranslation = (plVec3){0.0f, 2.0f, 0.0f};
229-
227+
ptProbe->tFlags = PL_ENVIRONMENT_PROBE_FLAGS_REALTIME;
230228

231229
// load models
232230

233-
234231
// plTransformComponent* ptTargetTransform = NULL;
235232
// ptEditorData->tTrackPoint = gptEcs->create_transform(ptMainComponentLibrary, "track 0", &ptTargetTransform);
236233
// ptTargetTransform->tTranslation = (plVec3){0.1f, 0.017f};

sandbox/pl_ecs_tools.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ pl_show_ecs_window(plEntity* ptSelectedEntity, plComponentLibrary* ptLibrary, bo
123123
{
124124
ptProbeComp->tFlags |= PL_ENVIRONMENT_PROBE_FLAGS_DIRTY;
125125
}
126+
gptUi->input_float("Range:", &ptProbeComp->fRange, NULL, 0);
126127
gptUi->end_collapsing_header();
127128
}
128129

shaders/defines.glsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const int PL_MATERIAL_METALLICROUGHNESS = 1 << 0;
3333
// iRenderingFlags
3434
const int PL_RENDERING_FLAG_USE_PUNCTUAL = 1 << 0;
3535
const int PL_RENDERING_FLAG_USE_IBL = 1 << 1;
36+
const int PL_RENDERING_FLAG_SHADOWS = 1 << 2;
3637

3738
// lights
3839
const int PL_LIGHT_TYPE_DIRECTIONAL = 0;

shaders/filter_environment.comp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ vec3 sampleCube(vec3 v)
5656
{
5757
faceIndex = v.y < 0.0 ? 5 : 4;
5858
ma = 0.5 / vAbs.y;
59-
uv = vec2(v.x, v.y < 0.0 ? -v.z : v.z);
59+
uv = vec2(-v.x, v.y < 0.0 ? v.z : -v.z);
6060
}
6161
else
6262
{

0 commit comments

Comments
 (0)