mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 21:40:42 +00:00
Removed problematic ModVertexAlpha method, now done in shader
This commit is contained in:
parent
7b1b0ec41c
commit
bf037b7d29
@ -203,48 +203,6 @@ unsigned int Moon::getPhaseInt() const
|
|||||||
return 0;
|
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, ¤tVertex );
|
|
||||||
|
|
||||||
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)
|
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
|
||||||
: mHour(0.0f)
|
: mHour(0.0f)
|
||||||
, mDay(0)
|
, mDay(0)
|
||||||
@ -357,7 +315,6 @@ void SkyManager::create()
|
|||||||
atmosphere_ent->setRenderQueueGroup(RQG_SkiesEarly);
|
atmosphere_ent->setRenderQueueGroup(RQG_SkiesEarly);
|
||||||
atmosphere_ent->setVisibilityFlags(RV_Sky);
|
atmosphere_ent->setVisibilityFlags(RV_Sky);
|
||||||
atmosphere_ent->getSubEntity (0)->setMaterialName ("openmw_atmosphere");
|
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->setRenderQueueGroup(RQG_SkiesEarly+5);
|
||||||
clouds_ent->getSubEntity(0)->setMaterialName ("openmw_clouds");
|
clouds_ent->getSubEntity(0)->setMaterialName ("openmw_clouds");
|
||||||
clouds_ent->setCastShadows(false);
|
clouds_ent->setCastShadows(false);
|
||||||
|
|
||||||
ModVertexAlpha(clouds_ent, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mCreated = true;
|
mCreated = true;
|
||||||
|
@ -218,8 +218,6 @@ namespace MWRender
|
|||||||
float mGlare; // target
|
float mGlare; // target
|
||||||
float mGlareFade; // actual
|
float mGlareFade; // actual
|
||||||
|
|
||||||
void ModVertexAlpha(Ogre::Entity* ent, unsigned int meshType);
|
|
||||||
|
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
bool mSunEnabled;
|
bool mSunEnabled;
|
||||||
bool mMasserEnabled;
|
bool mMasserEnabled;
|
||||||
|
7
extern/shiny/CMakeLists.txt
vendored
7
extern/shiny/CMakeLists.txt
vendored
@ -24,13 +24,6 @@ set(SOURCE_FILES
|
|||||||
Main/ShaderSet.cpp
|
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)
|
if (DEFINED SHINY_USE_WAVE_SYSTEM_INSTALL)
|
||||||
# use system install
|
# use system install
|
||||||
else()
|
else()
|
||||||
|
20
extern/shiny/Main/ShaderInstance.cpp
vendored
20
extern/shiny/Main/ShaderInstance.cpp
vendored
@ -363,12 +363,12 @@ namespace sh
|
|||||||
|
|
||||||
if (Factory::getInstance ().getShaderDebugOutputEnabled ())
|
if (Factory::getInstance ().getShaderDebugOutputEnabled ())
|
||||||
writeDebugFile(source, name + ".pre");
|
writeDebugFile(source, name + ".pre");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef SHINY_WRITE_SHADER_DEBUG
|
#ifdef SHINY_WRITE_SHADER_DEBUG
|
||||||
writeDebugFile(source, name + ".pre");
|
writeDebugFile(source, name + ".pre");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// why do we need our own preprocessor? there are several custom commands available in the shader files
|
// 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
|
// (for example for binding uniforms to properties or auto constants) - more below. it is important that these
|
||||||
@ -648,12 +648,12 @@ namespace sh
|
|||||||
|
|
||||||
if (Factory::getInstance ().getShaderDebugOutputEnabled ())
|
if (Factory::getInstance ().getShaderDebugOutputEnabled ())
|
||||||
writeDebugFile(source, name);
|
writeDebugFile(source, name);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef SHINY_WRITE_SHADER_DEBUG
|
#ifdef SHINY_WRITE_SHADER_DEBUG
|
||||||
writeDebugFile(source, name);
|
writeDebugFile(source, name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mProgram->getSupported())
|
if (!mProgram->getSupported())
|
||||||
{
|
{
|
||||||
|
@ -7,19 +7,18 @@
|
|||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||||
|
|
||||||
shColourInput(float4)
|
shOutput(float, alphaFade)
|
||||||
shOutput(float4, colourPassthrough)
|
|
||||||
|
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||||
colourPassthrough = colour;
|
alphaFade = shInputPosition.z < 150.0 ? 0.0 : 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shInput(float4, colourPassthrough)
|
shInput(float, alphaFade)
|
||||||
#if MRT
|
#if MRT
|
||||||
shDeclareMrtOutput(1)
|
shDeclareMrtOutput(1)
|
||||||
#endif
|
#endif
|
||||||
@ -27,7 +26,7 @@
|
|||||||
|
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
shOutputColour(0) = colourPassthrough * atmosphereColour;
|
shOutputColour(0) = atmosphereColour * float4(1,1,1,alphaFade);
|
||||||
|
|
||||||
#if MRT
|
#if MRT
|
||||||
shOutputColour(1) = float4(1,1,1,1);
|
shOutputColour(1) = float4(1,1,1,1);
|
||||||
|
@ -8,21 +8,20 @@
|
|||||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||||
shVertexInput(float2, uv0)
|
shVertexInput(float2, uv0)
|
||||||
shOutput(float2, UV)
|
shOutput(float2, UV)
|
||||||
shColourInput(float4)
|
shOutput(float, alphaFade)
|
||||||
shOutput(float4, colourPassthrough)
|
|
||||||
|
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
colourPassthrough = colour;
|
|
||||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||||
UV = uv0;
|
UV = uv0;
|
||||||
|
alphaFade = shInputPosition.z < 100.f ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shInput(float2, UV)
|
shInput(float2, UV)
|
||||||
shInput(float4, colourPassthrough)
|
shInput(float, alphaFade)
|
||||||
#if MRT
|
#if MRT
|
||||||
shDeclareMrtOutput(1)
|
shDeclareMrtOutput(1)
|
||||||
#endif
|
#endif
|
||||||
@ -42,7 +41,7 @@
|
|||||||
|
|
||||||
float4 albedo = shSample(diffuseMap1, scrolledUV) * (1-cloudBlendFactor) + shSample(diffuseMap2, scrolledUV) * cloudBlendFactor;
|
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
|
#if MRT
|
||||||
shOutputColour(1) = float4(1,1,1,1);
|
shOutputColour(1) = float4(1,1,1,1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user