diff --git a/source/graphics/Model.cpp b/source/graphics/Model.cpp index 56b9cd9554..c2ba6ddc20 100644 --- a/source/graphics/Model.cpp +++ b/source/graphics/Model.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -236,12 +236,10 @@ void CModel::ValidatePosition() // For CPU skinning, we precompute as much as possible so that the only // per-vertex work is a single matrix*vec multiplication. // For GPU skinning, we try to minimise CPU work by doing most computation - // in the vertex shader instead. - // Using g_RenderingOptions to detect CPU vs GPU is a bit hacky, - // and this doesn't allow the setting to change at runtime, but there isn't - // an obvious cleaner way to determine what data needs to be computed. - bool worldSpaceBoneMatrices = !g_RenderingOptions.GetGPUSkinning(); - bool computeBlendMatrices = !g_RenderingOptions.GetGPUSkinning(); + // in the compute shader instead. + const bool isGPUSkinningEnabled{g_RenderingOptions.GetGPUSkinning()}; + const bool worldSpaceBoneMatrices{!isGPUSkinningEnabled}; + const bool computeBlendMatrices{!isGPUSkinningEnabled}; if (m_BoneMatrices && worldSpaceBoneMatrices) { diff --git a/source/renderer/ModelRenderer.cpp b/source/renderer/ModelRenderer.cpp index 03906065bd..b1e2ebe15b 100644 --- a/source/renderer/ModelRenderer.cpp +++ b/source/renderer/ModelRenderer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -219,6 +219,7 @@ void ShaderModelRenderer::Submit(int cullGroup, CModel* model) const void* key = m->vertexRenderer.get(); if (!rdata || rdata->GetKey() != key) { + model->InvalidatePosition(); rdata = m->vertexRenderer->CreateModelData(key, model); model->SetRenderData(rdata); model->SetDirty(~0u); diff --git a/source/renderer/RenderingOptions.cpp b/source/renderer/RenderingOptions.cpp index d0e55252b5..ddcee98211 100644 --- a/source/renderer/RenderingOptions.cpp +++ b/source/renderer/RenderingOptions.cpp @@ -248,6 +248,9 @@ void CRenderingOptions::ReadConfigAndSetupHooks() m_GPUSkinning = true; else LOGMESSAGE("GPU skinning isn't supported on the current hardware."); + + if (CRenderer::IsInitialised()) + g_Renderer.MakeShadersDirty(); }); m_ConfigHooks->Setup("renderactors", m_RenderActors);