Options:

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

14 Comments so far »

  1. by Catalin Zima - XNA and HLSL blog » Converting Displacement Maps into Normal maps, on 02.06.08 @ 3:46 am

    [...] on my VTF tutorial, I came across the need to apply lighting to a terrain. For lighting, we need normals, of course, [...]

  2. by Vertex shaders « xnacode, on 02.17.08 @ 11:36 pm

    [...] Found a nice tutorial on vertexshaders here. Nice intro to HLSL as [...]

  3. by Catalin Zima - XNA and HLSL blog » MVP going to Seattle :), on 04.02.08 @ 4:21 pm

    [...] wrote a number of articles, tutorials and samples, including: Deferred Rendering, Vertex Textures, Pie Menu component, Fog of War, and [...]

  4. by tiger shan, on 06.18.08 @ 8:46 am

    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

  5. by Catalin Zima, on 06.18.08 @ 4:33 pm

    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.

  6. by Peter, on 09.13.08 @ 1:34 pm

    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

  7. by Catalin Zima, on 09.14.08 @ 6:45 pm

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

  8. by wang dong, on 03.20.09 @ 3:12 pm

    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.

  9. by Armigus, on 04.29.09 @ 3:21 am

    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.

  10. by th, on 02.03.10 @ 7:30 am

    the Ziggyware link is broken…

  11. by Tim, on 02.08.10 @ 7:47 pm

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

  12. by Catalin Zima, on 02.08.10 @ 8:17 pm

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

  13. by lakstyo, on 02.10.10 @ 11:55 am

    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

  14. by Month Later, on 03.10.10 @ 8:48 pm

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

Comment RSS · TrackBack URI

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: