Add subsampling

This commit is contained in:
Miloslav Číž 2019-09-28 21:42:02 +02:00
parent 78c3b2e2b4
commit f971f1d423
2 changed files with 29 additions and 3 deletions

13
main.c
View File

@ -161,11 +161,18 @@ void SFG_pixelFunc(RCL_PixelInfo *pixel)
else
{
color = SFG_getTexel(SFG_backgrounds[0],
SFG_backgroundScaleMap[(pixel->position.x + SFG_backgroundScroll) % SFG_RESOLUTION_Y],
SFG_backgroundScaleMap[(pixel->position.x * SFG_RAYCASTING_SUBSAMPLE + SFG_backgroundScroll) % SFG_RESOLUTION_Y],
// ^ TODO: get rid of mod?
SFG_backgroundScaleMap[pixel->position.y]);
}
SFG_setPixel(pixel->position.x,pixel->position.y,color);
RCL_Unit screenX = pixel->position.x * SFG_RAYCASTING_SUBSAMPLE;
for (uint8_t i = 0; i < SFG_RAYCASTING_SUBSAMPLE; ++i)
{
SFG_setPixel(screenX,pixel->position.y,color);
screenX++;
}
}
RCL_Unit SFG_texturesAt(int16_t x, int16_t y)
@ -273,7 +280,7 @@ void SFG_init()
RCL_initCamera(&SFG_camera);
RCL_initRayConstraints(&SFG_rayConstraints);
SFG_camera.resolution.x = SFG_RESOLUTION_X;
SFG_camera.resolution.x = SFG_RESOLUTION_X / SFG_RAYCASTING_SUBSAMPLE;
SFG_camera.resolution.y = SFG_RESOLUTION_Y;
SFG_camera.height = RCL_UNITS_PER_SQUARE;
SFG_camera.position.x = RCL_UNITS_PER_SQUARE * 5;

View File

@ -5,10 +5,29 @@
#define SFG_RESOLUTION_X 1024
#define SFG_RESOLUTION_Y 768
/**
Whether shadows (fog) should be dithered, i.e. more smooth (needs a bit more
performance).
*/
#define SFG_DITHERED_SHADOW 1
/**
Maximum number of squares that will be traversed by any cast ray. Smaller
number is faster but can cause visual artifacts.
*/
#define SFG_RAYCASTING_MAX_STEPS 30
/**
Maximum number of hits any cast ray will register. Smaller number is faster
but can cause visual artifacts.
*/
#define SFG_RAYCASTING_MAX_HITS 10
/**
How many times rendering should be subsampled horizontally. Bigger number
can significantly improve performance (by casting fewer rays), but can look
a little worse.
*/
#define SFG_RAYCASTING_SUBSAMPLE 1
#endif // guard