diff --git a/GL/lighting.c b/GL/lighting.c index 2ae13d9..b6dfe42 100644 --- a/GL/lighting.c +++ b/GL/lighting.c @@ -340,9 +340,9 @@ GL_FORCE_INLINE void _glLightVertexDirectional(uint8_t* final, int8_t lid, float F += (LdotN * MATERIAL.diffuse[X] * LIGHTS[lid].diffuse[X]); \ if(MATERIAL.exponent) \ F += FPOW(FI * NdotH, MATERIAL.exponent) * MATERIAL.specular[X] * LIGHTS[lid].specular[X]; \ - FO = (uint8_t) (F * 255.0f); \ + FO = (uint8_t) (_MIN(F * 255.0f, 255.0f)); \ \ - final[T] += _MIN(FO, final[T] - FO); \ + final[T] += _MIN(FO, 255 - final[T]); \ _PROCESS_COMPONENT(R8IDX, 0); _PROCESS_COMPONENT(G8IDX, 1); @@ -361,9 +361,9 @@ GL_FORCE_INLINE void _glLightVertexPoint(uint8_t* final, int8_t lid, float LdotN F += (LdotN * MATERIAL.diffuse[X] * LIGHTS[lid].diffuse[X]); \ if(MATERIAL.exponent) \ F += FPOW(FI * NdotH, MATERIAL.exponent) * MATERIAL.specular[X] * LIGHTS[lid].specular[X]; \ - FO = (uint8_t) (F * att * 255.0f); \ + FO = (uint8_t) (_MIN(F * att * 255.0f, 255.0f)); \ \ - final[T] += _MIN(FO, final[T] - FO); \ + final[T] += _MIN(FO, 255 - final[T]); \ _PROCESS_COMPONENT(R8IDX, 0); _PROCESS_COMPONENT(G8IDX, 1);