   [DONE]smoothing out my heightmap
  Hey!i just implemented heightmaps in my engine.Here is a screenshot of a heightmap in my incomplete RTS like gamehttp://img257.imageshack.us/img257/5839/72759396.jpgit's blocky...is it because:A) the texture i use in the example is too rough orB) my lighting algorithm is a bit simple orC) im missing something else?Thnx in Advance![Edited by - EternityZA on September 8, 2009 3:23:56 PM]
  Try converting your heightmap to a grayscale bitmap (if it isnt already) to visualize what it should look like.   ;  it looks like your using per face normals instead of per vertex normals. Your terrain also looks a bit lumpy, try bluring your heightmap too.   ;  per vertex lighting will help a bit but the best thing u can do isuse a normalmap to do the lighting   ;Quote:Original post by zedzper vertex lighting will help a bit but the best thing u can do isuse a normalmap to do the lightingLet's walk before we can run, though :-)I think the problem is twofold:As other have mentioned, use per-vertex normals andI don't know where it's coming from, but I can see that you've got nice smooth hills defined, but then you see to have applied some kind of noise that's offseting individual vertices by a bit... what does your source data look like?;  >>Let's walk before we can run, though :-)I dont know Ild say using a normalmap is prolly easier than calculating the normalsIt will look a lot better thats a given :)landscape is a special case, since all normals deviate from up, u dont need to calculate tangents/normals for the terrain, thus all u need to do is.create a normalmap in a program, eg photoshop/gimp have plugin's+ just draw that on the terrainwith egshading = dot( normalmap, light_direction );   ;  i used a little app called HME to generate the texture map as a bmp image which i convert to a TGA image in photoshop. It has a smoothing function that i have not used, il try that later, and if it doesnt give the desired effect i can just blur my texture in photoshop i guess.as for my normals. i currently calculate the normal of a triangle and then i assighn it to all 3 points of the triangle (is that what is meant by "using per face normals"?). Anyway i should just get the average normal for each point right? based on all the triangles connected to it (btw if a point forms part of for example 4 triangles and i have calculated the normals for all 4 of them how do i calculate the average normal?).i hope im understanding everything correctly so far.EDIT: heres an heightmap generated with HMEhttp://img193.imageshack.us/img193/8461/31172129.png(imageshack seems to have converted it to PNG format, hope it doesnt affect the image)   ;  wel il probely try alternitives later. for now il just stick with generating better normals since i need to do that anyway for all my other models.EDIT: TBH im not exactly sure what a normal map is and why would it look better than just useing normals?   ;  Yes, calculating the polygon's normal and applying to all three vertices is per-face normals. You should calculate normals for all your faces, then to generate per-vertex normals, average all the normals together for faces that share the same vertex.Nv = (Nf1 + Nf2 + Nf...) / NumberOfFacesThis will provide you with a per-vertex normal. This will definitely be an improvement.A normal map is simply a a texture which encodes the normal in it's RGB channels (R = X-Axis, G = Y-Axis, B = Z-Axis - however those are arbitrary since you can use whichever channels for whichever axis you wish, but this is the norm). This means that you have a per-pixel normal, which you then use in your fragment shader lighting calculations. However, that requires you to be using Shaders.It would probably be best for you to calculate the per-vertex normals, see whether that provides a look you're happy with. If not, you can very easily convert your existing heightmap texture into a normal map using the nVidia Photoshop plug-in or numerous tools available on the internet.   ;Quote:Original post by zedzI don't know, I'd say using a normal-map is probably easier than calculating the normalsIt will look a lot better thats a given :)Unless you're using a world-space normal map (the 'norm' is tangent space), you need to calculate correct per-vertex normals *and* binormals and tangents to perform normal mapping (so it is harder than per-vertex normals).