@@ -1193,7 +1193,7 @@ pl_renderer_create_scene(plSceneInit tInit)
11931193 .iTreeDepth = 6 ,
11941194 .fMaxHeight = 500.0f ,
11951195 .fMinHeight = 0.0f ,
1196- .fMaxBaseError = 1.0f ,
1196+ .fMaxBaseError = 0.1f ,
11971197 .tCenter = {0 }
11981198 };
11991199 plTerrainProcessInfo tTerrainInfo = {
@@ -3100,7 +3100,13 @@ pl_renderer_prepare_scene(plScene* ptScene)
31003100 .tColor = ptLight -> tColor ,
31013101 .iShadowIndex = (int )ptScene -> uDOffset ++ ,
31023102 .iCastShadow = 1 ,
3103- .iCascadeCount = (int )ptLight -> uCascadeCount
3103+ .iCascadeCount = (int )ptLight -> uCascadeCount ,
3104+ .afCascadeSplits = {
3105+ ptLight -> afCascadeSplits [0 ],
3106+ ptLight -> afCascadeSplits [1 ],
3107+ ptLight -> afCascadeSplits [2 ],
3108+ ptLight -> afCascadeSplits [3 ]
3109+ }
31043110 };
31053111 pl_sb_push (ptScene -> sbtDirectionLightData , tLight );
31063112
@@ -3122,7 +3128,13 @@ pl_renderer_prepare_scene(plScene* ptScene)
31223128 .tColor = ptLight -> tColor ,
31233129 .iShadowIndex = 0 ,
31243130 .iCastShadow = ptLight -> tFlags & PL_LIGHT_FLAG_CAST_SHADOW ,
3125- .iCascadeCount = (int )ptLight -> uCascadeCount
3131+ .iCascadeCount = (int )ptLight -> uCascadeCount ,
3132+ .afCascadeSplits = {
3133+ ptLight -> afCascadeSplits [0 ],
3134+ ptLight -> afCascadeSplits [1 ],
3135+ ptLight -> afCascadeSplits [2 ],
3136+ ptLight -> afCascadeSplits [3 ]
3137+ }
31263138 };
31273139 pl_sb_push (ptScene -> sbtDirectionLightData , tLight );
31283140 }
@@ -3424,7 +3436,7 @@ pl_renderer_prepare_scene(plScene* ptScene)
34243436 .tDLightShadowDataBuffer = ptProbe -> tDLightShadowDataBuffer ,
34253437 .sbtDLightShadowData = ptProbe -> sbtDLightShadowData
34263438 };
3427- pl__renderer_generate_cascaded_shadow_map (ptCSMEncoder , ptCSMCommandBuffer , ptScene , uFace , uProbeIndex , & atEnvironmentCamera [uFace ], tCSMInfo );
3439+ pl__renderer_generate_cascaded_shadow_map (ptCSMEncoder , ptCSMCommandBuffer , ptScene , uFace , uProbeIndex , & atEnvironmentCamera [uFace ], tCSMInfo , NULL );
34283440
34293441 gptGfx -> pop_render_debug_group (ptCSMEncoder );
34303442 gptGfx -> end_render_pass (ptCSMEncoder );
@@ -3510,6 +3522,10 @@ pl_renderer_prepare_view(plView* ptView, plCamera* ptCamera)
35103522 ptView -> tData .tFogColor = gptData -> tRuntimeOptions .tFogColor ;
35113523 ptView -> tData .fFogLinearParam0 = 1.0f / (ptView -> tData .fFogCutOffDistance - ptView -> tData .fFogStart );
35123524 ptView -> tData .fFogLinearParam1 = - ptView -> tData .fFogStart / (ptView -> tData .fFogCutOffDistance - ptView -> tData .fFogStart );
3525+ // ptView->tData.tCameraPos.xyz = ptCamera->tPos;
3526+ ptView -> tData .tCameraPos .x = ptCamera -> fNearZ ;
3527+ ptView -> tData .tCameraPos .y = ptCamera -> fFarZ ;
3528+ ptView -> tData .tCameraPos .w = (ptCamera -> fFarZ - ptCamera -> fNearZ );
35133529
35143530 const float fFogDensity = - (float )(ptView -> tData .fFogHeightFalloff * (ptCamera -> tPos .y - ptView -> tData .fFogHeight ));
35153531 ptView -> tData .tFogDensity = (plVec3 ){gptData -> tRuntimeOptions .fFogDensity , fFogDensity , gptData -> tRuntimeOptions .fFogDensity * expf (fFogDensity )};
@@ -3536,7 +3552,7 @@ pl_renderer_prepare_view(plView* ptView, plCamera* ptCamera)
35363552 .tDLightShadowDataBuffer = ptView -> atDLightShadowDataBuffer [uFrameIdx ],
35373553 .sbtDLightShadowData = ptView -> sbtDLightShadowData
35383554 };
3539- pl__renderer_generate_cascaded_shadow_map (ptCSMEncoder , ptCSMCmdBuffer , ptScene , ptView -> uIndex , 0 , ptCamera , tCSMInfo );
3555+ pl__renderer_generate_cascaded_shadow_map (ptCSMEncoder , ptCSMCmdBuffer , ptScene , ptView -> uIndex , 0 , ptCamera , tCSMInfo , ptView -> pt3DDrawList );
35403556
35413557 gptGfx -> pop_render_debug_group (ptCSMEncoder );
35423558 gptGfx -> end_render_pass (ptCSMEncoder );
@@ -3762,6 +3778,27 @@ pl_renderer_render_view(plView* ptView, plCamera* ptCamera, plCamera* ptCullCame
37623778 };
37633779 pl__render_view_gbuffer_fill_pass (ptScene , ptMainEncoder , & tGbufferFillPassInfo );
37643780
3781+ // move to function
3782+ {
3783+ const plMat4 tMVP = pl_mul_mat4 (& ptCamera -> tProjMat , & ptCamera -> tViewMat );
3784+
3785+ gptGfx -> set_depth_bias (ptMainEncoder , 0.0f , 0.0f , 0.0f );
3786+ gptGfx -> bind_shader (ptMainEncoder , ptScene -> tTerrainShader );
3787+ gptGfx -> bind_vertex_buffer (ptMainEncoder , ptScene -> ptTerrain -> tVertexBuffer );
3788+ plBindGroupHandle atBindGroups [] = {ptScene -> atSceneBindGroups [uFrameIdx ], ptView -> atDeferredBG1 [uFrameIdx ]};
3789+ gptGfx -> bind_graphics_bind_groups (
3790+ ptMainEncoder ,
3791+ ptScene -> tTerrainShader ,
3792+ 0 , 2 ,
3793+ atBindGroups ,
3794+ 0 , NULL
3795+ );
3796+
3797+
3798+ for (uint32_t i = 0 ; i < pl_sb_size (ptScene -> ptTerrain -> sbtChunkFiles ); i ++ )
3799+ pl__render_chunk (ptScene , ptScene -> ptTerrain , ptCamera , ptMainEncoder , & ptScene -> ptTerrain -> sbtChunkFiles [i ].tFile .atChunks [0 ], & ptScene -> ptTerrain -> sbtChunkFiles [i ].tFile , & tMVP , 0 );
3800+ }
3801+
37653802 gptGfx -> next_subpass (ptMainEncoder , NULL );
37663803
37673804 plDeferredLightingPassInfo tDeferredLightingPassInfo = {
@@ -3796,27 +3833,6 @@ pl_renderer_render_view(plView* ptView, plCamera* ptCamera, plCamera* ptCullCame
37963833 };
37973834 pl__render_view_forward_pass (ptScene , ptMainEncoder , ptView -> atViewBG [uFrameIdx ], & tForwardPassInfo );
37983835
3799- // move to function
3800- {
3801- const plMat4 tMVP = pl_mul_mat4 (& ptCamera -> tProjMat , & ptCamera -> tViewMat );
3802-
3803- gptGfx -> set_depth_bias (ptMainEncoder , 0.0f , 0.0f , 0.0f );
3804- gptGfx -> bind_shader (ptMainEncoder , ptScene -> tTerrainShader );
3805- gptGfx -> bind_vertex_buffer (ptMainEncoder , ptScene -> ptTerrain -> tVertexBuffer );
3806- plBindGroupHandle atBindGroups [] = {ptScene -> atSceneBindGroups [uFrameIdx ], ptView -> atViewBG [uFrameIdx ]};
3807- gptGfx -> bind_graphics_bind_groups (
3808- ptMainEncoder ,
3809- ptScene -> tTerrainShader ,
3810- 0 , 2 ,
3811- atBindGroups ,
3812- 0 , NULL
3813- );
3814-
3815-
3816- for (uint32_t i = 0 ; i < pl_sb_size (ptScene -> ptTerrain -> sbtChunkFiles ); i ++ )
3817- pl__render_chunk (ptScene , ptScene -> ptTerrain , ptCamera , ptMainEncoder , & ptScene -> ptTerrain -> sbtChunkFiles [i ].tFile .atChunks [0 ], & ptScene -> ptTerrain -> sbtChunkFiles [i ].tFile , & tMVP , 0 );
3818- }
3819-
38203836 gptGfx -> pop_render_debug_group (ptMainEncoder );
38213837
38223838 // end main render pass
0 commit comments