From c4e7364802c07e06ee35dc4cd0526e9e3bcc0413 Mon Sep 17 00:00:00 2001 From: Vladislav Belov Date: Thu, 6 Aug 2026 11:32:02 +0200 Subject: [PATCH] Removes unused BuildColor4ub from ModelRenderer We don't need to calculate shading on CPU since we always use shaders. Refs: a9c27b412b4cd725d59364b14451044c9395e841 --- source/graphics/LightEnv.h | 19 ------------------- source/renderer/ModelRenderer.cpp | 23 ----------------------- source/renderer/ModelRenderer.h | 16 ---------------- 3 files changed, 58 deletions(-) diff --git a/source/graphics/LightEnv.h b/source/graphics/LightEnv.h index 2d01eaceff..692c2c2ae8 100644 --- a/source/graphics/LightEnv.h +++ b/source/graphics/LightEnv.h @@ -53,25 +53,6 @@ public: void SetElevation(float f); void SetRotation(float f); - /** - * Calculate brightness of a point of a unit with the given normal vector, - * for rendering with CPU lighting. - * The resulting color contains both ambient and diffuse light. - * To cope with sun overbrightness, the color is scaled by 0.5. - * - * @param normal normal vector (must have length 1) - */ - RGBColor EvaluateUnitScaled(const CVector3D& normal) const - { - float dot = -normal.Dot(m_SunDir); - - RGBColor color = m_AmbientColor; - if (dot > 0) - color += m_SunColor * dot; - - return color * 0.5f; - } - // Comparison operators bool operator==(const CLightEnv& o) const { diff --git a/source/renderer/ModelRenderer.cpp b/source/renderer/ModelRenderer.cpp index a0a89aec28..42a381b446 100644 --- a/source/renderer/ModelRenderer.cpp +++ b/source/renderer/ModelRenderer.cpp @@ -156,29 +156,6 @@ void ModelRenderer::BuildPositionAndNormals( } } -// static -void ModelRenderer::BuildColor4ub( - CModel* model, - const VertexArrayIterator& Normal, - const VertexArrayIterator& Color) -{ - PROFILE("lighting vertices"); - - CModelDefPtr mdef = model->GetModelDef(); - size_t numVertices = mdef->GetNumVertices(); - const CLightEnv& lightEnv = g_Renderer.GetSceneRenderer().GetLightEnv(); - CColor shadingColor = model->GetShadingColor(); - - for (size_t j = 0; j < numVertices; ++j) - { - RGBColor tempcolor = lightEnv.EvaluateUnitScaled(Normal[j]); - tempcolor.X *= shadingColor.r; - tempcolor.Y *= shadingColor.g; - tempcolor.Z *= shadingColor.b; - Color[j] = ConvertRGBColorTo4ub(tempcolor); - } -} - // static void ModelRenderer::GenTangents(const CModelDefPtr& mdef, std::vector& newVertices, bool gpuSkinning) { diff --git a/source/renderer/ModelRenderer.h b/source/renderer/ModelRenderer.h index b0c944a2dd..3eb7b3b629 100644 --- a/source/renderer/ModelRenderer.h +++ b/source/renderer/ModelRenderer.h @@ -141,22 +141,6 @@ public: const VertexArrayIterator& Position, const VertexArrayIterator& Normal); - /** - * BuildColor4ub: Build lighting colors for the given model, - * based on previously calculated world space normals. - * - * @param model The model that is to be lit. - * @param Normal Array of the model's normal vectors, animated and - * transformed into world space. - * @param Color Points to the array that will receive the lit vertex color. - * The array behind the iterator must large enough to hold - * model->GetModelDef()->GetNumVertices() vertices. - */ - static void BuildColor4ub( - CModel* model, - const VertexArrayIterator& Normal, - const VertexArrayIterator& Color); - /** * BuildUV: Copy UV coordinates into the given vertex array. *