Add fog
This commit is contained in:
parent
cfe2f711de
commit
71a034d74c
3 changed files with 34 additions and 12 deletions
30
renderer.h
30
renderer.h
|
@ -36,6 +36,7 @@
|
|||
#define LCR_ANIMATE_CAR (LCR_SETTING_CAR_ANIMATION_SUBDIVIDE != 0)
|
||||
|
||||
#if LCR_SETTING_POTATO_GRAPHICS
|
||||
#undef S3L_PERSPECTIVE_CORRECTION
|
||||
#define S3L_PERSPECTIVE_CORRECTION 0
|
||||
#define S3L_NEAR_CROSS_STRATEGY 1
|
||||
#define S3L_FLAT 1
|
||||
|
@ -84,6 +85,9 @@ struct
|
|||
*/
|
||||
S3L_Model3D models[LCR_RENDERER_MODEL_COUNT];
|
||||
|
||||
uint_fast16_t pixelColor; /**< Holds pixel color for _LCR_pixelFunc3D. This
|
||||
is needed is texture subsampling is on. */
|
||||
|
||||
uint32_t frame;
|
||||
uint8_t loadedChunks[8]; ///< Numbers of loaded map chunks.
|
||||
|
||||
|
@ -278,9 +282,6 @@ int _LCR_rendererQuadLooksConvex(S3L_Unit quad[8])
|
|||
return 1;
|
||||
}
|
||||
|
||||
uint16_t _LCR_pixelColor = 0; /**< Holds pixel color for _LCR_pixelFunc3D. This
|
||||
is needed is texture subsampling is on. */
|
||||
|
||||
/**
|
||||
Used as a fragment shader by small3dlib. This function will be called for
|
||||
every rasterized 3D pixel, we use it write actual pixels to the screen with
|
||||
|
@ -362,6 +363,7 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
|
|||
}
|
||||
else if (pixel->modelIndex == 8)
|
||||
{
|
||||
|
||||
// car model
|
||||
LCR_loadImage(LCR_IMAGE_CAR);
|
||||
|
||||
|
@ -464,6 +466,11 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
|
|||
}
|
||||
}
|
||||
|
||||
#if LCR_SETTING_FOG
|
||||
if (pixel->depth > (S3L_MAX_DEPTH >> 18))
|
||||
LCR_imageChangeBrightness(0);
|
||||
#endif
|
||||
|
||||
// shift the UVs to the origin (prevent high values of UV coords)
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
|
@ -518,7 +525,7 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
|
|||
barycentric[1] = pixel->barycentric[1] / 8;
|
||||
barycentric[2] = pixel->barycentric[2] / 8;
|
||||
|
||||
_LCR_pixelColor = LCR_sampleImage(
|
||||
LCR_renderer.pixelColor = LCR_sampleImage(
|
||||
(barycentric[0] * LCR_renderer.triUVs[0] +
|
||||
barycentric[1] * LCR_renderer.triUVs[2] +
|
||||
barycentric[2] * LCR_renderer.triUVs[4])
|
||||
|
@ -535,7 +542,16 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
|
|||
LCR_renderer.texSubsampleCount--;
|
||||
#endif
|
||||
|
||||
LCR_gameDrawPixelXYUnsafe(pixel->x,pixel->y,_LCR_pixelColor);
|
||||
LCR_gameDrawPixelXYUnsafe(pixel->x,pixel->y,
|
||||
#if LCR_SETTING_FOG
|
||||
(((uint_fast16_t) 0) - (
|
||||
(pixel->depth < (S3L_MAX_DEPTH >> 20)) |
|
||||
((pixel->depth < (S3L_MAX_DEPTH >> 19)) &
|
||||
((pixel->x | pixel->y) % 2)) |
|
||||
((pixel->x ^ pixel->y) % 2))) &
|
||||
#endif
|
||||
LCR_renderer.pixelColor);
|
||||
|
||||
#endif // LCR_SETTING_POTATO_GRAPHICS
|
||||
}
|
||||
|
||||
|
@ -1210,8 +1226,6 @@ uint8_t LCR_rendererInit(void)
|
|||
LCR_renderer.ghostModel->transform.scale =
|
||||
LCR_renderer.carModel->transform.scale;
|
||||
|
||||
LCR_renderer.ghostModel->transform.translation.x -= LCR_GAME_UNIT / 4; // why is this here? TODO
|
||||
|
||||
#if LCR_ANIMATE_CAR
|
||||
for (int i = 0; i < LCR_CAR_VERTEX_COUNT * 3; ++i)
|
||||
LCR_renderer.animatedCarVerts[i] = LCR_carVertices[i];
|
||||
|
@ -1894,7 +1908,9 @@ void LCR_rendererDrawMenu(const char *tabName,const char **items,
|
|||
int stripHeight = (2 * LCR_EFFECTIVE_RESOLUTION_Y) / 7;
|
||||
int stripHeight2 = LCR_EFFECTIVE_RESOLUTION_Y / 9;
|
||||
int i = 0;
|
||||
#if !(LCR_SETTING_POTATO_GRAPHICS || LCR_SETTING_332_COLOR)
|
||||
uint16_t effect = LCR_renderer.frame >> 1;
|
||||
#endif
|
||||
|
||||
LCR_LOG2("drawing menu");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue