TESTS: use a fixed volume and no noise filled volume for the tests

master
Martin Gerhardy 2022-03-01 23:58:23 +01:00
parent 5e180e1209
commit 2e06087ce0
4 changed files with 31 additions and 20 deletions

View File

@ -6,9 +6,7 @@
#include "voxel/MaterialColor.h"
#include "voxel/Region.h"
#include "voxel/Voxel.h"
#include "voxel/RawVolumeWrapper.h"
#include "voxelutil/VolumeVisitor.h"
#include "voxelgenerator/NoiseGenerator.h"
#include "video/ScopedViewPort.h"
#include <glm/gtc/type_ptr.hpp>
@ -60,9 +58,15 @@ void TestComputeTexture3D::initVolume() {
voxel::Region region(0, 0, 0, width - 1, height - 1, _depth - 1);
_volume = std::make_shared<voxel::RawVolume>(region);
math::Random random;
voxel::RawVolumeWrapper wrapper(_volume.get());
voxelgenerator::noise::generate(wrapper, 4, 2.0f, 0.01f, 0.5f, voxelgenerator::noise::NoiseType::ridgedMF, random);
_volume->setVoxel(0, 1, 0, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(1, 1, 0, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(2, 1, 0, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(0, 1, 1, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(1, 1, 1, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(2, 1, 1, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(0, 1, 2, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(1, 1, 2, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(2, 1, 2, createVoxel(voxel::VoxelType::Leaf, 0));
const int amount = voxelutil::visitVolume(*_volume.get(), [] (int x, int y, int z, const voxel::Voxel& voxel) {
});
Log::info("%i voxels", amount);

View File

@ -9,9 +9,7 @@
#include "computevideo/ComputeVideo.h"
#include "voxel/Region.h"
#include "voxel/Voxel.h"
#include "voxel/RawVolumeWrapper.h"
#include "voxelutil/VolumeVisitor.h"
#include "voxelgenerator/NoiseGenerator.h"
#include <memory>
#define GL_INTEROP 0
@ -77,9 +75,15 @@ app::AppState TestGPUMC::onInit() {
voxel::Region region(0, 0, 0, REGION_SIZE - 1, REGION_SIZE - 1, REGION_SIZE - 1);
_volume = std::make_shared<voxel::RawVolume>(region);
math::Random random;
voxel::RawVolumeWrapper wrapper(_volume.get());
voxelgenerator::noise::generate(wrapper, 4, 2.0f, 0.01f, 0.5f, voxelgenerator::noise::NoiseType::ridgedMF, random);
_volume->setVoxel(0, 1, 0, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(1, 1, 0, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(2, 1, 0, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(0, 1, 1, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(1, 1, 1, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(2, 1, 1, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(0, 1, 2, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(1, 1, 2, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(2, 1, 2, createVoxel(voxel::VoxelType::Leaf, 0));
const int amount = voxelutil::visitVolume(*_volume.get(), [] (int x, int y, int z, const voxel::Voxel& voxel) {
});
Log::info("%i voxels", amount);

View File

@ -6,8 +6,6 @@
#include "voxel/MaterialColor.h"
#include "voxel/Region.h"
#include "voxel/Voxel.h"
#include "voxel/RawVolumeWrapper.h"
#include "voxelgenerator/NoiseGenerator.h"
#include "testcore/TestAppMain.h"
#include <memory>
@ -36,11 +34,16 @@ app::AppState TestVoxelGPU::onInit() {
}
voxel::Region region(0, 0, 0, _workSize.x - 1, _workSize.y - 1, _workSize.z - 1);
_volume = std::make_shared<voxel::RawVolume>(region);
math::Random random;
voxel::RawVolumeWrapper wrapper(_volume.get());
voxelgenerator::noise::generate(wrapper, 4, 2.0f, 0.01f, 0.5f, voxelgenerator::noise::NoiseType::ridgedMF, random);
_volume = core::make_shared<voxel::RawVolume>(region);
_volume->setVoxel(0, 1, 0, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(1, 1, 0, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(2, 1, 0, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(0, 1, 1, createVoxel(voxel::VoxelType::Dirt, 0));
_volume->setVoxel(1, 1, 1, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(2, 1, 1, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(0, 1, 2, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(1, 1, 2, createVoxel(voxel::VoxelType::Leaf, 0));
_volume->setVoxel(2, 1, 2, createVoxel(voxel::VoxelType::Leaf, 0));
compute::TextureConfig cfg3d;
cfg3d.type(compute::TextureType::Texture3D).format(compute::TextureFormat::RG).dataformat(compute::TextureDataFormat::UNSIGNED_INT8);
static_assert(sizeof(voxel::Voxel) == 2, "Texture type must be changed if the voxel size is not 16 bits anymore");
@ -60,7 +63,7 @@ app::AppState TestVoxelGPU::onInit() {
app::AppState TestVoxelGPU::onCleanup() {
_mesher.shutdown();
_volumeTexture->shutdown();
_volume = std::shared_ptr<voxel::RawVolume>();
_volume = core::SharedPtr<voxel::RawVolume>();
return Super::onCleanup();
}

View File

@ -8,7 +8,7 @@
#include "compute/Texture.h"
#include "voxel/RawVolume.h"
#include "TestvoxelgpuComputeShaders.h"
#include <memory>
#include <vector>
class TestVoxelGPU: public TestApp {
private:
@ -16,7 +16,7 @@ private:
compute::MesherShader& _mesher;
std::vector<uint8_t> _output;
compute::TexturePtr _volumeTexture;
std::shared_ptr<voxel::RawVolume> _volume;
core::SharedPtr<voxel::RawVolume> _volume;
glm::ivec3 _workSize { 64, 64, 64 };
void onRenderUI() override;