Jump to content
  • Advertisement
Sign in to follow this  
multifractal

Sampling at the Edges of Heightmaps for Normal Mapping

This topic is 1415 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

Hello, 

I am creating heightmaps on the GPU and then using a Sobel filter to create a normal map for that heightmap. The Sobel filter works by sampling the 8 pixels surrounding a central pixel. The obvious problem is that when the central pixel is located on the edge of a heightmap the filter will not be able to sample all the edges. To resolve this problem I decided to expand the size of the heightmap from 256x256 pixels to 258x258 pixels. Then when I generate the heightmap for a particular quad I do the following: 


vec3 p = vec3(uv.x, 0.0, uv.y);

//size is the size of the current quad
p *= (size + 2);
p -= (1.0/(size + 2.0));
//'meshoffset' offsets the scaled meshes points from the origin
p += meshOffset;

when it comes to sample the heightmap I warp the UV coordinates like so: 


//the uv coordinates range from (0.0,0.0),(0.0, 1.0/17.0),(0.0, 2.0/17.0)...-> (1.0, 1.0)
uv *= (15.0/17.0);
uv += (1.0/17.0);

yet this still does not cause the edges to match up. 

 

Does anyone have any experience with this?

Thanks. 

Share this post


Link to post
Share on other sites
Advertisement
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!