US 7158135 B2
The number of graphic objects in a visual tile rendered varies as a function of distance between the tile and a viewpoint in a simulation. Fewer objects are rendered when the tile is far from the viewpoint, and vise versa. A level of detail (LOD) value is pseudo-randomly selected and associated with each object, indicating the maximum distance at which the object will be visible. A current LOD value is determined for the tile. An object is rendered if its LOD value is equal or greater than the current LOD value of the tile. Objects are faded into and out of view by modulating an opacity value as the current LOD value changes. Texture values of an object are adjusted as a function of ambient and direct components of light on the object, to achieve lighting corresponding to time of day, current season, and/or region in the simulated world.
1. A method for efficiently rendering graphic objects within a visual tile that is included in a plurality of visual tiles of an electronic simulation, so that a number of the graphic objects that are visible in the visual tile from a viewpoint varies with a distance between the viewpoint and the visual tile, comprising the steps of:
(a) for each graphic object in the visual tile, pseudo-randomly selecting a level of detail (LOD) value for inclusion in data defining the graphic object, said LOD value being thus associated with the graphic object and indicating a maximum relative distance between the viewpoint and the visual tile at which the graphic object will be visible in the electronic simulation;
(b) determining a current LOD value for the visual tile as a function of the distance between the visual tile and the viewpoint in the electronic simulation;
(c) comparing the current LOD value for the visual tile with the LOD values that were pseudo-randomly selected for each of the graphic objects in the visual tile to determine the graphic object that are visible for the current LOD value; and
(d) rendering and displaying each graphic object that is visible for the current LOD value of the visual tile, so that the number of the graphic objects visible in the visual tile increases as the distance between the visual tile and the viewpoint decreases.
2. The method of
(a) determining a seed value as a function of a location of the visual tile in the electronic simulation;
(b) generating the LOD value as a function of the seed value; and
(c) assigning the LOD value to the graphic object.
3. The method of
(a) detecting that the visual tile is within a predefined maximum range of the viewpoint;
(b) determining the distance between the visual tile and the viewpoint; and
(c) determining the LOD value associated with the distance that was determined in the preceding step.
4. The method of
(a) determining a mapping of a texture to a size of the graphic object according to an integral cell size of the texture such that an integral cell of the texture is not divided;
(b) applying the texture to at least one surface of the graphic object according to the mapping; and
(c) displaying the graphic object with the texture applied to the graphic object.
5. The method of
6. The method of
(a) a solid graphic object, such that the step of rendering the graphic object as the solid graphic object comprises the step of displaying a plurality of adjacent surfaces of the graphic object in accordance with the data defining the graphic object and by applying textures to each surface of the graphic object that is visible; and
(b) an orthogonal-plane graphic object, such that the step of rendering the orthogonal-plane graphic object comprises the step of displaying a pair of orthogonal planes in accordance with the data defining the graphic object and applying textures to the orthogonal planes.
7. The method of
8. A system for efficiently rendering graphic objects within a visual tile that is included in a plurality of visual tiles of an electronic simulation, so that a number of the graphic objects that are visible in the visual tile from a viewpoint varies with a distance between the viewpoint and the visual tile, comprising:
(a) a processor;
(b) a display in communication with the processor; and
(c) a memory in communication with the processor and storing machine instructions that cause the processor to:
(i) for each graphic object in the visual tile, pseudo-randomly select a level of detail (LOD) value for inclusion in data defining the graphic object, said LOD value being thus associated with the graphic object and indicating a maximum relative distance between the viewpoint and the visual tile at which the graphic object will be visible in the electronic simulation;
(ii) determine a current LOD value for the visual tile as a function of the distance between the visual tile and the viewpoint in the electronic simulation;
(iii) compare the current LOD value for the visual tile with the LOD values that were pseudo-randomly selected for each of the graphic objects in the visual tile to determine the graphic object that are visible for the current LOD value; and
(iv) render each graphic object that is visible for the current LOD value of the visual tile, so that the number of the graphic objects visible in the visual tile increases as the distance between the visual tile and the viewpoint decreases.
9. The system of
(a) determine a seed value as a function of a location of the visual tile in the electronic simulation;
(b) generate the LOD value as a function of the seed value; and
(c) assign the LOD value to the graphic object.
10. The system of
(a) detect that the visual tile is within a predefined maximum range of the viewpoint;
(b) determine the distance between the visual tile and the viewpoint; and
(c) determine the LOD value associated with the distance that was determined in the preceding step.
11. The system of
(a) determine a mapping of a texture to a size of the graphic object according to an integral cell size of the texture such that an integral cell of the texture is not divided;
(b) apply the texture to at least one surface of the graphic object according to the mapping; and
(c) display the graphic with the texture applied to the graphic object.
12. The system of
13. The system of
This application is a continuation of prior patent application Ser. No. 10/096,217, filed on Mar. 11, 2002 now U.S. Pat. No. 6,952,207, the benefit of the filing date of which is hereby claimed under 35 U.S.C. § 120.
The present invention generally relates to automatically rendering scenery objects in a computer environmental simulation, and more specifically, pertains to efficiently rendering a variety of graphical objects in a visually realistic manner over a perceptible region of the computer environmental simulation.
Computer games and other applications that display a virtual environment often include background scenery to enhance the simulation of the environment. It is common to employ simple color patterns and/or other texture data to represent a terrain or other background surfaces in the environment. The background environment is often repetitively tiled using a relatively limited number of variations. Typically, these simple backgrounds are only two-dimensional (2D), and are not very realistic. However, 2D backgrounds can have much more complex and varied textures and may be designed to be computationally efficient in covering a large area in a simulated virtual environment.
To increase the realism of a simulation, three-dimensional (3D) scenery objects are sometimes used instead of, or in addition to, 2D backgrounds. For example, it is common to include 3D buildings, walls, vegetation, and other scenery objects in computer games. To provide even more realism, a well-known or easily recognized scenery object, such as a landmark or building, may be mapped to a specific location within the simulated environment corresponding to the location of the real object in the environment. Some simulations are thus able to provide very detailed scenery objects in a limited region of the simulated environment, but because of the labor involved, the detail is confined to a relatively small area. For instance, some automobile racing games include very detailed scenery objects that correspond to real buildings, traffic signs, trees, and other objects along some selected streets of cities in which auto races are held, but the remainder of the simulated streets of the cities lack detail and variety.
However, even with foreseeable increases in processor speeds and storage sizes, it is impractical to define, store, and render a scenery object corresponding to each real object over an extended area, such as an entire metropolitan area. The problem becomes even more significant when the simulated environment includes the entire surface of the Earth. Consequently, in prior art simulated virtual environments, 3D scenery objects are often used to simulate specific landmarks in only a few limited areas, while 2D terrain background is typically used in the remaining larger areas of the simulation. For example, as indicated above, it is common to provide 3D simulations of specific landmark buildings in the central portions of a metropolitan area, while using 2D terrain backgrounds in the outskirts.
Clearly, it would generally be desirable to provide more realistic 3D scenery throughout a simulated environment. One method to achieve this result is to pseudo-randomly populate 2D terrain backgrounds with 3D scenery objects that appear realistic, but do not necessarily replicate real objects in the environment. A method to pseudo-randomly generate data for such 3D scenery objects is described in a commonly assigned patent application entitled, “Automatic Scenery Object Generation,” which is filed concurrently. Rendering such automatically generated 3D scenery objects in real time requires a more efficient processing technique than is currently employed for rendering only a relatively few landmarks in limited areas. Landmark objects, or other fixed 3D scenery objects, can be preprocessed for efficient rendering, because their location, size, and other characteristics are known well before rendering is needed.
Similarly, some prior systems utilize a library of fixed 3D scenery objects to randomly populate a scene. Although the location of the objects may be randomly determined, the size, shape, texture, and other characteristics are predetermined. Thus, these library objects can be preprocessed for rendering in a manner similar to that used for landmarks or other fixed objects that are manually created and inserted into a simulated environment.
In contrast, the characteristics of automatically generated scenery objects may not be known unless and until it is determined that the scenery objects should be generated. For example, it is desirable to condition object rendering on whether the object is “within view,” or whether the object will be within view shortly, or whether the object is not viewable due to darkness, or upon other criteria that must be satisfied during execution of the simulation. Further, it would be more efficient and more realistic to only render objects that are within view, and to gradually fade in more objects as they become closer to a user's viewpoint. It would be desirable to have predefined object data, but only render those objects that satisfy criteria appropriate for the current circumstances of the simulation during execution. Similarly, it would be desirable to render objects with realistic lighting depending on current conditions in the simulated environment, including for example, the time of day, season of the year, and regional location of the objects in the simulated environment. To provide scenic variety with automatically generated realistic objects, it will be preferable to pseudo-randomly generate and render 3D scenery objects during execution of a simulation in an efficient manner that does not rely on significant preprocessing.
An important application for such efficient rendering of a simulated environment arises when providing a realistic terrain over which aircraft fly in a flight simulator program. A solution to the problems described above was developed for use in Microsoft Corporation's FLIGHT SIMULATOR 2002™ product, which was released for sale in 2001. Subsequently, others appear to have recognized the value of automatically generating a variety of scenery objects that are related to the underlying 2D terrain texture in a simulated environment and have released similar products. However, these other products do not appear to render scenery objects in a manner that obtains the desired efficiencies described above. For example, a freeware product called TERRAMODELS™, produced by Softlang Software and Allen Kriesman, Inc., reportedly generates scenery objects to populate the background landscape in a flight simulator program called FLY II™, which is sold by Terminal Reality, Inc. However, FLY II™ does not appear to vary the number of objects rendered at various distances from a viewpoint of the user, and does not appear to provide other rendering efficiencies discussed above.
The present invention is directed to a method and system for determining when to render a particular graphic object within one of a plurality of visual tiles in an electronic simulation, so that the rendering is efficient and more realistically portrays what an observer would expect to see as the distance decreases between the graphic objects and an observer's viewpoint. The determination is made as a function of a distance between the visual tile and the viewpoint in the electronic simulation. Graphic objects associated with the visual tile are pseudo-randomly associated with a plurality of different distance ranges such that fewer of the graphic objects are rendered when the visual tile is far from the viewpoint, and more of the graphic objects are rendered when the visual tile is closer to the viewpoint. Rendering of the graphic objects is initially triggered when the visual tile comes within a predetermined distance of the viewpoint. Additional graphic objects are then rendered as the distance decreases between the visual tile and the viewpoint. Conversely, some of the graphic objects are removed from the rendered view as the distance increases between the visual tile and the viewpoint.
Preferably, when a visual tile falls within a predefined maximum range from the viewpoint, a level of detail (LOD) value is pseudo-randomly selected for each graphic object in the visual tile and included in data defining the graphic object, which are associated with the visual tile. The LOD value indicates a maximum radial distance between the viewpoint and the visual tile at which the graphic object will be visible in the electronic simulation, i.e., a radial range of rings centered about the viewpoint within which the graphic object will be visible. Preferably, the LOD value is pseudo-randomly selected based on a seed value that is a function of the location of the visual tile in the simulation. During each frame, a current LOD value is determined for the visual tile and compared with the LOD values that were pseudo-randomly selected for each of the graphic objects in the visual tile. Graphic objects associated with the tile are rendered if they have the same LOD value as the current LOD value determined for the tile. Preferably, the graphic objects are faded into view and out of view by modulating an opacity value as the current LOD value is changing. When the current LOD value changes, the number of graphic objects that are rendered also changes, but by fading in or fading out the graphic objects over time, an abrupt change in the number of graphic objects that are rendered is avoided.
Each graphic object is preferably rendered as either a solid object with multiple adjacent surfaces (e.g., buildings) or as an orthogonal-planar object (e.g., trees or other vegetation). Textures are applied to the adjacent surfaces or orthogonal planes of these different types of objects. However, to prevent undesirable splits in the textures where surfaces adjoin, such as at a window or doorway, the textures are mapped to the size of a graphic object in increments of an integral cell size of the texture.
Another aspect of the invention is directed to efficiently rendering a graphic object based on conditions in the simulated environment. For example, the location of a light source, such as the sun, and an intensity of light incident on the graphic object are determined as a function of the time of day, the current season of the year, and/or the location of the graphic object in the simulated world. Similarly, the texture applied to the graphic object is selected as a function of the conditions in the simulated environment. The texture values at each point on the graphic object are further adjusted as a function of the light source direction and the intensity of the light incident on the graphic object. To make such adjustments, a normal is calculated for each surface of the graphic object, so that an ambient component and a direct light component can be determined relative to each normal. These light components are used to adjust the colors of the texture at each point. Each point (display pixel) on a surface of the graphic object is also adjusted by modulating the opacity value to cause the graphic object to fade into and out of view as noted above, or as the environment changes between day and night lighting conditions.
Another aspect of the invention is directed to a machine readable medium storing machine instructions for causing a processor to perform the steps of the method described above.
The foregoing aspects and many of the attendant advantages of this invention will become more readily appreciated as the same becomes better understood by reference to the following detailed description, when taken in conjunction with the accompanying drawings, wherein:
Exemplary Operating Environment
With reference to
A number of program modules may be stored on the hard disk, magnetic disk 29, optical disk 31, ROM 24 or RAM 25, including an operating system 35, one or more application programs 36, other program modules 37, and program data 38. A user may enter commands and information into PC 20 through input devices such as a keyboard 40 and a pointing device 42. Pointing device 42 may include a mouse, stylus, wireless remote control, or other pointer. Other input devices (not shown) may include a joystick, game pad, wheel, pedal, microphone, satellite dish, scanner, digital camera, digital video recorder, or the like. These and other input/output (I/O) devices are often connected to processing unit 21 through an I/O interface 46 that is coupled to the system bus 23. The term I/O interface is intended to encompass each interface specifically used for a serial port, a parallel port, a game port, a keyboard port, and/or a universal serial bus (USB). A monitor 47 or other type of display device is also connected to system bus 23 via an appropriate interface, such as a video adapter 48, and is usable to display application programs, Web pages, the simulated environment provided-by the present invention, and/or other information. In addition to the monitor, PCs are often coupled to other peripheral output devices (not shown), such as speakers (through a sound card or other audio interface—not shown) and printers.
As indicated above, the invention may be practiced on a single computing device; however, PC 20 may operate in a networked environment using logical connections to one or more remote computers, such as a remote computer 49. Remote computer 49 may be another PC, a server (which is typically generally configured much like PC 20), a router, a network PC, a peer device, or a satellite or other common network node, and typically includes many or all of the elements described above in connection with PC 20, although only an external memory storage device 50 has been illustrated in
When used in a LAN networking environment, PC 20 is connected to LAN 51 through a network interface or adapter 53. When used in a WAN networking environment, PC 20 typically includes a modem 54, or other means such as a cable modem, Digital Subscriber Line (DSL) interface, or an Integrated Service Digital Network (ISDN) interface, for establishing communications over WAN 52. One type of WAN commonly used for communication is the Internet. Modem 54, which may be internal or external, is connected to the system bus 23 or coupled to the bus via I/O device interface 46, i.e., through a serial port. In a networked environment, program modules depicted relative to PC 20, or portions thereof, may be stored in the remote memory storage device. It will be appreciated that the network connections shown are exemplary and other means of establishing a communications link between the computers may be used, such as wireless communication and wide band network links.
As noted above, a preferred embodiment of the present invention was initially developed as an automatic scenery generator to produce landscape as a background for aircraft flying in Microsoft Corporation's FLIGHT SIMULATOR 2002™ flight simulator program. In this exemplary embodiment, the invention makes use of underlying terrain data and automatically generated scenery object data in rendering scenery objects that overlay the terrain data. Information regarding the underlying terrain data and automatically generated scenery object data is described in applicants' concurrently filed patent application entitled, “Automatic Scenery Object Generation,” the drawings and specification of which are hereby specifically incorporated herein by reference.
Other architectural styles are provided in different texture files. Also, a separate texture file corresponds to a night-time version of texture 60. Other versions of a texture file may be included for winter conditions, e.g., when snow is partially covering the roof textures. Alternatively, different versions of the same wall and roof textures may be provided in a single texture file. In general, a number of wall and roof textures are preferably included in a single texture file to provide visual variety for the graphic objects. Further, utilizing a single texture file enables pipelining of the data in the texture file on a video card and minimizes loading different data for different texture files, thereby reducing memory access requirements and improving rendering speed.
Correspondingly, roof texture cells may need adjusting during rendering to fit the building width and depth. For example, roof texture 68 is adjusted to fit the building footprint. For sufficiently large building footprints, such as for industrial warehouses, multiple cells of a roof texture may be applied to cover the roof area rather than adjusting a single cell of the selected roof texture. Note, however, that it is preferable to avoid applying multiple cells of a pitched roof texture over a large area. Preferably, a pitched roof is applied only to buildings with a small footprint area, such as a house 94. Multiple cells of a pitched roof texture may be applied along a long thin building such that the crest of the roof parallels the long dimension of the building. However, to reduce computing complexity and maintain realism, it is preferable to avoid multiple crests over a large building and to avoid blending pitched roofs with intersecting crests.
Other scenery objects, such as vegetation, are preferably rendered as a simpler type of object. For example, a tree 96 is rendered as a pair of intersecting orthogonal planes. The tree texture is rendered on each of the orthogonal planes, providing a 3D appearance from most viewing angles.
Assignment of an LOD ring to an object is preferably made as a function of a seed value that is based on the location of the tile in relation to other tiles in the simulated environment. The seed value is used to initiate random assignment of an LOD ring for each object in the tile in a daisy chain fashion. In practice, the seed value is used by a random number function to generate a number that will fall in the range of an LOD ring. The generated number is then used as a seed value for randomly selecting another LOD ring for the next object in the tile. Thus, the LOD ring for each object in the tile is randomly determined, but each object in the tile will always be assigned its same LOD ring. Since the randomization process is initiated with a consistent seed value based on the tile location, the objects will be consistently rendered (or removed) in the same order. Additional scenery objects are rendered in the tile as the aircraft flies closer to the tile, and fewer are rendered in the tile as the aircraft flies away from the tile. LOD rings can be set at any increment of distance from the viewpoint. Each LOD ring preferably corresponds to a different increment or percentage of objects in the tile that will be rendered and visible.
After assigning an LOD ring to each scenery object of the tile, the Autogen module determines, at a step 114, what the current LOD ring is for the tile. The current LOD ring is the LOD ring in which the tile is disposed. In other words, a tile is in a specific LOD ring if the radial distance between the tile and the viewpoint (typically the aircraft) is between the inner and outer radial distances of the LOD ring, relative to the viewpoint. Based on the current LOD ring, the Autogen module determines, at a decision step 116, whether a batch of scenery objects were previously built for the tile at the current LOD ring. A batch of scenery objects for a tile may have been previously built when the simulated aircraft flew close enough to the tile to cause that batch of scenery objects to be built. However, the aircraft may have later flown far enough away from the tile such that the objects in the tile would nolonger be visible. If a batch of scenery objects were previously built and still remain in memory, the Autogen module accesses that previously built batch of objects, at a step 118. It is contemplated that previously built objects may be retained or cached in memory until some predetermined period of time lapses, until memory capacity is required for more recently built objects, until the distance from the viewing point exceeds some predetermined value, or until some other criteria are met.
If a batch of scenery objects was not previously built for the tile at the current LOD ring, the Autogen module selects the lowest-priority terrain class associated with the tile that has scenery objects associated with that terrain class. Multiple terrain classes may be associated with the tile in a prioritized order. For example, a suburban terrain class may be at a lower priority than an urban terrain class. Different types and sizes of scenery objects may be associated with each terrain class and masked or otherwise blended into the tile. For ease of processing, the scenery objects of each terrain class are processed together. Thus, at a step 120, the Autogen module selects the next lowest-priority terrain class to be processed. At a step 122, the Autogen module accesses data associated with an object of the selected terrain class and associated with an LOD ring corresponding to or radially outside the current LOD ring. With the object data, the Autogen module generates additional rendering data at a step 124, as necessary to build the object. Additional detail regarding step 124 is described below with regard to
At a decision step 128, the Autogen module then determines whether another object in the selected terrain class is associated with an LOD ring equal to, or radially outside, the current LOD ring. If another object is to be built, control returns to step 122. Once all of the objects have been built that are associated with an LOD ring that is equal to, or radially outside, the current LOD ring, for the selected terrain class, the Autogen module determines, at a decision step 130, whether another terrain class is associated with the tile to be rendered. If more objects must be built for another terrain class associated with the tile, control returns to step 120. When all of the scenery objects associated with an LOD ring that is equal to, or radially outside, the current LOD ring, have been built or accessed from a previously built batch of objects, the objects associated with an LOD ring that is equal to, or outside, the current LOD ring are rendered as described in further detail below.
As indicated above,
The Autogen module also determines a whiteness value to be applied to each wall of the building, at a substep 138. The whiteness value corresponds to the amount of ambient (i.e., diffuse) and direct light from a light source that is incident on each wall of the building. The whiteness value is used to adjust the texture color values on the wall and roof surfaces of the building. Specifically, for each surface of the building, a corresponding original texture color value from the texture file is multiplied by a combination of the ambient and direct light components of the light incident on the surface. In particular, a directional component of the direct light is determined with regard to each surface normal, and the directional component is added to the ambient light component for each wall of the building.
When the building is rendered for display, the sum of the directional component and the ambient component of the light incident on each surface are multiplied by each color value of the corresponding original texture at each point (display pixel) on the building. Preferably, the sum is limited to a value between zero and one, where the value of one represents pure white light. The above discussion can be summarized for each primary color value (i.e., red, green, and blue) by the following equation:
Once the lighting is determined, the Autogen module determines, at a step 140, a center of the building footprint relative to the center of the tile. Relative to the building center, the Autogen module determines a width, depth, and rotation angle of the building, at a step 142. The rotation angle of the building is relative to the orientation of the tile. At a step 144, the Autogen module then determines opposite corner points for the building footprint. From the corner points, the Autogen module creates a full building footprint, at a step 146. Control then passes to a step 148 via a connector A.
At a step 154, the Autogen module reads the building type from the previously generated object data. As indicated above, the building type may, for example, be a house, a warehouse, or a variety of multi-floor office or apartment buildings. The Autogen module determines, at a decision step 156, whether a pitched roof is appropriate for the building type. If a pitched roof is appropriate for the building type, the Autogen module calculates roof surface normals, lighting, color, and triangles for the roof surfaces, at a step 158. At a step 160, the Autogen module reads the wall texture data from the previously derived texture file. If the time of day indicates dusk lighting conditions, day-time wall texture data may be blended with night-time wall texture data to further enhance realism of the simulation. Similarly, the Autogen module reads the appropriate roof texture, at a step 162, and blends the day and night roof textures, if appropriate, based upon the time of day. At a step 164, the Autogen module sets an opacity value that is used to fade the building into or out of view as the radial distance of the building from the viewpoint changes between adjacent LOD rings. At this point all of the graphics data is defined for the building to be displayed.
At a step 176, the Autogen module reads the appropriate portion of the vegetation texture from the previously derived file. Preferably, the Autogen module also applies an alpha mask, causing the texture values to be transparent outside boundaries of the vegetation image. Specifically, the alpha mask has a color key outside an outline of the vegetation object. The color key indicates that the area outside the vegetation image should be transparent, so that the rectangular outline of the orthogonal planes do not appear in the simulation. The Autogen module also determines lighting for the vegetation object and adjusts the texture color values, at a step 178, in a similar fashion to that described above in regard to building objects.
When the rendering module has begun to display all building objects as a function of the LOD ring associated with the building objects and the current LOD ring, the rendering module also begins displaying other scenery objects. For example, at a step 186, the rendering module displays a vegetation object associated with an LOD ring that is equal to or beyond the current LOD ring. As described above, the vegetation object is displayed in two orthogonal planes. Vegetation objects are also preferably faded into or out of view, as described above. At a decision step 188, the rendering module determines whether another vegetation object is associated with an LOD ring equal to or beyond the current LOD ring. If another vegetation object is to be displayed for the current LOD ring, control returns to step 186. Once all scenery objects associated with an LOD ring equal to or beyond the current LOD ring have been displayed, control returns to a scenery database module that maintains overall control of scenery generation and rendering.
Although the present invention has been described in connection with the preferred form of practicing it and modifications thereto, those of ordinary skill in the art will understand that many other modifications can be made to the present invention within the scope of the claims that follow. For example, scenery objects may be rendered on a wall texture tile, on a tile of a fictitious world, or other background. Accordingly, it is not intended that the scope of the invention in any way be limited by the above description, but instead be determined entirely by reference to the claims that follow.