Fix horizon offset

This commit is contained in:
Miloslav Ciz 2025-02-03 12:58:42 +01:00
parent f24db847ce
commit 7f00b5aa5f
7 changed files with 34 additions and 40 deletions

View file

@ -41,8 +41,8 @@
// NOTE: ^ S3L_F sometimes makes some triangles bug, S3L_F/2 seems to fix it
// but it's more jerky, maybe try to apply anti-overflow in S3L?
#define LCR_RENDERER_CHUNK_RESOLUTION 4 // do not change
#define LCR_RENDERER_LOD_BLOCKS 64 // do not change
#define LCR_RENDERER_CHUNK_RESOLUTION 4 // do not change
#define LCR_RENDERER_LOD_BLOCKS 64 // do not change
#define LCR_RENDERER_CHUNK_SIZE_HORIZONTAL \
((LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT) / LCR_RENDERER_CHUNK_RESOLUTION)
@ -1346,19 +1346,16 @@ void LCR_rendererDrawSky(int sky, S3L_Unit offsetH, S3L_Unit offsetV)
LCR_loadImage(sky + 3);
bottomColor = LCR_sampleImage(LCR_IMAGE_SIZE - 1,LCR_IMAGE_SIZE - 1);
anchorPoint[0] = ((LCR_EFFECTIVE_RESOLUTION_X * offsetH)
/ S3L_F) %
anchorPoint[0] = ((LCR_EFFECTIVE_RESOLUTION_X * offsetH) / S3L_F) %
(2 * LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE);
if (anchorPoint[0] < 0)
anchorPoint[0] += 2 * LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE;
anchorPoint[1] =
(LCR_EFFECTIVE_RESOLUTION_Y) / 2 - // 3: we place the center a bit more up
(LCR_SETTING_HORIZON_SHIFT * LCR_EFFECTIVE_RESOLUTION_Y) / 100 -
(LCR_EFFECTIVE_RESOLUTION_Y * offsetV) / S3L_F
- LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE;
anchorPoint[1] = LCR_EFFECTIVE_RESOLUTION_Y / 2 - (LCR_EFFECTIVE_RESOLUTION_Y
* offsetV) / S3L_F - ((LCR_IMAGE_SIZE * LCR_SETTING_HORIZON_SHIFT) / 100 *
LCR_SETTING_SKY_SIZE);
pixelIndex = 0;
y = anchorPoint[1] < 0 ? anchorPoint[1] : 0;