How to use heat perlin map in mapgenv7

Griiimon
Member
 
Posts: 11
Joined: Sun Jan 08, 2017 13:20
IRC: TelepathicVampire
In-game: Griiimon

How to use heat perlin map in mapgenv7

by Griiimon » Fri Jan 13, 2017 21:18

I've tried to implement a function that returns the temperature at the player's position based on the heatmap supplied by mapgenv7 but the values fluctuate heavily even within a given biome.
I don't know anything about perlin noise but from the posts i read i figured out this code:

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
function getTemperatureAtPlayer(player)
            pos= player:getpos()
            noise = biome_lib.perlin_temperature:get2d({x=pos.x, y=pos.z})
            heat= -noise * 55 + 30
return heat
end



-noise * 55 + 30 will (roughly) translate the value to celsius

I'm not really sure what i am doing, only what i want to accomplish :)


For my purpose even knowing the biome at the player position would suffice. No success with that either..
 

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

Re: How to use heat perlin map in mapgenv7

by paramat » Sat Jan 14, 2017 20:49

Don't use biome_lib mod, use the biome heat noise parameters here (and ignore the heat blend noise)
https://github.com/minetest/minetest/blob/master/src/mg_biome.h#L138
 

Griiimon
Member
 
Posts: 11
Joined: Sun Jan 08, 2017 13:20
IRC: TelepathicVampire
In-game: Griiimon

Re: How to use heat perlin map in mapgenv7

by Griiimon » Mon Jan 16, 2017 00:53

I'm at a loss here. I've never used perlin noise before. The code i tried:

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
heatparam = {
   offset = 50,
   scale = 50,
   spread = {x=1000, y=1000, z=1000},
   seed = 5349,
   octaves = 3,
   persist = 0.5,
   lacunarity = 2.0
}

pos= player:getpos()

perlin= minetest.get_perlin(heatparam)
-- perlin= minetest.get_perlin_map(heatparam, {x=1000, y=1000, z=1000})
            
noise= perlin:get2d({x=pos.x,y=pos.z})
-- noise= perlin:get3d(pos)
            
minetest.chat_send_player(name, "Noise "..noise)


The values returned don't reflect temperatures of biomes in my tests.

Using perlin map and using the spread as size resulted in a crash, probably because the player pos was out of bounds.
 

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

Re: How to use heat perlin map in mapgenv7

by paramat » Mon Jan 16, 2017 01:09

My mod code might help https://github.com/paramat/snowdrift/blob/master/init.lua#L66
I think you need to round the position values before using with noise.
Don't use perlinmaps, they are for mapgen use.

Remember the value returned has an average value of 50 and varies roughly 75 either side of 50, it's not in celcius, compare the value to the diagram here https://forum.minetest.net/viewtopic.php?f=18&t=15939
 

Griiimon
Member
 
Posts: 11
Joined: Sun Jan 08, 2017 13:20
IRC: TelepathicVampire
In-game: Griiimon

Re: How to use heat perlin map in mapgenv7

by Griiimon » Mon Jan 16, 2017 02:28

Thank you so much! Couldn't have done it without your advice.

For anyone how needs it, here is a function that returns an approximation of the temperature at a given position in celcius based on the mapgenv7 heat map:

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
heatparam = {
   offset = 0,
   scale = 1,
   spread = {x=1000, y=1000, z=1000},
   seed = 5349,
   octaves = 3,
   persist = 0.5,
   lacunarity = 2.0
}

function get_temperature_at(pos)

   perlin= minetest.get_perlin(heatparam)
   noise= perlin:get2d({x=math.floor(pos.x),y=math.floor(pos.z)})

   noise=noise+0.1
   
   adjust= math.sqrt(math.abs(noise))
   if(noise < 0) then
      adjust= -adjust
   end
   
   temperature= adjust * 30 + 10

   return temperature

end
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: How to use heat perlin map in mapgenv7

by TumeniNodes » Tue Jan 17, 2017 17:43

Griiimon wrote:Thank you so much! Couldn't have done it without your advice.

For anyone how needs it, here is a function that returns an approximation of the temperature at a given position in celcius based on the mapgenv7 heat map:

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
heatparam = {
   offset = 0,
   scale = 1,
   spread = {x=1000, y=1000, z=1000},
   seed = 5349,
   octaves = 3,
   persist = 0.5,
   lacunarity = 2.0
}

function get_temperature_at(pos)

   perlin= minetest.get_perlin(heatparam)
   noise= perlin:get2d({x=math.floor(pos.x),y=math.floor(pos.z)})

   noise=noise+0.1
   
   adjust= math.sqrt(math.abs(noise))
   if(noise < 0) then
      adjust= -adjust
   end
   
   temperature= adjust * 30 + 10

   return temperature

end


I'd die... I can't adjust for celcius : ( (uhhhh, why can't everyone just be American...? ) :D
Flick?... Flick who?
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 8 guests

cron