Nebula
Loading...
Searching...
No Matches
terraincontext.cc File Reference
#include "terraincontext.h"
#include "graphics/graphicsserver.h"
#include "frame/framesubgraph.h"
#include "graphics/cameracontext.h"
#include "graphics/view.h"
#include "dynui/imguicontext.h"
#include "jobs2/jobs2.h"
#include "imgui.h"
#include "renderutil/drawfullscreenquad.h"
#include "core/cvar.h"
#include "lighting/lightcontext.h"
#include "raytracing/raytracingcontext.h"
#include "occupancyquadtree.h"
#include "texturetilecache.h"
#include "resources/resourceserver.h"
#include "materials/materialloader.h"
#include "terrain/shaders/terrain.h"
#include "terrain/shaders/terrain_mesh_generate.h"
#include "terrain/shaders/terrain_tile_write.h"
#include "frame/default.h"

Classes

struct  Terrain::PhysicalTileUpdate
 
struct  Terrain::SubTexture
 
struct  Terrain::SubTextureCompressed
 
struct  Terrain::TerrainVert
 
struct  Terrain::TerrainTri
 
struct  Terrain::TerrainQuad
 

Namespaces

namespace  Terrain
 The occupancy quad tree implements a tree which allows for a quick search.
 

Enumerations

enum  Terrain::BiomeLoadBits {
  Terrain::AlbedoLoaded = 0x1 , Terrain::NormalLoaded = 0x2 , Terrain::MaterialLoaded = 0x4 , Terrain::MaskLoaded = 0x8 ,
  Terrain::WeightsLoaded = 0x10
}
 

Functions

 N_DECLARE_COUNTER (N_TERRAIN_TOTAL_AVAILABLE_DATA, Terrain Total Data Size)
 
 Terrain::__ImplementContext (TerrainContext, TerrainContext::terrainAllocator)
 
void Terrain::PackSubTexture (const SubTexture &subTex, TerrainSubTexture &compressed)
 
void Terrain::UnpackPageDataEntry (uint *packed, uint &status, uint &subTextureIndex, uint &mip, uint &maxMip, uint &subTextureTileX, uint &subTextureTileY)
 Unpack from packed ushort vectors to full size.
 
template<typename T >
uint Terrain::Upload (T *data, uint size, uint alignment)
 
void Terrain::IndirectionUpdate (uint mip, uint physicalOffsetX, uint physicalOffsetY, uint indirectionOffsetX, uint indirectionOffsetY, uint subTextureTileX, uint subTextureTileY)
 
void Terrain::IndirectionErase (uint mip, uint indirectionOffsetX, uint indirectionOffsetY, uint subTextureTileX, uint subTextureTileY)
 
void Terrain::IndirectionMoveGrow (uint oldMaxMip, uint oldTiles, const Math::uint2 &oldCoord, uint newMaxMip, uint newTiles, const Math::uint2 &newCoord)
 Copies mip chain from old region to new region which is bigger by mapping mips 0..X to 1..X in the new region.
 
void Terrain::IndirectionMoveShrink (uint oldMaxMip, uint oldTiles, const Math::uint2 &oldCoord, uint newMaxMip, uint newTiles, const Math::uint2 &newCoord)
 Copies mip chain from old region to new region which is smaller, mapping mips 0..X to 0..X-1 in the new region.
 
void Terrain::IndirectionClear (uint mips, uint tiles, const Math::uint2 &coord)
 Clear old region.
 

Variables

Threading::Event Terrain::subtexturesFinishedEvent
 
Threading::Event Terrain::sectionCullFinishedEvent
 
Threading::AtomicCounter Terrain::subtexturesDoneCounter = 0
 
Threading::AtomicCounter Terrain::sectionCullDoneCounter = 0
 
const uint Terrain::IndirectionTextureSize = 2048
 
const uint Terrain::SubTextureWorldSize = 64
 
const uint Terrain::SubTextureMaxTiles = 256
 
const uint Terrain::IndirectionNumMips = Math::log2(SubTextureMaxTiles) + 1
 
const float Terrain::SubTextureRange = 300.0f
 
const float Terrain::SubTextureSwapDistance = 10.0f
 
const float Terrain::SubTextureFadeStart = 200.0f
 
const uint Terrain::SubTextureMaxPixels = 65536
 
const uint Terrain::SubTextureMaxUpdates = 1024
 
const uint Terrain::LowresFallbackSize = 4096
 
const uint Terrain::LowresFallbackMips = Math::log2(LowresFallbackSize) + 1
 
