Shadowmap size limit

This commit is contained in:
Mid 2025-10-12 20:43:17 +03:00
parent 69f355eae4
commit 2ebab9358d
2 changed files with 6 additions and 2 deletions

View File

@ -2150,7 +2150,7 @@ void k3PassIrregular(struct k3Offscreen *mainview, mat4 mainproj, mat4 maincam)
#endif
// Constructs shadowmap atlas, saves `offscr` for own use
void k3PassShadowmap(mat4 projection, mat4 cam, struct k3Offscreen *offscr) {
void k3PassShadowmap(mat4 projection, mat4 cam, struct k3Offscreen *offscr, float cellSizeLimit) {
glm_mat4_copy(projection, ProjMat);
glm_mat4_copy(cam, CamMat);
@ -2194,6 +2194,10 @@ void k3PassShadowmap(mat4 projection, mat4 cam, struct k3Offscreen *offscr) {
uint16_t sz = k3TexSzX(offscr->depth);
float cellSz = (float) sz / cellsPerDimension;
if(cellSizeLimit > 0) {
cellSz = fminf(cellSizeLimit, cellSz);
}
k3BeginOffscreen(offscr);
size_t i = 0;
for(size_t li = 0; li < LightCount; li++) {

View File

@ -185,7 +185,7 @@ void k3BatchClear();
void k3PassForward(mat4 projection, mat4 cam);
void k3PassDepthOnly(mat4 projection, mat4 cam, int clear, int cull);
void k3PassShadowmap(mat4 projection, mat4 cam, struct k3Offscreen *offscr);
void k3PassShadowmap(mat4 projection, mat4 cam, struct k3Offscreen *offscr, float cellSizeLimit);
struct k3Offscreen;
struct k3Offscreen *k3OffscreenCreateMultisampled(struct k3Tex *diffuse, struct k3Tex *depth, uint8_t samples);