mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-06 19:01:21 +03:00
Better fog
This commit is contained in:
parent
11bced737f
commit
3bf18c601c
27 changed files with 268 additions and 95 deletions
|
@ -182,7 +182,7 @@ float omw_GetPointLightRadius(int index)
|
|||
{"@ubo", mUBO ? "1" : "0"},
|
||||
{"@normals", technique.getNormals() ? "1" : "0"},
|
||||
{"@reverseZ", SceneUtil::AutoDepth::isReversed() ? "1" : "0"},
|
||||
{"@radialFog", Settings::Manager::getBool("radial fog", "Shaders") ? "1" : "0"},
|
||||
{"@radialFog", Settings::Manager::getBool("radial fog", "Fog") ? "1" : "0"},
|
||||
{"@hdr", technique.getHDR() ? "1" : "0"},
|
||||
{"@in", mLegacyGLSL ? "varying" : "in"},
|
||||
{"@out", mLegacyGLSL ? "varying" : "out"},
|
||||
|
|
|
@ -84,9 +84,6 @@ namespace SceneUtil
|
|||
|
||||
stateset->setRenderBinDetails(renderBin, "RenderBin");
|
||||
|
||||
// Let the shader know we're dealing with simple water here.
|
||||
stateset->addUniform(new osg::Uniform("simpleWater", true));
|
||||
|
||||
return stateset;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/misc/stringops.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
namespace Shader
|
||||
{
|
||||
|
@ -509,4 +510,22 @@ namespace Shader
|
|||
program->addShader(linkedShader);
|
||||
}
|
||||
|
||||
int ShaderManager::reserveGlobalTextureUnits(int count)
|
||||
{
|
||||
{
|
||||
// Texture units from `8 - numberOfShadowMaps` to `8` are used for shadows, so we skip them here.
|
||||
// TODO: Maybe instead of fixed texture units use `reserveGlobalTextureUnits` for shadows as well.
|
||||
static const int numberOfShadowMaps = Settings::Manager::getBool("enable shadows", "Shadows") ?
|
||||
std::clamp(Settings::Manager::getInt("number of shadow maps", "Shadows"), 1, 8) :
|
||||
0;
|
||||
if (getAvailableTextureUnits() >= 8 && getAvailableTextureUnits() - count < 8)
|
||||
mReservedTextureUnits = mMaxTextureUnits - (8 - numberOfShadowMaps);
|
||||
}
|
||||
|
||||
if (getAvailableTextureUnits() < count + 1)
|
||||
throw std::runtime_error("Can't reserve texture unit; no available units");
|
||||
mReservedTextureUnits += count;
|
||||
return mMaxTextureUnits - mReservedTextureUnits;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,6 +54,12 @@ namespace Shader
|
|||
|
||||
bool createSourceFromTemplate(std::string& source, std::vector<std::string>& linkedShaderTemplateNames, const std::string& templateName, const ShaderManager::DefineMap& defines);
|
||||
|
||||
void setMaxTextureUnits(int maxTextureUnits) { mMaxTextureUnits = maxTextureUnits; }
|
||||
int getMaxTextureUnits() const { return mMaxTextureUnits; }
|
||||
int getAvailableTextureUnits() const { return mMaxTextureUnits - mReservedTextureUnits; }
|
||||
|
||||
int reserveGlobalTextureUnits(int count);
|
||||
|
||||
private:
|
||||
void getLinkedShaders(osg::ref_ptr<osg::Shader> shader, const std::vector<std::string>& linkedShaderNames, const DefineMap& defines);
|
||||
void addLinkedShaders(osg::ref_ptr<osg::Shader> shader, osg::ref_ptr<osg::Program> program);
|
||||
|
@ -80,6 +86,9 @@ namespace Shader
|
|||
std::mutex mMutex;
|
||||
|
||||
osg::ref_ptr<const osg::Program> mProgramTemplate;
|
||||
|
||||
int mMaxTextureUnits = 0;
|
||||
int mReservedTextureUnits = 0;
|
||||
};
|
||||
|
||||
bool parseForeachDirective(std::string& source, const std::string& templateName, size_t foundPos);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue