I am working on a raycasting engine in C, similar to the one used in classic games like Wolfenstein 3D. I have implemented basic texture mapping, but the rendered walls appear very pixelated. I would like to reduce this pixelation to achieve smoother visuals.
Here is the relevant part of my code that handles texture mapping: (TILE_SIZE is 32)
int texelX;
if (ray[i].wasHitVertical)
texelX = (int)ray[i].intersection.y % TILE_SIZE;
else
texelX = (int)ray[i].intersection.x % TILE_SIZE;
// Scale texelX to the texture width
texelX = (texelX * texture.width) / TILE_SIZE;
for (int y = wallTop; y < wallBottom; y++)
{
int distanceFromTop = y + (wallStripHeight / 2) - (HEIGHT / 2);
int texelY = distanceFromTop * ((double)texture.height / wallStripHeight);
// Ensure texelY stays within the texture height bounds
texelY = texelY % texture.height;
int color = get_texture_color(texelX, texelY, texture);
my_mlx_pixel_put(&mlx->img, i, y, color);
}
The rendered walls appear pixelated, and I would like to reduce this pixelation to achieve smoother visuals.
NOTES:
I am only allowed to use the minilibX library for graphics, and also rendering xpm textures.