WO2023193639A1 - Image rendering method and apparatus, readable medium and electronic device - Google Patents

Image rendering method and apparatus, readable medium and electronic device Download PDF

Info

Publication number
WO2023193639A1
WO2023193639A1 PCT/CN2023/084542 CN2023084542W WO2023193639A1 WO 2023193639 A1 WO2023193639 A1 WO 2023193639A1 CN 2023084542 W CN2023084542 W CN 2023084542W WO 2023193639 A1 WO2023193639 A1 WO 2023193639A1
Authority
WO
WIPO (PCT)
Prior art keywords
height
shadow
pixel
pixel point
scene image
Prior art date
Application number
PCT/CN2023/084542
Other languages
French (fr)
Chinese (zh)
Inventor
金祎
Original Assignee
北京字跳网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京字跳网络技术有限公司 filed Critical 北京字跳网络技术有限公司
Publication of WO2023193639A1 publication Critical patent/WO2023193639A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/10Geometric effects
    • G06T15/20Perspective computation
    • G06T15/205Image-based rendering
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/60Shadow generation

Definitions

  • the present disclosure relates to the technical field of image processing, and specifically, to an image rendering method, device, readable medium, electronic equipment, computer program product, and computer program.
  • a depth map of the scene is first rendered at the light source position, and then the entire scene is rendered at the camera, and compared with the previously rendered depth map to obtain the shadow effect of the scene.
  • the amount of data that needs to be processed for two scene renderings is relatively large, resulting in relatively low rendering efficiency.
  • the present disclosure provides an image rendering method, which method includes:
  • the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is at the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, And the height of the pixels in the height direction of the world space is greater than or equal to the preset height threshold.
  • an image rendering device which includes:
  • the image acquisition module is used to obtain the scene image to be rendered in the target scene
  • An image rendering module configured to determine, for each pixel in the scene image, a target shadow height corresponding to the pixel, and determine a shadow value corresponding to the pixel according to the target shadow height. Shadow values are used to render the pixels to render the scene image;
  • the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is at the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, And the height of the pixels in the height direction of the world space is greater than or equal to the preset height threshold.
  • the present disclosure provides a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processing device, the steps of the method described in the first aspect of the present disclosure are implemented.
  • the present disclosure provides electronic equipment, including:
  • a processing device configured to execute the computer program in the storage device to implement the steps of the method described in the first aspect of the present disclosure.
  • the present disclosure provides a computer program product, which includes a computer program.
  • the computer program When the computer program is executed by a processing device, the steps of the method described in the first aspect of the present disclosure are implemented.
  • the present disclosure provides a computer program.
  • the computer program When the computer program is executed by a processing device, the steps of the method described in the first aspect of the present disclosure are implemented.
  • FIG. 1 is a flowchart of an image rendering method according to an exemplary embodiment of the present disclosure.
  • FIG. 2 is a schematic diagram of a target shadow height according to an exemplary embodiment of the present disclosure.
  • FIG. 3 is a flowchart of another image rendering method according to an exemplary embodiment of the present disclosure.
  • Figure 4 is a schematic diagram of a shadow height according to an exemplary embodiment of the present disclosure.
  • FIG. 5 is a block diagram of an image rendering device according to an exemplary embodiment of the present disclosure.
  • FIG. 6 is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure.
  • the term “include” and its variations are open-ended, ie, “including but not limited to.”
  • the term “based on” means “based at least in part on.”
  • the term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one additional embodiment”; and the term “some embodiments” means “at least some embodiments”. Relevant definitions of other terms will be given in the description below.
  • a prompt message is sent to the user to clearly remind the user that the operation requested will require the acquisition and use of the user's personal information. Therefore, users can autonomously choose whether to provide personal information to software or hardware such as electronic devices, applications, servers or storage media that perform the operations of the technical solution of the present disclosure based on the prompt information.
  • the method of sending prompt information to the user may be, for example, a pop-up window, and the prompt information may be presented in the form of text in the pop-up window.
  • the pop-up window can also contain a selection control for the user to choose "agree” or "disagree” to provide personal information to the electronic device.
  • the current mobile perspective shadow solutions include Cascade Shadow Map algorithm, baked shadows, contact shadows, etc.
  • the Cascade Shadow Map algorithm is equivalent to rendering the scene twice during the processing process, and the corresponding Drawcall (drawing initiation) data volume will be relatively large, resulting in CPU (Central Processing Unit, Central Processing Unit) and GPU (Graphics Processing Unit) , graphics processor) is also relatively large, which affects the rendering efficiency.
  • CPU Central Processing Unit
  • GPU Graphics Processing Unit
  • graphics processor graphics processor
  • the present disclosure provides an image rendering method, device, readable medium and electronic equipment, which can determine the shadow value of the pixel point according to the target shadow height corresponding to the pixel point, and then determine the shadow value of the pixel point according to the shadow value. Rendering is performed so that the amount of data that needs to be processed during the rendering process is relatively small, thereby improving the efficiency of image rendering.
  • Figure 1 is a flow chart of an image rendering method according to an exemplary embodiment of the present disclosure. As shown in Figure 1, the method may include:
  • the target scene may be a game scene
  • the scene image may be an image that needs to be rendered in the game scene.
  • the target shadow height is the height of the specified pixel in the shadow of the scene image
  • the specified pixel is the same as the horizontal position of the pixel in the world space corresponding to the target scene, and is in the world space height square Pixels whose upward height is greater than or equal to the preset height threshold.
  • the preset height threshold may be the height corresponding to the pixel that has the same position in the height direction of the world space and the highest position in the horizontal direction of the world space.
  • Figure 2 is a schematic diagram of a target shadow height according to an exemplary embodiment of the present disclosure. As shown in Figure 2, the terrain in the scene image is rendered from a top-down perspective.
  • the target shadow height can be the world The intersection point of the straight line in the height direction of space and the straight line in the direction of the light source.
  • Shadow saturate(exp(MaxOcclusionHeight–C*positionWS.y)) (1)
  • Shadow is the shadow value
  • MaxOcclusionHeight is the target shadow height
  • positionWS.y is the y-axis of the coordinates of the world space corresponding to the pixel point
  • C is a preset constant
  • C can be pre-tested based on experiments. For example, C can be 20.
  • the function of the Saturate(x) function is to return 0 when the value of x is less than or equal to 0, to return 1 when the value of x is greater than or equal to 1, and to return 1 when the value of x is between 0 and 1. If the value is between , x is returned.
  • the shadow value corresponding to the pixel it means that the pixel is not in shadow.
  • the shadow value corresponding to the pixel When the shadow value corresponding to the pixel is 1, it means that the pixel is in shadow, and the color of the shadow is the darkest. , when the shadow value corresponding to the pixel is between 0 and 1, the corresponding shadow color can be rendered according to the size of the shadow value. For example, the larger the shadow value, the darker the color. The shadow value The smaller it is, the lighter the color can be.
  • the pixel After obtaining the shadow value corresponding to the pixel, the pixel can be rendered by referring to the rendering method in the prior art, which will not be described again here.
  • the shadow value of the pixel can be determined according to the target shadow height corresponding to the pixel, and the pixel can be rendered according to the shadow value. In this way, the amount of data that needs to be processed during the rendering process is relatively small, thereby improving image rendering. s efficiency.
  • Figure 3 is a flowchart of another image rendering method according to an exemplary embodiment of the present disclosure. As shown in Figure 3, the method may include:
  • the target scene may be a game scene
  • the scene image may be an image that needs to be rendered in the game scene.
  • the coordinates of the world space corresponding to the pixel, the pixel size corresponding to the height texture, and the proportion of the world space can be obtained to determine the corresponding coordinates of the scene image.
  • the offset value between the center point of the terrain and the origin of the coordinates of the world space corresponding to the pixel point, and the pixel is determined based on the coordinates of the world space corresponding to the pixel point, the offset value, the scale and the pixel size.
  • the texture coordinates corresponding to the point can be obtained through existing techniques, and will not be described again here.
  • the world space ratio corresponding to the height texture can be preset according to the scene image. For example, if the pixel occupies 1m*1m world space, the ratio can be 1. The smaller the ratio, the smaller the pixel in the scene image. The greater the density, the better the rendering effect.
  • (cellU, cellV) is the texture coordinate corresponding to the pixel point
  • positionWS.x is the x-axis of the coordinates of the pixel point corresponding to the world space
  • positionWS.z is the z-axis of the coordinates of the pixel point corresponding to the world space
  • HeightOcclusionStartPoint is The offset value
  • TexelsPerMeter is the proportion of the world space corresponding to the pixel
  • HeightOcclusionTex_TexelSize is the pixel size corresponding to the height texture.
  • the pixel size can be a quaternion, and the pixel size can be represented by a four-dimensional vector.
  • the four-dimensional vector can be Vector4(1/width, 1/height, width, height).
  • the height texture may include a shadow height corresponding to each pixel of the scene image.
  • the height texture can be obtained, and based on the texture coordinates of the pixel, it is determined whether the height texture is the same as the pixel.
  • Specified pixels corresponding to the target scene have the same position in the horizontal direction of the world space and have a height greater than or equal to the preset height threshold in the height direction of the world space.
  • the height texture can be obtained in advance in the following way: for each pixel in the scene image, determine the scene depth of the pixel in the direction of the light source in the scene image, and determine the scene depth corresponding to the pixel based on the scene depth. Shadow height, and a set of shadow heights corresponding to multiple pixels is used as the height texture.
  • the ShadowMap algorithm For each pixel in the scene image, you can refer to the implementation of the ShadowMap algorithm to determine the scene depth of the pixel in the direction of the light source in the scene image. Further, for each pixel in the scene image, after determining the scene depth of the pixel in the direction of the light source in the scene image, the terrain height corresponding to the pixel can be determined. After determining the position corresponding to the terrain height When in the shadow of the scene image, a preset height interval is obtained, and the shadow height corresponding to the pixel is determined based on the terrain height and the preset height interval.
  • the terrain height may be the height of a reference plane located directly below the pixel in the height direction of the world space coordinate in the scene image.
  • the reference plane may be the ground or the highest point of a tree.
  • the plane on which it is located, the terrain height can be obtained in advance based on the terrain in the scene image.
  • the preset height interval can be pre-tested based on the scene image. The smaller the preset height interval, the higher the accuracy of determining the shadow height. However, due to the relatively large amount of calculation, the performance will be poor. For scenarios with relatively high accuracy requirements and low performance requirements, you can set a smaller preset height interval. For example, the preset height interval can be 5m. For scenarios with relatively low accuracy requirements and high performance requirements, A larger preset height interval can be set. For example, the preset height interval can be 7m. The present disclosure does not limit the setting method of the preset height interval.
  • the terrain height when it is determined that the position corresponding to the terrain height is in the shadow of the scene image, the terrain height can be used as the undetermined height, and the shadow height determination step is executed in a loop until a new undetermined height is determined. If the position corresponding to the height is not in the shadow of the scene image, the difference between the new undetermined height and the preset height interval is used as the shadow height corresponding to the pixel.
  • the step of determining the shadow height includes: determining whether the position corresponding to the undetermined height is in the shadow according to the scene depth, and if the position corresponding to the undetermined height is in the shadow, spacing the undetermined height from the preset height The sum value is used as the new pending height.
  • the position corresponding to the undetermined height is in the shadow of the scene image.
  • the terrain height h is in in the shadow.
  • Table 1 lists the shadow heights corresponding to multiple pixels in the scene image. As shown in Table 1, the shadow heights corresponding to the pixels in the scene image include 0, 25, 30, and 35. It should be noted that the table The shadow height shown in 1 is only the shadow height corresponding to some pixels in the scene image.
  • the present disclosure can obtain the shadow height corresponding to each pixel point in the scene image in advance, or can obtain the shadow height corresponding to each pixel point in the scene image in real time, and the present disclosure is not limited to this. Compared with the method of obtaining the shadow height in real time, obtaining the shadow height in advance can reduce the performance overhead during image rendering and further improve rendering efficiency.
  • the shadow height corresponding to the pixel can be filtered for each pixel in the scene image, and the filtered shadow height is composed of A collection of textures that serve as that height. In this way, the shadow height can be blurred once, making the overall edge of the shadow rendering softer and achieving a soft shadow effect.
  • the ESM algorithm in Logarithmic Space Filtering can be used to filter the shadow height corresponding to each pixel.
  • the filtering formula can be:
  • d is the filtered shadow height corresponding to the current pixel in the scene image
  • d 0 is the shadow height corresponding to the current pixel
  • d i is the shadow height corresponding to the i-th pixel around the current pixel.
  • N is 8
  • w 0 is the weight value corresponding to the current pixel
  • w i is the weight value corresponding to the i-th pixel
  • c is a preset constant, which can be obtained through pre-testing based on experiments, for example, c is 20.
  • the weight value corresponding to each pixel can be predetermined according to the filtering method. For example, if the filtering method is 3*3 BOX filtering, then the weight value corresponding to each pixel is the same, both 1/9. If the filtering method is Gaussian filtering, the weight value corresponding to each pixel is different.
  • the current pixel in the scene image is the pixel in row 2 and column 6 (the pixel with black background in Table 1)
  • the current pixel The shadow height corresponding to the point is 30, and the shadow heights (d 1 ⁇ d 8 ) corresponding to the eight pixel points around the current pixel point are 30, 30, 30, 30, 0, 0, 0, and 30 respectively.
  • Figure 4 is a schematic diagram of a shadow height according to an exemplary embodiment of the present disclosure. As shown in Figure 4, in terms of resolution An image of 4096*4096 in R16 format displays the shadow height corresponding to each pixel in the scene image.
  • the target shadow height corresponding to the pixel can be determined from the pre-obtained height texture corresponding to the scene image based on the texture coordinates corresponding to the pixel in the scene image, and the shadow of the pixel can be determined based on the target shadow height. value, the pixel is rendered according to the shadow value.
  • the present disclosure can also perform filtering processing on the shadow height obtained in advance to achieve the effect of soft shadow.
  • Figure 5 is a block diagram of an image rendering device according to an exemplary embodiment of the present disclosure. As shown in Figure 5, the device may include:
  • the image acquisition module 501 is used to acquire the scene image to be rendered in the target scene
  • the image rendering module 502 is configured to determine, for each pixel point in the scene image, the target shadow height corresponding to the pixel point, and determine the shadow value corresponding to the pixel point according to the target shadow height. Shadow values are used to render the pixels to render the scene image;
  • the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is at the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, And the height of the pixels in the height direction of the world space is greater than or equal to the preset height threshold.
  • the image rendering module 502 is also used to:
  • the shadow height corresponding to the specified pixel point is used as the target shadow height.
  • the image rendering module 502 is also used to:
  • the texture coordinates corresponding to the pixel are determined based on the coordinates of the pixel corresponding to the world space, the ratio, the pixel size and the offset value.
  • the image rendering module 502 is also used to:
  • For each pixel in the scene image determine the scene depth of the pixel in the direction of the light source in the scene image, and determine the shadow height corresponding to the pixel according to the scene depth;
  • a set of shadow heights corresponding to multiple pixel points is used as the height texture.
  • the image rendering module 502 is also used to:
  • a preset height interval is obtained, and the shadow height corresponding to the pixel is determined based on the terrain height and the preset height interval.
  • the image rendering module 502 is also used to:
  • the shadow height determination steps include:
  • the sum of the interval between the undetermined height and the preset height is used as the new undetermined height.
  • the image rendering module 502 is also used to:
  • the set of the shadow heights corresponding to the plurality of pixels, as the height texture includes:
  • the set of filtered shadow heights is used as the height texture.
  • the image rendering module 502 is also used to:
  • the shadow value corresponding to the pixel is determined.
  • the scene image is a game scene image.
  • the shadow value of the pixel can be determined according to the target shadow height corresponding to the pixel, and the pixel can be rendered according to the shadow value. In this way, the amount of data that needs to be processed during the rendering process is relatively small, thereby improving image rendering. s efficiency.
  • Terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile phones, notebook computers, digital broadcast receivers, PDA (Personal Digital Assistant, personal digital assistant), PAD (tablet computer), PMP (Portable Media Player, portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc.
  • PDA Personal Digital Assistant
  • PAD tablet computer
  • PMP Portable Media Player
  • vehicle-mounted terminals such as vehicle-mounted navigation terminals
  • fixed terminals such as digital TVs, desktop computers, etc.
  • the electronic device shown in FIG. 6 is only an example and should not impose any limitations on the functions and scope of use of the embodiments of the present disclosure.
  • the electronic device 600 may include a processing device (such as a central processing unit, a graphics processor, etc.) 601, which may process data according to a program stored in a read-only memory (Read Only Memory, ROM) 602 or from a storage device 608
  • a processing device such as a central processing unit, a graphics processor, etc.
  • the program loaded into the random access memory (Random Access Memory, RAM) 603 performs various appropriate actions and processing.
  • RAM 603 Random Access Memory
  • various programs and data required for the operation of the electronic device 600 are also stored.
  • the processing device 601, ROM 602 and RAM 603 are connected to each other via a bus 604.
  • An input/output (I/O) interface 605 is also connected to bus 604.
  • the following devices can be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a Liquid Crystal Display (LCD) , an output device 607 such as a speaker, a vibrator, etc.; a storage device 608 including a magnetic tape, a hard disk, etc.; and a communication device 609.
  • the communication device 609 may allow the electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data.
  • FIG. 6 illustrates electronic device 600 with various means, it should be understood that implementation or availability of all illustrated means is not required. More or fewer means may alternatively be implemented or provided.
  • embodiments of the present disclosure include a computer program product including a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the method illustrated in the flowchart.
  • the computer program may be downloaded and installed from the network via communication device 609, or from storage device 608, or from ROM 602.
  • the processing device 601 When the computer program is executed by the processing device 601, the above functions defined in the method of the embodiment of the present disclosure are performed.
  • the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two.
  • the computer-readable storage medium may be, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination thereof. More specific examples of computer readable storage media may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard drive, random access memory (RAM), read only memory (ROM), removable Programmd read-only memory (EPROM or flash memory), fiber optics, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above.
  • a computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device .
  • Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wire, optical cable, RF (radio frequency), etc., or any suitable combination of the above.
  • the client and server can communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can communicate with digital data in any form or medium.
  • Communications e.g., communications network
  • Examples of communication networks include Local Area Networks (LANs), Wide Area Networks (WANs), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any current network for knowledge or future research and development.
  • LANs Local Area Networks
  • WANs Wide Area Networks
  • the Internet e.g., the Internet
  • end-to-end networks e.g., ad hoc end-to-end networks
  • the above-mentioned computer-readable medium may be included in the above-mentioned electronic device; it may also exist independently without being assembled into the electronic device.
  • the computer-readable medium carries one or more programs.
  • the electronic device obtains the scene image to be rendered in the target scene; and targets each scene image in the scene image.
  • pixel points determine the target shadow height corresponding to the pixel point, determine the shadow value corresponding to the pixel point according to the target shadow height, and render the pixel point according to the shadow value to render the pixel point.
  • the scene image wherein, the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is the horizontal direction of the world space corresponding to the pixel point in the target scene. Pixel points with the same position and a height greater than or equal to a preset height threshold in the height direction of the world space.
  • Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, including but not limited to object-oriented programming languages—such as Java, Smalltalk, C++, and Includes conventional procedural programming languages - such as "C" or similar programming languages.
  • the program code can be completed Execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server.
  • the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as an Internet service provider). connected via the Internet).
  • LAN local area network
  • WAN wide area network
  • Internet service provider such as an Internet service provider
  • each block in the flowchart or block diagram may represent a module, segment, or portion of code that contains one or more logic functions that implement the specified executable instructions.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown one after another may actually execute substantially in parallel, or they may sometimes execute in the reverse order, depending on the functionality involved.
  • each block of the block diagram and/or flowchart illustration, and combinations of blocks in the block diagram and/or flowchart illustration can be implemented by special purpose hardware-based systems that perform the specified functions or operations. , or can be implemented using a combination of specialized hardware and computer instructions.
  • the modules involved in the embodiments of the present disclosure can be implemented in software or hardware.
  • the name of the module does not constitute a limitation on the module itself under certain circumstances.
  • the image acquisition module can also be described as "a module that acquires the scene image to be rendered in the target scene.”
  • exemplary types of hardware logic components include: field programmable gate array (Field Programmable Gate Array, FPGA), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), application specific standard product (Application Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), etc.
  • a machine-readable medium may be a tangible medium that may contain or store a program for use by or in connection with an instruction execution system, apparatus, or device.
  • the machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
  • Machine-readable media may include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any suitable combination of the foregoing.
  • machine-readable storage media would include one or more wire-based electrical connections, laptop disks, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • RAM random access memory
  • ROM read only memory
  • EPROM or flash memory erasable programmable read only memory
  • CD-ROM portable compact disk read-only memory
  • magnetic storage device or any suitable combination of the above.
  • Example 1 provides an image rendering method.
  • the method includes: obtaining a scene image to be rendered in a target scene; and determining, for each pixel point in the scene image, the The target shadow height corresponding to the pixel point is determined, and the shadow value corresponding to the pixel point is determined according to the target shadow height, and the pixel point is rendered according to the shadow value to render the scene image; wherein, The target shadow height is the height of a designated pixel in the shadow of the scene image, and the designated pixel is at the same position as the pixel in the horizontal direction of the world space corresponding to the target scene, and in Pixels whose height in the height direction of the world space is greater than or equal to a preset height threshold.
  • Example 2 provides the method of Example 1. Determining the target shadow height corresponding to the pixel point includes: determining the texture coordinates corresponding to the pixel point; according to the texture coordinates and The height texture corresponding to the scene image obtained in advance determines the designated pixel point, and the height texture includes each image of the scene image. The shadow height corresponding to the pixel point; the shadow height corresponding to the specified pixel point is used as the target shadow height.
  • Example 3 provides the method of Example 2. Determining the texture coordinates corresponding to the pixel point includes: obtaining the coordinates of the pixel point corresponding to the world space, the height texture corresponding to The pixel size and the proportion of the world space; determine the offset value between the center point of the terrain corresponding to the scene image and the origin of the coordinates of the world space corresponding to the pixel point; according to the corresponding coordinates of the pixel point to the world The spatial coordinates, the scale, the pixel size and the offset value determine the texture coordinates corresponding to the pixel point.
  • the height texture is pre-acquired in the following manner: for each pixel point in the scene image, determine whether the pixel point is in the scene image The scene depth in the direction of the light source is determined, and the shadow height corresponding to the pixel point is determined according to the scene depth; a set of the shadow heights corresponding to multiple pixel points is used as the height texture.
  • determining the shadow height corresponding to the pixel point according to the scene depth includes: determining the terrain height corresponding to the pixel point, and the terrain height is the height of the reference plane located directly below the pixel point in the height direction of the coordinates of the world space corresponding to the pixel point in the scene image; when it is determined that the position corresponding to the terrain height is located in the scene image In the case of shadow, a preset height interval is obtained, and the shadow height corresponding to the pixel is determined based on the terrain height and the preset height interval.
  • determining the shadow height corresponding to the pixel point according to the terrain height and the preset height interval includes: using the terrain height as an undetermined height, and execute the shadow height determination step in a loop until it is determined that the position corresponding to the new undetermined height is not in the shadow of the scene image, and the difference between the new undetermined height and the preset height interval is used as the corresponding pixel point
  • the shadow height of The sum of the height and the preset height interval is used as the new pending height.
  • Example 7 before using a set of shadow heights corresponding to a plurality of pixel points as the height texture, the method further includes: The shadow height is subjected to filtering processing; the set of the shadow heights corresponding to a plurality of the pixel points as the height texture includes: the set of the shadow heights after filtering is used as The highly textured.
  • determining the shadow value corresponding to the pixel point according to the target shadow height includes: according to the coordinates of the pixel point corresponding to the world space and the Shadow height determines the shadow value corresponding to the pixel.
  • Example 9 provides the method of any one of Examples 1-8, and the scene image is a game scene image.
  • Example 10 provides an image rendering device, which includes: an image acquisition module for acquiring a scene image to be rendered in a target scene; an image rendering module for For each pixel in the scene image, determine the target shadow height corresponding to the pixel, and determine the shadow value corresponding to the pixel according to the target shadow height. According to the shadow value, calculate the shadow value for the pixel. Rendering is performed to render the scene image; wherein the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is corresponding to the pixel point in the target scene.
  • the pixels have the same position in the horizontal direction of the world space and the height in the height direction of the world space is greater than or equal to the preset height threshold.
  • Example 11 provides a computer-readable medium having a computer-readable medium stored thereon A computer program that, when executed by a processing device, implements the steps of the method described in any one of Examples 1-9.
  • Example 12 provides an electronic device, including: a storage device having a computer program stored thereon; and a processing device configured to execute the computer program in the storage device, to Implement the steps of the method described in any of Examples 1-9.
  • Example 13 provides a computer program product, including a computer program that, when executed by a processing device, implements the steps of the method described in any one of Examples 1-9.
  • Example 14 provides a computer program that, when executed by a processing device, implements the steps of the method described in any of Examples 1-9 of the present disclosure.
  • the scene image to be rendered in the target scene is obtained; for each pixel in the scene image, the target shadow height corresponding to the pixel is determined, and based on the target shadow height, the target shadow height is determined.
  • the shadow value corresponding to the pixel point is used to render the pixel point according to the shadow value to render the scene image; wherein the target shadow height is the height of the designated pixel point in the shadow of the scene image.
  • the designated pixel point is a pixel point that has the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, and has a height greater than or equal to a preset height threshold in the height direction of the world space.
  • the present disclosure can determine the shadow value of a pixel based on the target shadow height corresponding to the pixel, and render the pixel based on the shadow value. In this way, the amount of data that needs to be processed during the rendering process is relatively small, thereby improving the efficiency of the pixel. Image rendering efficiency.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Graphics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computing Systems (AREA)
  • Geometry (AREA)
  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)

