• Pingback: Catalin Zima - XNA and HLSL blog » Converting Displacement Maps into Normal maps

  • Pingback: Vertex shaders « xnacode

  • Pingback: Catalin Zima - XNA and HLSL blog » MVP going to Seattle :)

  • tiger shan

    Hey man, Your tutorials on terrain through GPU are great, I was wondering if you can post some sort of GRID SETUP for geoClipmap or optimize terrain performance tutorial for the terrain part.

    Thanks

  • http://www.catalinzima.com Catalin Zima

    I did not work with geoclipmaps so far, so I cannot help you on that one. Besides, the popular form of geoclipmaps (as seen on the pages I linked to) on the GPU using vertex textures is patented for now.

    Sorry.

  • Peter

    Hello. Could you tell me if is it possible to get somehow terrain height Y at position X,Y from shader or from morph texture? I was thinking about using your terrain in my game but I have to find somehow collisions?

    Cheers

  • http://www.catalinzima.com Catalin Zima

    Well, you could theoretically do GetData on the morph texture, but I’m not sure how performant that is.

  • wang dong

    In my computor, when I double click the *.sln file, a diagbox is poped-up ,showing that the *.csproj cannot be opend and the project type is not supported by this installation.

    My compile enviroment is Microsoft studio 2005, XNA Game Studio 2.0.

    I have also setup Microsoft Visual C# 2008 and XNA Game Studio 3.0

    None of these can open your project

    I have one XNA 2.0 demo project,and it is OK.

  • http://Addingquadtreestovertextextureterrains Armigus

    Your vertex textures work well for smaller terrains like in your example but how about much larger ones (4097×4097)? I have the foundation for an answer but I can’t get it to work yet.

    Part of the idea is to have the nodes of a quadtree maintain a Rectangle structure so that the leaves can have their own subset of the main texture:

    private Texture2D BuildTex()
    {
    Rectangle texArea = _region.Augment(1,1);
    int xl = texArea.Width;
    int yl = texArea.Height;
    Color[] data = new Color[xl*yl];
    _root.Map.GetData(0, texArea, data, 0, data.Length);
    Texture2D tex = new Texture2D(_root.Game.GraphicsDevice, xl, yl);
    tex.SetData(data);

    return tex;
    }

    QuadTerrain _root is the parent tree object reference for the nodes, and it maintains a Game reference and the main Texture2D Map. _region is the Rectangle and the Augment method is a custom extension method:

    public static Rectangle Augment(this Rectangle r, int dx, int dy)
    {
    return new Rectangle(r.X, r.Y, r.Width + dx, r.Height + dy);
    }

    The patchwork textures need common edges to stitch together properly.

    During update each node checks itself for frustum visibility:

    QuadNode:
    public virtual void Update(BoundingFrustum cone)
    {
    _enabled = cone.Intersects(_boundary);
    if (_enabled)
    for (int c = 0; c < 4; c++) _children.Update(cone);
    }

    QuadLeaf :: QuadNode:
    public override void Update(BoundingFrustum cone)
    {
    _enabled = cone.Intersects(_boundary);
    }

    The QuadTerrain, as a GameComponent, sets things in motion:
    public override void Update(GameTime gameTime)
    {
    _root.Update(_cam.Frustum);
    base.Update(gameTime);
    }

    My problem is that the leaves are not referencing separate pieces of the map as intended but are all showing the same part, and that part varies with camera location and direction! Each leaf has a separate effect cloned from the parent in QuadTerrain and its own texture clipped from the original, so this should not happen.

    The frustum culling works, BTW.

    I originally wrote because I was getting no terrain at all, but adding the Update method to QuadTerrain fixed that.

    I have way too much material for a more detailed disclosure right here. I can send you what I have minus the big map textures (25 MB and nearly incompressible), but you will need to email me with a return address first.

  • th

    the Ziggyware link is broken…

  • Tim

    Thats because ziggyware is gone, its been down for a while now and apparently for good :(

  • http://www.catalinzima.com Catalin Zima

    Sorry.
    I’ll try to repost it on my site when I get some free time.

  • lakstyo

    Hi,
    I think I really need your VTF article.
    Since I googled and can’t found reliable article abaut VTF in XNA, especially abaout implementing VTF in particle rendering.

    I hope you repost your article soon.
    Thank you.

    Regards

  • Month Later

    This looked good, hope you get time to repost this.

  • http://Website DragonSix

    I found the original files here: http://catalinzima.spaces.live.com/blog/cns!3D9ECAE1F2DC56EF!267.entry
    It’s on an old xna version, making it hard to understand and use. Hopefully you’ll find the time to upgrade those.

  • http://Website JG