@@ -198,11 +198,17 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plEditorData* ptEditorData)
198198 ptEditorData -> tSunlight = gptEcs -> create_directional_light (ptMainComponentLibrary , "sunlight" , (plVec3 ){-0.375f , -1.0f , -0.085f }, & ptLight );
199199 ptLight -> uCascadeCount = 4 ;
200200 ptLight -> uShadowResolution = 2048 ;
201+ ptLight -> afCascadeSplits [0 ] = 2.0f ;
202+ ptLight -> afCascadeSplits [1 ] = 8.0f ;
203+ ptLight -> afCascadeSplits [2 ] = 15.0f ;
204+ ptLight -> afCascadeSplits [3 ] = 35.0f ;
201205 ptLight -> tFlags |= PL_LIGHT_FLAG_CAST_SHADOW ;
202206
203- gptEcs -> create_point_light (ptMainComponentLibrary , "light" , (plVec3 ){0.0f , 2.0f , 2.0f }, & ptLight );
207+ ptEditorData -> tPointLight = gptEcs -> create_point_light (ptMainComponentLibrary , "light" , (plVec3 ){0.0f , 2.0f , 2.0f }, & ptLight );
204208 ptLight -> uShadowResolution = 2048 ;
205209 ptLight -> tFlags |= PL_LIGHT_FLAG_CAST_SHADOW ;
210+ plTransformComponent * ptLightTransform = gptEcs -> add_component (ptMainComponentLibrary , PL_COMPONENT_TYPE_TRANSFORM , ptEditorData -> tPointLight );
211+ ptLightTransform -> tTranslation = (plVec3 ){0.0f , 1.497f , 0.0f };
206212
207213 // load models
208214
@@ -312,6 +318,10 @@ pl_app_update(plEditorData* ptEditorData)
312318 plCameraComponent * ptCullCamera = gptEcs -> get_component (ptMainComponentLibrary , PL_COMPONENT_TYPE_CAMERA , ptEditorData -> tCullCamera );
313319 gptCamera -> update (ptCullCamera );
314320
321+ plTransformComponent * ptLightTransform = gptEcs -> get_component (ptMainComponentLibrary , PL_COMPONENT_TYPE_TRANSFORM , ptEditorData -> tPointLight );
322+ plLightComponent * ptPointLight = gptEcs -> get_component (ptMainComponentLibrary , PL_COMPONENT_TYPE_LIGHT , ptEditorData -> tPointLight );
323+ ptPointLight -> tPosition = ptLightTransform -> tTranslation ;
324+
315325 if (ptEditorData -> bSceneLoaded )
316326 {
317327 // run ecs system
@@ -358,6 +368,7 @@ pl_app_update(plEditorData* ptEditorData)
358368 }
359369
360370 gptUi -> set_next_window_pos ((plVec2 ){0 , 0 }, PL_UI_COND_ONCE );
371+ gptUi -> set_next_window_size ((plVec2 ){500.0f , 800.0f }, PL_UI_COND_ONCE );
361372
362373 if (gptUi -> begin_window ("Pilot Light" , NULL , PL_UI_WINDOW_FLAGS_NONE ))
363374 {
@@ -427,10 +438,39 @@ pl_app_update(plEditorData* ptEditorData)
427438 const float pfWidths [] = {200.0f };
428439 gptUi -> layout_row (PL_UI_LAYOUT_ROW_TYPE_DYNAMIC , 0.0f , 1 , pfRatios );
429440 plLightComponent * ptLight = gptEcs -> get_component (ptMainComponentLibrary , PL_COMPONENT_TYPE_LIGHT , ptEditorData -> tSunlight );
430- int iCascadeCount = (int )ptLight -> uCascadeCount ;
431- if (gptUi -> slider_int ("Sunlight Cascades" , & iCascadeCount , 1 , 4 , 0 ))
441+ // plLightComponent* ptPointLight = gptEcs->get_component(ptMainComponentLibrary, PL_COMPONENT_TYPE_LIGHT, ptEditorData->tPointLight);
442+
443+ if (ptLight )
432444 {
433- ptLight -> uCascadeCount = (uint32_t )iCascadeCount ;
445+ int iCascadeCount = (int )ptLight -> uCascadeCount ;
446+ if (gptUi -> slider_int ("Sunlight Cascades" , & iCascadeCount , 1 , 4 , 0 ))
447+ {
448+ ptLight -> uCascadeCount = (uint32_t )iCascadeCount ;
449+ }
450+
451+ // int iResolution = (int)ptLight->uShadowResolution;
452+ gptUi -> input_float4 ("Cascades" , ptLight -> afCascadeSplits , NULL , 0 );
453+ }
454+
455+ if (ptPointLight )
456+ {
457+ gptUi -> input_float ("Point Light Radius" , & ptPointLight -> fRadius , NULL , 0 );
458+ gptUi -> input_float ("Point Light Range" , & ptPointLight -> fRange , NULL , 0 );
459+ int iResolution = (int )ptPointLight -> uShadowResolution ;
460+ uint32_t auResolutions [] = {
461+ 128 ,
462+ 256 ,
463+ 512 ,
464+ 1024 ,
465+ 2048
466+ };
467+ static int iSelection = 4 ;
468+ gptUi -> radio_button ("Point Light Resolution: 128" , & iSelection , 0 );
469+ gptUi -> radio_button ("Point Light Resolution: 256" , & iSelection , 1 );
470+ gptUi -> radio_button ("Point Light Resolution: 512" , & iSelection , 2 );
471+ gptUi -> radio_button ("Point Light Resolution: 1024" , & iSelection , 3 );
472+ gptUi -> radio_button ("Point Light Resolution: 2048" , & iSelection , 4 );
473+ ptPointLight -> uShadowResolution = auResolutions [iSelection ];
434474 }
435475
436476 gptUi -> layout_row (PL_UI_LAYOUT_ROW_TYPE_STATIC , 0.0f , 1 , pfWidths );
0 commit comments