Tài liệu 3D Game Programming All in One- P16 docx

30 291 0
Tài liệu 3D Game Programming All in One- P16 docx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Then choose Image, Rotate, Free Rotate to get the Free Rotate dialog box (see Figure 11.9). Click the Right button in the Direction frame, and click the Free button in the Degrees frame. Finally, type 1.00 in the text box next to the Free button, and click OK. This will rotate the selected area 1 full degree to the right (see Figure 11.10). You should have your rotated area with the selection mar- quee still surrounding it. Don't touch anything yet—leave the selection as it is. Now after having explained the Crop tool, I'll show you another way to crop the image that is sometimes more convenient than using the Crop tool. With the rotated area still selected, choose Image, Crop to Selection and the image will be cropped for you! You will then end up with an image as shown in Figure 11.11 suitable for use as a texture. Now compare Figure 11.11 with Figure 11.7 and you will see the difference. Original Artwork The other approach to creating textures is to use original artwork. Some people believe this is not a real option for them, because they think they can't draw or paint to save their lives. I tend to feel that everyone can learn the techniques required. My intent here, however, is not to teach you how to draw, so if you want to learn more, I encourage you to look into tak- ing some lessons. If you are satisfied with your artistic skills, then you have another rich avenue for texture gen- eration available to you. The techniques used to convert a photograph to a texture can also be used to convert your hand-made images to textures. Another approach for creating original artwork is to create your images directly in a tool like Paint Shop Pro. You can draw freehand using the mouse or a pen tablet. Sources 357 Figure 11.8 Rectangular Selection tool icon. Figure 11.9 The Free Rotate dialog box. Figure 11.10 The rotated woodgrain. Figure 11.11 The cropped woodgrain image. Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. With tools like Paint Shop Pro you have a wide variety of means for creating textures, including a specific Texture Effects tool in the Effects menu, as shown in Chapter 8. Figure 11.12 shows examples of textures created using the built-in features of Paint Shop Pro. I encourage you to explore this tool in depth. It can really be a timesaver. And you can use it to create some knockout textures. Scaling Issues When creating your textures, you will need to pay attention to the issue of scale. The sizes of the things within an image that is used to make a texture have a particular relationship to other real-world objects. We are subconsciously aware of many of these relation- ships from our exposure to the world in general and will notice when the textures are out of proportion to the items they adorn. If it's bad enough the effect can sometimes be similar to the sound of fingernails being dragged across a chalkboard! Figure 11.13 shows two stylized houses. The bricks in house A are far too large, while the bricks in house B are more appropriately sized, yet may still be a bit too large. Yes, there are some uses for stone blocks having proportions such as those in house A, but they are rarely used in bungalow-sized or two-story homes, as depicted in the figure. The scale issue can pop up anywhere, as you can see in Figure 11.14. The texture image in the corrugated metal bridge surface is probably about 10 times larger than is appropriate. Sometimes you might need to redo the texture to match—other times you can adjust how the texture is applied to the polygons using the modeling tools. My rule of thumb is that if the texture image size is 64 pixels by 64 pixels or smaller and needs to be made larger, you should make a new texture at the larger size. The same goes the other way: If the image size Chapter 11 ■ Structural Material Textures358 Figure 11.14 Scaling error. Figure 11.13 Scaling bricks. Figure 11.12 Example textures. Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. is larger than 64 pixels by 64 pixels and needs to be made smaller, then make a new tex- ture at the smaller size. Tiling Many structures have large surfaces with repeating patterns. The best way to approach making textures for these surfaces is to create one smaller texture that is replicated many times across the surface, rather than simply making one large texture. The replication will usually take place in two dimensions. It is important to make sure that the edges of the texture align properly when they meet. Figure 11.15 shows this to good effect. You can see the obvious horizontal as well as the more subtle artifacts in house A where the tiled brick textures don't quite line up. In house B, where care was taken to ensure that the texture edges matched up correctly, those artifacts aren't visible. However, in house B in Figure 11.15 there is another obvious artifact of tiling, this time caused by asymmetric lighting effects in the texture shading. You can see each repeated texture tile—its position is marked by the presence of the darker shaded bricks in a repeated pattern. This effect can be quite subtle and difficult to detect in an image viewed in isolation. Figure 11.16 shows the texture used in house B of Figure 11.15. Looking at it in isolation, you would be hard pressed to notice the subtly darker shaded bricks. The simplest way to fix up a texture for use as a tiled tex- ture is to copy the left edge, about 5 or 10 pixels wide, mirror the copy horizontally, and then paste the copy on the right side of the image. Do the same for the bottom edge. Of course, you can go from top to bottom or right to left as well. The important step is the mirroring. After placing the mirrored edges, spend a little time blending their inner edges with the interior portions of the image. Figure 11.17 shows a stone block texture that is a candi- date for use in a tiling situation. Figure 11.18 shows the texture tiled in a set of four. Again, you can see the artifacts caused by the mismatched edges. Tiling 359 Figure 11.15 Tiled brick texture. Figure 11.17 A stone texture. Figure 11.16 The brick texture with asymmetric shading. Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Figure 11.19 shows the left edge being copied, mirrored, and placed on the right. Figure 11.20 shows the same thing happening with the bottom edge. Finally, Figure 11.21 shows the tiled result. Texture Types There are far too many texture types and class- es of material appear- ances for me to enu- merate them with any sort of thoroughness. Given that, there is a much smaller set of tex- ture types that are found over and over in nature and man-made structures. Most of the following textures are types that are used for buildings, bridges, and other man-made items in a game world. Irregular Irregular textures tend to have a general disorder and random appearance, like that shown in Figure 11.22. Dirt and grass are examples of irregular textures. Quite often irregular textures are combined with other, different irregular textures in order to give a weathered or dam- aged appearance to an area or surface. Chapter 11 ■ Structural Material Textures360 Figure 11.18 Poorly tiled stone texture. Figure 11.19 Replicating the left edge. Figure 11.20 Replicating the bottom edge. Figure 11.21 Properly tiled stone texture. Figure 11.22 An irregular texture. Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Rough Rough textures, as shown in Figure 11.23, sometimes have somewhat the same sense about them as irregular textures. They are often used as tiles on a surface like a sidewalk or rough concrete walls. Pebbled Pebbled textures are another example of textures often used for paved surfaces and stone walls. Tarmacadam pavement is an example of a finely pebbled surface when viewed from a distance of about 5 or 6 feet. Figure 11.24 shows a more obvious pebbled texture that could be used for a wall or deco- rative planter. Woodgrain Figure 11.25 shows a woodgrain texture that has many highly variant bundles of lines rang- ing from fine to coarse that run roughly parallel to each other, sometimes interrupted by swirls and knots. Some kinds of stone have similar appearances. Smooth We all know when something is smooth—there are no discernable bumps or irregularities to our touch. Depicting smoothness in textures can be a little diffi- cult. We usually create a rather bland surface look and then introduce a few soft and mild irregularities in order to emphasize the smoothness. Figure 11.26 shows a smooth texture. Texture Types 361 Figure 11.23 A rough texture. Figure 11.24 A pebbled texture. Figure 11.25 A woodgrain texture. Figure 11.26 A smooth texture. Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Patterned Patterned textures are pretty straightforward. The intent is not necessarily to convey the contour, bumpiness, or feel of a surface, but rather to represent regular shapes or patterns that appear on an item. Figure 11.27 depicts a pattern that could be used to represent the louvers of an air duct in a wall. Fabric Fabric textures emulate the appearance of things like canvas or carpet. Fabrics may be woven or not, but they all tend to exhibit fine repetitive shapes. Figure 11.28 shows a woven fabric texture that could be canvas. Metallic Metallic textures tend to have a dominant color, with a strong dark shadow that follows the outer contours of the metallic object and a bright accent color that runs along raised surfaces. Figure 11.29 shows a texture that could be used for a metal tube. Reflective A reflective texture simulates the effect of a light source in the scene reflecting strongly off the surface of the tex- tured object. Figure 11.30 is such a texture that might be depicting a bright overhead light reflecting off a window. Plastic Plastic textures are sim- ilar to metallic textures in their manner of shading and highlight- ing. Plastic tends to have more of an oily appearance to it at times, so the shading and highlights are often more sinuous. As shown in Figure 11.31, Chapter 11 ■ Structural Material Textures362 Figure 11.27 A patterned texture. Figure 11.28 A fabric texture. Figure 11.29 A metallic texture. Figure 11.30 A reflective texture. Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. the highlights tend to be less clearly defined than with metallic textures, while the light source often appears as a distinct highlight. Moving Right Along In this chapter, we examined how to collect images to use in applying textures to objects that represent real-world structures. We saw some of the processing techniques that we may need to use to prepare our images for use as tex- tures, like color matching and cropping. Some of the areas that can be more problematic when considering textures for structures are scaling the images and preparing them to be "tiled" if the texture will be used in a repeating fashion. A texture that can be tiled is one whose opposite edges can be mated together without producing a noticeable seam. Finally, we explored some of the more common texture patterns and characteristics that are used in games. In the next chapter, we will look at terrains, which are often used to provide that touch of realism in our game worlds. Some of the ideas we've covered in this chapter will certain- ly be useful in the next chapter as well. Moving Right Along 363 Figure 11.31 A plastic texture. Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. This page intentionally left blank Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 365 Terrains chapter 12 M any games take place exclusively inside buildings or structures, like tunnels. And many other games involve exclusive outdoor game play. Then there are some games that have a mix of each. When your game has an outdoor component, you need to represent the terrain, which in game terms is the combination of the topography (hilliness, for example) and ground cover (grass, gravel, sand, and so on). The topography is modeled using a 3D model, and the ground cover is represented by textures. In addition to representing the ground, you also need to represent the sky, if you want to have interesting outdoor game play. Typically, a construct called a skybox is used to repre- sent all of the sky, from horizon to horizon. Terrains Explained To understand terrains in a game development context, we need to look at the characteristics of the terrain we want to model. These characteris- tics will drive our need for the data that defines the terrain we want to make and therefore will heavi- ly influence how and where we obtain that data. Terrain Characteristics A basic unit of terrain is the tile. Essentially a ter- rain tile is a collection of polygons that form a 3D model that represents the terrain, as depict- ed in Figure 12.1. Figure 12.1 An untextured terrain tile. Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. When we model terrain in a game, there are a number of choices we have to make. We need to decide the level of terrain fidelity we want to achieve. Another choice is to figure out the spread of the terrain. Finally, we need to decide what sort of freedom the terrain embodies. Table 12.1 lists characteristics and the ramifications of each of these choices. Chapter 12 ■ Terrains366 Table 12.1 Terrain Characteristics Characteristic Description Fidelity Terrain fidelity measures how accurately the terrain reflects real topography found somewhere in the world—how realistic it is. The realism can be reflected in both the modeling and the textures. Modeling fidelity can be described as any of the following: Realistic: Accurate at 1:1 scale in all dimensions with high-resolution textures representing the terrain cover. Semirealistic: Accurately scaled, usually to a smaller size. Often the vertical scale is 1:1 while the horizontal scales are around 1:2. The game World War II Online by Cornered Rat Software has all of Western Europe modeled in this fashion. The game uses medium-to-low resolution textures to represent ground cover. Quasi-Realistic: Not accurately scaled in any dimension, but still attempts to represent a real location in the world. Usually employs high-resolution ground cover textures. The scales and textures are chosen to give a sense of the locale that works well in the game environment. NovaLogic's Delta Force series takes this approach. Unrealistic: Everything else! Unrealistic terrain is most commonly used to specifically enhance game play or the backstory of the game. Spread Terrain spread is the degree to which areas of the terrain are unique. Terrain is created in units called tiles. The spread is related to these tiles in one of three ways: Infinite: A square terrain region is repeated, or tiled, in all cardinal directions, such that when the player leaves a region to the west, he enters a new copy of the same terrain tile from the east. This continues for as long as the player keeps moving in that one direction. Finite: The terrain tiles are repeated in all directions, but at some point the repetition stops. Untiled: Terrain tiles are not repeated. Freedom Terrain freedom is the measure of how much the player's in-game movements are restricted by the terrain. Terrain freedom is closely coupled with terrain spread. There are really only two degrees of terrain freedom: Closed: Closed terrain limits player movements in all cardinal directions at some point. With closed terrain, at some point after a player has been moving in a particular direction, he cannot continue that way, either because there is a virtual physical barrier or because the program prevents further movement. In any case, the terrain is usually modeled beyond the barrier only as far as the player can see. After that—nothing. Open: Open terrain allows player movement in any direction for as long as the player wants. Some games will warp the player to the "other side" of the world, where he will keep crossing terrain tile copies until he returns to the place he started. Team LRN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... that does not in any way imply that it is not a capable program, especially in the low-poly world that computer games inhabit In fact, the stripped-down nature of MilkShape certainly makes it easier to learn than most of the "big boys." Installing MilkShape 3D If you want to install only MilkShape 3D from the enclosed CD, do the following: 1 Browse to your CD in the \MS3D directory (MS3D is the abbreviated... model terrain in a 3D world In both cases 3D polygon models represent terrains In the external method we include the terrain as just another object in the game world This method offers much freedom of manipulation You can rotate the terrain model, skew it, and otherwise subject it to all manner of indignities All 3D engines support this approach While flexible, it is usually an inefficient way to render... texture In the bottom row from left to right are dirt, a muddy track, and eroded wet sand Tiling Unless you are going to create specific terrain cover textures for every square inch of terrain, you will end up tiling your terrain cover at some point All the issues brought up with tiling in other contexts apply here, such as matching texture edges to get seamless transitions and ensuring lighting in the... elevation information for specific coordinates of places on Earth DEM files can be converted to a format used by game engines called a height map We won't go into detail about how to use DEM data for your game, but you can use several of the resources listed in the appendixes to locate the data and tools needed Terrain Modeling There are basically two approaches that 3D game engines use to model terrain in. .. this, Terrain Manager terrains can sometimes be made larger and more complex than those created using other approaches Most 3D engines, like Torque, that use a Terrain Manager also provide terrain generation, manipulation, and editing tools that we can use to create our own terrains Usually importing height maps is available for terrain generation Some engines, like Torque, have built -in Terrain Editors...Terrain Modeling There are practical considerations that direct our terrain design choices Many game engines simply aren't capable of handling the distances involved in large-scale terrains or the number of objects required to appropriately populate them Some game genres aren't suited to open terrains—the player needs to be confined in order to advance the game story as required Terrain Data When... for obtaining real-world terrain data If we aren't modeling a real location, we've seen how we can create our own imaginary terrain using Paint Shop Pro, so that we can satisfy the needs of our game We also looked at terrain cover, and how to create images for use as terrain cover We also learned about some of the visual anomalies, like terrain tiling seams that might make our terrains less pleasing,... inefficient way to render complex large terrains Team LRN 367 368 Chapter 12 ■ Terrains The second approach is the internal method, where terrain is rendered by special code in the game engine often called a Terrain Manager Using the Terrain Manager approach allows game engine programmers to apply specific memory and performance optimizations to the terrain object, because they can discard unnecessary... gain is offset by the fact that our terrain will now be blockier and less realistic Figure 12.2 A terrain height map Figure 12.3 shows a terrain model generated from the height map shown in Figure 12.2 In this case MilkShape was used to import the height map and create the terrain object Team LRN Terrain Modeling Terrain Cover In the simplest sense, terrain cover refers to all the stuff that you find... X-axis in step 8 of this list Team LRN Figure 12.15 Terraform Editor Figure 12.16 The Operation dialog box 375 376 Chapter 12 ■ Terrains Figure 12.17 The Load File dialog box The white line in the map shows the terrain boundary, representing the extents of your terrain before repeating In the main 3D view, a green translucent box illustrates this boundary, as you can see in Figure 12.19 The terrain boundary . tools needed. Terrain Modeling There are basically two approaches that 3D game engines use to model terrain in a 3D world. In both cases 3D polygon models. where terrain is rendered by special code in the game engine often called a Terrain Manager. Using the Terrain Manager approach allows game engine programmers

Ngày đăng: 26/01/2014, 18:20

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan