sticky

Hello,

I would like to start this thread as hopefully a complete how-to with 3D Landscapes until the documentation is availalble.

Here are my initial questions:

These would pertain more for those that want a shooter or mmorg, but useful for all!

1.) How would one load a 3d heightmap and view it
2.) How can you apply splatting to the landscape using alpha maps
3.) How can one go about paging the landscape ie: each sector would be (say 512 x 512) - how can you load/unload the maps to save resources.
4.) Performance - why choose .png over .bmp or .jpg for heightmap, alphamp and textures



Re: XNA Game Studio Express Loading 3D Landscapes

CodePfo

I wouldn't hold my breath for documentation in XNA on how to make 3d landscapes. Their are many options, and the ones you use will be unique to your project. Search google or yahoo for all of your questions and then apply them to XNA. If you haven't worked with heightmaps and terrain before, I recomend the brute force approach as it will give you results much quicker than trying to implement geomipmap or a shader technique. If you plan on deploying to 360, writing a one-size-fits-all paging engine is going to be really difficult I would think.

I'm using brute force because I don't anticipate huge polygon counts in my game.




Re: XNA Game Studio Express Loading 3D Landscapes

Nick Gravelyn

sticky wrote:

4.) Performance - why choose .png over .bmp or .jpg for heightmap, alphamp and textures



Primarily because PNG contains not only the RGB components, but also an alpha channel which gives you 4 different values for each pixel with which you can create your terrain however you want. Another benefit of the PNG file is that it is (generally) smaller than BMP or JPG. This becomes especially apparent when using large sizes (2048x2048 for example).

As for textures, again, the benefit is the transparency. It allows to you texture a non-rectangular pattern on top of another texture without hiding the bottom one.




Re: XNA Game Studio Express Loading 3D Landscapes

Jon Watte

There is no real performance difference between PNG or TGA or JPG (except JPG doesn't have an alpha channel). If loading from disk time is a problem, the more compressed format will work better.

However, DXT compressed data will render faster (and load pretty fast, too), because it's compressed on the actual card, which the other formats are not (they are decompressed and uploaded as RGB(A)32).

Note that you can't even use PNG or JPG or TGA in XNA, because the content pipeline will convert the data to some compressed or uncompressed format. For performance, I would suggest using DXT5 compressed data. However, the default DXT converters in the XNA Studio all will chroma-key bright magenta to black/transparent, which means that they will all decompress and then recompress the data, leading to some quality loss if you provide the data in DXT5 format in the first place.

When it comes to splatting with an alpha map, assuming you have five terrain kinds, and a texture that maps four of the kinds on top of the fifth (using some format that decompresses to RGBA), and the mapping texture is mapped using coordinates 0-1,0-1 over your heightfield, and the "terrain type" textures are tiled 32 times across the same heightfield, here's the pixel shader:

// calculate a channel-mapped blended texture value
float4 mapping = tex2D(mappingTexture, texcoord.xy);
float2 mapCoord = texcoord.xy * 32;
float4 base = tex2D(baseTexture, mapCoord);
base = lerp(tex2D(overlayTexture1, mapCoord), base, mapping.x);
base = lerp(tex2D(overlayTexture2, mapCoord), base, mapping.x);
base = lerp(tex2D(overlayTexture3, mapCoord), base, mapping.x);
base = lerp(tex2D(overlayTexture4, mapCoord), base, mapping.x);
// now 'base' is your texture color; do lighting on it as usual

The compiler will be able to hoist the tex2D() calls to the beginning of the function (as they are all indepdent), so this shader is 2.0 compliant (the "3 dependencies max" rule is not broken).






Re: XNA Game Studio Express Loading 3D Landscapes


Re: XNA Game Studio Express Loading 3D Landscapes

sticky

Thank you everyone for your responses. I guess i need to decide how to proceed - i have invested a lot of time in TV3D 6.5 beta engine - if they were half as kind as you people i would never have looked elsewhere.

I pretty much (ok, kinda) understand what you are saying about the landscapes. In TV, i would just do something like this to add all of the splatting layers...

LandScape.GenerateLandscape(width, height, chunkx, chunky, etc...)

_LandScape.AddSplattingTexture(gMain.TVGlobals.GetTex(kvp.Key), 100f);
_LandScape.ExpandSplattingTexture(gMain.TVGlobals.GetTex(kvp.Value),
gMain.TVGlobals.GetTex(kvp.Key), 0);

just an example... looks like to do something like this in here, i would have to provide all of the implementation ...

I will do my research and look at the link you gave me, etc. so I can post better questions, or what i have found.

thanks,





Re: XNA Game Studio Express Loading 3D Landscapes

sticky

Is there a difference in the XNA tutorials and the GSE tutorials that use the XNA framework ie: will GSE hide the complexities when creating landscapes (ie: using GSE will i still have to do all of the math, etc figuring out where the vertices go )

thanks,





Re: XNA Game Studio Express Loading 3D Landscapes

Jon Watte

There is no way to use XNA without GSE. GSW does not hide the math.





Re: XNA Game Studio Express Loading 3D Landscapes

Jim Perry

Sure there is. People have gotten XNA to work using Visual Studio and not the C# Express IDE (at least beta 2, I'm not sure about 1.0).




Re: XNA Game Studio Express Loading 3D Landscapes

BLiTZWiNG

You can use XNA without GSE, you just don't get access to the content pipeline, though I did see Shawn say in a reply that he could make the content pipeline a seperate entity to download, seperate of the XNA framework, if developers wanted it that way.

I think that'd be pretty kewl too.