From 6b0f5e86fb16c0b1e536cbab37b8af6177e2518d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Tue, 25 Sep 2018 10:04:16 +0200 Subject: [PATCH] Tune the parameters --- demo2.cpp | 15 ++++++++------- general.hpp | 10 ++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/demo2.cpp b/demo2.cpp index 552415f..3a1354b 100644 --- a/demo2.cpp +++ b/demo2.cpp @@ -22,9 +22,8 @@ //#define RENDER_COMPLEX /* ^ Turns on rendering using a more precise but slower algorithm. This can - be seen at less shaky head bobbing when moving. However the latter - algorithm doesn't support some features (rooling doors, floor textures, - ...). */ + be seen at less shaky head bobbing when moving. However it doesn't + support many other features, so the result actually looks worse. */ //#define NO_TEXTURES /* ^ Turns off textures and only uses colors, which increases FPS. */ @@ -927,7 +926,7 @@ int16_t intensity = 0; if (pixel->isFloor) { if (pixel->texCoords.y > 3 * RCL_UNITS_PER_SQUARE) // leave astrip of untextured floor - color = pixel->depth > RCL_UNITS_PER_SQUARE * 5 ? + color = pixel->depth > (RCL_UNITS_PER_SQUARE * 6 + RCL_UNITS_PER_SQUARE / 2) ? textureAverageColors[1] : sampleImage(textures[1],pixel->texCoords.x / FLOOR_TEXTURE_SCALE,pixel->texCoords.y / FLOOR_TEXTURE_SCALE); else @@ -953,9 +952,9 @@ int16_t intensity = 0; #ifndef NO_MIRROR intensity = pixel->isFloor ? - -1 * (pixel->depth - mirror * 128) / RCL_UNITS_PER_SQUARE : 0; + 2 - (pixel->depth - mirror * 128) / RCL_UNITS_PER_SQUARE : 0; #else - intensity = -1 * pixel->depth / (RCL_UNITS_PER_SQUARE * 2); + intensity = 2 - pixel->depth / (RCL_UNITS_PER_SQUARE * 2); #endif color = addIntensity(color,intensity); @@ -1065,7 +1064,9 @@ int main() cFloor = rgbToIndex(3,3,2); cCeiling = rgbToIndex(3,2,0); - player.setPositionSquare(6,5); + player.setPositionSquare(9,1); +//player.mCamera.position.y -= RCL_UNITS_PER_SQUARE / 2; +//player.mCamera.direction = -50; player.mCamera.height = RCL_CAMERA_COLL_HEIGHT_BELOW; player.mCamera.resolution.y = RESOLUTION_Y; diff --git a/general.hpp b/general.hpp index a5502a3..62bbeb8 100644 --- a/general.hpp +++ b/general.hpp @@ -174,6 +174,16 @@ inline uint8_t addRGB(uint8_t color, int16_t red, int16_t green, int16_t blue) return rgbToIndex(r,g,b); } +/** + Inits a color gradient from darkest (0, -7 intensity) to brightest + (14, +7 intensity). Index 7 will have the base color. +*/ +void initGradient(unsigned char dest[15], unsigned char baseColor) +{ + for (int8_t i = 0; i < 15; ++i) + dest[i] = addIntensity(baseColor, i - 7); +} + /** Samples an image by normalized coordinates - each coordinate is in range 0 to RCL_UNITS_PER_SQUARE (from raycastlib).