Merge branch 'master' of git://github.com/zinnschlag/openmw into terrainfix

actorid
scrawl 12 years ago
commit 09180666b2

@ -203,48 +203,6 @@ unsigned int Moon::getPhaseInt() const
return 0;
}
void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
{
// Get the vertex colour buffer of this mesh
const Ogre::VertexElement* ves_diffuse = ent->getMesh()->getSubMesh(0)->vertexData->vertexDeclaration->findElementBySemantic( Ogre::VES_DIFFUSE );
HardwareVertexBufferSharedPtr colourBuffer = ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource());
// Lock
void* pData = colourBuffer->lock(HardwareBuffer::HBL_NORMAL);
// Iterate over all vertices
int vertex_size = colourBuffer->getVertexSize();
float * currentVertex = NULL;
for (unsigned int i=0; i<colourBuffer->getNumVertices(); ++i)
{
// Get a pointer to the vertex colour
ves_diffuse->baseVertexPointerToElement( pData, &currentVertex );
unsigned char alpha=0;
if (meshType == 0) alpha = i%2 ? 0 : 255; // this is a cylinder, so every second vertex belongs to the bottom-most row
else if (meshType == 1)
{
if (i>= 49 && i <= 64) alpha = 0; // bottom-most row
else if (i>= 33 && i <= 48) alpha = 64; // second bottom-most row
else alpha = 255;
}
// NB we would have to swap R and B depending on rendersystem specific VertexElementType, but doesn't matter since they are both 1
uint8 tmpR = static_cast<uint8>(255);
uint8 tmpG = static_cast<uint8>(255);
uint8 tmpB = static_cast<uint8>(255);
uint8 tmpA = static_cast<uint8>(alpha);
// Modify
*((uint32*)currentVertex) = tmpR | (tmpG << 8) | (tmpB << 16) | (tmpA << 24);
// Move to the next vertex
pData = static_cast<unsigned char *> (pData) + vertex_size;
}
// Unlock
ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock();
}
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
: mHour(0.0f)
, mDay(0)
@ -357,7 +315,6 @@ void SkyManager::create()
atmosphere_ent->setRenderQueueGroup(RQG_SkiesEarly);
atmosphere_ent->setVisibilityFlags(RV_Sky);
atmosphere_ent->getSubEntity (0)->setMaterialName ("openmw_atmosphere");
ModVertexAlpha(atmosphere_ent, 0);
}
@ -371,8 +328,6 @@ void SkyManager::create()
clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5);
clouds_ent->getSubEntity(0)->setMaterialName ("openmw_clouds");
clouds_ent->setCastShadows(false);
ModVertexAlpha(clouds_ent, 1);
}
mCreated = true;

@ -218,8 +218,6 @@ namespace MWRender
float mGlare; // target
float mGlareFade; // actual
void ModVertexAlpha(Ogre::Entity* ent, unsigned int meshType);
bool mEnabled;
bool mSunEnabled;
bool mMasserEnabled;

@ -24,13 +24,6 @@ set(SOURCE_FILES
Main/ShaderSet.cpp
)
# In Debug mode, write the shader sources to the current directory
if (DEFINED CMAKE_BUILD_TYPE)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DSHINY_WRITE_SHADER_DEBUG)
endif()
endif()
if (DEFINED SHINY_USE_WAVE_SYSTEM_INSTALL)
# use system install
else()

