1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Merge remote-tracking branch 'upstream/master' into Visuals-Vol-2

This commit is contained in:
Gefüllte Taubenbrust 2024-10-11 20:44:12 +02:00
commit b6c099073f
183 changed files with 3919 additions and 1642 deletions

View file

@ -322,6 +322,9 @@ public:
private:
// Are shaders even enabled?
bool m_enabled;
// The id of the thread that is allowed to use irrlicht directly
std::thread::id m_main_thread;
@ -360,6 +363,12 @@ ShaderSource::ShaderSource()
// Add a dummy ShaderInfo as the first index, named ""
m_shaderinfo_cache.emplace_back();
m_enabled = g_settings->getBool("enable_shaders");
if (!m_enabled) {
warningstream << "You are running " PROJECT_NAME_C " with shaders disabled, "
"this is not a recommended configuration." << std::endl;
}
// Add main global constant setter
addShaderConstantSetterFactory(new MainShaderConstantSetterFactory());
}
@ -368,9 +377,11 @@ ShaderSource::~ShaderSource()
{
MutexAutoLock lock(m_shaderinfo_cache_mutex);
if (!m_enabled)
return;
// Delete materials
video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()->
getGPUProgrammingServices();
auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
for (ShaderInfo &i : m_shaderinfo_cache) {
if (!i.name.empty())
gpu->deleteShaderMaterial(i.material);
@ -499,9 +510,11 @@ void ShaderSource::rebuildShaders()
{
MutexAutoLock lock(m_shaderinfo_cache_mutex);
if (!m_enabled)
return;
// Delete materials
video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()->
getGPUProgrammingServices();
auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
for (ShaderInfo &i : m_shaderinfo_cache) {
if (!i.name.empty()) {
gpu->deleteShaderMaterial(i.material);
@ -548,12 +561,11 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
}
shaderinfo.material = shaderinfo.base_material;
bool enable_shaders = g_settings->getBool("enable_shaders");
if (!enable_shaders)
if (!m_enabled)
return shaderinfo;
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices();
auto *gpu = driver->getGPUProgrammingServices();
if (!driver->queryFeature(video::EVDF_ARB_GLSL) || !gpu) {
throw ShaderException(gettext("Shaders are enabled but GLSL is not "
"supported by the driver."));
@ -561,7 +573,7 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
// Create shaders header
bool fully_programmable = driver->getDriverType() == video::EDT_OGLES2 || driver->getDriverType() == video::EDT_OPENGL3;
std::stringstream shaders_header;
std::ostringstream shaders_header;
shaders_header
<< std::noboolalpha
<< std::showpoint // for GLSL ES
@ -588,10 +600,14 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
attribute mediump vec4 inVertexTangent;
attribute mediump vec4 inVertexBinormal;
)";
// Our vertex color has components reversed compared to what OpenGL
// normally expects, so we need to take that into account.
vertex_header += "#define inVertexColor (inVertexColor.bgra)\n";
fragment_header = R"(
precision mediump float;
)";
} else {
/* legacy OpenGL driver */
shaders_header << R"(
#version 120
#define lowp