Abstract

The present disclosure relates to an image rendering method and apparatus, a readable medium, an electronic device, a computer program product, and a computer program. The method comprises: acquiring a scene image to be rendered in a target scene; in respect of each pixel point in the scene image, determining a target shadow height corresponding to the pixel point, determining a shadow value corresponding to the pixel point according to the target shadow height, and, according to the shadow value, rendering the pixel point so as to render the scene image. The target shadow height is the height of a specified pixel point in the shadow of the scene image, the specified pixel point being a pixel point having a same position with the pixel point in the horizontal direction of a world space corresponding to the target scene, and having a height in the height direction of the world space greater than or equal to a preset height threshold. That is to say, the present disclosure can determine the shadow value of the pixel point according to the target shadow height corresponding to the pixel point, and can render the pixel point according to the shadow value, so that during a rendering process, the amount of data required to be processed is small, thereby improving the image rendering efficiency.

Description

图像渲染方法、装置、可读介质及电子设备Image rendering methods, devices, readable media and electronic equipment
相关申请的交叉引用Cross-references to related applications
本申请要求于2022年04月07日提交的申请号为202210363937.X、名称为“图像渲染方法、装置、可读介质及电子设备”的中国专利申请的优先权,此申请的内容通过引用并入本文。This application claims priority to the Chinese patent application with application number 202210363937. Enter this article.
技术领域Technical field
本公开涉及图像处理技术领域,具体地,涉及一种图像渲染方法、装置、可读介质、电子设备、计算机程序产品及计算机程序。The present disclosure relates to the technical field of image processing, and specifically, to an image rendering method, device, readable medium, electronic equipment, computer program product, and computer program.
背景技术Background technique
随着游戏行业的不断发展,用户对于画面表现的要求越来越高,为了增强游戏的显示效果,通常会使用相关实时阴影技术为场景中运动的游戏对象渲染阴影。With the continuous development of the game industry, users have higher and higher requirements for picture performance. In order to enhance the display effect of the game, related real-time shadow technology is usually used to render shadows for moving game objects in the scene.
相关技术中,在光源位置处先渲染出一张场景的深度图,然后再在相机处对整个场景进行渲染,并与之前渲染的深度图进行比较,得到场景的阴影效果。但是,在远景物件比较多的情况下,两次场景渲染需要处理的数据量比较大,导致渲染效率比较低。In related technologies, a depth map of the scene is first rendered at the light source position, and then the entire scene is rendered at the camera, and compared with the previously rendered depth map to obtain the shadow effect of the scene. However, when there are many distant objects, the amount of data that needs to be processed for two scene renderings is relatively large, resulting in relatively low rendering efficiency.
发明内容Contents of the invention
提供该发明内容部分以便以简要的形式介绍构思,这些构思将在后面的具体实施方式部分被详细描述。该发明内容部分并不旨在标识要求保护的技术方案的关键特征或必要特征,也不旨在用于限制所要求的保护的技术方案的范围。This Summary is provided to introduce in a simplified form concepts that are further described in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to be used to limit the scope of the claimed technical solution.
第一方面,本公开提供一种图像渲染方法,所述方法包括:In a first aspect, the present disclosure provides an image rendering method, which method includes:
获取目标场景中待渲染的场景图像;Get the scene image to be rendered in the target scene;
针对所述场景图像中的每个像素点,确定所述像素点对应的目标阴影高度,并根据所述目标阴影高度,确定所述像素点对应的阴影值,根据所述阴影值,对所述像素点进行渲染,以渲染所述场景图像;For each pixel in the scene image, determine the target shadow height corresponding to the pixel, determine the shadow value corresponding to the pixel according to the target shadow height, and determine the shadow value according to the shadow value. Render pixels to render the scene image;
其中,所述目标阴影高度为处于所述场景图像的阴影中的指定像素点的高度,所述指定像素点为与所述像素点在所述目标场景对应的世界空间的水平方向上位置相同,且在所述世界空间的高度方向上高度大于或等于预设高度阈值的像素点。Wherein, the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is at the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, And the height of the pixels in the height direction of the world space is greater than or equal to the preset height threshold.
第二方面,本公开提供一种图像渲染装置,所述装置包括:In a second aspect, the present disclosure provides an image rendering device, which includes:
图像获取模块,用于获取目标场景中待渲染的场景图像;The image acquisition module is used to obtain the scene image to be rendered in the target scene;
图像渲染模块,用于针对所述场景图像中的每个像素点,确定所述像素点对应的目标阴影高度,并根据所述目标阴影高度,确定所述像素点对应的阴影值,根据所述阴影值,对所述像素点进行渲染,以渲染所述场景图像; An image rendering module, configured to determine, for each pixel in the scene image, a target shadow height corresponding to the pixel, and determine a shadow value corresponding to the pixel according to the target shadow height. Shadow values are used to render the pixels to render the scene image;
其中,所述目标阴影高度为处于所述场景图像的阴影中的指定像素点的高度,所述指定像素点为与所述像素点在所述目标场景对应的世界空间的水平方向上位置相同,且在所述世界空间的高度方向上高度大于或等于预设高度阈值的像素点。Wherein, the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is at the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, And the height of the pixels in the height direction of the world space is greater than or equal to the preset height threshold.
第三方面,本公开提供一种计算机可读介质,其上存储有计算机程序,该计算机程序被处理装置执行时实现本公开第一方面所述方法的步骤。In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processing device, the steps of the method described in the first aspect of the present disclosure are implemented.
第四方面,本公开提供电子设备,包括:In a fourth aspect, the present disclosure provides electronic equipment, including:
存储装置,其上存储有计算机程序;a storage device having a computer program stored thereon;
处理装置,用于执行所述存储装置中的所述计算机程序,以实现本公开第一方面所述方法的步骤。A processing device, configured to execute the computer program in the storage device to implement the steps of the method described in the first aspect of the present disclosure.
第五方面,本公开提供一种计算机程序产品,包括计算机程序,计算机程序被处理装置执行时实现本公开第一方面所述方法的步骤。In a fifth aspect, the present disclosure provides a computer program product, which includes a computer program. When the computer program is executed by a processing device, the steps of the method described in the first aspect of the present disclosure are implemented.
第六方面,本公开提供一种计算机程序,计算机程序被处理装置执行时实现本公开第一方面所述方法的步骤。In a sixth aspect, the present disclosure provides a computer program. When the computer program is executed by a processing device, the steps of the method described in the first aspect of the present disclosure are implemented.
本公开的其他特征和优点将在随后的具体实施方式部分予以详细说明。Other features and advantages of the present disclosure will be described in detail in the detailed description that follows.
附图说明Description of the drawings
结合附图并参考以下具体实施方式,本公开各实施例的上述和其他特征、优点及方面将变得更加明显。贯穿附图中,相同或相似的附图标记表示相同或相似的元素。应当理解附图是示意性的,原件和元素不一定按照比例绘制。在附图中:The above and other features, advantages, and aspects of various embodiments of the present disclosure will become more apparent with reference to the following detailed description taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It is to be understood that the drawings are schematic and that elements and elements are not necessarily drawn to scale. In the attached picture:
图1是根据本公开一示例性实施例示出的一种图像渲染方法的流程图。FIG. 1 is a flowchart of an image rendering method according to an exemplary embodiment of the present disclosure.
图2是根据本公开一示例性实施例示出的一种目标阴影高度的示意图。FIG. 2 is a schematic diagram of a target shadow height according to an exemplary embodiment of the present disclosure.
图3是根据本公开一示例性实施例示出的另一种图像渲染方法的流程图。FIG. 3 is a flowchart of another image rendering method according to an exemplary embodiment of the present disclosure.
图4是根据本公开一示例性实施例示出的一种阴影高度示意图。Figure 4 is a schematic diagram of a shadow height according to an exemplary embodiment of the present disclosure.
图5是根据本公开一示例性实施例示出的一种图像渲染装置的框图。FIG. 5 is a block diagram of an image rendering device according to an exemplary embodiment of the present disclosure.
图6是根据本公开一示例性实施例示出的一种电子设备的框图。FIG. 6 is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure.
具体实施方式Detailed ways
下面将参照附图更详细地描述本公开的实施例。虽然附图中显示了本公开的某些实施例,然而应当理解的是,本公开可以通过各种形式来实现,而且不应该被解释为限于这里阐述的实施例,相反提供这些实施例是为了更加透彻和完整地理解本公开。应当理解的是,本公开的附图及实施例仅用于示例性作用,并非用于限制本公开的保护范围。Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the disclosure are shown in the drawings, it should be understood that the disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, which rather are provided for A more thorough and complete understanding of this disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of the present disclosure.
应当理解,本公开的方法实施方式中记载的各个步骤可以按照不同的顺序执行,和/或并行执行。此外,方法实施方式可以包括附加的步骤和/或省略执行示出的步骤。本公开的范围在此方面不受限制。It should be understood that various steps described in the method implementations of the present disclosure may be executed in different orders and/or in parallel. Furthermore, method embodiments may include additional steps and/or omit performance of illustrated steps. The scope of the present disclosure is not limited in this regard.
本文使用的术语“包括”及其变形是开放性包括,即“包括但不限于”。术语“基于”是“至少部分地基于”。术语“一个实施例”表示“至少一个实施例”;术语“另一实施例”表示“至少一个另外的实施例”;术语“一些实施例”表示“至少一些实施例”。其他术语的相关定义将在下文描述中给出。 As used herein, the term "include" and its variations are open-ended, ie, "including but not limited to." The term "based on" means "based at least in part on." The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; and the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below.
需要注意,本公开中提及的“第一”、“第二”等概念仅用于对不同的装置、模块或单元进行区分,并非用于限定这些装置、模块或单元所执行的功能的顺序或者相互依存关系。It should be noted that concepts such as “first” and “second” mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units. Or interdependence.
需要注意,本公开中提及的“一个”、“多个”的修饰是示意性而非限制性的,本领域技术人员应当理解,除非在上下文另有明确指出,否则应该理解为“一个或多个”。It should be noted that the modifications of "one" and "plurality" mentioned in this disclosure are illustrative and not restrictive. Those skilled in the art will understand that unless the context clearly indicates otherwise, it should be understood as "one or Multiple”.
本公开实施方式中的多个装置之间所交互的消息或者信息的名称仅用于说明性的目的,而并不是用于对这些消息或信息的范围进行限制。The names of messages or information exchanged between multiple devices in the embodiments of the present disclosure are for illustrative purposes only and are not used to limit the scope of these messages or information.
可以理解的是,在使用本公开各实施例公开的技术方案之前,均应当依据相关法律法规通过恰当的方式对本公开所涉及个人信息的类型、使用范围、使用场景等告知用户并获得用户的授权。It can be understood that before using the technical solutions disclosed in the embodiments of this disclosure, users should be informed of the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations and obtain the user's authorization. .
例如,在响应于接收到用户的主动请求时,向用户发送提示信息,以明确地提示用户,其请求执行的操作将需要获取和使用到用户的个人信息。从而,使得用户可以根据提示信息来自主地选择是否向执行本公开技术方案的操作的电子设备、应用程序、服务器或存储介质等软件或硬件提供个人信息。For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly remind the user that the operation requested will require the acquisition and use of the user's personal information. Therefore, users can autonomously choose whether to provide personal information to software or hardware such as electronic devices, applications, servers or storage media that perform the operations of the technical solution of the present disclosure based on the prompt information.
作为一种可选的但非限定性的实现方式,响应于接收到用户的主动请求,向用户发送提示信息的方式例如可以是弹窗的方式,弹窗中可以以文字的方式呈现提示信息。此外,弹窗中还可以承载供用户选择“同意”或者“不同意”向电子设备提供个人信息的选择控件。As an optional but non-limiting implementation method, in response to receiving the user's active request, the method of sending prompt information to the user may be, for example, a pop-up window, and the prompt information may be presented in the form of text in the pop-up window. In addition, the pop-up window can also contain a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
可以理解的是,上述通知和获取用户授权过程仅是示意性的,不对本公开的实现方式构成限定,其它满足相关法律法规的方式也可应用于本公开的实现方式中。It can be understood that the above process of notifying and obtaining user authorization is only illustrative and does not limit the implementation of the present disclosure. Other methods that satisfy relevant laws and regulations can also be applied to the implementation of the present disclosure.
同时,可以理解的是,本技术方案所涉及的数据(包括但不限于数据本身、数据的获取或使用)应当遵循相应法律法规及相关规定的要求。At the same time, it can be understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of corresponding laws, regulations and relevant regulations.
首先,对本公开的应用场景进行说明。目前的移动端远景阴影方案包括Cascade Shadow Map算法、烘焙阴影、接触阴影等。其中,Cascade Shadow Map算法在处理过程中相当于把场景渲染了两次,对应的Drawcall(绘制发起)的数据量会比较大,导致CPU(Central Processing Unit,中央处理器)和GPU(Graphics Processing Unit,图形处理器)的开销也比较大,影响渲染的效率,烘焙阴影的烘焙速度比较慢,接触阴影的渲染效果比较差。First, the application scenarios of the present disclosure will be described. The current mobile perspective shadow solutions include Cascade Shadow Map algorithm, baked shadows, contact shadows, etc. Among them, the Cascade Shadow Map algorithm is equivalent to rendering the scene twice during the processing process, and the corresponding Drawcall (drawing initiation) data volume will be relatively large, resulting in CPU (Central Processing Unit, Central Processing Unit) and GPU (Graphics Processing Unit) , graphics processor) is also relatively large, which affects the rendering efficiency. The baking speed of baked shadows is relatively slow, and the rendering effect of contact shadows is relatively poor.
为了解决上述存在的问题,本公开提供一种图像渲染方法、装置、可读介质及电子设备,可以根据像素点对应的目标阴影高度确定该像素点的阴影值,根据该阴影值对该像素点进行渲染,这样,渲染过程中需要处理的数据量比较小,从而提高了图像渲染的效率。In order to solve the above existing problems, the present disclosure provides an image rendering method, device, readable medium and electronic equipment, which can determine the shadow value of the pixel point according to the target shadow height corresponding to the pixel point, and then determine the shadow value of the pixel point according to the shadow value. Rendering is performed so that the amount of data that needs to be processed during the rendering process is relatively small, thereby improving the efficiency of image rendering.
下面结合具体实施例对本公开进行说明。The present disclosure will be described below with reference to specific embodiments.
图1是根据本公开一示例性实施例示出的一种图像渲染方法的流程图,如图1所示,该方法可以包括:Figure 1 is a flow chart of an image rendering method according to an exemplary embodiment of the present disclosure. As shown in Figure 1, the method may include:
S101、获取目标场景中待渲染的场景图像。S101. Obtain the scene image to be rendered in the target scene.
其中,该目标场景可以是游戏场景,该场景图像可以是该游戏场景中需要进行渲染处理的图像。The target scene may be a game scene, and the scene image may be an image that needs to be rendered in the game scene.
S102、针对该场景图像中的每个像素点,确定该像素点对应的目标阴影高度,并根据该目标阴影高度,确定该像素点对应的阴影值,根据该阴影值,对该像素点进行渲染,以渲染该场景图像。S102. For each pixel in the scene image, determine the target shadow height corresponding to the pixel, determine the shadow value corresponding to the pixel based on the target shadow height, and render the pixel based on the shadow value. , to render the scene image.
其中,该目标阴影高度为处于该场景图像的阴影中的指定像素点的高度,该指定像素点为与该像素点在该目标场景对应的世界空间的水平方向上位置相同,且在该世界空间的高度方 向上高度大于或等于预设高度阈值的像素点。该预设高度阈值可以是与该像素点在世界空间的高度方向上位置相同,且在该世界空间的水平方向上位置最高的像素点对应的高度。图2是根据本公开一示例性实施例示出的一种目标阴影高度的示意图,如图2所示,按照自上而下的视角渲染该场景图像中的地形,该目标阴影高度可以是该世界空间的高度方向的直线与光源方向的直线的交点。Wherein, the target shadow height is the height of the specified pixel in the shadow of the scene image, the specified pixel is the same as the horizontal position of the pixel in the world space corresponding to the target scene, and is in the world space height square Pixels whose upward height is greater than or equal to the preset height threshold. The preset height threshold may be the height corresponding to the pixel that has the same position in the height direction of the world space and the highest position in the horizontal direction of the world space. Figure 2 is a schematic diagram of a target shadow height according to an exemplary embodiment of the present disclosure. As shown in Figure 2, the terrain in the scene image is rendered from a top-down perspective. The target shadow height can be the world The intersection point of the straight line in the height direction of space and the straight line in the direction of the light source.
在本步骤中,针对该场景图像中的每个像素点,可以先确定该像素点对应的指定像素点,确定该指定像素点的高度,并将该指定像素点的高度作为该像素点对应的目标阴影高度。In this step, for each pixel in the scene image, you can first determine the designated pixel corresponding to the pixel, determine the height of the designated pixel, and use the height of the designated pixel as the height corresponding to the pixel. Target shadow height.
进一步地,在得到该像素点对应的目标阴影高度后,可以获取该像素点对应世界空间的坐标,并通过以下公式计算得到该像素点对应的阴影值:
Shadow=saturate(exp(MaxOcclusionHeight–C*positionWS.y))   (1)
Further, after obtaining the target shadow height corresponding to the pixel, the coordinates of the world space corresponding to the pixel can be obtained, and the shadow value corresponding to the pixel can be calculated through the following formula:
Shadow=saturate(exp(MaxOcclusionHeight–C*positionWS.y)) (1)
其中,Shadow为该阴影值,MaxOcclusionHeight为该目标阴影高度,positionWS.y为该像素点对应世界空间的坐标的y轴,C为预设常量,C可以根据试验预先测试得到,例如,C可以是20。Saturate(x)函数的作用是在x的取值小于或等于0的情况下,返回0,在x的取值大于或等于1的情况下,返回1,在x的取值为0到1之间的数值情况下,返回x。在该像素点对应的阴影值为0的情况下,表示该像素点未处于阴影中,在该像素点对应的阴影值为1的情况下,表示该像素点处于阴影中,且阴影的颜色最深,在该像素点对应的阴影值在0到1之间的数值情况下,可以根据该阴影值的大小渲染对应的阴影颜色,示例地,该阴影值越大,颜色可以越深,该阴影值越小,颜色可以越浅。Among them, Shadow is the shadow value, MaxOcclusionHeight is the target shadow height, positionWS.y is the y-axis of the coordinates of the world space corresponding to the pixel point, C is a preset constant, and C can be pre-tested based on experiments. For example, C can be 20. The function of the Saturate(x) function is to return 0 when the value of x is less than or equal to 0, to return 1 when the value of x is greater than or equal to 1, and to return 1 when the value of x is between 0 and 1. If the value is between , x is returned. When the shadow value corresponding to the pixel is 0, it means that the pixel is not in shadow. When the shadow value corresponding to the pixel is 1, it means that the pixel is in shadow, and the color of the shadow is the darkest. , when the shadow value corresponding to the pixel is between 0 and 1, the corresponding shadow color can be rendered according to the size of the shadow value. For example, the larger the shadow value, the darker the color. The shadow value The smaller it is, the lighter the color can be.
在得到该像素点对应的阴影值后,可以参照现有技术的渲染方式对该像素点进行渲染,此处不再赘述。After obtaining the shadow value corresponding to the pixel, the pixel can be rendered by referring to the rendering method in the prior art, which will not be described again here.
采用上述方法,可以根据像素点对应的目标阴影高度确定该像素点的阴影值,根据该阴影值对该像素点进行渲染,这样,渲染过程中需要处理的数据量比较小,从而提高了图像渲染的效率。Using the above method, the shadow value of the pixel can be determined according to the target shadow height corresponding to the pixel, and the pixel can be rendered according to the shadow value. In this way, the amount of data that needs to be processed during the rendering process is relatively small, thereby improving image rendering. s efficiency.
图3是根据本公开一示例性实施例示出的另一种图像渲染方法的流程图,如图3所示,该方法可以包括:Figure 3 is a flowchart of another image rendering method according to an exemplary embodiment of the present disclosure. As shown in Figure 3, the method may include:
S301、获取目标场景中待渲染的场景图像。S301. Obtain the scene image to be rendered in the target scene.
其中,该目标场景可以是游戏场景,该场景图像可以是该游戏场景中需要进行渲染处理的图像。The target scene may be a game scene, and the scene image may be an image that needs to be rendered in the game scene.
S302、针对该场景图像中的每个像素点,确定该像素点对应的纹理坐标。S302. For each pixel in the scene image, determine the texture coordinates corresponding to the pixel.
在一种可能的实现方式中,针对该场景图像中的每个像素点,可以获取该像素点对应世界空间的坐标、该高度纹理对应的像素尺寸以及世界空间的比例,确定该场景图像对应的地形的中心点与该像素点对应该世界空间的坐标的原点之间的偏移值,并根据该像素点对应该世界空间的坐标、该偏移值、该比例以及该像素尺寸,确定该像素点对应的该纹理坐标。其中,该像素点对应该世界空间的坐标和该高度纹理对应的像素尺寸可以通过现有技术的方式获取,此处不再赘述。该高度纹理对应的世界空间比例可以是根据该场景图像预先设置的,例如,若该像素点占用1m*1m的世界空间,则该比例可以是1,该比例越小,该场景图像中像素点的密度越大,渲染效果更好。In a possible implementation, for each pixel in the scene image, the coordinates of the world space corresponding to the pixel, the pixel size corresponding to the height texture, and the proportion of the world space can be obtained to determine the corresponding coordinates of the scene image. The offset value between the center point of the terrain and the origin of the coordinates of the world space corresponding to the pixel point, and the pixel is determined based on the coordinates of the world space corresponding to the pixel point, the offset value, the scale and the pixel size. The texture coordinates corresponding to the point. The coordinates of the world space corresponding to the pixel point and the pixel size corresponding to the height texture can be obtained through existing techniques, and will not be described again here. The world space ratio corresponding to the height texture can be preset according to the scene image. For example, if the pixel occupies 1m*1m world space, the ratio can be 1. The smaller the ratio, the smaller the pixel in the scene image. The greater the density, the better the rendering effect.
示例地,可以通过以下公式计算得到该像素点对应的纹理坐标:
cellU=(positionWS.x-HeightOcclusionStartPoint)*TexelsPerMeter*
HeightOcclusionTex_TexelSize    (2)
cellV=(positionWS.z-HeightOcclusionStartPoint)*TexelsPerMeter*
HeightOcclusionTex_TexelSize    (3)
For example, the texture coordinates corresponding to the pixel can be calculated by the following formula:
cellU=(positionWS.x-HeightOcclusionStartPoint)*TexelsPerMeter*
HeightOcclusionTex_TexelSize (2)
cellV=(positionWS.z-HeightOcclusionStartPoint)*TexelsPerMeter*
HeightOcclusionTex_TexelSize (3)
其中,(cellU,cellV)为该像素点对应的纹理坐标,positionWS.x为该像素点对应世界空间的坐标的x轴,positionWS.z为该像素点对应世界空间的坐标的z轴,HeightOcclusionStartPoint为该偏移值,TexelsPerMeter为该像素点对应的世界空间的比例,HeightOcclusionTex_TexelSize为该高度纹理对应的像素尺寸,该像素尺寸可以是一个四元数,可以通过一个四维向量表示该像素尺寸,示例地,该四维向量可以是Vector4(1/width,1/height,width,height)。Among them, (cellU, cellV) is the texture coordinate corresponding to the pixel point, positionWS.x is the x-axis of the coordinates of the pixel point corresponding to the world space, positionWS.z is the z-axis of the coordinates of the pixel point corresponding to the world space, and HeightOcclusionStartPoint is The offset value, TexelsPerMeter is the proportion of the world space corresponding to the pixel, and HeightOcclusionTex_TexelSize is the pixel size corresponding to the height texture. The pixel size can be a quaternion, and the pixel size can be represented by a four-dimensional vector. For example, The four-dimensional vector can be Vector4(1/width, 1/height, width, height).
S303、针对该场景图像中的每个像素点,根据该像素点的纹理坐标和预先获取的该场景图像对应的高度纹理,确定指定像素点。S303. For each pixel in the scene image, determine the designated pixel according to the texture coordinates of the pixel and the pre-obtained height texture corresponding to the scene image.
其中,该高度纹理可以包括该场景图像的每个像素点对应的阴影高度。The height texture may include a shadow height corresponding to each pixel of the scene image.
在本步骤中,针对该场景图像中的每个像素点,在获取该像素点的纹理坐标后,可以获取该高度纹理,根据该像素点的纹理坐标,确定该高度纹理中与该像素点在该目标场景对应的世界空间的水平方向上位置相同,且在该世界空间的高度方向上高度大于或等于预设高度阈值的指定像素点。In this step, for each pixel in the scene image, after obtaining the texture coordinates of the pixel, the height texture can be obtained, and based on the texture coordinates of the pixel, it is determined whether the height texture is the same as the pixel. Specified pixels corresponding to the target scene have the same position in the horizontal direction of the world space and have a height greater than or equal to the preset height threshold in the height direction of the world space.
该高度纹理可以通过以下方式预先获取:针对该场景图像中的每个像素点,确定该像素点在该场景图像中的光源方向的场景深度,并根据该场景深度,确定该像素点对应的该阴影高度,并将多个像素点对应的阴影高度所构成的集合,作为该高度纹理。The height texture can be obtained in advance in the following way: for each pixel in the scene image, determine the scene depth of the pixel in the direction of the light source in the scene image, and determine the scene depth corresponding to the pixel based on the scene depth. Shadow height, and a set of shadow heights corresponding to multiple pixels is used as the height texture.
针对该场景图像中的每个像素点,可以参考ShadowMap算法的实现方式,确定该像素点在该场景图像中的光源方向的场景深度。进一步地,针对该场景图像中的每个像素点,在确定该像素点在该场景图像中的光源方向的场景深度后,可以确定该像素点对应的地形高度,在确定该地形高度对应的位置处于该场景图像的阴影中的情况下,获取预设高度间隔,并根据该地形高度和该预设高度间隔,确定该像素点对应的该阴影高度。该地形高度可以是该场景图像中在该世界空间坐标的高度方向上位于该像素点正下方的参考面的高度,如图3所示,该参考面可以是地面,也可以是树木的最高点所处的平面,该地形高度可以根据该场景图像中的地形预先获取。其中,该预设高度间隔可以根据该场景图像预先测试得到,该预设高度间隔越小,确定的该阴影高度的准确率越高,但是由于运算量比较大,性能会比较差。针对准确率要求比较高、性能要求比较低的场景,可以设置较小的预设高度间隔,示例地,该预设高度间隔可以是5m,针对准确率要求比较低、性能要求比较高的场景,可以设置较大的预设高度间隔,示例地,该预设高度间隔可以是7m,本公开对该预设高度间隔的设置方式不作限定。For each pixel in the scene image, you can refer to the implementation of the ShadowMap algorithm to determine the scene depth of the pixel in the direction of the light source in the scene image. Further, for each pixel in the scene image, after determining the scene depth of the pixel in the direction of the light source in the scene image, the terrain height corresponding to the pixel can be determined. After determining the position corresponding to the terrain height When in the shadow of the scene image, a preset height interval is obtained, and the shadow height corresponding to the pixel is determined based on the terrain height and the preset height interval. The terrain height may be the height of a reference plane located directly below the pixel in the height direction of the world space coordinate in the scene image. As shown in Figure 3, the reference plane may be the ground or the highest point of a tree. The plane on which it is located, the terrain height can be obtained in advance based on the terrain in the scene image. The preset height interval can be pre-tested based on the scene image. The smaller the preset height interval, the higher the accuracy of determining the shadow height. However, due to the relatively large amount of calculation, the performance will be poor. For scenarios with relatively high accuracy requirements and low performance requirements, you can set a smaller preset height interval. For example, the preset height interval can be 5m. For scenarios with relatively low accuracy requirements and high performance requirements, A larger preset height interval can be set. For example, the preset height interval can be 7m. The present disclosure does not limit the setting method of the preset height interval.
在一种可能的实现方式中,在确定该地形高度对应的位置处于该场景图像的阴影中的情况下,可以将该地形高度作为待定高度,并循环执行阴影高度确定步骤,直至确定新的待定高度对应的位置未处于该场景图像的阴影中,将新的待定高度与该预设高度间隔的差值作为该像素点对应的阴影高度。其中,该阴影高度确定步骤包括:根据该场景深度,确定该待定高度对应的位置是否处于阴影中,在该待定高度对应的位置处于阴影中的情况下,将该待定高度与该预设高度间隔的和值作为新的待定高度。In a possible implementation, when it is determined that the position corresponding to the terrain height is in the shadow of the scene image, the terrain height can be used as the undetermined height, and the shadow height determination step is executed in a loop until a new undetermined height is determined. If the position corresponding to the height is not in the shadow of the scene image, the difference between the new undetermined height and the preset height interval is used as the shadow height corresponding to the pixel. Wherein, the step of determining the shadow height includes: determining whether the position corresponding to the undetermined height is in the shadow according to the scene depth, and if the position corresponding to the undetermined height is in the shadow, spacing the undetermined height from the preset height The sum value is used as the new pending height.
示例地,可以根据该像素点对应的场景深度,确定该待定高度对应的位置是否处于该场景图像的阴影中,继续以图2为例进行说明,从图2可以看出,该地形高度h处于阴影中,在这 种情况下,可以先确定h+5(预设高度间隔为5m)对应的位置是否处于阴影中,若h+5对应的位置处于阴影中,则继续确定h+10对应的位置是否处于阴影中,以此类推,若最终确定h+30对应的位置未处于阴影中,则确定h+25为该阴影高度。For example, according to the scene depth corresponding to the pixel point, it can be determined whether the position corresponding to the undetermined height is in the shadow of the scene image. Continuing to illustrate with Figure 2 as an example, it can be seen from Figure 2 that the terrain height h is in in the shadow, here In this case, you can first determine whether the position corresponding to h+5 (the default height interval is 5m) is in shadow. If the position corresponding to h+5 is in shadow, continue to determine whether the position corresponding to h+10 is in shadow. , and by analogy, if it is finally determined that the position corresponding to h+30 is not in the shadow, then h+25 is determined to be the shadow height.
表1列举了该场景图像中的多个像素点对应的阴影高度,如表1所示,该场景图像中的像素点对应的阴影高度包括0、25、30、35,需要说明的是,表1所示的阴影高度只是该场景图像中的部分像素点对应的阴影高度。
Table 1 lists the shadow heights corresponding to multiple pixels in the scene image. As shown in Table 1, the shadow heights corresponding to the pixels in the scene image include 0, 25, 30, and 35. It should be noted that the table The shadow height shown in 1 is only the shadow height corresponding to some pixels in the scene image.
表1Table 1
需要说明的是,本公开可以预先获取该场景图像中每个像素点对应的阴影高度,也可以实时获取该场景图像中每个像素点对应的阴影高度,本公开对此不作限定。相比实时获取阴影高度的方法,预先获取阴影高度可以降低图像渲染过程中的性能开销,进一步提高渲染效率。It should be noted that the present disclosure can obtain the shadow height corresponding to each pixel point in the scene image in advance, or can obtain the shadow height corresponding to each pixel point in the scene image in real time, and the present disclosure is not limited to this. Compared with the method of obtaining the shadow height in real time, obtaining the shadow height in advance can reduce the performance overhead during image rendering and further improve rendering efficiency.
在得到该场景图像中的每个像素点对应的阴影高度后,针对该场景图像中的每个像素点,可以对该像素点对应的阴影高度进行滤波处理,将滤波处理后的阴影高度所构成的集合,作为该高度纹理。这样,可以对该阴影高度进行一次模糊处理,使得阴影渲染的整体边缘比较柔和,实现软阴影的效果。After obtaining the shadow height corresponding to each pixel in the scene image, the shadow height corresponding to the pixel can be filtered for each pixel in the scene image, and the filtered shadow height is composed of A collection of textures that serve as that height. In this way, the shadow height can be blurred once, making the overall edge of the shadow rendering softer and achieving a soft shadow effect.
示例地,可以通过Logarithmic Space Filtering(对数空间滤波)中的ESM算法对每个像素点对应的阴影高度进行滤波处理,例如,以该场景图像中的任一像素点对应的阴影高度为例,其中,滤波公式可以是:
For example, the ESM algorithm in Logarithmic Space Filtering can be used to filter the shadow height corresponding to each pixel. For example, taking the shadow height corresponding to any pixel in the scene image as an example, Among them, the filtering formula can be:
其中,d为该场景图像中的当前像素点对应的滤波后的阴影高度,d0为该当前像素点对应的阴影高度,di为该当前像素点周围的第i个像素点对应的阴影高度,N为8,w0为该当前像素点对应的权重值,wi为第i个像素点对应的权重值,c为预设常量,可以根据试验预先测试得到,例如,c以是20。每个像素点对应的权重值可以根据滤波方式预先确定,示例地,若滤波方式为3*3的BOX滤波,则每个像素点对应的权重值相同,均为1/9,若滤波方式为高斯滤波,则每个像素点对应的权重值则不同。Among them, d is the filtered shadow height corresponding to the current pixel in the scene image, d 0 is the shadow height corresponding to the current pixel, and d i is the shadow height corresponding to the i-th pixel around the current pixel. , N is 8, w 0 is the weight value corresponding to the current pixel, w i is the weight value corresponding to the i-th pixel, c is a preset constant, which can be obtained through pre-testing based on experiments, for example, c is 20. The weight value corresponding to each pixel can be predetermined according to the filtering method. For example, if the filtering method is 3*3 BOX filtering, then the weight value corresponding to each pixel is the same, both 1/9. If the filtering method is Gaussian filtering, the weight value corresponding to each pixel is different.
针对表1所示的该场景图像对应的像素点的阴影高度,若该场景图像中的当前像素点为第2行第6列的像素点(表1中黑色背景的像素点),该当前像素点对应的阴影高度为30,该当前像素点周围的8个像素点对应的阴影高度(d1~d8)分别是30、30、30、30、0、0、0、30。Regarding the shadow height of the pixel corresponding to the scene image shown in Table 1, if the current pixel in the scene image is the pixel in row 2 and column 6 (the pixel with black background in Table 1), the current pixel The shadow height corresponding to the point is 30, and the shadow heights (d 1 ~ d 8 ) corresponding to the eight pixel points around the current pixel point are 30, 30, 30, 30, 0, 0, 0, and 30 respectively.
图4是根据本公开一示例性实施例示出的一种阴影高度示意图,如图4所示,以分辨率 为4096*4096、格式为R16的图像显示该场景图像中的每个像素点对应的阴影高度。Figure 4 is a schematic diagram of a shadow height according to an exemplary embodiment of the present disclosure. As shown in Figure 4, in terms of resolution An image of 4096*4096 in R16 format displays the shadow height corresponding to each pixel in the scene image.
S304、针对该场景图像中的每个像素点,将该指定像素点对应的阴影高度,作为该目标阴影高度。S304. For each pixel in the scene image, use the shadow height corresponding to the specified pixel as the target shadow height.
S305、针对该场景图像中的每个像素点,根据该像素点对应世界空间的坐标和该目标阴影高度,确定该像素点对应的阴影值。S305. For each pixel in the scene image, determine the shadow value corresponding to the pixel according to the coordinates of the world space corresponding to the pixel and the target shadow height.
S306、针对该场景图像中的每个像素点,根据该阴影值,对该像素点进行渲染,以渲染该场景图像。S306: For each pixel in the scene image, render the pixel according to the shadow value to render the scene image.
采用上述方法,可以根据场景图像中的像素点对应的纹理坐标,从预先获取的该场景图像对应的高度纹理中确定该像素点对应的目标阴影高度,根据该目标阴影高度确定该像素点的阴影值,根据该阴影值对该像素点进行渲染,这样,渲染过程中需要处理的数据量比较小,使得运行性能比较高,从而提高了图像渲染的效率,并且,渲染过程中对显存的开销也比较小,可以节省磁盘和内存空间。进一步地,本公开还可以对预先获取的阴影高度进行滤波处理,实现软阴影的效果。Using the above method, the target shadow height corresponding to the pixel can be determined from the pre-obtained height texture corresponding to the scene image based on the texture coordinates corresponding to the pixel in the scene image, and the shadow of the pixel can be determined based on the target shadow height. value, the pixel is rendered according to the shadow value. In this way, the amount of data that needs to be processed during the rendering process is relatively small, making the running performance relatively high, thereby improving the efficiency of image rendering, and the overhead of video memory during the rendering process is also reduced. It is relatively small and can save disk and memory space. Furthermore, the present disclosure can also perform filtering processing on the shadow height obtained in advance to achieve the effect of soft shadow.
图5是根据本公开一示例性实施例示出的一种图像渲染装置的框图,如图5所示,该装置可以包括:Figure 5 is a block diagram of an image rendering device according to an exemplary embodiment of the present disclosure. As shown in Figure 5, the device may include:
图像获取模块501,用于获取目标场景中待渲染的场景图像;The image acquisition module 501 is used to acquire the scene image to be rendered in the target scene;
图像渲染模块502,用于针对该场景图像中的每个像素点,确定所述像素点对应的目标阴影高度,并根据所述目标阴影高度,确定所述像素点对应的阴影值,根据所述阴影值,对所述像素点进行渲染,以渲染所述场景图像;The image rendering module 502 is configured to determine, for each pixel point in the scene image, the target shadow height corresponding to the pixel point, and determine the shadow value corresponding to the pixel point according to the target shadow height. Shadow values are used to render the pixels to render the scene image;
其中,所述目标阴影高度为处于所述场景图像的阴影中的指定像素点的高度,所述指定像素点为与所述像素点在所述目标场景对应的世界空间的水平方向上位置相同,且在所述世界空间的高度方向上高度大于或等于预设高度阈值的像素点。Wherein, the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is at the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, And the height of the pixels in the height direction of the world space is greater than or equal to the preset height threshold.
可选地,该图像渲染模块502,还用于:Optionally, the image rendering module 502 is also used to:
确定该像素点对应的纹理坐标;Determine the texture coordinates corresponding to the pixel;
根据所述纹理坐标和预先获取的所述场景图像对应的高度纹理,确定所述指定像素点,所述高度纹理包括所述场景图像的每个像素点对应的阴影高度;Determine the designated pixel point according to the texture coordinates and the pre-obtained height texture corresponding to the scene image, where the height texture includes the shadow height corresponding to each pixel point of the scene image;
将所述指定像素点对应的阴影高度,作为所述目标阴影高度。The shadow height corresponding to the specified pixel point is used as the target shadow height.
可选地,该图像渲染模块502,还用于:Optionally, the image rendering module 502 is also used to:
获取该像素点对应该世界空间的坐标、该高度纹理对应的像素尺寸以及世界空间的比例;Obtain the coordinates of the pixel corresponding to the world space, the pixel size corresponding to the height texture, and the proportion of the world space;
确定该场景图像对应的地形的中心点与该像素点对应该世界空间的坐标的原点之间的偏移值;Determine the offset value between the center point of the terrain corresponding to the scene image and the origin of the coordinates of the world space corresponding to the pixel point;
根据该像素点对应该世界空间的坐标、该比例、该像素尺寸以及该偏移值,确定该像素点对应的该纹理坐标。The texture coordinates corresponding to the pixel are determined based on the coordinates of the pixel corresponding to the world space, the ratio, the pixel size and the offset value.
可选地,该图像渲染模块502,还用于:Optionally, the image rendering module 502 is also used to:
针对该场景图像中的每个该像素点,确定该像素点在该场景图像中的光源方向的场景深度,并根据该场景深度,确定该像素点对应的该阴影高度;For each pixel in the scene image, determine the scene depth of the pixel in the direction of the light source in the scene image, and determine the shadow height corresponding to the pixel according to the scene depth;
将多个该像素点对应的该阴影高度所构成的集合,作为该高度纹理。A set of shadow heights corresponding to multiple pixel points is used as the height texture.
可选地,该图像渲染模块502,还用于:Optionally, the image rendering module 502 is also used to:
确定该像素点对应的地形高度,该地形高度为该场景图像中在该世界空间坐标的高度方 向上位于该像素点正下方的参考面的高度;Determine the terrain height corresponding to the pixel, which is the height of the scene image in the world space coordinates. The height of the reference surface directly below the pixel;
在确定该地形高度对应的位置处于该场景图像的阴影中的情况下,获取预设高度间隔,并根据该地形高度和该预设高度间隔,确定该像素点对应的该阴影高度。When it is determined that the position corresponding to the terrain height is in the shadow of the scene image, a preset height interval is obtained, and the shadow height corresponding to the pixel is determined based on the terrain height and the preset height interval.
可选地,该图像渲染模块502,还用于:Optionally, the image rendering module 502 is also used to:
将该地形高度作为待定高度,并循环执行阴影高度确定步骤,直至确定新的待定高度对应的位置未处于该场景图像的阴影中,将新的待定高度与该预设高度间隔的差值作为该像素点对应的阴影高度;Use the terrain height as the undetermined height, and loop through the shadow height determination steps until it is determined that the position corresponding to the new undetermined height is not in the shadow of the scene image, and use the difference between the new undetermined height and the preset height interval as the The height of the shadow corresponding to the pixel;
该阴影高度确定步骤包括:The shadow height determination steps include:
根据该场景深度,确定该待定高度对应的位置是否处于阴影中;According to the depth of the scene, determine whether the position corresponding to the undetermined height is in shadow;
在该待定高度对应的位置处于阴影中的情况下,将该待定高度与该预设高度间隔的和值作为新的待定高度。When the position corresponding to the undetermined height is in the shadow, the sum of the interval between the undetermined height and the preset height is used as the new undetermined height.
可选地,该图像渲染模块502,还用于:Optionally, the image rendering module 502 is also used to:
对该阴影高度进行滤波处理;Filter the shadow height;
该将多个该像素点对应的该阴影高度所构成的集合,作为该高度纹理包括:The set of the shadow heights corresponding to the plurality of pixels, as the height texture, includes:
将滤波处理后的该阴影高度所构成的集合,作为该高度纹理。The set of filtered shadow heights is used as the height texture.
可选地,该图像渲染模块502,还用于:Optionally, the image rendering module 502 is also used to:
根据该像素点对应世界空间的坐标和该阴影高度,确定该像素点对应的阴影值。According to the coordinates of the world space corresponding to the pixel and the height of the shadow, the shadow value corresponding to the pixel is determined.
可选地,该场景图像为游戏场景图像。Optionally, the scene image is a game scene image.
通过上述装置,可以根据像素点对应的目标阴影高度确定该像素点的阴影值,根据该阴影值对该像素点进行渲染,这样,渲染过程中需要处理的数据量比较小,从而提高了图像渲染的效率。Through the above device, the shadow value of the pixel can be determined according to the target shadow height corresponding to the pixel, and the pixel can be rendered according to the shadow value. In this way, the amount of data that needs to be processed during the rendering process is relatively small, thereby improving image rendering. s efficiency.
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the devices in the above embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method, and will not be described in detail here.
下面参考图6,其示出了适于用来实现本公开实施例的电子设备(例如终端设备或服务器)600的结构示意图。本公开实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(Personal Digital Assistant,个人数字助理)、PAD(平板电脑)、PMP(Portable Media Player,便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图6示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。Referring now to FIG. 6 , a schematic structural diagram of an electronic device (such as a terminal device or a server) 600 suitable for implementing embodiments of the present disclosure is shown. Terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile phones, notebook computers, digital broadcast receivers, PDA (Personal Digital Assistant, personal digital assistant), PAD (tablet computer), PMP (Portable Media Player, portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. The electronic device shown in FIG. 6 is only an example and should not impose any limitations on the functions and scope of use of the embodiments of the present disclosure.
如图6所示,电子设备600可以包括处理装置(例如中央处理器、图形处理器等)601,其可以根据存储在只读存储器(Read Only Memory,ROM)602中的程序或者从存储装置608加载到随机访问存储器(Random Access Memory,RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有电子设备600操作所需的各种程序和数据。处理装置601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in Figure 6, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processor, etc.) 601, which may process data according to a program stored in a read-only memory (Read Only Memory, ROM) 602 or from a storage device 608 The program loaded into the random access memory (Random Access Memory, RAM) 603 performs various appropriate actions and processing. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, ROM 602 and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
通常,以下装置可以连接至I/O接口605:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置606;包括例如液晶显示器(Liquid Crystal Display,LCD)、扬声器、振动器等的输出装置607;包括例如磁带、硬盘等的存储装置608;以及通信装置609。通信装置609可以允许电子设备600与其他设备进行无线或有线通信以交换数 据。虽然图6示出了具有各种装置的电子设备600,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。Generally, the following devices can be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a Liquid Crystal Display (LCD) , an output device 607 such as a speaker, a vibrator, etc.; a storage device 608 including a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. according to. Although FIG. 6 illustrates electronic device 600 with various means, it should be understood that implementation or availability of all illustrated means is not required. More or fewer means may alternatively be implemented or provided.
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在非暂态计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置609从网络上被下载和安装,或者从存储装置608被安装,或者从ROM 602被安装。在该计算机程序被处理装置601执行时,执行本公开实施例的方法中限定的上述功能。In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product including a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the method illustrated in the flowchart. In such embodiments, the computer program may be downloaded and installed from the network via communication device 609, or from storage device 608, or from ROM 602. When the computer program is executed by the processing device 601, the above functions defined in the method of the embodiment of the present disclosure are performed.
需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two. The computer-readable storage medium may be, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination thereof. More specific examples of computer readable storage media may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard drive, random access memory (RAM), read only memory (ROM), removable Programmed read-only memory (EPROM or flash memory), fiber optics, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In this disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device . Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wire, optical cable, RF (radio frequency), etc., or any suitable combination of the above.
在一些实施方式中,客户端、服务器可以利用诸如HTTP(HyperText Transfer Protocol,超文本传输协议)之类的任何当前已知或未来研发的网络协议进行通信,并且可以与任意形式或介质的数字数据通信(例如,通信网络)互连。通信网络的示例包括局域网(Local Area Network,LAN),广域网(Wide Area Network,WAN),网际网(例如,互联网)以及端对端网络(例如,ad hoc端对端网络),以及任何当前已知或未来研发的网络。In some embodiments, the client and server can communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can communicate with digital data in any form or medium. Communications (e.g., communications network) interconnections. Examples of communication networks include Local Area Networks (LANs), Wide Area Networks (WANs), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any current network for knowledge or future research and development.
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; it may also exist independently without being assembled into the electronic device.
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备:获取目标场景中待渲染的场景图像;针对所述场景图像中的每个像素点,确定所述像素点对应的目标阴影高度,并根据所述目标阴影高度,确定所述像素点对应的阴影值,根据所述阴影值,对所述像素点进行渲染,以渲染所述场景图像;其中,所述目标阴影高度为处于所述场景图像的阴影中的指定像素点的高度,所述指定像素点为与所述像素点在所述目标场景对应的世界空间的水平方向上位置相同,且在所述世界空间的高度方向上高度大于或等于预设高度阈值的像素点。The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains the scene image to be rendered in the target scene; and targets each scene image in the scene image. pixel points, determine the target shadow height corresponding to the pixel point, determine the shadow value corresponding to the pixel point according to the target shadow height, and render the pixel point according to the shadow value to render the pixel point. The scene image; wherein, the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is the horizontal direction of the world space corresponding to the pixel point in the target scene. Pixel points with the same position and a height greater than or equal to a preset height threshold in the height direction of the world space.
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括但不限于面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言——诸如“C”语言或类似的程序设计语言。程序代码可以完 全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)——连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, including but not limited to object-oriented programming languages—such as Java, Smalltalk, C++, and Includes conventional procedural programming languages - such as "C" or similar programming languages. The program code can be completed Execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In situations involving remote computers, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as an Internet service provider). connected via the Internet).
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, segment, or portion of code that contains one or more logic functions that implement the specified executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown one after another may actually execute substantially in parallel, or they may sometimes execute in the reverse order, depending on the functionality involved. It will also be noted that each block of the block diagram and/or flowchart illustration, and combinations of blocks in the block diagram and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or operations. , or can be implemented using a combination of specialized hardware and computer instructions.
描述于本公开实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,模块的名称在某种情况下并不构成对该模块本身的限定,例如,图像获取模块还可以被描述为“获取目标场景中待渲染的场景图像的模块”。The modules involved in the embodiments of the present disclosure can be implemented in software or hardware. Among them, the name of the module does not constitute a limitation on the module itself under certain circumstances. For example, the image acquisition module can also be described as "a module that acquires the scene image to be rendered in the target scene."
本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可编程门阵列(Field Programmable Gate Array,FPGA)、专用集成电路(Application Specific Integrated Circuit,ASIC)、专用标准产品(Application Specific Standard Product,ASSP)、片上系统(System on Chip,SOC)、复杂可编程逻辑设备(Complex Programmable Logic Device,CPLD)等等。The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: field programmable gate array (Field Programmable Gate Array, FPGA), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), application specific standard product (Application Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), etc.
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of this disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media may include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include one or more wire-based electrical connections, laptop disks, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
根据本公开的一个或多个实施例,示例1提供了一种图像渲染方法,所述方法包括:获取目标场景中待渲染的场景图像;针对所述场景图像中的每个像素点,确定所述像素点对应的目标阴影高度,并根据所述目标阴影高度,确定所述像素点对应的阴影值,根据所述阴影值,对所述像素点进行渲染,以渲染所述场景图像;其中,所述目标阴影高度为处于所述场景图像的阴影中的指定像素点的高度,所述指定像素点为与所述像素点在所述目标场景对应的世界空间的水平方向上位置相同,且在所述世界空间的高度方向上高度大于或等于预设高度阈值的像素点。According to one or more embodiments of the present disclosure, Example 1 provides an image rendering method. The method includes: obtaining a scene image to be rendered in a target scene; and determining, for each pixel point in the scene image, the The target shadow height corresponding to the pixel point is determined, and the shadow value corresponding to the pixel point is determined according to the target shadow height, and the pixel point is rendered according to the shadow value to render the scene image; wherein, The target shadow height is the height of a designated pixel in the shadow of the scene image, and the designated pixel is at the same position as the pixel in the horizontal direction of the world space corresponding to the target scene, and in Pixels whose height in the height direction of the world space is greater than or equal to a preset height threshold.
根据本公开的一个或多个实施例,示例2提供了示例1的方法,所述确定所述像素点对应的目标阴影高度包括:确定所述像素点对应的纹理坐标;根据所述纹理坐标和预先获取的所述场景图像对应的高度纹理,确定所述指定像素点,所述高度纹理包括所述场景图像的每个像 素点对应的阴影高度;将所述指定像素点对应的阴影高度,作为所述目标阴影高度。According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1. Determining the target shadow height corresponding to the pixel point includes: determining the texture coordinates corresponding to the pixel point; according to the texture coordinates and The height texture corresponding to the scene image obtained in advance determines the designated pixel point, and the height texture includes each image of the scene image. The shadow height corresponding to the pixel point; the shadow height corresponding to the specified pixel point is used as the target shadow height.
根据本公开的一个或多个实施例,示例3提供了示例2的方法,所述确定所述像素点对应的纹理坐标包括:获取所述像素点对应所述世界空间的坐标、该高度纹理对应的像素尺寸以及世界空间的比例;确定所述场景图像对应的地形的中心点与所述像素点对应所述世界空间的坐标的原点之间的偏移值;根据所述像素点对应所述世界空间的坐标、所述比例、所述像素尺寸以及所述偏移值,确定所述像素点对应的所述纹理坐标。According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2. Determining the texture coordinates corresponding to the pixel point includes: obtaining the coordinates of the pixel point corresponding to the world space, the height texture corresponding to The pixel size and the proportion of the world space; determine the offset value between the center point of the terrain corresponding to the scene image and the origin of the coordinates of the world space corresponding to the pixel point; according to the corresponding coordinates of the pixel point to the world The spatial coordinates, the scale, the pixel size and the offset value determine the texture coordinates corresponding to the pixel point.
根据本公开的一个或多个实施例,示例4中,所述高度纹理通过以下方式预先获取:针对所述场景图像中的每个所述像素点,确定所述像素点在所述场景图像中的光源方向的场景深度,并根据所述场景深度,确定所述像素点对应的所述阴影高度;将多个所述像素点对应的所述阴影高度所构成的集合,作为所述高度纹理。According to one or more embodiments of the present disclosure, in Example 4, the height texture is pre-acquired in the following manner: for each pixel point in the scene image, determine whether the pixel point is in the scene image The scene depth in the direction of the light source is determined, and the shadow height corresponding to the pixel point is determined according to the scene depth; a set of the shadow heights corresponding to multiple pixel points is used as the height texture.
根据本公开的一个或多个实施例,示例5中,所述根据所述场景深度,确定所述像素点对应的所述阴影高度包括:确定所述像素点对应的地形高度,所述地形高度为所述场景图像中在所述像素点对应所述世界空间的坐标的高度方向上位于所述像素点正下方的参考面的高度;在确定所述地形高度对应的位置处于所述场景图像的阴影中的情况下,获取预设高度间隔,并根据所述地形高度和所述预设高度间隔,确定所述像素点对应的所述阴影高度。According to one or more embodiments of the present disclosure, in Example 5, determining the shadow height corresponding to the pixel point according to the scene depth includes: determining the terrain height corresponding to the pixel point, and the terrain height is the height of the reference plane located directly below the pixel point in the height direction of the coordinates of the world space corresponding to the pixel point in the scene image; when it is determined that the position corresponding to the terrain height is located in the scene image In the case of shadow, a preset height interval is obtained, and the shadow height corresponding to the pixel is determined based on the terrain height and the preset height interval.
根据本公开的一个或多个实施例,示例6中,所述根据所述地形高度和所述预设高度间隔,确定所述像素点对应的所述阴影高度包括:将所述地形高度作为待定高度,并循环执行阴影高度确定步骤,直至确定新的待定高度对应的位置未处于所述场景图像的阴影中,将新的待定高度与所述预设高度间隔的差值作为所述像素点对应的阴影高度;所述阴影高度确定步骤包括:根据所述场景深度,确定所述待定高度对应的位置是否处于阴影中;在所述待定高度对应的位置处于阴影中的情况下,将所述待定高度与所述预设高度间隔的和值作为新的待定高度。According to one or more embodiments of the present disclosure, in Example 6, determining the shadow height corresponding to the pixel point according to the terrain height and the preset height interval includes: using the terrain height as an undetermined height, and execute the shadow height determination step in a loop until it is determined that the position corresponding to the new undetermined height is not in the shadow of the scene image, and the difference between the new undetermined height and the preset height interval is used as the corresponding pixel point The shadow height of The sum of the height and the preset height interval is used as the new pending height.
根据本公开的一个或多个实施例,示例7中,在所述将多个所述像素点对应的所述阴影高度所构成的集合,作为所述高度纹理前,所述方法还包括:对所述阴影高度进行滤波处理;所述将多个所述像素点对应的所述阴影高度所构成的集合,作为所述高度纹理包括:将滤波处理后的所述阴影高度所构成的集合,作为所述高度纹理。According to one or more embodiments of the present disclosure, in Example 7, before using a set of shadow heights corresponding to a plurality of pixel points as the height texture, the method further includes: The shadow height is subjected to filtering processing; the set of the shadow heights corresponding to a plurality of the pixel points as the height texture includes: the set of the shadow heights after filtering is used as The highly textured.
根据本公开的一个或多个实施例,示例8中,所述根据所述目标阴影高度,确定所述像素点对应的阴影值包括:根据所述像素点对应所述世界空间的坐标和所述阴影高度,确定所述像素点对应的阴影值。According to one or more embodiments of the present disclosure, in Example 8, determining the shadow value corresponding to the pixel point according to the target shadow height includes: according to the coordinates of the pixel point corresponding to the world space and the Shadow height determines the shadow value corresponding to the pixel.
根据本公开的一个或多个实施例,示例9提供了示例1-8中任一示例的方法,所述场景图像为游戏场景图像。According to one or more embodiments of the present disclosure, Example 9 provides the method of any one of Examples 1-8, and the scene image is a game scene image.
根据本公开的一个或多个实施例,示例10提供了一种图像渲染装置,所述装置包括:图像获取模块,用于获取目标场景中待渲染的场景图像;图像渲染模块,用于针对所述场景图像中的每个像素点,确定所述像素点对应的目标阴影高度,并根据所述目标阴影高度,确定所述像素点对应的阴影值,根据所述阴影值,对所述像素点进行渲染,以渲染所述场景图像;其中,所述目标阴影高度为处于所述场景图像的阴影中的指定像素点的高度,所述指定像素点为与所述像素点在所述目标场景对应的世界空间的水平方向上位置相同,且在所述世界空间的高度方向上高度大于或等于预设高度阈值的像素点。According to one or more embodiments of the present disclosure, Example 10 provides an image rendering device, which includes: an image acquisition module for acquiring a scene image to be rendered in a target scene; an image rendering module for For each pixel in the scene image, determine the target shadow height corresponding to the pixel, and determine the shadow value corresponding to the pixel according to the target shadow height. According to the shadow value, calculate the shadow value for the pixel. Rendering is performed to render the scene image; wherein the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is corresponding to the pixel point in the target scene. The pixels have the same position in the horizontal direction of the world space and the height in the height direction of the world space is greater than or equal to the preset height threshold.
根据本公开的一个或多个实施例,示例11提供了一种计算机可读介质,其上存储有计算 机程序,该计算机程序被处理装置执行时实现示例1-9中任一示例所述方法的步骤。In accordance with one or more embodiments of the present disclosure, Example 11 provides a computer-readable medium having a computer-readable medium stored thereon A computer program that, when executed by a processing device, implements the steps of the method described in any one of Examples 1-9.
根据本公开的一个或多个实施例,示例12提供了一种电子设备,包括:存储装置,其上存储有计算机程序;处理装置,用于执行所述存储装置中的所述计算机程序,以实现示例1-9中任一示例所述方法的步骤。According to one or more embodiments of the present disclosure, Example 12 provides an electronic device, including: a storage device having a computer program stored thereon; and a processing device configured to execute the computer program in the storage device, to Implement the steps of the method described in any of Examples 1-9.
根据本公开的一个或多个实施例,示例13提供了一种计算机程序产品,包括计算机程序,计算机程序被处理装置执行时实现示例1-9中任一示例所述方法的步骤。According to one or more embodiments of the present disclosure, Example 13 provides a computer program product, including a computer program that, when executed by a processing device, implements the steps of the method described in any one of Examples 1-9.
根据本公开的一个或多个实施例,示例14提供了提供一种计算机程序,计算机程序被处理装置执行时实现本公开示例1-9中任一示例所述方法的步骤。According to one or more embodiments of the present disclosure, Example 14 provides a computer program that, when executed by a processing device, implements the steps of the method described in any of Examples 1-9 of the present disclosure.
通过上述技术方案,通过获取目标场景中待渲染的场景图像;针对所述场景图像中的每个像素点,确定所述像素点对应的目标阴影高度,并根据所述目标阴影高度,确定所述像素点对应的阴影值,根据所述阴影值,对所述像素点进行渲染,以渲染所述场景图像;其中,所述目标阴影高度为处于所述场景图像的阴影中的指定像素点的高度,所述指定像素点为与所述像素点在所述目标场景对应的世界空间的水平方向上位置相同,且在所述世界空间的高度方向上高度大于或等于预设高度阈值的像素点。也就是说,本公开可以根据像素点对应的目标阴影高度确定该像素点的阴影值,根据该阴影值对该像素点进行渲染,这样,渲染过程中需要处理的数据量比较小,从而提高了图像渲染的效率。Through the above technical solution, the scene image to be rendered in the target scene is obtained; for each pixel in the scene image, the target shadow height corresponding to the pixel is determined, and based on the target shadow height, the target shadow height is determined. The shadow value corresponding to the pixel point is used to render the pixel point according to the shadow value to render the scene image; wherein the target shadow height is the height of the designated pixel point in the shadow of the scene image. , the designated pixel point is a pixel point that has the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, and has a height greater than or equal to a preset height threshold in the height direction of the world space. That is to say, the present disclosure can determine the shadow value of a pixel based on the target shadow height corresponding to the pixel, and render the pixel based on the shadow value. In this way, the amount of data that needs to be processed during the rendering process is relatively small, thereby improving the efficiency of the pixel. Image rendering efficiency.
以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a description of the preferred embodiments of the present disclosure and the technical principles applied. Those skilled in the art should understand that the disclosure scope involved in the present disclosure is not limited to technical solutions composed of specific combinations of the above technical features, but should also cover solutions composed of the above technical features or without departing from the above disclosed concept. Other technical solutions formed by any combination of equivalent features. For example, a technical solution is formed by replacing the above features with technical features with similar functions disclosed in this disclosure (but not limited to).
此外,虽然采用特定次序描绘了各操作,但是这不应当理解为要求这些操作以所示出的特定次序或以顺序次序执行来执行。在一定环境下,多任务和并行处理可能是有利的。同样地,虽然在上面论述中包含了若干具体实现细节,但是这些不应当被解释为对本公开的范围的限制。在单独的实施例的上下文中描述的某些特征还可以组合地实现在单个实施例中。相反地,在单个实施例的上下文中描述的各种特征也可以单独地或以任何合适的子组合的方式实现在多个实施例中。Furthermore, although operations are depicted in a specific order, this should not be understood as requiring that these operations be performed in the specific order shown or performed in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
尽管已经采用特定于结构特征和/或方法逻辑动作的语言描述了本主题,但是应当理解所附权利要求书中所限定的主题未必局限于上面描述的特定特征或动作。相反,上面所描述的特定特征和动作仅仅是实现权利要求书的示例形式。关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。 Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims. Regarding the devices in the above embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method, and will not be described in detail here.

