Jump to content
  • Advertisement
Sign in to follow this  
d1223m

terrain blending

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, im trying to produce a blendmap for my terrain. ive worked out the angle of each point and can do something like:
grass = rock = 0.0

if angle > some_specified_angle:
  rock = 1.0
else
  grass = 1.0

blendmap.put_pixel(x, y, color = [grass, rock, 0.0])

but how do i make it do a more gradual blend between the rock and the grass texture? i guess i have to introduce some range factor for the blend but i cant think how to do it thanks dunk

Share this post


Link to post
Share on other sites
Advertisement
you could just transform the angle to get your blending factors -
if (angle > pies)
if (angle < end blending threshold)
rock = (angle - threshold) * blending factor

or something of that sort. You can probably fit it all in to a single equation, ie, rock = angle*PI/34.54+e^angle, or whatever.

Share this post


Link to post
Share on other sites
sorry i dont understand [disturbed]

could you be more specific on the maths?

thanks for quick reply tho :)

Share this post


Link to post
Share on other sites
Please excuse me for assuming lack of knowledge, but it's really simple. I'd suggest looking up interpolation. Or just general maths.

I even attempted to copy your style. Aren't I nice...
rock = (angle - min_rock_angle) / (max_rock_angle - min_rock_angle)
if (rock < 0)
rock = 0
else if rock > 1)
rock = 1

BUT, before you use that, I'll walk you through it.

angle - min_rock_angle -We want the rock to start when angle gets above min angle. So by subtracting min angle, we have > 0 where rock is, < 0 where it isn't.
/ (max_rock_angle - min_rock_angle) -Max angle - min angle will give you the range of angles where rock goes from nothing to full. So if we divide our angle (currently between 0 and ?) by it, we will get no rock - full rock from 0 to 1, like we want.
Then just make sure the rockness is in a reasonable range.

Share this post


Link to post
Share on other sites
Quote:
Original post by RAZORUNREAL
Please excuse me for assuming lack of knowledge, but it's really simple. I'd suggest looking up interpolation. Or just general maths.


thanks, sometimes i just get a block and cant see the wood for the trees.

i get it now and am successfully using it



Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Kinda looks like an underwater scene, not knocking just commenting.

Share this post


Link to post
Share on other sites
How do you calculate the "angle"? There appears to be something wrong because the middles of all the rocky regions contain grass.

I would do it like this:
    // Assuming Z is up, and N is the normal and it its length is 1

factor = N.x*N.x + N.y*N.y; // Length (squared) of the projection of the normal on the XY plane
// Note: 1 is vertical terrain, 0 is horizontal terrain
lowThreshold = 0.5f; // tweak this
highThreshold = 0.7f; // tweak this
rock = ( factor - lowThreshold ) / ( highThreshold - lowThreshold );

rock = min( max( 0.0f, rock), 1.0f );

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!