How to use heat perlin map in mapgenv7

Post Reply
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 » Post

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:

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..

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: How to use heat perlin map in mapgenv7

by paramat » Post

Don't use biome_lib mod, use the biome heat noise parameters here (and ignore the heat blend noise)
https://github.com/minetest/minetest/bl ... ome.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 » Post

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

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.

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: How to use heat perlin map in mapgenv7

by paramat » Post

My mod code might help https://github.com/paramat/snowdrift/bl ... it.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 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 » Post

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:

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: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: How to use heat perlin map in mapgenv7

by TumeniNodes » Post

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:

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
A Wonderful World

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests