mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 12:09:19 +02:00
Heightmap terrain: .tch chunk packs, streaming with LOD, terrain painting, water and modifiers - terrain/<name>/terrain.yaml + <px>_<pz>.tch packs of 16x16 chunks (250 m, 0.5/1/2/5 m spacing), slices with crc-32 and optional zstd (vendored zstd 1.5.6 in ref/zstd) - heightmap_terrain [name] endheightmap_terrain directive replaces editorterrain - streamer: worker threads, camera + look-ahead loading, geomipmap LOD with skirts, pooled geometry - mat_terrain shader: up to 8 painted layer materials per chunk via texture arrays (opengl33); other renderers fall back to the dominant material - water bodies (outline + level), terrain modifiers (vertical profile shaping kept non-destructive) - F11 Terrain work mode rebuilt: chunks, sculpt, smooth, paint, point spacing, water tools
This commit is contained in:
@@ -39,5 +39,29 @@ gfx_renderer_factory *gfx_renderer_factory::get_instance()
|
||||
|
||||
gfx_renderer_factory *gfx_renderer_factory::instance;
|
||||
|
||||
material_handle gfx_renderer::Terrain_Material( material_handle const Reuse, std::vector<gfx::terrain_layer> const &Layers, int const Samples, std::uint8_t const *Weights, glm::vec3 const &Placement )
|
||||
{
|
||||
// without blending the chunk gets the material which covers the most of it
|
||||
if( Layers.empty() ) {
|
||||
return null_handle;
|
||||
}
|
||||
std::size_t best { 0 };
|
||||
if( ( Weights != nullptr ) && ( Samples > 0 ) ) {
|
||||
auto const samples { static_cast<std::size_t>( Samples + 1 ) * ( Samples + 1 ) };
|
||||
std::uint64_t bestsum { 0 };
|
||||
for( std::size_t layer = 0; layer < Layers.size(); ++layer ) {
|
||||
std::uint64_t sum { 0 };
|
||||
for( std::size_t i = 0; i < samples; ++i ) {
|
||||
sum += Weights[ layer * samples + i ];
|
||||
}
|
||||
if( sum > bestsum ) {
|
||||
bestsum = sum;
|
||||
best = layer;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Layers[ best ].material;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user