const uint Terrain::PhysicalTextureTileSize = 256
 
const uint Terrain::PhysicalTextureTileHalfPadding = 4
 
const uint Terrain::PhysicalTextureTilePadding = PhysicalTextureTileHalfPadding * 2
 
const uint Terrain::PhysicalTextureNumTiles = 32
 
const uint Terrain::PhysicalTextureTilePaddedSize = PhysicalTextureTileSize + PhysicalTextureTilePadding
 
const uint Terrain::PhysicalTextureSize = (PhysicalTextureTileSize) * PhysicalTextureNumTiles
 
const uint Terrain::PhysicalTexturePaddedSize = (PhysicalTextureTilePaddedSize) * PhysicalTextureNumTiles
 
const uint Terrain::TerrainShadowMapSize = 2048
 
struct { 
 
   TerrainSetupSettings   Terrain::settings 
 
   CoreGraphics::ShaderId   Terrain::terrainShader 
 
   CoreGraphics::ShaderId   Terrain::tileShader 
 
   CoreGraphics::ShaderProgramId   Terrain::terrainShadowProgram 
 
   CoreGraphics::ResourceTableId   Terrain::resourceTable 
 
   CoreGraphics::BufferId   Terrain::systemConstants 
 
   CoreGraphics::VertexLayoutId   Terrain::vlo 
 
   CoreGraphics::WindowId   Terrain::wnd 
 
   CoreGraphics::BufferId   Terrain::biomeBuffer 
 
   Terrain::MaterialLayers   Terrain::biomeMaterials 
 
   Util::Array< CoreGraphics::TextureId >   Terrain::biomeTextures 
 
   CoreGraphics::TextureId   Terrain::biomeMasks [Terrain::MAX_BIOMES] 
 
   CoreGraphics::TextureId   Terrain::biomeWeights [Terrain::MAX_BIOMES] 
 
   Threading::AtomicCounter   Terrain::biomeLoaded [Terrain::MAX_BIOMES][4] 
 
   uint   Terrain::biomeLowresGenerated [Terrain::MAX_BIOMES] 
 
   IndexT   Terrain::biomeCounter 
 
   Graphics::GraphicsEntityId   Terrain::sun 
 
   CoreGraphics::TextureId   Terrain::terrainShadowMap 
 
   Math::vec4   Terrain::cachedSunDirection 
 
   bool   Terrain::shadowMapInvalid 
 
   bool   Terrain::updateShadowMap 
 
   Threading::CriticalSection   Terrain::syncPoint 
 
   CoreGraphics::ResourceTableId   Terrain::terrainShadowResourceTable 
 
   CoreGraphics::TextureId   Terrain::terrainPosBuffer 
 
   float   Terrain::mipLoadDistance = 1500.0f 
 
   float   Terrain::mipRenderPadding = 150.0f 
 
   SizeT   Terrain::layers 
 
   bool   Terrain::debugRender 
 
   bool   Terrain::renderToggle 
 
Terrain::terrainState 
 
struct { 
 
   CoreGraphics::ShaderProgramId   Terrain::terrainPrepassProgram 
 
   CoreGraphics::PipelineId   Terrain::terrainPrepassPipeline 
 
   CoreGraphics::ShaderProgramId   Terrain::terrainPageClearUpdateBufferProgram 
 
   CoreGraphics::ShaderProgramId   Terrain::terrainResolveProgram 
 
   CoreGraphics::PipelineId   Terrain::terrainResolvePipeline 
 
   CoreGraphics::ShaderProgramId   Terrain::terrainTileWriteProgram 
 
   CoreGraphics::ShaderProgramId   Terrain::terrainWriteLowresProgram 
 
   bool   Terrain::virtualSubtextureBufferUpdate 
 
   CoreGraphics::BufferSet   Terrain::subtextureStagingBuffers 
 
   CoreGraphics::BufferId   Terrain::subTextureBuffer 
 
   CoreGraphics::BufferSet   Terrain::pageUpdateReadbackBuffers 
 
   CoreGraphics::TextureId   Terrain::indirectionTexture 
 
   CoreGraphics::TextureId   Terrain::indirectionTextureCopy 
 
   CoreGraphics::BufferId   Terrain::pageUpdateListBuffer 
 
   CoreGraphics::BufferId   Terrain::pageStatusBuffer 
 
   Threading::AtomicCounter   Terrain::numPatchesThisFrame 
 
   CoreGraphics::BufferSet   Terrain::patchConstants 
 
   CoreGraphics::BufferId   Terrain::runtimeConstants 
 
