Four Uses of VTF

This article covers four possible uses of Vertex Textures and example implementations in XNA for these effects. The article was written for XNA Game Studio 1.0 Refresh, and is posted on Ziggyware, where it can still be found here.

Four Uses of Vertex Textures

morph.jpgparticles.jpgparticlescollision.jpgtough31.jpg

Ziggyware is dead for quite a while. The chapter can be found below:

Introduction

Heightmap Terrain Rendering

Terrain Morphing

Particle Systems

Steps in Snow

Conclusions

  • #1 written by tiger shan
    about 3 years ago

    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

  • #2 written by Catalin Zima
    about 3 years ago

    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.

  • #3 written by Peter
    about 3 years ago

    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

  • #4 written by Catalin Zima
    about 3 years ago

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

  • #5 written by wang dong
    about 2 years ago

    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.

  • #6 written by Armigus
    about 2 years ago

    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.

  • #7 written by th
    about 2 years ago

    the Ziggyware link is broken…

  • #8 written by Tim
    about 1 year ago

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

  • #9 written by Catalin Zima
    about 1 year ago

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

  • #10 written by lakstyo
    about 1 year ago

    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

  • #11 written by Month Later
    about 1 year ago

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

  • #12 written by DragonSix
    about 1 year ago

    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.

  • #13 written by JG
    about 1 year ago