mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 18:59:57 +00:00
e27437f8ed
- Consistent triangle alignment, fixes a noticable crack near the census and excise office. Note that alignment is still not the same as vanilla. Vanilla uses a weird diagonal pattern. I hope there aren't more trouble spots that will force us to replicate vanilla, but at least we can do that now. - Fixes several blending issues and cell border seams - Fix map render to use the terrain bounding box instead of an arbitrary height - Different LODs are now properly connected instead of using skirts - Support self shadowing - Normals and colors are stored in the vertices instead of a texture, this enables per-vertex lighting which should improve performance, fix compatibility issues due to the PS getting too large and mimic vanilla better - Support a fixed function fallback (though the splatting shader usually performs better) - Designed for distant land support - test: https://www.youtube.com/watch?v=2wnd9EuPJIY - we can't really enable this yet due to depth precision issues when using a large view distance
76 lines
3.6 KiB
C++
76 lines
3.6 KiB
C++
#ifndef COMPONENTS_TERRAIN_STORAGE_H
|
|
#define COMPONENTS_TERRAIN_STORAGE_H
|
|
|
|
#include <components/esm/loadland.hpp>
|
|
#include <components/esm/loadltex.hpp>
|
|
|
|
#include <OgreAxisAlignedBox.h>
|
|
|
|
#include <OgreHardwareVertexBuffer.h>
|
|
|
|
namespace Terrain
|
|
{
|
|
|
|
/// We keep storage of terrain data abstract here since we need different implementations for game and editor
|
|
class Storage
|
|
{
|
|
private:
|
|
virtual ESM::Land* getLand (int cellX, int cellY) = 0;
|
|
virtual const ESM::LandTexture* getLandTexture(int index, short plugin) = 0;
|
|
|
|
public:
|
|
/// Get bounds of the whole terrain in cell units
|
|
virtual Ogre::AxisAlignedBox getBounds() = 0;
|
|
|
|
/// Get the minimum and maximum heights of a terrain chunk.
|
|
/// @note Should only be called for chunks <= 1 cell, i.e. leafs of the quad tree.
|
|
/// Larger chunks can simply merge AABB of children.
|
|
/// @param size size of the chunk in cell units
|
|
/// @param center center of the chunk in cell units
|
|
/// @param min min height will be stored here
|
|
/// @param max max height will be stored here
|
|
/// @return true if there was data available for this terrain chunk
|
|
bool getMinMaxHeights (float size, const Ogre::Vector2& center, float& min, float& max);
|
|
|
|
/// Fill vertex buffers for a terrain chunk.
|
|
/// @param lodLevel LOD level, 0 = most detailed
|
|
/// @param size size of the terrain chunk in cell units
|
|
/// @param center center of the chunk in cell units
|
|
/// @param vertexBuffer buffer to write vertices
|
|
/// @param normalBuffer buffer to write vertex normals
|
|
/// @param colourBuffer buffer to write vertex colours
|
|
void fillVertexBuffers (int lodLevel, float size, const Ogre::Vector2& center,
|
|
Ogre::HardwareVertexBufferSharedPtr vertexBuffer,
|
|
Ogre::HardwareVertexBufferSharedPtr normalBuffer,
|
|
Ogre::HardwareVertexBufferSharedPtr colourBuffer);
|
|
|
|
/// Create textures holding layer blend values for a terrain chunk.
|
|
/// @note The terrain chunk shouldn't be larger than one cell since otherwise we might
|
|
/// have to do a ridiculous amount of different layers. For larger chunks, composite maps should be used.
|
|
/// @param chunkSize size of the terrain 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 layerList names of the layer textures used will be written here
|
|
void getBlendmaps (float chunkSize, const Ogre::Vector2& chunkCenter, bool pack,
|
|
std::vector<Ogre::TexturePtr>& blendmaps,
|
|
std::vector<std::string>& layerList);
|
|
|
|
private:
|
|
void fixNormal (Ogre::Vector3& normal, int cellX, int cellY, int col, int row);
|
|
|
|
// Since plugins can define new texture palettes, we need to know the plugin index too
|
|
// in order to retrieve the correct texture name.
|
|
// pair <texture id, plugin id>
|
|
typedef std::pair<short, short> UniqueTextureId;
|
|
|
|
UniqueTextureId getVtexIndexAt(int cellX, int cellY,
|
|
int x, int y);
|
|
std::string getTextureName (UniqueTextureId id);
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|