   CoreGraphics::BufferWithStaging   Terrain::tileWriteBufferSet 
 
   CoreGraphics::TextureId   Terrain::physicalAlbedoCacheBC 
 
   CoreGraphics::TextureViewId   Terrain::physicalAlbedoCacheBCWrite 
 
   CoreGraphics::TextureId   Terrain::physicalNormalCacheBC 
 
   CoreGraphics::TextureViewId   Terrain::physicalNormalCacheBCWrite 
 
   CoreGraphics::TextureId   Terrain::physicalMaterialCacheBC 
 
   CoreGraphics::TextureViewId   Terrain::physicalMaterialCacheBCWrite 
 
   CoreGraphics::TextureId   Terrain::lowresAlbedo 
 
   CoreGraphics::TextureId   Terrain::lowresNormal 
 
   CoreGraphics::TextureId   Terrain::lowresMaterial 
 
   bool   Terrain::updateLowres = false 
 
   CoreGraphics::ResourceTableSet   Terrain::systemTable 
 
   CoreGraphics::ResourceTableId   Terrain::runtimeTable 
 
   SizeT   Terrain::numPageBufferUpdateEntries 
 
   Util::FixedArray< SubTexture >   Terrain::subTextures 
 
   Util::FixedArray< TerrainSubTexture >   Terrain::gpuSubTextures 
 
   Threading::AtomicCounter   Terrain::subTextureNumOutputs 
 
   Terrain::SubTextureUpdateJobOutput   Terrain::subTextureJobOutputs [SubTextureMaxUpdates
 
   OccupancyQuadTree   Terrain::indirectionOccupancy 
 
   OccupancyQuadTree   Terrain::physicalTextureTileOccupancy 
 
   TextureTileCache   Terrain::physicalTextureTileCache 
 
   Util::FixedArray< uint >   Terrain::indirectionMipOffsets 
 
   Util::FixedArray< uint >   Terrain::indirectionMipSizes 
 
   Util::Array< CoreGraphics::TextureCopy >   Terrain::indirectionTextureCopies 
 
   Util::Array< IndirectionEntry >   Terrain::indirectionEntryUpdates 
 
   Util::FixedArray< IndirectionEntry >   Terrain::indirectionBuffer 
 
   CoreGraphics::BufferSet   Terrain::indirectionUploadBuffers 
 
   Util::FixedArray< uint >   Terrain::indirectionUploadOffsets 
 
   Util::Array< TerrainTileWrite::TileWrite >   Terrain::tileWrites 
 
   Util::Array< TerrainTileWrite::TileWrite >   Terrain::tileWritesThisFrame 
 
   Util::Array< CoreGraphics::BufferCopy, 4 >   Terrain::indirectionBufferUpdatesThisFrame 
 
   Util::Array< CoreGraphics::TextureCopy, 4 >   Terrain::indirectionTextureUpdatesThisFrame 
 
   Util::Array< CoreGraphics::TextureCopy, 4 >   Terrain::indirectionTextureFromCopiesThisFrame 
 
   Util::Array< CoreGraphics::TextureCopy, 4 >   Terrain::indirectionTextureToCopiesThisFrame 
 
   Util::Array< CoreGraphics::BufferCopy, 4 >   Terrain::indirectionBufferClearsThisFrame 
 
   Util::Array< CoreGraphics::TextureCopy, 4 >   Terrain::indirectionTextureClearsThisFrame 
 
   uint   Terrain::numPixels 
 
Terrain::terrainVirtualTileState 
 
struct { 
 
   CoreGraphics::ShaderProgramId   Terrain::meshProgram 
 
   CoreGraphics::VertexAlloc   Terrain::vertexBuffer 
 
   CoreGraphics::VertexAlloc   Terrain::indexBuffer 
 
   CoreGraphics::ResourceTableId   Terrain::meshGenTable 
 
   CoreGraphics::BufferId   Terrain::patchBuffer 
 
   CoreGraphics::BufferId   Terrain::constantsBuffer 
 
   SizeT   Terrain::numTris 
 
   SizeT   Terrain::numPatches 
 
   bool   Terrain::updateMesh = false 
 
   std::function< void()>   Terrain::terrainSetupCallback 
 
   IndexT   Terrain::setupBlasFrame 
 
Terrain::raytracingState 
 

Function Documentation

◆ N_DECLARE_COUNTER()

N_DECLARE_COUNTER ( N_TERRAIN_TOTAL_AVAILABLE_DATA ,
Terrain Total Data Size )