maconbot / FFWD

This is the FFWD framework for XNA, that allows you to port Unity3D games to XNA for use on WP7 or XBox360 (XBLIG)
Microsoft Public License
1 stars 0 forks source link

Terrain and collision with culling #1

Open maconbot opened 12 years ago

maconbot commented 12 years ago

I was researching culling last night from a terrain standpoint: http://www.dustinhorne.com/post/2011/10/18/XNA-Terrain-with-LOD-Part-7-Better-Culling-With-2D-Shapes.aspx ...Looks like he is at the beginning of implementing Billboarding the same way unity does with trees. Not sure if any methods here would be of interest.

Terrain integration: Option A: Creating heightmaps using unity's built in tools and then loading the heightmap in both unity and xna in similar ways: http://www.unifycommunity.com/wiki/index.php?title=HeightmapFromTexture ...converting to .cs of course. Not sure if Heightmaps are faster in XNA than dealing with an object? A heightmap to me is a little more cumbersome from a design standpoint, but there are tuts out there for how to do in XNA. The bigger question is the texture map.

Option B: Converting the terrain to an object and then can easily bring into XNA just as another object: http://www.unifycommunity.com/wiki/index.php?title=TerrainObjExporter

I would finally look at being able to walk on the terrain using a technique like this: http://forums.create.msdn.com/forums/p/81553/493416.aspx#493416

maconbot commented 12 years ago

The Terrain to .bmp Unity .js code did not work on link above. Still curious about .obj as it basically should be exported out as a .fbx when ran through FFWD.

Continuing on with height map path. Basically Unity will allow you to export as a raw, which so far I haven't been able to find a way to import into XNA. The Content Importer won't even let me. I try playing with the build action and can never get the code to find the file. This may be a newbie thing however. If I could import the Photoshop .raw file I have found some code to play with here on getting XNA to read the data: http://www.riemers.net/Forum/index.php?var=1313&var2=0

I was looking at riemers tutorial on working with terrains from height maps...but he never explains how to get it to work on xbox and I saw some of the readers ran into trouble with no answers... http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series4/Gradient_skybox.php

Bitmap heightmaps seems to be what the XNA examples are using...Indexed color - 8 channel. B/W obviously.

So I'm just moving forward with this workflow for now...

I did find some interesting ideas out there however most of them build in earlier versions of VS. Here are links: Riemers completed project I guess? http://robobattle.codeplex.com/releases/view/21264 And his additions following the blog here: http://dracocepheus.blogspot.com/2008/12/xna-terrain-rendering-lesson-5.html

Also eventually curious about the pluses and minuses of using Perlin Noise to create the Terrain: http://dracocepheus.blogspot.com/2008/12/terrain-generation.html and I found this generator with source code for VS: http://digitseven.com/HeightmapGenerator.aspx

If anyone more versed in XMA want's to update the above project and setup to work with XBOX...it would give me a starting point, as is for now just moving forward with the manual RAW to BMP conversion and will work out this step at a latter time if needed.

Still curious if I can get texture splat mapping to work in xna for the paint on the terrain. I found this example on exporting it to a PNG http://answers.unity3d.com/questions/16830/how-do-i-extract-a-texture-map-from-a-terrain.html however if we have a PNG rather than textures it will exhaust our resources. Ideally I'd like to export the splat map from Unity, and reuse in XNA along with the height map. The goal originally was to be able to do this automatically...but first steps first. Right now however I am looking at a process of saving the RAW...using Unity's Terrain>Export HeightMap to Raw... then open that raw in any of the free converters and save out as bmp.

As for now I will proceed with the limit of 4 textures and just do things simply, as one user suggested...get stuff done then go back and optimize once further down the road...though you have to admit figuring out Multitexture Splat Mapping with Alpha Blending would be pretty sweet! http://forums.create.msdn.com/forums/p/27837/153572.aspx

"To start with, focus on getting basic splatting working, where you do a separate alpha blended pass for each texture layer. That way you have no fixed limits and can use as many textures as you like.

Once you have the basics going, multitexturing is a possible optimization. For instance if you have a terrain cell that uses 11 different textures, instead of 11 draw calls, you could collapse this down to just 3 draw calls, using 4 mutlitexture layers in each. Mutlitexturing is not neccessary for correctness, though, just a possible way to boost performance once you get a bit further down the road." -Shawn Hargreaves