use of net.glowstone.util.noise.SimplexOctaveGenerator in project Glowstone by GlowstoneMC.
the class MesaGroundGenerator method initialize.
private void initialize(long seed) {
if (seed != this.seed || colorNoise == null || canyonScaleNoise == null || canyonHeightNoise == null) {
Random random = new Random(seed);
colorNoise = new SimplexOctaveGenerator(random, 1);
colorNoise.setScale(1 / 512.0D);
initializeColorLayers(random);
canyonHeightNoise = new SimplexOctaveGenerator(random, 4);
canyonHeightNoise.setScale(1 / 4.0D);
canyonScaleNoise = new SimplexOctaveGenerator(random, 1);
canyonScaleNoise.setScale(1 / 512.0D);
this.seed = seed;
}
}
use of net.glowstone.util.noise.SimplexOctaveGenerator in project Glowstone by GlowstoneMC.
the class OverworldGenerator method createWorldOctaves.
@Override
protected void createWorldOctaves(World world, Map<String, OctaveGenerator> octaves) {
Random seed = new Random(world.getSeed());
OctaveGenerator gen = new PerlinOctaveGenerator(seed, 16, 5, 5);
gen.setXScale(heightNoiseScaleX);
gen.setZScale(heightNoiseScaleZ);
octaves.put("height", gen);
gen = new PerlinOctaveGenerator(seed, 16, 5, 33, 5);
gen.setXScale(coordinateScale);
gen.setYScale(heightScale);
gen.setZScale(coordinateScale);
octaves.put("roughness", gen);
gen = new PerlinOctaveGenerator(seed, 16, 5, 33, 5);
gen.setXScale(coordinateScale);
gen.setYScale(heightScale);
gen.setZScale(coordinateScale);
octaves.put("roughness2", gen);
gen = new PerlinOctaveGenerator(seed, 8, 5, 33, 5);
gen.setXScale(coordinateScale / detailNoiseScaleX);
gen.setYScale(heightScale / detailNoiseScaleY);
gen.setZScale(coordinateScale / detailNoiseScaleZ);
octaves.put("detail", gen);
gen = new SimplexOctaveGenerator(seed, 4, 16, 16);
gen.setScale(surfaceScale);
octaves.put("surface", gen);
}
use of net.glowstone.util.noise.SimplexOctaveGenerator in project Glowstone by GlowstoneMC.
the class OverworldGenerator method generateChunkData.
@Override
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomes) {
ChunkData chunkData = generateRawTerrain(world, chunkX, chunkZ);
int cx = chunkX << 4;
int cz = chunkZ << 4;
SimplexOctaveGenerator octaveGenerator = ((SimplexOctaveGenerator) getWorldOctaves(world).get("surface"));
int sizeX = octaveGenerator.getSizeX();
int sizeZ = octaveGenerator.getSizeZ();
if (((GlowServer) ServerProvider.getServer()).doesUseGraphicsCompute()) {
CLKernel noiseGen = null;
CLBuffer<FloatBuffer> noise = null;
try {
// Initialize OpenCL stuff and put args
CLProgram program = OpenCompute.getProgram("net/glowstone/CLRandom.cl");
int workSize = sizeX * octaveGenerator.getSizeY() * sizeZ;
noise = OpenCompute.getContext().createFloatBuffer(workSize, CLMemory.Mem.WRITE_ONLY);
noiseGen = OpenCompute.getKernel(program, "GenerateNoise");
noiseGen.putArg(random.nextFloat()).putArg(random.nextFloat()).putArg(noise).putArg(workSize);
// Calculate noise on GPU
OpenCompute.getQueue().put1DRangeKernel(noiseGen, 0, OpenCompute.getGlobalSize(workSize), OpenCompute.getLocalSize()).putReadBuffer(noise, true);
// Use noise
for (int x = 0; x < sizeX; x++) {
for (int z = 0; z < sizeZ; z++) {
if (GROUND_MAP.containsKey(biomes.getBiome(x, z))) {
GROUND_MAP.get(biomes.getBiome(x, z)).generateTerrainColumn(chunkData, world, random, cx + x, cz + z, biomes.getBiome(x, z), noise.getBuffer().get(x | z << 4));
} else {
groundGen.generateTerrainColumn(chunkData, world, random, cx + x, cz + z, biomes.getBiome(x, z), noise.getBuffer().get(x | z << 4));
}
}
}
} finally {
// Clean up
if (noise != null) {
ServerProvider.getServer().getScheduler().runTaskAsynchronously(null, noise::release);
}
if (noiseGen != null) {
noiseGen.rewind();
}
}
} else {
double[] surfaceNoise = octaveGenerator.getFractalBrownianMotion(cx, cz, 0.5D, 0.5D);
for (int x = 0; x < sizeX; x++) {
for (int z = 0; z < sizeZ; z++) {
if (GROUND_MAP.containsKey(biomes.getBiome(x, z))) {
GROUND_MAP.get(biomes.getBiome(x, z)).generateTerrainColumn(chunkData, world, random, cx + x, cz + z, biomes.getBiome(x, z), surfaceNoise[x | z << 4]);
} else {
groundGen.generateTerrainColumn(chunkData, world, random, cx + x, cz + z, biomes.getBiome(x, z), surfaceNoise[x | z << 4]);
}
}
}
}
return chunkData;
}
Aggregations