diff --git a/src/render/software/Rasterizer.cpp b/src/render/software/Rasterizer.cpp index f54a8c6..e2b48b4 100644 --- a/src/render/software/Rasterizer.cpp +++ b/src/render/software/Rasterizer.cpp @@ -31,13 +31,15 @@ struct paysages::software::RenderScanlines int right; }; -Rasterizer::Rasterizer(SoftwareRenderer* renderer, int client_id): +Rasterizer::Rasterizer(SoftwareRenderer* renderer, int client_id, const Color &color): renderer(renderer), client_id(client_id) { + this->color = new Color(color); } Rasterizer::~Rasterizer() { + delete color; } void Rasterizer::pushProjectedTriangle(CanvasPortion *canvas, const Vector3 &pixel1, const Vector3 &pixel2, const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2, const Vector3 &location3) @@ -329,7 +331,12 @@ void Rasterizer::renderScanLines(CanvasPortion *canvas, RenderScanlines* scanlin scanInterpolate(renderer->render_camera, &down, &diff, fy / dy, ¤t); CanvasFragment fragment(current.pixel.z, Vector3(current.location.x, current.location.y, current.location.z), current.client); - fragment.setColor((cury == starty || cury == endy) ? COLOR_GREY : COLOR_WHITE); + + Color frag_color = *color; + if (cury == starty || cury == endy) + frag_color.mask(Color(0.0, 0.0, 0.0, 0.3)); + fragment.setColor(frag_color); + canvas->pushFragment(current.x, current.y, fragment); } } diff --git a/src/render/software/Rasterizer.h b/src/render/software/Rasterizer.h index 1bb410c..4e237f1 100644 --- a/src/render/software/Rasterizer.h +++ b/src/render/software/Rasterizer.h @@ -15,7 +15,7 @@ typedef struct RenderScanlines RenderScanlines; class SOFTWARESHARED_EXPORT Rasterizer { public: - Rasterizer(SoftwareRenderer *renderer, int client_id); + Rasterizer(SoftwareRenderer *renderer, int client_id, const Color &color); virtual ~Rasterizer(); inline SoftwareRenderer *getRenderer() const {return renderer;} @@ -30,6 +30,7 @@ protected: void pushDisplacedTriangle(CanvasPortion *canvas, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &ov1, const Vector3 &ov2, const Vector3 &ov3); void pushDisplacedQuad(CanvasPortion *canvas, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &v4, const Vector3 &ov1, const Vector3 &ov2, const Vector3 &ov3, const Vector3 &ov4); + Color* color; SoftwareRenderer *renderer; int client_id; diff --git a/src/render/software/SkyRasterizer.cpp b/src/render/software/SkyRasterizer.cpp index 4bb6719..5bb9ff0 100644 --- a/src/render/software/SkyRasterizer.cpp +++ b/src/render/software/SkyRasterizer.cpp @@ -11,7 +11,7 @@ #define SPHERE_SIZE 20000.0 SkyRasterizer::SkyRasterizer(SoftwareRenderer* renderer, int client_id): - Rasterizer(renderer, client_id) + Rasterizer(renderer, client_id, Color(0.3, 0.7, 1.0)) { } diff --git a/src/render/software/TerrainRasterizer.cpp b/src/render/software/TerrainRasterizer.cpp index 0aa386c..a723137 100644 --- a/src/render/software/TerrainRasterizer.cpp +++ b/src/render/software/TerrainRasterizer.cpp @@ -11,7 +11,7 @@ #include "CanvasPortion.h" TerrainRasterizer::TerrainRasterizer(SoftwareRenderer* renderer, int client_id): - Rasterizer(renderer, client_id) + Rasterizer(renderer, client_id, Color(0.5, 0.3, 0.3)) { } diff --git a/src/render/software/WaterRasterizer.cpp b/src/render/software/WaterRasterizer.cpp index 9af4ef4..6f99ac4 100644 --- a/src/render/software/WaterRasterizer.cpp +++ b/src/render/software/WaterRasterizer.cpp @@ -5,7 +5,7 @@ #include "ParallelQueue.h" WaterRasterizer::WaterRasterizer(SoftwareRenderer* renderer, int client_id): - Rasterizer(renderer, client_id) + Rasterizer(renderer, client_id, Color(0.1, 0.3, 0.6)) { }