| Catalin 的个人资料Catalin 's Blog日志列表 | 帮助 |
|
|
8月31日 Mass Effect Release Date Announced!The release date for my most anticipated game has just been announced. It's November 20 for U.S. and November 23 for Europe. For those who don't know, Mass Effect is a Sci-Fi Roleplaying Game made by none other than BIOWARE, the company that gave us Baldur's Gate, Neverwinter Nights, Star Wars: KOTOR, and Jade Empire. For more information about the game, go to the official page, where you can see some screenshots, or watch some videos. Can't wait to get my hands on this one. 8月25日 XNA Gamefest Videos Online!The videos from the first day of Gamefest are online! Check them out here. 8月24日 Introduction to Vertex Textures
Ever since the appearance of programmable GPUs, there has been a significant difference between the capabilities of vertex and pixel shaders. Shader Model 3.0 took the first steps in providing common functionality between the two, and DirectX 10 took the final step and unified the Instruction Set between all types of shaders (Pixel, Vertex and the new Geometry Shaders). Since this is a XNA blog, and I didn't have the chance to experiment with DirectX10, I will focus on one feature of Shader Model 3.0 that builds towards this unification, which is Vertex Texture Fetch ( VTF ). This article will only be introductory, with little to no actual code. But a full tutorial will follow, covering several effects that can be achieved using VTF. As you probably know by now, traditionally, Vertex Shaders deal with transforming the vertices, and manipulating or setting properties like position, color, normal, texture coordinates. After this, vertices define triangles, which are then transformed into pixels. At this step, Pixel Shaders come into play, and can be used for texturing, bump mapping, normal mapping, and lots of other effects we all love. Vertex Texture Fetch allows us to read data from textures inside a Vertex Shader, just like Pixel Shaders do. Actually, not EXACTLY like Pixel Shaders do, there are some limitations, but I'll come back to that in a moment. To use VTF, you will need either an Xbox 360 (which has an unified shader architecture), or a NVIDIA graphics card from the GeForce 6 series, or greater. For those owning ATI GPUs there is another technique called Render To Vertex Buffer (R2VB), which can be used to achieve similar results. The assembler function used to read textures in a Vertex Shader is texldl. However, since I like HLSL more, and never wrote a shader in asm, I'll talk about the HLSL version. So, in HLSL, the most important instruction used for VTF is tex2Dlod. The usage is tex2Dlod( s , t ), where s is a 2D texture sampler, and t is a 4 component vector. The instruction reads a texture, using an user-defined mipmap level. This mipmap level is specified through the 4th component of the texture coordinate vector ( t.w ). Depending on the application you might get to use the mipmap level, or not. In most cases, I've used the default level 0, so a usual call took the form:
Different mipmap levels can be used when you intend to simulate water or terrain using VTF, but the levels have to be computed manually. Vertex Textures behave like Pixel Textures except for the following restrictions:
Implementing bilinear filtering in vertex textures is not too complicated, and most times, the performance hit will not be too high, since neighboring pixels are usually present in the cache. Other types of filtering (trilinear, bicubic) can also be implemented, but they need more texture fetches, and use several mipmaps levels, so the performance hit is much higher. I will cover bilinear filtering in one part of the tutorial that will come soon. Keep in mind that a vertex texture fetch is not as fast as a pixel texture fetch, so using vertex textures carelessly can yield some serious performance hits. Some tips on improving performance when using VTF are:
That concludes the introduction to vertex textures. The tutorial will continue, and show some examples of what can be done using vertex textures. You can find a small sample that morphs terrain between two heightmaps, using vertex textures, here. It is for Windows, so you'll need a NVIDIA GeForce 6 series video card, or higher. Here is the Xbox 360 version, but I didn't get to test this before uploading it, since my Xbox is not available, at the moment. Note: the downloads are .ccgame packages, so you'll need to have XNA GSE 1.0 Refresh installed. I hope this was interesting enough. If you have any suggestions, or if there are any mistakes in my facts, please point them to me. 8月23日 First entry in my blogHi there! I've been thinking for a while to get my own blog started, but I just didn't have the time. I begin today, with this post. My name is Catalin Zima, and I am a student in Computer Science, at the Technical University of Cluj Napoca, Romania. "What will this blog be about?" Mainly, it will be about Microsoft's XNA Framework, XNA Game Studio, and game development, but from time to time, you will see posts about certain games or books that interest me most, like Mass Effect, or George R.R. Martin's "A Song of Ice and Fire". "What? Another XNA blog?" My intentions are not reinventing the wheel, nor saying what lots of others have said. Instead, I'll try to post about interesting techniques that I use in my games, or troubles I run into that others might run into themselves. My code may not always be of top-performance (unless it's a post on performance :) ), but it will try to illustrate ideas as clear as possible. First, some resources for those that want to start XNA:
That's about it, for now. My next entry (in a few days) will be a short introduction about a very cool feature of Shader Model 3.0, namely Vertex Texture Fetch, followed by a tutorial on several uses of VTF, sometime in the following weeks. Suggestions? Comments? |
|
|