/// <summary> /// Get the chunk at the given location (if it's loaded) /// </summary> /// <param name="chunkLocation">the location of the chunk to grab</param> /// <param name="withMeshes">get the chunk with it's mesh</param> /// <param name="withNeighbors">get the chunk with neighbors linked</param> /// <returns>the chunk data or null if there's none loaded</returns> public IVoxelChunk getChunk(Coordinate chunkLocation, bool withMeshes = false, bool withNeighbors = false, bool withNeighborsNeighbors = false, bool fullNeighborEncasement = false) { // just get an empty chunk for this one if this is out of bounds if (!chunkLocation.isWithin(Coordinate.Zero, chunkBounds)) { return(Chunk.GetEmptyChunk(chunkLocation, withNeighbors)); } IVoxelStorage voxels = chunkDataStorage.getChunkVoxelData(chunkLocation); IVoxelChunk[] neighbors = null; if (withNeighbors) { neighbors = new IVoxelChunk[Directions.All.Length]; foreach (Directions.Direction direction in Directions.All) { Coordinate neighborLocation = chunkLocation + direction.Offset; neighbors[direction.Value] = getChunk(neighborLocation, withMeshes, withNeighborsNeighbors, fullNeighborEncasement); } } return(new Chunk( chunkLocation, voxels, neighbors, withMeshes ? chunkDataStorage.getChunkMesh(chunkLocation) : null )); }
public void PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage) { foreach (var modifier in Modifiers) { modifier.PrepareLocalStorage(context, storage); } VoxelLayout.PrepareLocalStorage(context, storage); }
public void PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage) { if (!Enabled) { return; } storage.RequestTempStorage(32); }
/// <summary> /// Threaded function, loads all the voxel data for this chunk /// </summary> protected override void doWork(Coordinate chunkLocation) { // if the chunk is empty, lets try to fill it. IVoxelChunk chunk = jobManager.chunkManager.level.getChunk(chunkLocation); if (chunk.isEmpty && !chunk.isLoaded) { IVoxelStorage voxelData = jobManager.chunkManager.generateVoxelDataForChunk(chunkLocation); jobManager.chunkManager.level.chunkDataStorage.setChunkVoxelData(chunkLocation, voxelData); } }
/// <summary> /// Generate the given set of voxeldata at the given location offset /// </summary> /// <param name="location">The xyz to use as an offset for generating these voxels</param> /// <param name="voxelData">The voxel data to populate</param> public void generateAllAt(Coordinate location, IVoxelStorage voxelData) { Coordinate.Zero.until(voxelData.bounds, (coordinate) => { VoxelsGenerated++; Coordinate globalLocation = coordinate + (location * voxelData.bounds); float noiseValue = getNoiseValueAt(globalLocation); Voxel.Type newVoxelType = getVoxelTypeFor(noiseValue, globalLocation); if (newVoxelType != Voxel.Types.Empty) { voxelData.set(coordinate, newVoxelType); } }); }
/// <summary> /// Generate the given set of voxeldata at the given location offset /// </summary> /// <param name="location">The xyz to use as an offset for generating these voxels</param> /// <param name="voxelData">The voxel data to populate</param> public void generateAllAt(Coordinate location, IVoxelStorage voxelData) { isoSurfaceLevel = getIsoSurfaceLevel(); Coordinate.Zero.until(voxelData.bounds, (coordinate) => { VoxelsGenerated++; Coordinate globalLocation = coordinate + (location * voxelData.bounds); float isoSurfaceDensityValue = getNoiseValueAt(globalLocation); Voxel.Type newVoxelType = getVoxelTypeFor(isoSurfaceDensityValue); if (newVoxelType != Terrain.Types.Air) { voxelData.set(coordinate, newVoxelType); } }); }
public void Render(VoxelStorageContext storageContext, IVoxelStorage Storage, RenderDrawContext drawContext) { if (NeedToRecreateTexture(MSAARenderTarget, new Vector3(voxelizationView.ViewSize.X, voxelizationView.ViewSize.Y, 1), PixelFormat.R8G8B8A8_UNorm, MultisampleCount.X8)) { MSAARenderTarget = Texture.New(storageContext.device, TextureDescription.New2D((int)voxelizationView.ViewSize.X, (int)voxelizationView.ViewSize.Y, new MipMapCount(false), PixelFormat.R8G8B8A8_UNorm, TextureFlags.RenderTarget, 1, GraphicsResourceUsage.Default, MultisampleCount.X8), null); } drawContext.CommandList.ResetTargets(); if (MSAARenderTarget != null) { drawContext.CommandList.SetRenderTarget(null, MSAARenderTarget); } Storage.Render(storageContext, drawContext, voxelizationView); }
public void PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage) { StorageMethod.PrepareLocalStorage(context, storage, 4, 1); Graphics.PixelFormat format = Graphics.PixelFormat.R16G16B16A16_Float; switch (StorageFormat) { case StorageFormats.RGBA8: format = Graphics.PixelFormat.R8G8B8A8_UNorm; break; case StorageFormats.R10G10B10A2: format = Graphics.PixelFormat.R10G10B10A2_UNorm; break; case StorageFormats.RGBA16F: format = Graphics.PixelFormat.R16G16B16A16_Float; break; } storage.UpdateTexture(context, ref IsotropicTex, format, 1); }
virtual public int PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage) { return(StorageMethod.PrepareLocalStorage(context, storage, 4, LayoutCount)); }
public abstract void PrepareOutputStorage(VoxelStorageContext context, IVoxelStorage storage);
public abstract void PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage);
public override void PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage) { BufferOffset = storage.RequestTempStorage(32); }
public void PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage) { }
/// <summary> /// Set the given voxeldata to the given chunk location in this level's active storage/memmory /// </summary> /// <param name="chunkLocation"></param> /// <param name="voxelData"></param> public abstract void setChunkVoxelData(Coordinate chunkLocation, IVoxelStorage voxelData);
/// <summary> /// Generate all the voxels in the given collection with this source /// </summary> /// <param name="voxelData"></param> public void generateAll(IVoxelStorage voxelData) { generateAllAt(Coordinate.Zero, voxelData); }
virtual public void PrepareOutputStorage(VoxelStorageContext context, IVoxelStorage storage) { storage.UpdateTexture(context, ref storageTex, StorageFormatToPixelFormat(), LayoutCount); }
public void PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage) { StorageMethod.PrepareLocalStorage(context, storage, 4, 6); storage.UpdateTexture(context, ref IsotropicTex, Graphics.PixelFormat.R16G16B16A16_Float, 6); }
public override void PrepareOutputStorage(VoxelStorageContext context, IVoxelStorage storage) { storage.UpdateTexture(context, ref SolidityTex, Graphics.PixelFormat.R8_UNorm, 1); }
public int PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage, int channels, int layoutCount) { return(storage.RequestTempStorage(TempStorageFormat.GetBits(channels) * layoutCount)); }
public override void PrepareLocalStorage(VoxelStorageContext context, IVoxelStorage storage) { BufferOffset = VoxelLayout.PrepareLocalStorage(context, storage); }
public override void PrepareOutputStorage(VoxelStorageContext context, IVoxelStorage storage) { storage.UpdateTexture(context, ref CoverageTex, Graphics.PixelFormat.R11G11B10_Float, 1); }
public override void PrepareOutputStorage(VoxelStorageContext context, IVoxelStorage storage) { VoxelLayout.PrepareOutputStorage(context, storage); }