Claims (14)

  1. 一种图像渲染方法,所述方法包括:An image rendering method, the method includes:
    获取目标场景中待渲染的场景图像;Get the scene image to be rendered in the target scene;
    针对所述场景图像中的每个像素点,确定所述像素点对应的目标阴影高度,并根据所述目标阴影高度,确定所述像素点对应的阴影值,根据所述阴影值,对所述像素点进行渲染,以渲染所述场景图像;For each pixel in the scene image, determine the target shadow height corresponding to the pixel, determine the shadow value corresponding to the pixel according to the target shadow height, and determine the shadow value according to the shadow value. Render pixels to render the scene image;
    其中,所述目标阴影高度为处于所述场景图像的阴影中的指定像素点的高度,所述指定像素点为与所述像素点在所述目标场景对应的世界空间的水平方向上位置相同,且在所述世界空间的高度方向上高度大于或等于预设高度阈值的像素点。Wherein, the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is at the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, And the height of the pixels in the height direction of the world space is greater than or equal to the preset height threshold.
  2. 根据权利要求1所述的方法,其中,所述确定所述像素点对应的目标阴影高度包括:The method according to claim 1, wherein determining the target shadow height corresponding to the pixel point includes:
    确定所述像素点对应的纹理坐标;Determine the texture coordinates corresponding to the pixel;
    根据所述纹理坐标和预先获取的所述场景图像对应的高度纹理,确定所述指定像素点,所述高度纹理包括所述场景图像的每个像素点对应的阴影高度;Determine the designated pixel point according to the texture coordinates and the pre-obtained height texture corresponding to the scene image, where the height texture includes the shadow height corresponding to each pixel point of the scene image;
    将所述指定像素点对应的阴影高度,作为所述目标阴影高度。The shadow height corresponding to the specified pixel point is used as the target shadow height.
  3. 根据权利要求2所述的方法,其中,所述确定所述像素点对应的纹理坐标包括:The method according to claim 2, wherein determining the texture coordinates corresponding to the pixel points includes:
    获取所述像素点对应所述世界空间的坐标、所述高度纹理对应的像素尺寸以及世界空间的比例;Obtain the coordinates of the pixel corresponding to the world space, the pixel size corresponding to the height texture, and the proportion of the world space;
    确定所述场景图像对应的地形的中心点与所述像素点对应所述世界空间的坐标的原点之间的偏移值;Determine the offset value between the center point of the terrain corresponding to the scene image and the origin of the coordinates of the world space corresponding to the pixel point;
    根据所述像素点对应所述世界空间的坐标、所述比例、所述像素尺寸以及所述偏移值,确定所述像素点对应的所述纹理坐标。The texture coordinates corresponding to the pixel point are determined according to the coordinates of the pixel point corresponding to the world space, the scale, the pixel size and the offset value.
  4. 根据权利要求2或3所述的方法,其中,所述高度纹理通过以下方式预先获取:The method according to claim 2 or 3, wherein the height texture is pre-obtained in the following manner:
    针对所述场景图像中的每个所述像素点,确定所述像素点在所述场景图像中的光源方向的场景深度,并根据所述场景深度,确定所述像素点对应的所述阴影高度;For each pixel point in the scene image, determine the scene depth of the pixel point in the direction of the light source in the scene image, and determine the shadow height corresponding to the pixel point based on the scene depth. ;
    将多个所述像素点对应的所述阴影高度所构成的集合,作为所述高度纹理。A set of the shadow heights corresponding to a plurality of pixel points is used as the height texture.
  5. 根据权利要求4所述的方法,其中,所述根据所述场景深度,确定所述像素点对应的所述阴影高度包括:The method according to claim 4, wherein determining the shadow height corresponding to the pixel point according to the scene depth includes:
    确定所述像素点对应的地形高度,所述地形高度为所述场景图像中在所述像素点对应所述世界空间的坐标的高度方向上位于所述像素点正下方的参考面的高度;Determine the terrain height corresponding to the pixel point, where the terrain height is the height of the reference plane located directly below the pixel point in the scene image in the height direction of the coordinates of the world space corresponding to the pixel point;
    在确定所述地形高度对应的位置处于所述场景图像的阴影中的情况下,获取预设高度间隔,并根据所述地形高度和所述预设高度间隔,确定所述像素点对应的所述阴影高度。When it is determined that the position corresponding to the terrain height is in the shadow of the scene image, a preset height interval is obtained, and based on the terrain height and the preset height interval, the position corresponding to the pixel point is determined. Shadow height.
  6. 根据权利要求5所述的方法,其中,所述根据所述地形高度和所述预设高度间隔,确定所述像素点对应的所述阴影高度包括:The method according to claim 5, wherein determining the shadow height corresponding to the pixel point according to the terrain height and the preset height interval includes:
    将所述地形高度作为待定高度,并循环执行阴影高度确定步骤,直至确定新的待定高度对应的位置未处于所述场景图像的阴影中,将新的待定高度与所述预设高度间隔的 差值作为所述像素点对应的阴影高度;The terrain height is used as the undetermined height, and the shadow height determination step is executed cyclically until it is determined that the position corresponding to the new undetermined height is not in the shadow of the scene image, and the new undetermined height is spaced from the preset height by The difference is used as the shadow height corresponding to the pixel;
    所述阴影高度确定步骤包括:The steps of determining the shadow height include:
    根据所述场景深度,确定所述待定高度对应的位置是否处于阴影中;According to the scene depth, determine whether the position corresponding to the undetermined height is in shadow;
    在所述待定高度对应的位置处于阴影中的情况下,将所述待定高度与所述预设高度间隔的和值作为新的待定高度。When the position corresponding to the undetermined height is in a shadow, the sum of the interval between the undetermined height and the preset height is used as the new undetermined height.
  7. 根据权利要求4-6中任一项所述的方法,其中,在所述将多个所述像素点对应的所述阴影高度所构成的集合,作为所述高度纹理前,所述方法还包括:The method according to any one of claims 4 to 6, wherein before using a set of the shadow heights corresponding to a plurality of pixel points as the height texture, the method further includes :
    对所述阴影高度进行滤波处理;Filter the shadow height;
    所述将多个所述像素点对应的所述阴影高度所构成的集合,作为所述高度纹理包括:The set of the shadow heights corresponding to a plurality of pixel points, as the height texture, includes:
    将滤波处理后的所述阴影高度所构成的集合,作为所述高度纹理。The set of filtered shadow heights is used as the height texture.
  8. 根据权利要求1-7中任一项所述的方法,其中,所述根据所述目标阴影高度,确定所述像素点对应的阴影值包括:The method according to any one of claims 1 to 7, wherein determining the shadow value corresponding to the pixel point according to the target shadow height includes:
    根据所述像素点对应所述世界空间的坐标和所述目标阴影高度,确定所述像素点对应的阴影值。The shadow value corresponding to the pixel point is determined according to the coordinates of the pixel point corresponding to the world space and the target shadow height.
  9. 根据权利要求1-8中任一项所述的方法,其中,所述场景图像为游戏场景图像。The method according to any one of claims 1-8, wherein the scene image is a game scene image.
  10. 一种图像渲染装置,所述装置包括:An image rendering device, the device includes:
    图像获取模块,用于获取目标场景中待渲染的场景图像;The image acquisition module is used to obtain the scene image to be rendered in the target scene;
    图像渲染模块,用于针对所述场景图像中的每个像素点,确定所述像素点对应的目标阴影高度,并根据所述目标阴影高度,确定所述像素点对应的阴影值,根据所述阴影值,对所述像素点进行渲染,以渲染所述场景图像;An image rendering module, configured to determine, for each pixel in the scene image, a target shadow height corresponding to the pixel, and determine a shadow value corresponding to the pixel according to the target shadow height. Shadow values are used to render the pixels to render the scene image;
    其中,所述目标阴影高度为处于所述场景图像的阴影中的指定像素点的高度,所述指定像素点为与所述像素点在所述目标场景对应的世界空间的水平方向上位置相同,且在所述世界空间的高度方向上高度大于或等于预设高度阈值的像素点。Wherein, the target shadow height is the height of a designated pixel point in the shadow of the scene image, and the designated pixel point is at the same position as the pixel point in the horizontal direction of the world space corresponding to the target scene, And the height of the pixels in the height direction of the world space is greater than or equal to the preset height threshold.
  11. 一种计算机可读介质,其上存储有计算机程序,所述计算机程序被处理装置执行时实现权利要求1-9中任一项所述方法的步骤。A computer-readable medium having a computer program stored thereon, which implements the steps of the method of any one of claims 1-9 when executed by a processing device.
  12. 一种电子设备,包括:An electronic device including:
    存储装置,其上存储有计算机程序;a storage device having a computer program stored thereon;
    处理装置,用于执行所述存储装置中的所述计算机程序,以实现权利要求1-9中任一项所述方法的步骤。A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1-9.
  13. 一种计算机程序产品,包括计算机程序,所述计算机程序被处理装置执行时实现权利要求1-9中任一项所述方法的步骤。A computer program product comprising a computer program that implements the steps of the method according to any one of claims 1-9 when executed by a processing device.
  14. 一种计算机程序,所述计算机程序被处理装置执行时实现权利要求1-9中任一项所述方法的步骤。 A computer program which, when executed by a processing device, implements the steps of the method of any one of claims 1-9.
PCT/CN2023/084542 2022-04-07 2023-03-28 Image rendering method and apparatus, readable medium and electronic device WO2023193639A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210363937.XA CN114742934A (en) 2022-04-07 2022-04-07 Image rendering method and device, readable medium and electronic equipment
CN202210363937.X 2022-04-07

Publications (1)

Publication Number Publication Date
WO2023193639A1 true WO2023193639A1 (en) 2023-10-12

Family

ID=82278380

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/084542 WO2023193639A1 (en) 2022-04-07 2023-03-28 Image rendering method and apparatus, readable medium and electronic device

Country Status (2)

Country Link
CN (1) CN114742934A (en)
WO (1) WO2023193639A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114742934A (en) * 2022-04-07 2022-07-12 北京字跳网络技术有限公司 Image rendering method and device, readable medium and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102436673A (en) * 2011-10-24 2012-05-02 克拉玛依红有软件有限责任公司 Shadow drafting method of large-scale outdoor scene
CN104103089A (en) * 2014-07-29 2014-10-15 无锡梵天信息技术股份有限公司 Real-time soft shadow realization method based on image screen space
CN109993823A (en) * 2019-04-11 2019-07-09 腾讯科技(深圳)有限公司 Shading Rendering method, apparatus, terminal and storage medium
US11232628B1 (en) * 2020-11-10 2022-01-25 Weta Digital Limited Method for processing image data to provide for soft shadow effects using shadow depth information
CN114119854A (en) * 2021-11-29 2022-03-01 北京字跳网络技术有限公司 Shadow rendering method, game file packaging method and corresponding devices
CN114742934A (en) * 2022-04-07 2022-07-12 北京字跳网络技术有限公司 Image rendering method and device, readable medium and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102436673A (en) * 2011-10-24 2012-05-02 克拉玛依红有软件有限责任公司 Shadow drafting method of large-scale outdoor scene
CN104103089A (en) * 2014-07-29 2014-10-15 无锡梵天信息技术股份有限公司 Real-time soft shadow realization method based on image screen space
CN109993823A (en) * 2019-04-11 2019-07-09 腾讯科技(深圳)有限公司 Shading Rendering method, apparatus, terminal and storage medium
US11232628B1 (en) * 2020-11-10 2022-01-25 Weta Digital Limited Method for processing image data to provide for soft shadow effects using shadow depth information
CN114119854A (en) * 2021-11-29 2022-03-01 北京字跳网络技术有限公司 Shadow rendering method, game file packaging method and corresponding devices
CN114742934A (en) * 2022-04-07 2022-07-12 北京字跳网络技术有限公司 Image rendering method and device, readable medium and electronic equipment

Also Published As

Publication number Publication date
CN114742934A (en) 2022-07-12

Similar Documents

Publication Publication Date Title
US11887325B2 (en) Face image processing method and apparatus, readable medium, and electronic device
CN110728622B (en) Fisheye image processing method, device, electronic equipment and computer readable medium
CN112733820B (en) Obstacle information generation method and device, electronic equipment and computer readable medium
WO2024104248A1 (en) Rendering method and apparatus for virtual panorama, and device and storage medium
WO2023193639A1 (en) Image rendering method and apparatus, readable medium and electronic device
WO2024016930A1 (en) Special effect processing method and apparatus, electronic device, and storage medium
WO2023116801A1 (en) Particle effect rendering method and apparatus, device, and medium
WO2023193642A1 (en) Video processing method and apparatus, device and storage medium
WO2024032752A1 (en) Method and apparatus for generating transition special effect image, device, and storage medium
WO2024037556A1 (en) Image processing method and apparatus, and device and storage medium
WO2024016923A1 (en) Method and apparatus for generating special effect graph, and device and storage medium
WO2023231926A1 (en) Image processing method and apparatus, device, and storage medium
WO2024088141A1 (en) Special-effect processing method and apparatus, electronic device, and storage medium
WO2024027820A1 (en) Image-based animation generation method and apparatus, device, and storage medium
CN113673446A (en) Image recognition method and device, electronic equipment and computer readable medium
WO2024041623A1 (en) Special effect map generation method and apparatus, device, and storage medium
WO2023169287A1 (en) Beauty makeup special effect generation method and apparatus, device, storage medium, and program product
WO2023193613A1 (en) Highlight shading method and apparatus, and medium and electronic device
WO2023174087A1 (en) Method and apparatus for generating special effect video, and device and storage medium
WO2023138468A1 (en) Virtual object generation method and apparatus, device, and storage medium
WO2023109564A1 (en) Video image processing method and apparatus, and electronic device and storage medium
WO2023025085A1 (en) Audio processing method and apparatus, and device, medium and program product
CN113274735B (en) Model processing method and device, electronic equipment and computer readable storage medium
CN114419299A (en) Virtual object generation method, device, equipment and storage medium
CN111862342A (en) Texture processing method and device for augmented reality, electronic equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23784203

Country of ref document: EP

Kind code of ref document: A1