-
-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement density functions for terrain generation #98
Conversation
cf9fc84
to
505c6bf
Compare
I bit off more than I can chew. Here is another stepping stone towards chunk generation: the density functions. I will keep on working towards terrain generation. |
3fd54b5
to
1e6f371
Compare
fn sample_2d(sampler: &SimplexNoiseSampler, x: i32, z: i32) -> f32 { | ||
let i = x / 2; | ||
let j = z / 2; | ||
let k = x % 2; | ||
let l = z % 2; | ||
|
||
let f = 100f32 - ((x * x + z * z) as f32).sqrt() * 8f32; | ||
let mut f = f.clamp(-100f32, 80f32); | ||
|
||
for m in -12..=12 { | ||
for n in -12..=12 { | ||
let o = (i + m) as i64; | ||
let p = (j + n) as i64; | ||
|
||
if (o * o + p * p) > 4096i64 | ||
&& sampler.sample_2d(o as f64, p as f64) < -0.9f32 as f64 | ||
{ | ||
let g = ((o as f32).abs() * 3439f32 + (p as f32).abs() * 147f32) % 13f32 + 9f32; | ||
let h = (k - m * 2) as f32; | ||
let q = (l - n * 2) as f32; | ||
let r = 100f32 - (h * h + q * q).sqrt() * g; | ||
let s = r.clamp(-100f32, 80f32); | ||
|
||
f = f.max(s); | ||
} | ||
} | ||
} | ||
|
||
f | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is is vanilla ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
I see you almost have |
Straight from Java lol, i am not entirely sure what they do. seems like they are just reused code for generating splines |
1e6f371
to
165b266
Compare
I don't like if someone just copies Java code and then even say that he don't know what the code does. So you said your goal is to have the Plains biome generation working. Do you need everything here for this, Or is something missing ? |
Yeah, it's not ideal. I can do a re-write once I have a better idea of everything that is going on. This is needed for all generation, so is a stepping stone to plains generation |
Not knowing is a bad way of putting it. I know what they do; they're just reused and are pretty basic so I don't know what to name them |
I would like to have good function names at least |
Functions have been renamed |
noice, can you may fix the conflicts ? |
692b37d
to
30fdb14
Compare
rebased, should be good |
WIP
This PR has the end goal of generating plains biomes