mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
Merge pull request #2278 from Capostrophic/blendmap
Remove unused and unfinished blendmap packing feature
This commit is contained in:
commit
115f12823a
4 changed files with 14 additions and 30 deletions
|
@ -375,8 +375,7 @@ namespace ESMTerrain
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Storage::getBlendmaps(float chunkSize, const osg::Vec2f &chunkCenter,
|
void Storage::getBlendmaps(float chunkSize, const osg::Vec2f &chunkCenter, ImageVector &blendmaps, std::vector<Terrain::LayerInfo> &layerList)
|
||||||
bool pack, ImageVector &blendmaps, std::vector<Terrain::LayerInfo> &layerList)
|
|
||||||
{
|
{
|
||||||
osg::Vec2f origin = chunkCenter - osg::Vec2f(chunkSize/2.f, chunkSize/2.f);
|
osg::Vec2f origin = chunkCenter - osg::Vec2f(chunkSize/2.f, chunkSize/2.f);
|
||||||
int cellX = static_cast<int>(std::floor(origin.x()));
|
int cellX = static_cast<int>(std::floor(origin.x()));
|
||||||
|
@ -416,11 +415,8 @@ namespace ESMTerrain
|
||||||
layerList.push_back(getLayerInfo(getTextureName(*it)));
|
layerList.push_back(getLayerInfo(getTextureName(*it)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int numTextures = textureIndices.size();
|
// size-1 since the base layer doesn't need blending
|
||||||
// numTextures-1 since the base layer doesn't need blending
|
int numBlendmaps = textureIndices.size() - 1;
|
||||||
int numBlendmaps = pack ? static_cast<int>(std::ceil((numTextures - 1) / 4.f)) : (numTextures - 1);
|
|
||||||
|
|
||||||
int channels = pack ? 4 : 1;
|
|
||||||
|
|
||||||
// Second iteration - create and fill in the blend maps
|
// Second iteration - create and fill in the blend maps
|
||||||
const int blendmapSize = (realTextureSize-1) * chunkSize + 1;
|
const int blendmapSize = (realTextureSize-1) * chunkSize + 1;
|
||||||
|
@ -430,10 +426,8 @@ namespace ESMTerrain
|
||||||
|
|
||||||
for (int i=0; i<numBlendmaps; ++i)
|
for (int i=0; i<numBlendmaps; ++i)
|
||||||
{
|
{
|
||||||
GLenum format = pack ? GL_RGBA : GL_ALPHA;
|
|
||||||
|
|
||||||
osg::ref_ptr<osg::Image> image (new osg::Image);
|
osg::ref_ptr<osg::Image> image (new osg::Image);
|
||||||
image->allocateImage(blendmapImageSize, blendmapImageSize, 1, format, GL_UNSIGNED_BYTE);
|
image->allocateImage(blendmapImageSize, blendmapImageSize, 1, GL_ALPHA, GL_UNSIGNED_BYTE);
|
||||||
unsigned char* pData = image->data();
|
unsigned char* pData = image->data();
|
||||||
|
|
||||||
for (int y=0; y<blendmapSize; ++y)
|
for (int y=0; y<blendmapSize; ++y)
|
||||||
|
@ -443,18 +437,16 @@ namespace ESMTerrain
|
||||||
UniqueTextureId id = getVtexIndexAt(cellX, cellY, x+rowStart, y+colStart, cache);
|
UniqueTextureId id = getVtexIndexAt(cellX, cellY, x+rowStart, y+colStart, cache);
|
||||||
assert(textureIndicesMap.find(id) != textureIndicesMap.end());
|
assert(textureIndicesMap.find(id) != textureIndicesMap.end());
|
||||||
int layerIndex = textureIndicesMap.find(id)->second;
|
int layerIndex = textureIndicesMap.find(id)->second;
|
||||||
int blendIndex = (pack ? static_cast<int>(std::floor((layerIndex - 1) / 4.f)) : layerIndex - 1);
|
|
||||||
int channel = pack ? std::max(0, (layerIndex-1) % 4) : 0;
|
|
||||||
|
|
||||||
int alpha = (blendIndex == i) ? 255 : 0;
|
int alpha = (layerIndex == i+1) ? 255 : 0;
|
||||||
|
|
||||||
int realY = (blendmapSize - y - 1)*imageScaleFactor;
|
int realY = (blendmapSize - y - 1)*imageScaleFactor;
|
||||||
int realX = x*imageScaleFactor;
|
int realX = x*imageScaleFactor;
|
||||||
|
|
||||||
pData[((realY+0)*blendmapImageSize + realX + 0)*channels + channel] = alpha;
|
pData[(realY+0)*blendmapImageSize + realX + 0] = alpha;
|
||||||
pData[((realY+1)*blendmapImageSize + realX + 0)*channels + channel] = alpha;
|
pData[(realY+1)*blendmapImageSize + realX + 0] = alpha;
|
||||||
pData[((realY+0)*blendmapImageSize + realX + 1)*channels + channel] = alpha;
|
pData[(realY+0)*blendmapImageSize + realX + 1] = alpha;
|
||||||
pData[((realY+1)*blendmapImageSize + realX + 1)*channels + channel] = alpha;
|
pData[(realY+1)*blendmapImageSize + realX + 1] = alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blendmaps.push_back(image);
|
blendmaps.push_back(image);
|
||||||
|
|
|
@ -92,14 +92,10 @@ namespace ESMTerrain
|
||||||
/// @note May be called from background threads.
|
/// @note May be called from background threads.
|
||||||
/// @param chunkSize size of the terrain chunk in cell units
|
/// @param chunkSize size of the terrain chunk in cell units
|
||||||
/// @param chunkCenter center of the chunk in cell units
|
/// @param chunkCenter center of the chunk in cell units
|
||||||
/// @param pack Whether to pack blend values for up to 4 layers into one texture (one in each channel) -
|
|
||||||
/// otherwise, each texture contains blend values for one layer only. Shader-based rendering
|
|
||||||
/// can utilize packing, FFP can't.
|
|
||||||
/// @param blendmaps created blendmaps will be written here
|
/// @param blendmaps created blendmaps will be written here
|
||||||
/// @param layerList names of the layer textures used will be written here
|
/// @param layerList names of the layer textures used will be written here
|
||||||
virtual void getBlendmaps (float chunkSize, const osg::Vec2f& chunkCenter, bool pack,
|
virtual void getBlendmaps (float chunkSize, const osg::Vec2f& chunkCenter, ImageVector& blendmaps,
|
||||||
ImageVector& blendmaps,
|
std::vector<Terrain::LayerInfo>& layerList);
|
||||||
std::vector<Terrain::LayerInfo>& layerList);
|
|
||||||
|
|
||||||
virtual float getHeightAt (const osg::Vec3f& worldPos);
|
virtual float getHeightAt (const osg::Vec3f& worldPos);
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ std::vector<osg::ref_ptr<osg::StateSet> > ChunkManager::createPasses(float chunk
|
||||||
{
|
{
|
||||||
std::vector<LayerInfo> layerList;
|
std::vector<LayerInfo> layerList;
|
||||||
std::vector<osg::ref_ptr<osg::Image> > blendmaps;
|
std::vector<osg::ref_ptr<osg::Image> > blendmaps;
|
||||||
mStorage->getBlendmaps(chunkSize, chunkCenter, false, blendmaps, layerList);
|
mStorage->getBlendmaps(chunkSize, chunkCenter, blendmaps, layerList);
|
||||||
|
|
||||||
bool useShaders = mSceneManager->getForceShaders();
|
bool useShaders = mSceneManager->getForceShaders();
|
||||||
if (!mSceneManager->getClampLighting())
|
if (!mSceneManager->getClampLighting())
|
||||||
|
|
|
@ -69,14 +69,10 @@ namespace Terrain
|
||||||
/// @note May be called from background threads. Make sure to only call thread-safe functions from here!
|
/// @note May be called from background threads. Make sure to only call thread-safe functions from here!
|
||||||
/// @param chunkSize size of the terrain chunk in cell units
|
/// @param chunkSize size of the terrain chunk in cell units
|
||||||
/// @param chunkCenter center of the chunk in cell units
|
/// @param chunkCenter center of the chunk in cell units
|
||||||
/// @param pack Whether to pack blend values for up to 4 layers into one texture (one in each channel) -
|
|
||||||
/// otherwise, each texture contains blend values for one layer only. Shader-based rendering
|
|
||||||
/// can utilize packing, FFP can't.
|
|
||||||
/// @param blendmaps created blendmaps will be written here
|
/// @param blendmaps created blendmaps will be written here
|
||||||
/// @param layerList names of the layer textures used will be written here
|
/// @param layerList names of the layer textures used will be written here
|
||||||
virtual void getBlendmaps (float chunkSize, const osg::Vec2f& chunkCenter, bool pack,
|
virtual void getBlendmaps (float chunkSize, const osg::Vec2f& chunkCenter, ImageVector& blendmaps,
|
||||||
ImageVector& blendmaps,
|
std::vector<LayerInfo>& layerList) = 0;
|
||||||
std::vector<LayerInfo>& layerList) = 0;
|
|
||||||
|
|
||||||
virtual float getHeightAt (const osg::Vec3f& worldPos) = 0;
|
virtual float getHeightAt (const osg::Vec3f& worldPos) = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue