Graphics systems may be used to rasterize scenes to a computer display. Such systems may expose application programming interfaces (APIs) that allow a program to access specialized hardware features such as video card features that provide faster or specialized rendering. In rendering a scene, objects may be rendered to a target. To apply an effect to some portion of rendering, programs often switch the rendering target to an intermediate target and then apply the effect when compositing the intermediate target to a final target. In many graphics systems, switching targets is an expensive operation and may further degrade performance by causing cache thrashing.
Briefly, aspects of the subject matter described herein relate to applying effects to a target via compositing rendering layers. In aspects, an intent is determined and an area of a target copied to a surface based on the intent. Then, rendering may continue to the target without changing to another target. Later, the surface is composited back to the target to apply an effect to the target.
This Summary is provided to briefly identify some aspects of the subject matter that is further described below in the Detailed Description. This Summary is not intended to identify key or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
The phrase “subject matter described herein” refers to subject matter described in the Detailed Description unless the context clearly indicates otherwise. The term “aspects” should be read as “one or more aspects”. Identifying aspects of the subject matter described in the Detailed Description is not intended to identify key or essential features of the claimed subject matter.
The aspects described above and other aspects will become apparent from the following Detailed Description when taken in conjunction with the drawings, in which:
Exemplary Operating Environment
Aspects of the subject matter described herein are operational with numerous other general purpose or special purpose computing system environments or configurations. Examples of well known computing systems, environments, and/or configurations that may be suitable for use with aspects of the subject matter described herein include, but are not limited to, personal computers, server computers, hand-held or laptop devices, multiprocessor systems, microcontroller-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
Aspects of the subject matter described herein may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and so forth, which perform particular tasks or implement particular abstract data types. Aspects of the subject matter described herein may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
With reference to
Computer 110 typically includes a variety of computer-readable media. Computer-readable media can be any available media that can be accessed by the computer 110 and includes both volatile and nonvolatile media, and removable and non-removable media. By way of example, and not limitation, computer-readable media may comprise computer storage media and communication media. Computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by the computer 110. Communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared and other wireless media. Combinations of any of the above should also be included within the scope of computer-readable media.
The system memory 130 includes computer storage media in the form of volatile and/or nonvolatile memory such as read only memory (ROM) 131 and random access memory (RAM) 132. A basic input/output system 133 (BIOS), containing the basic routines that help to transfer information between elements within computer 110, such as during start-up, is typically stored in ROM 131. RAM 132 typically contains data and/or program modules that are immediately accessible to and/or presently being operated on by processing unit 120. By way of example, and not limitation,
The computer 110 may also include other removable/non-removable, volatile/nonvolatile computer storage media. By way of example only,
The drives and their associated computer storage media, discussed above and illustrated in
The computer 110 may operate in a networked environment using logical connections to one or more remote computers, such as a remote computer 180. The remote computer 180 may be a personal computer, a server, a router, a network PC, a peer device or other common network node, and typically includes many or all of the elements described above relative to the computer 110, although only a memory storage device 181 has been illustrated in
When used in a LAN networking environment, the computer 110 is connected to the LAN 171 through a network interface or adapter 170. When used in a WAN networking environment, the computer 110 typically includes a modem 172 or other means for establishing communications over the WAN 173, such as the Internet. The modem 172, which may be internal or external, may be connected to the system bus 121 via the user input interface 160 or other appropriate mechanism. In a networked environment, program modules depicted relative to the computer 110, or portions thereof, may be stored in the remote memory storage device. By way of example, and not limitation,
Compositing Rendering Layers
A layer may include objects of a graphics scene that are to be manipulated collectively, particularly, when individual manipulation on the objects of the layer may produce undesirable results. For example, depending on the Z ordering of the objects 210 and 215 and their transparencies, applying an effect of transparency to the objects 210 and 215 individually and sequentially may result in a different rendering than applying the transparency to the layer. For example, if a transparency of 60% is applied to each of the objects 210 and 215, the area within the intersection of the circle 210 and the square 215 may be rendered with one color if the circle 210 is rendered before the square 215 and with another color if the square 215 is rendered before the circle.
In addition, if it is desired to have whatever is drawn behind the layer show through the objects 210 and 215 at 50%, for example, and each of the objects 210 and 215 is assigned a transparency of 50%, then rendering the objects 210 and 215 individually and blending transparencies may cause the area of the circle 210 that is within the square 215 to have a transparency of 25%. This may cause less of whatever is drawn behind the layer to show through than desired.
To address this problem, the objects 210 and 215 may be flattened into a surface (e.g., treated as if both lie in the same plane) as shown in
Switching targets, however, from the main target to the intermediate target may cause performance degradation as previously mentioned. In order to avoid state changes that result from changing the target from the target 225 to a target including the surface 205, a copy of an area on the target 225 may be obtained and stored in memory (sometimes called a surface). After the copy is obtained, rendering to the target 225 may continue. After the target 225 is rendered, the copy may then be composited back (e.g., copied back while optionally applying an effect) into the target 225. When compositing the copy back into the target 225, a post rendering effect may be applied.
At block 310, a determination is performed as to the intent and properties of the effect. As an example of a property, a blur effect may have a property that it involves nine pixels for every rendered pixel. As examples of intent, an effect may be used to anti-alias pixels, change the transparency in some fashion, clip to a geometric mask, and other effects known to those skilled in the art. The intent of the effect may be thought of as the reason why the effect is applied.
The intent of the effect may be determined in various ways. For example, the intent of the effect may be determined via heuristics. For example, if the manipulation for each pixel involves other pixels, a blurring or sharpening intent may be inferred. As another example, an intent may also be determined via an identifier associated with the effect. The identifier may be passed via an API or method call, for example. In yet another example, the intent may be determined by the method called. For example, a call to a method associated with a blur effect likely indicates a blur intent.
At block 315, a determination is made as to capture and setup steps needed for the intent and properties of the effect. For example, a determination may involve determining an area affected by the effect. In an anti-aliased masking effect, for example, edges of mask(s) may be relevant whereas internal areas may not be relevant.
At block 320, areas of the target are selected to copy to another surface. At block 325, the areas are copied to the surface. At block 330, rendering continues to the main target. At block 335, the surface is copied back to the main target. While copying back the surface an effect may be applied.
At block 340, the actions stop.
In applying a geometric mask, a layer 405 upon which the mask is applied may include two shapes. When a program requests that a mask be applied, a determination may be made as to the intent (e.g., geometric mask) of the request as described previously.
Upon determining that the intent is to apply a geometric mask to the layer 405, an outer bound 415 of the geometric mask 420 and outer bound 410 of layer 405 may be found. Considering the relative positions 422 of the layer 405 and geometric mask 420, the outer bounds 410 and 415 may then be intersected to find an area of interest 425.
In addition, an inner bounds 430 of the geometric mask 420 may be found to determine an area that will not need manipulation. By intersecting the area of the outer bounds 415 that is outside the area of the inner bounds 430 with the outer bounds 410, an area 435 that needs to be copied may be found. This area 435 may then be copied to a surface and rendering may continue to the current target. Since a portion of layer 405 extends beyond the geometric mask outer bounds 415, the area of interest 425 should be used to constrain rendering of the layer 405.
After the rendering is completed, the area 435 copied to the surface may be composited with the target in accordance with the following formula:
T′=Eα*T+(1−Eα)*S
where T is target after the layer is rendered, T′ is the target after the surface is composited back into the target, S is the surface, and Eα is 1 inside the geometric mask 420 and 0 outside the geometric mask 420. Furthermore, Eα may be any value from 0 to 1, which allows for an anti-aliased interpretation of the geometric mask sampling and may produce higher quality results than aliased masking (often referred to as clipping).
When a layer is opaque, a source over blend with alpha scale effect applied to the layer (also known as the source) may be defined as:
T′=Eα*L+(1−Eα)*T
where Eα is the alpha effect, L is the layer, T is the current target and T′ is the target that results after applying the alpha scale effect. An alpha effect is any function that operates on alpha. Note that typically the alpha scale effect is applied on a pixel-by-pixel basis. Thus, each of the variables above may reference the color and alpha values of a pixel.
When a layer is not opaque, a source over blend with alpha scale effect may be defined as:
T′=Eα*L+(1−Eα*Lα)*T
where Lα is the alpha of the layer.
When applying an alpha effect in accordance with aspects of the subject matter described herein, the area of interest may be copied to a surface (S). Rendering may then continue on the main target until it is desired to composite the surface back to the main target. For example, source over blending of the layer may proceed as follows:
T′=L+(1−Lα)*T
Then, the target (now T′) may be updated to T″ as follows:
T″=Eα*T′+(1−Eα)*S
In blend operations, some graphics rendering systems, however, may not allow a factor Eα to be used with T′ in the same operation in which (1−Eα) is used with S. In such APIs, an alternative is to premultiply the Eα into the T′ before using a blend operation supported by such APIs as follows:
T′int=0+Eα*T′
T″=(1−Eα)*S+1*T′int
If the source S is opaque, more optimal actions may be taken when working with such APIs when compositing S back to the main target. For example, an intermediate source S′ may be created (within texture pipeline) as follows:
S′=(1−Eα)*S
Then the final target may be updated as follows:
T″=S′+(1−Sα)*T′
While some effects have been described above, it will be appreciated that other effects may also take advantage of aspects of the subject matter described herein. In essence any effect which can be generated by copying an area to a surface, continuing to render to the same target, and then compositing the surface back (with post-manipulation as needed) to the target may benefit from aspects of the subject matter described herein as changing targets may be an expensive operation.
Aspects of the subject matter described above may be performed by the video interface 190 and a program module of the program modules 136 described in conjunction with
As can be seen from the foregoing detailed description, aspects have been described related to compositing rendering layers. While aspects of the subject matter described herein are susceptible to various modifications and alternative constructions, certain illustrated embodiments thereof are shown in the drawings and have been described above in detail. It should be understood, however, that there is no intention to limit aspects of the claimed subject matter to the specific forms disclosed, but on the contrary, the intention is to cover all modifications, alternative constructions, and equivalents falling within the spirit and scope of various aspects of the subject matter described herein.
Number | Name | Date | Kind |
---|---|---|---|
5481669 | Poulton et al. | Jan 1996 | A |
5581670 | Bier et al. | Dec 1996 | A |
5617114 | Bier et al. | Apr 1997 | A |
5867166 | Myhrvold et al. | Feb 1999 | A |
5870098 | Gardiner | Feb 1999 | A |
5883627 | Pleyer | Mar 1999 | A |
6031529 | Migos et al. | Feb 2000 | A |
6177945 | Pleyer | Jan 2001 | B1 |
6369830 | Brunner et al. | Apr 2002 | B1 |
6570578 | Smirnov et al. | May 2003 | B1 |
6601057 | Underwood et al. | Jul 2003 | B1 |
6639594 | Zhang et al. | Oct 2003 | B2 |
6717584 | Kulczycka | Apr 2004 | B2 |
6734873 | Herf et al. | May 2004 | B1 |
6919891 | Schneider et al. | Jul 2005 | B2 |
7071937 | Collodi | Jul 2006 | B1 |
7106343 | Hickman | Sep 2006 | B1 |
7403209 | Liao et al. | Jul 2008 | B2 |
7474314 | Minchew et al. | Jan 2009 | B2 |
20030085904 | Kulczycka | May 2003 | A1 |
20030132937 | Schneider et al. | Jul 2003 | A1 |
20030197716 | Krueger | Oct 2003 | A1 |
20040015610 | Treadwell | Jan 2004 | A1 |
20040039934 | Land et al. | Feb 2004 | A1 |
20040075699 | Franchi et al. | Apr 2004 | A1 |
20050060759 | Rowe et al. | Mar 2005 | A1 |
20050132305 | Guichard et al. | Jun 2005 | A1 |
20050243086 | Schechter et al. | Nov 2005 | A1 |
20060066925 | Hasegawa et al. | Mar 2006 | A1 |
Number | Date | Country | |
---|---|---|---|
20070052722 A1 | Mar 2007 | US |