sudoplaygames / joise Goto Github PK
View Code? Open in Web Editor NEWJoise is a 2D, 3D, 4D and 6D modular noise library written in Java.
Home Page: https://joise.sudoplaygames.com/
License: Other
Joise is a 2D, 3D, 4D and 6D modular noise library written in Java.
Home Page: https://joise.sudoplaygames.com/
License: Other
The future is here.
ModuleFractal#calcWeights(FractalType)
is only ever called when ModuleFractal#setType(FractalType)
is called. The calcWeights
method uses the following mutable fields: lacunarity
, H
, offset
, and gain
. If a user calls any of the setters for the aforementioned fields, the scale
and bias
for each octave will not be recalculated with the new field value.
Additionally, when reconstructing the ModuleFractal
from a ModuleMap
, the setType(FractalType)
method is called before any other setter method preventing proper scale
and bias
calculation.
I recently got the platformer terrain generation working, and it looks amazing. I'm extremely happy with the result but I just have a few questions. I'm trying to generate worlds as big as Terraria which is a few million blocks. My blocks are 32x32 and when I start to scale the numbers up to make my world bigger it starts taking WAY longer to generate. It takes me about 14 seconds to generate 1.3 million blocks and my PC has a fast processor as well. It's not the rendering, it's the actual generation. I'll post a part of my generation code and I'm wondering how to speed up the performance? I haven't even gotten to the part where I generate ores, dirt, grass, trees, etc. so I'm hoping that I'm just using something wrong. Here's the code:
long start = System.currentTimeMillis();
/*
* WIDTH is 37760 pixels, I multiply a number by my block width which is 32. HEIGHT uses the same formula but a different number and it is 37440
*/
System.out.println("Starting world generation of world with dimensions " + WIDTH + " x " + HEIGHT + " estimated block count: " + ((WIDTH * HEIGHT) / (Block.WIDTH * Block.HEIGHT)));
/*
* This will be later to split up the rendering. I've tried generating individual chunks but the noise doesn't work well, it needs to be generated all at once
*/
List<Chunk> world = new ArrayList<>();
List<Block> blocks = new ArrayList<>();
Module gen = Noise.getNoiseMod();
float px, py, raw;
// Carve basic world shape with air and stone
for (int x = 0; x < WIDTH; x += Block.WIDTH)
{
for (int y = 0; y < HEIGHT; y += Block.HEIGHT)
{
px = x / (float) WIDTH;
py = y / (float) HEIGHT;
raw = (float) gen.get(px, py);
raw = Math.max(0, Math.min(1, raw));
if (raw == 1)
{
blocks.add(new Block(BlockType.STONE, x, y));
}
else
{
blocks.add(new Block(BlockType.AIR, x, y));
}
}
}
Chunk c = new Chunk(blocks); // For use with generating ores, etc.
// Add ores - Here's where I need the most performance because I'll be looping through the world and checking for certain conditions
/*for (int x = 0; x < WIDTH; x += Block.WIDTH)
{
for (int y = 0; y < HEIGHT; y += Block.HEIGHT)
{
}
}*/
float end = (System.currentTimeMillis() - start) / 1000;
System.out.println("Finished generating world (" + blocks.size() + " blocks) in " + end + " seconds");
world.add(c);
return world;
The code style for this project needs to be brought in-line with the style that I use in all my other projects. Once finished, the code style should be exported and maintained as part of the repository.
Code cleanup:
#define MaxSources 20
public static final int MAX_SOURCES = 10;
It looks like the value is only used in the ModuleCombiner and ModuleFractal class.
From an end-user perspective, what will altering this value from 10 to 20 affect?
Right now, the module factory is hardcoded to support only the modules defined in the library. This precludes support for custom modules. Custom modules can still be created, chained and sampled, but not serialized into from the ModuleMap data structure.
For example, if someone wanted to use their own version of ModuleCos, named as such, without overriding overwriting Joise's internal ModuleCos, it couldn't be done without renaming the custom module.
If we use the fully qualified class name, however, it could be done: com.sudoplay.joise.module.ModuleCos
is distinct from something like com.custom.ModuleCos
, and the system would be able to tell the two apart when serializing / deserializing.
Hello, I am not sure if this is the right place to ask, but I found your library just amazing and I would like to tell you about.
I am facing a problem while using the library, I have made a few test with the different modules, and my comprehension is that I must now the final dimensions of my map before generating it. Let me explain:
the get
function of the modules look this way
get(x, y) // x and t are value between 0 and 1
so I need to call
get(x / map_witdh, y / map_heigh)
in order to obtain the point value.
I would like to use it in an inifinite map, so that if the player is at coord (1000, 400), I just need to generate the surrounding blocks etc...
Is there a way to achieve that? I am quite sure I have missed something. A documentation or a wiki would be very helpful.
Thank you
I'm trying to use Joise with the GWT backend for libGDX and apparently it has some incompatibilities. I forked to work on the problem, so hopefully there will be a PR from me to fix this issue soon.
I have listed the build errors I am getting which I believe indicate incompatibilities with GWT in this comment here.
What's going on here...?
Could we upload to maven central so it's easy to add to a project, so i can just do in my gradle dependencies { compile "com.blah..".. }
I'm not very familiar with gradle, maven, or maven central, perhaps you are though :)
ModuleBasisFunction rotation axis and angle are not written to or read from the ModuleMap. Should store x, y, z and angle; recalculate rotation matrix when loaded.
Additional problems with ModuleBasisFunction:
setSeed(long)
could use a single angle instead of two anglesHow do you make platformer terrain like in the Minecraft worlds example on the ANL site? Your example just makes noise but I don't know how to take it a step further and make a terraria-like game.
This poses a bit of a performance problem if, for example, the user is only going to sample the module chain for a single type of dimensional noise (ie. 2D, 3D, 4D or 6D) and uses a high sample rate large number of samples in the auto-correct module. The extra calculations, the extra time spent, is unnecessary.
I propose the following:
calculate()
method into multiple methods: calculate2D()
, calculate3D()
, calculate4D()
, and calculate6D()
calculate()
methodcalculateAll()
that is equivalent to the calculate()
methodThis would allow the user to perform only the calculations necessary for the type of dimensional noise they are going to sample.
src/main/java/...
src/test/java/...
The library needs some proper multi-threading tests to identify which classes are thread safe and which are not. I suspect that the PRNGs are not thread safe; the ModuleCache class is also possibly not thread safe.
Hi there, would it be possible for you to create a simple example of how to use your library. The included example is using includes that are not included.
Just a simple sample from start to finish would be great.
Thanks
Gradlew.bat gives me this:
> No such property: ossrhUsername for class: org.gradle.api.publication.maven.in
ternal.ant.DefaultGroovyMavenDeployer
I'm currently porting the C++ code myself to use in a C# project, since I sometimes don't understand the quirks of C++ I use this as a reference.
In the cache module, to me it seems it has to store the results for a given x,y pair so that when the cache is called again, the value is returned. Unless I miss something, your code ports the C++ version correctly, but they both just seem to cache the last value & only will work if the next call is the same coordinate.
is this library multithreaded/thread safe, and which parts? the original library, accidental noise is threadable afaik.
1.0.3 works fine on GWT, but 1.0.4 produces the following errors:
ModuleFactoryRegistry.java
[ERROR] Line 68: The method format(String, String) is undefined for the type String
[ERROR] Line 79: The method format(String, String) is undefined for the type String
ModuleFractal has constant values for default octaves, frequency and lacunarity that are never used.
where is the eval6D function?
ModuleFractal should extend SeededModule and override to set all source seed names.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.