Thread: Terrain engine idea

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Terrain engine idea

    Ok some of you are going to think I'm crazy on this one and some of you might consider me a genius.

    If any of you have done raycasting you know that it is extremely fast when you split the rays into their component parts and then move through the map based on tangents one component at a time.

    The inherent problem with terrains is this: too many polies and while this can be solved using quadtrees and other algos I am going to present another possible solution.


    My idea is as follows. Create and or pre-compute a large terrain from a heightmap. Sectorize the map by assigning numbers to represent the sectors. Store each mesh in an array that represents each sector. For instance, sector 1 would represent ID3DXMesh MapMeshes[1] and so on.

    Create a small tile map much like wolfenstein or the old 2D tile maps. Then to draw the scene, simply raycast through the map based on tangents. When you hit a number, render that mesh to the screen if its visible - this can be tested quite easily using a z buffer. So let's say each mesh was 16x16 cells. You could represent a very large terrain with a minimal 2D map. The x,y and z positions of the meshes are easy to compute. Simply compute each mesh in local space - that is everything is centered around 0,0,0. Then translate the matrix by x*rayworldx,y*rayworldy,z*rayworldz. This would put the mesh in place where it needs to be. Of course more calculation would be needed to compensate for cell size but you get the idea. So in a sense we are still raycasting, but we are rendering meshes that represent the entire mesh.

    This technique would save on the number of actual primitives being drawn at one time because each mesh would have a set number of primitives. As well, you could render this extremely fast because only the 'sections' that lie within your view will be rendered. These sections are computed by the ray caster. If you render this front to back and store the tops of each column -that is the screen.y component of each vertex then this would be a fast render. If the y component of the vertex being rendered is above and beyond (on z) the y component of the one previously rendered there - draw it, else skip it. The z buffer is handled by D3D but the trick would be up to you - think about it. You won't see any terrain vertexes that are not higher on the screen than the highest vertex for that column of pixels. This presents more problems because not all vertexes will lie on columns - it would be possible that two vertexes would be connected and thus you would have to find the point at which that line intersects the desired column, but it could be done.

    With this method I think it would be possible to render extremely large distances with little trouble and the framerate would be very good.

    So what do you guys think?

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    i have no clue what you just said....
    My Website

    "Circular logic is good because it is."

  3. #3
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    i understood exactly what you said. raytrace only the tiles that get hit in the mesh. the problem i see is reflections. ie you will not know what gets hit or value changes unless you calculate a compairison value. to compair it with. i may be off on this but there might be somethings outside of the view that might need be changed so that it works correctly. good idea

  4. #4
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    implement it and see if it actually works

  5. #5
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    i think there might be some side-effects you havn't thought of...if it were that easy wouldn't game companies be using the same procedure?
    edit: my 800th post!! again!

  6. #6
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    you can't think of every possible problem until you actually DO something, now can you? It's a rhetorical question, don't answer.

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Well I'm not even sure its possible, but it sounds plausible.

    Right now I'm focusing on improving the visual detail and adding water - complete with water caustics using vertex and/or pixel shaders.

    Oh and about the remark don't you think that game companies would be using it....


    No, I don't. Very very very few companies completely write an engine from scratch, most are bought to speed up the design process. And with the attitude that it has already been done before or that the experts somehow know it all and we could never do something they haven't thought of.....will simply get you nowhere. Games are all about ingenuity and no...everything has not been done yet. The more I code in 3D the more I realize how many different effects, techniques, algos, etc., can be derived. There are so many effects to create and so many graphical boundaries to break that there is no way possible only a select few will do it. Games are where they are today really because of a collective effort between companies, programmers, artists, directors, gamers themselves, and indie developers. The field has come a long way but there is a long way to go and I'm not sure it will ever end. Quite exciting really.

    Oh and here is a shot of my hi-res terrain - but it suffers from wrapping which the trained eye will immediately catch.

    Coord you know of a way to multisample the texture being applied to each quad?? Perhaps lightmap it or something or alpha blend it with a diffuse greyscale texture?? Close up textures just get to blurry to be of any use.
    Last edited by VirtualAce; 04-01-2004 at 05:12 PM.

  8. #8
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    I don't think there's very much new theory to be sought. All of the paradigms that we could possibly take in terms of games have been thought of. The problem is getting stuff to work. The ideas of voxels (which are really just pixels with a depth component, or a 'volumetric pixel') have been around since forever, but there's no hardware that can support it, so the problem is implementation. In case you don't know, worlds built out of voxels take vast amounts of data. A given quake2 map converted to a voxel renderer takes over 3 GB of data (3-5MB in .bsp format before).

    The direction we are eventually headed in has already been laid out, which is true, realtime, omni directional ray tracing which perfectly simulates shooting photons in an infinite number of directions and interacts perfectly with surfaces. Everything will look 'real', but what we have got right now suffices.

    EDIT:
    Coord you know of a way to multisample the texture being applied to each quad?? Perhaps lightmap it or something or alpha blend it with a diffuse greyscale texture?? Close up textures just get to blurry to be of any use.
    I know how to do lightmapping, but again it's only in the context of OpenGL. I don't know if 'multi sampling' and multi texturing are the same thing. It isn't that hard to do once you have the texture information, at least with OpenGL. I have no clue what you guys do with direct doodle.

    EDIT1: wait, if you're talking about swapping textures so that it looks nice up close but gradually puts a crappier copy as it gets farther away, then look into mip mapping. And once again, Mr. Helpful over here only knows how to do it with OpenGL.

    EDIT2:
    as a side note, I think commanche, a helipcopter fighter game, was one of the only commercial games to pull off using a voxel based renderer for landscape
    Last edited by Silvercord; 04-01-2004 at 07:21 PM.

  9. #9
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169
    Quote Originally Posted by Silvercord
    but there's no hardware that can support it, so the problem is implementation.
    hmmmmmm that's really not so true anymore. 3d monitors are really taking off here and should be commercially available (fairly cheaply) in a matter of years. *dredges up some links*

    http://www.actuality-systems.com/ //this one has specs mentioning how many voxels it can display (i think)

    http://www.seereal.com/default.en.htm //uses opponent processing to make the object appear 3d, so im not sure it can really display voxels... maybe in cheater form tho

    http://www.dti3d.com/ //another opponent processing one. not too expensive tho.

    hmmmmmm there's a much better example of how cool 3d displays are, but i can't remember the website. they use a special projector that projects on a distilled water jetstream. the resolution is amazing and the size nearly limitless. you can also walk thru it

    sorry, just realized my post is pretty off topic. someone will find it interesting tho i hope.
    "uh uh uh, you didn't say the magic word"
    -Jurassic Park

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Terrain Screenshot and Discussion
    By Epo in forum Game Programming
    Replies: 28
    Last Post: 01-20-2006, 08:26 PM
  2. Start of updated terrain engine
    By VirtualAce in forum Game Programming
    Replies: 7
    Last Post: 06-16-2005, 09:25 PM
  3. Engine <=> DX/OGL | c++ ?
    By darkcloud in forum Game Programming
    Replies: 6
    Last Post: 05-13-2005, 12:19 AM
  4. DirectX engine nearing completion
    By VirtualAce in forum Game Programming
    Replies: 2
    Last Post: 01-12-2004, 05:07 PM
  5. Tile Engine Scripting Idea. Suggestions?
    By napkin111 in forum Game Programming
    Replies: 8
    Last Post: 07-28-2003, 02:01 PM