mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 03:19:40 +00:00
override nif transparency settings (part 1)
This commit is contained in:
parent
2a4fcf42a3
commit
a727bcd4a4
7 changed files with 177 additions and 4 deletions
|
@ -227,6 +227,9 @@ endif (APPLE)
|
|||
configure_file(${OpenMW_SOURCE_DIR}/files/settings-default.cfg
|
||||
"${OpenMW_BINARY_DIR}/settings-default.cfg")
|
||||
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/transparency-overrides.cfg
|
||||
"${OpenMW_BINARY_DIR}/transparency-overrides.cfg")
|
||||
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local
|
||||
"${OpenMW_BINARY_DIR}/openmw.cfg")
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
|
||||
|
@ -308,6 +311,7 @@ if(DPKG_PROGRAM)
|
|||
|
||||
#Install global configuration files
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "../etc/openmw/" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <components/files/fixedpath.hpp>
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/nifoverrides/nifoverrides.hpp>
|
||||
|
||||
#include <components/nifbullet/bullet_nif_loader.hpp>
|
||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||
|
@ -349,6 +350,13 @@ void OMW::Engine::go()
|
|||
|
||||
mFpsLevel = settings.getInt("fps", "HUD");
|
||||
|
||||
// load nif overrides
|
||||
NifOverrides::Overrides nifOverrides;
|
||||
if (boost::filesystem::exists(mCfgMgr.getLocalPath().string() + "/transparency-overrides.cfg"))
|
||||
nifOverrides.loadTransparencyOverrides(mCfgMgr.getLocalPath().string() + "/transparency-overrides.cfg");
|
||||
else if (boost::filesystem::exists(mCfgMgr.getGlobalPath().string() + "/transparency-overrides.cfg"))
|
||||
nifOverrides.loadTransparencyOverrides(mCfgMgr.getGlobalPath().string() + "/transparency-overrides.cfg");
|
||||
|
||||
mOgre->configure(!boost::filesystem::is_regular_file(mCfgMgr.getOgreConfigPath()),
|
||||
mCfgMgr.getOgreConfigPath().string(),
|
||||
mCfgMgr.getLogPath().string(),
|
||||
|
|
|
@ -6,6 +6,10 @@ add_component_dir (settings
|
|||
settings
|
||||
)
|
||||
|
||||
add_component_dir (nifoverrides
|
||||
nifoverrides
|
||||
)
|
||||
|
||||
add_component_dir (bsa
|
||||
bsa_archive bsa_file
|
||||
)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "ogre_nif_loader.hpp"
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/nifoverrides/nifoverrides.hpp>
|
||||
|
||||
typedef unsigned char ubyte;
|
||||
|
||||
|
@ -282,11 +283,21 @@ void NIFLoader::createMaterial(const String &name,
|
|||
// other values. 237 basically means normal transparencly.
|
||||
if (alphaFlags == 237)
|
||||
{
|
||||
// Enable transparency
|
||||
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
|
||||
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName);
|
||||
if (result.first)
|
||||
{
|
||||
pass->setAlphaRejectFunction(CMPF_GREATER_EQUAL);
|
||||
pass->setAlphaRejectValue(result.second);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enable transparency
|
||||
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
|
||||
|
||||
//pass->setDepthCheckEnabled(false);
|
||||
pass->setDepthWriteEnabled(false);
|
||||
//pass->setDepthCheckEnabled(false);
|
||||
pass->setDepthWriteEnabled(false);
|
||||
std::cout << "alpha 237; material: " << name << " texName: " << texName << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
warn("Unhandled alpha setting for texture " + texName);
|
||||
|
|
37
components/nifoverrides/nifoverrides.cpp
Normal file
37
components/nifoverrides/nifoverrides.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "nifoverrides.hpp"
|
||||
|
||||
#include <OgreStringConverter.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
using namespace NifOverrides;
|
||||
|
||||
Ogre::ConfigFile Overrides::mTransparencyOverrides = Ogre::ConfigFile();
|
||||
|
||||
void Overrides::loadTransparencyOverrides (const std::string& file)
|
||||
{
|
||||
mTransparencyOverrides.load(file);
|
||||
}
|
||||
|
||||
TransparencyResult Overrides::getTransparencyOverride(const std::string& texture)
|
||||
{
|
||||
TransparencyResult result;
|
||||
result.first = false;
|
||||
|
||||
std::string tex = texture;
|
||||
boost::to_lower(tex);
|
||||
|
||||
Ogre::ConfigFile::SectionIterator seci = mTransparencyOverrides.getSectionIterator();
|
||||
while (seci.hasMoreElements())
|
||||
{
|
||||
Ogre::String sectionName = seci.peekNextKey();
|
||||
if (sectionName == tex)
|
||||
{
|
||||
result.first = true;
|
||||
result.second = Ogre::StringConverter::parseInt(mTransparencyOverrides.getSetting("alphaRejectValue", sectionName));
|
||||
break;
|
||||
}
|
||||
seci.getNext();
|
||||
}
|
||||
return result;
|
||||
}
|
23
components/nifoverrides/nifoverrides.hpp
Normal file
23
components/nifoverrides/nifoverrides.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef COMPONENTS_NIFOVERRIDES_H
|
||||
#define COMPONENTS_NIFOVERRIDES_H
|
||||
|
||||
#include <OgreConfigFile.h>
|
||||
|
||||
namespace NifOverrides
|
||||
{
|
||||
|
||||
typedef std::pair<bool, int> TransparencyResult;
|
||||
|
||||
/// \brief provide overrides for some model / texture properties that bethesda has chosen poorly
|
||||
class Overrides
|
||||
{
|
||||
public:
|
||||
static Ogre::ConfigFile mTransparencyOverrides;
|
||||
void loadTransparencyOverrides (const std::string& file);
|
||||
|
||||
static TransparencyResult getTransparencyOverride(const std::string& texture);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
86
files/transparency-overrides.cfg
Normal file
86
files/transparency-overrides.cfg
Normal file
|
@ -0,0 +1,86 @@
|
|||
# Bethesda has used wrong transparency settings for many textures
|
||||
# (who would have guessed)
|
||||
# This is very unfortunate because objects with real transparency:
|
||||
# - cannot cast shadows
|
||||
# - cannot receive advanced framebuffer effects like depth of field or ambient occlusion
|
||||
# - cannot cover lens flare effects (the lens flare will just shine through)
|
||||
|
||||
# This file lists textures that should be using alpha rejection instead of transparency
|
||||
# basically these are textures that are not translucent (i.e. at one spot on the texture, either transparent or opaque)
|
||||
|
||||
# Note: all the texture names here have to be lowercase
|
||||
|
||||
[textures\tx_flag_imp_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_ivy_02.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_ivy_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_sail.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_saltrice_04.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_black_lichen_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_leaves_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_leaves_02.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_leaves_03.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_ai_heather_01.dds]
|
||||
alphaRejectValue = 96
|
||||
|
||||
[textures\tx_goldkanet_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_goldkanet_02.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_plant_tails00.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_vine_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_comberry_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_willow_flower_02.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_cork_bulb_02.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_v_b_telvanni_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_green_lichen_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_roobrush_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_bittergreen_02.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_chokeweed_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_de_banner_book_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_bannerd_w_a_shop_01.dds]
|
||||
alphaRejectValue = 128
|
||||
|
||||
[textures\tx_banner_temple_02.dds]
|
||||
alphaRejectValue = 128
|
Loading…
Reference in a new issue