Converting perlin noise from mapgen.cpp to lua format

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Converting perlin noise from mapgen.cpp to lua format

by paramat » Thu Jan 17, 2013 04:42

So i found the perlin for choosing normal or desert biomes ...
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
double d = noise2d_perlin(
0.6+(float)p2d.X/250, 0.2+(float)p2d.Y/250,
seed+9130, 3, 0.50);
if(d > 0.45)
return BT_DESERT;
if(d > 0.35 && (noise2d( p2d.X, p2d.Y, int(seed) ) + 1.0) > ( 0.45 - d ) * 20.0 )
return BT_DESERT;
return BT_NORMAL;

0.6 and 0.2 seem to be the offsets, 250 the scale, 9130 the seeddiff, 3 octaves, 0.5 persistence.
Would the lua equivalent perlin pattern be ...

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local perlin1 = env:get_perlin(9130, 3, 0.5, 250)
local noise = perlin1:get2d({x=pos.x + 150, y=pos.z + 50})
?

Since 0.6 * 250 = 150 and 0.2 * 250 = 50.

I want to get a grip on the pattern used for desert biomes :)
Last edited by paramat on Thu Jan 17, 2013 04:46, edited 1 time in total.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Fri Jan 18, 2013 05:15

I found a way to test this and the answer is yes, sorry to bother you with the question ;)
Last edited by paramat on Fri Jan 18, 2013 22:39, edited 1 time in total.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

by Casimir » Fri Jan 18, 2013 17:30

I hope you will use that for your conifers mod. I really like it, but is always looks strange when they spawn at the edge of the desert.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Fri Jan 18, 2013 22:39

Funny you post that i am about to do exactly that for perlin conifers ongen 0.1.2.
Last edited by paramat on Sat Jan 19, 2013 01:27, edited 1 time in total.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 17 guests

cron