@ -191,15 +191,48 @@ namespace sh
&mGlobalSettings);
int lastModified = boost::filesystem::last_write_time (boost::filesystem::path(sourceFile));
mShadersLastModifiedNew[sourceFile] = lastModified;
if (mShadersLastModified.find(sourceFile) != mShadersLastModified.end()
&& mShadersLastModified[sourceFile] != lastModified)
{
newSet.markDirty ();
// delete any outdated shaders based on this shader set.
if ( boost::filesystem::exists(mPlatform->getCacheFolder())
&& boost::filesystem::is_directory(mPlatform->getCacheFolder()))
{
boost::filesystem::directory_iterator end_iter;
for( boost::filesystem::directory_iterator dir_iter(mPlatform->getCacheFolder()) ; dir_iter != end_iter ; ++dir_iter)
{
if (boost::filesystem::is_regular_file(dir_iter->status()) )
{
boost::filesystem::path file = dir_iter->path();
std::string pathname = file.filename().string();
// get first part of filename, e.g. main_fragment_546457654 -> main_fragment
// there is probably a better method for this...
std::vector<std::string> tokens;
boost::split(tokens, pathname, boost::is_any_of("_"));
tokens.erase(--tokens.end());
std::string shaderName;
for (std::vector<std::string>::const_iterator vector_iter = tokens.begin(); vector_iter != tokens.end();)
{
shaderName += *(vector_iter++);
if (vector_iter != tokens.end())
shaderName += "_";
}
if (shaderName == it->first)
{
boost::filesystem::remove(file);
std::cout << "Removing outdated file: " << file << std::endl;
}
}
}
}
anyShaderDirty = true;
}
mShadersLastModified[sourceFile] = lastModified;
mShaderSets.insert(std::make_pair(it->first, newSet));
}
}
@ -313,11 +346,11 @@ namespace sh
if (mReadSourceCache)
{
// save the last modified time of shader sources
// save the last modified time of shader sources (as of when they were loaded)
std::ofstream file;
file.open(std::string(mPlatform->getCacheFolder () + "/lastModified.txt").c_str());
for (LastModifiedMap::const_iterator it = mShadersLastModified.begin(); it != mShadersLastModified.end(); ++it)
for (LastModifiedMap::const_iterator it = mShadersLastModifiedNew.begin(); it != mShadersLastModifiedNew.end(); ++it)
{
file << it->first << "\n" << it->second << std::endl;
}

@ -185,6 +185,7 @@ namespace sh
ConfigurationMap mConfigurations;
LodConfigurationMap mLodConfigurations;
LastModifiedMap mShadersLastModified;
LastModifiedMap mShadersLastModifiedNew;
PropertySetGet mGlobalSettings;

@ -337,8 +337,7 @@ namespace sh
size_t pos;
bool readCache = Factory::getInstance ().getReadSourceCache () && boost::filesystem::exists(
Factory::getInstance ().getCacheFolder () + "/" + mName)
&& !mParent->isDirty ();
Factory::getInstance ().getCacheFolder () + "/" + mName);
bool writeCache = Factory::getInstance ().getWriteSourceCache ();
@ -363,12 +362,6 @@ namespace sh
if (Factory::getInstance ().getShaderDebugOutputEnabled ())
writeDebugFile(source, name + ".pre");
else
{
#ifdef SHINY_WRITE_SHADER_DEBUG
writeDebugFile(source, name + ".pre");
#endif
}
// why do we need our own preprocessor? there are several custom commands available in the shader files
// (for example for binding uniforms to properties or auto constants) - more below. it is important that these
@ -648,12 +641,6 @@ namespace sh
if (Factory::getInstance ().getShaderDebugOutputEnabled ())
writeDebugFile(source, name);
else
{
#ifdef SHINY_WRITE_SHADER_DEBUG
writeDebugFile(source, name);
#endif
}
if (!mProgram->getSupported())
{

@ -17,7 +17,6 @@ namespace sh
, mName(name)
, mCgProfile(cgProfile)
, mHlslProfile(hlslProfile)
, mIsDirty(false)
{
if (type == "vertex")
mType = GPT_Vertex;

@ -30,9 +30,6 @@ namespace sh
/// so it does not matter if you pass any extra properties that the shader does not care about.
ShaderInstance* getInstance (PropertySetGet* properties);
void markDirty() { mIsDirty = true; }
///< Signals that the cache is out of date, and thus should not be used this time
private:
PropertySetGet* getCurrentGlobalSettings() const;
std::string getBasePath() const;
@ -41,12 +38,8 @@ namespace sh
std::string getHlslProfile() const;
int getType() const;
bool isDirty() { return mIsDirty; }
friend class ShaderInstance;
bool mIsDirty;
private:
GpuProgramType mType;
std::string mSource;

@ -7,19 +7,18 @@
SH_BEGIN_PROGRAM
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
shColourInput(float4)
shOutput(float4, colourPassthrough)
shOutput(float, alphaFade)
SH_START_PROGRAM
{
shOutputPosition = shMatrixMult(wvp, shInputPosition);
colourPassthrough = colour;
alphaFade = shInputPosition.z < 150.0 ? 0.0 : 1.0;
}
#else
SH_BEGIN_PROGRAM
shInput(float4, colourPassthrough)
shInput(float, alphaFade)
#if MRT
shDeclareMrtOutput(1)
#endif
@ -27,7 +26,7 @@
SH_START_PROGRAM
{
shOutputColour(0) = colourPassthrough * atmosphereColour;
shOutputColour(0) = atmosphereColour * float4(1,1,1,alphaFade);
#if MRT
shOutputColour(1) = float4(1,1,1,1);

@ -8,21 +8,20 @@
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
shVertexInput(float2, uv0)
shOutput(float2, UV)
shColourInput(float4)
shOutput(float4, colourPassthrough)
shOutput(float, alphaFade)
SH_START_PROGRAM
{
colourPassthrough = colour;
shOutputPosition = shMatrixMult(wvp, shInputPosition);
UV = uv0;
alphaFade = (shInputPosition.z <= 200.f) ? ((shInputPosition.z <= 100.f) ? 0.0 : 0.25) : 1.0;
}
#else
SH_BEGIN_PROGRAM
shInput(float2, UV)
shInput(float4, colourPassthrough)
shInput(float, alphaFade)
#if MRT
shDeclareMrtOutput(1)
#endif
@ -42,7 +41,7 @@
float4 albedo = shSample(diffuseMap1, scrolledUV) * (1-cloudBlendFactor) + shSample(diffuseMap2, scrolledUV) * cloudBlendFactor;
shOutputColour(0) = colourPassthrough * float4(cloudColour, 1) * albedo * float4(1,1,1, cloudOpacity);
shOutputColour(0) = float4(cloudColour, 1) * albedo * float4(1,1,1, cloudOpacity * alphaFade);
#if MRT
shOutputColour(1) = float4(1,1,1,1);

Loading…
Cancel
Save