Flood effect rendering method and apparatus, electronic device, and machine-readable storage medium
Patent Information
- Application Number
- CN202310454152.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-24
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2043-04-24
AI Technical Summary
上述方案如果直接迁移到移动端,虽然能够达到比较好的泛光效果,但其带宽开销是非常巨大的
[0016]根据本发明实施例的泛光效果渲染方法、装置、电子设备及机器可读存储介质,提取第一初始纹理中的高光部位的像素,获得第二初始纹理,将第二初始纹理作为最上层的下采样对象,逐层进行下采样,得到每层的下采样纹理。之后,从最下层开始,且将最下层的下采样纹理作为当前层的上采样对象,逐层对每层的上采样对象进行上采样,得到每层的上采样纹理,其中,除最下层外的每层的上采样对象为下层的上采样纹理与当前层的下采样纹理的混合结果。基于该最上层的上采样纹理,获得具有泛光效果的纹理,从而能基于该具有泛光效果的纹理进行渲染。上述泛光效果渲染过程,规避了对多个采样纹理进行高斯模糊(Gaussian Blur)处理带来的频繁切换渲染目标,整个泛光效果渲染过程所需要的贴图采样数目和渲染通道(render pass)数目具有可观的降低,从而降低性能开销。在逐层进行上采样时,将下层的上采样纹理与当前层的下采样纹理的混合,能够达到更柔和的泛光效果,在节省性能开销的前提下能够达到与采用高斯模糊处理相近似的泛光效果,以较低的性能开销实现较好泛光效果,便于应用于移动端实现泛光效果的渲染。
Smart Images

Figure CN116637365B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computers, and in particular to a method, apparatus, electronic device, and machine-readable storage medium for rendering floodlight effects. Background Technology
[0002] Bloom effect is a common and fundamental post-processing effect in game scenes. On desktop, the bloom effect produced by game engines is relatively soft, meaning it's quite good. To achieve a good bloom effect, desktop game engines typically use multiple layers of rendered texture maps and apply a corresponding Gaussian blur to each layer. This rendering process requires a large number of texture samples and render passes overall. While this approach can achieve a good bloom effect on mobile devices, the bandwidth overhead is enormous.
[0003] For rendering bloom effects on mobile devices, the aforementioned solution, including Gaussian blur processing, cannot be directly applied. Therefore, a bloom effect rendering solution is needed that achieves good bloom effects while reducing performance overhead. Summary of the Invention
[0004] In view of this, the present invention provides a method, apparatus, electronic device and machine-readable storage medium for rendering floodlight effects, which achieves better floodlight effects while reducing performance overhead and is easy to apply to mobile devices.
[0005] In a first aspect, embodiments of the present invention provide a method for rendering a flood effect, comprising: acquiring a first initial texture to be flood processed; extracting pixels of the highlight region in the first initial texture to obtain a second initial texture; using the second initial texture as the topmost downsampling object, performing downsampling layer by layer to obtain a downsampled texture for each layer, wherein the downsampling object of the lower layer is the downsampled texture obtained from the upper layer, and the downsampled texture corresponding to the lower layer is smaller than the downsampled texture corresponding to the upper layer; starting from the bottommost layer, and using the downsampled texture of the bottommost layer as the upsampling object of the current layer, performing upsampling layer by layer on the upsampled object of each layer to obtain an upsampled texture for each layer, wherein the upsampled object of each layer other than the bottommost layer is a mixture of the upsampled texture of the lower layer and the downsampled texture of the current layer; obtaining a texture with a flood effect based on the upsampled texture of the topmost layer, and rendering based on the texture with a flood effect.
[0006] According to any of the foregoing embodiments of the first aspect of the present invention, the flood effect rendering method further includes: superimposing the texture with the flood effect onto the first initial texture to obtain the flood effect at the highlight area of the first initial texture.
[0007] According to any of the foregoing embodiments of the first aspect of the present invention, the step of extracting the pixels of the highlight region in the first initial texture to obtain the second initial texture includes: performing a filtering operation on the first initial texture through a preset filter to remove first pixels with a brightness value less than a preset brightness threshold and retain second pixels with a brightness value greater than or equal to the preset brightness threshold; and obtaining the second initial texture based on all the second pixels.
[0008] According to any of the foregoing embodiments of the first aspect of the present invention, the step of obtaining the second initial texture based on all the second pixels includes: forming a third initial texture with the same texture size as the first initial texture by using all the second pixels; and reducing the texture size of the third initial texture according to a preset reduction ratio to obtain the second initial texture.
[0009] According to any of the foregoing embodiments of the first aspect of the present invention, the total number of downsampling operations when downsampling layer by layer is 4 to 8.
[0010] According to any of the foregoing embodiments of the first aspect of the present invention, the total number of upsampling operations when performing upsampling layer by layer is equal to the total number of downsampling operations when performing downsampling layer by layer.
[0011] According to any of the foregoing embodiments of the first aspect of the present invention, the total number of upsampling operations when performing upsampling layer by layer is one or two fewer than the total number of downsampling operations when performing downsampling layer by layer.
[0012] According to any of the foregoing embodiments of the first aspect of the present invention, the step of superimposing the texture with the flood effect onto the first initial texture to obtain the flood effect at the highlight area of the first initial texture includes: when it is confirmed that the texture size of the texture with the flood effect is smaller than the texture size of the first initial texture, the texture size of the texture with the flood effect is enlarged according to a preset magnification ratio to be equal to the texture size of the first initial texture, and superimposed onto the first initial texture.
[0013] Secondly, embodiments of the present invention provide a flood effect rendering apparatus, comprising: a first initial texture acquisition module, configured to acquire a first initial texture to be flood processed; a second initial texture acquisition module, configured to extract pixels of the highlight region in the first initial texture to obtain a second initial texture; a downsampling module, configured to use the second initial texture as the topmost downsampling object, and perform downsampling layer by layer to obtain a downsampled texture for each layer, wherein the downsampling object of the lower layer is the downsampled texture obtained by the upper layer sampling, and the downsampled texture corresponding to the lower layer is smaller than the downsampled texture corresponding to the upper layer; an upsampling module, configured to start from the bottommost layer, and use the bottommost downsampled texture as the upsampling object of the current layer, and perform upsampling layer by layer on the upsampled object of each layer to obtain an upsampled texture for each layer, wherein the upsampled object of each layer other than the bottommost layer is a mixture of the upsampled texture of the lower layer and the downsampled texture of the current layer; and a flood effect texture acquisition module, configured to obtain a texture with a flood effect based on the topmost upsampled texture, and perform rendering based on the texture with a flood effect.
[0014] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement a floodlight effect rendering method according to any of the foregoing embodiments of the first aspect of the present invention.
[0015] Fourthly, embodiments of the present invention provide a machine-readable storage medium, characterized in that the machine-readable storage medium stores machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the floodlight effect rendering method according to any of the foregoing embodiments of the first aspect of the present invention.
[0016] According to embodiments of the present invention, a method, apparatus, electronic device, and machine-readable storage medium for rendering a flood effect extracts pixels from the highlight areas of a first initial texture to obtain a second initial texture. The second initial texture is then used as the topmost downsampling object, and downsampling is performed layer by layer to obtain downsampled textures for each layer. Then, starting from the bottommost layer, and using the bottommost downsampled texture as the upsampling object for the current layer, upsampling is performed layer by layer on the upsampled object to obtain upsampled textures for each layer. The upsampled object for each layer, except the bottommost layer, is a mixture of the upsampled texture of the lower layer and the downsampled texture of the current layer. Based on the topmost upsampled texture, a texture with a flood effect is obtained, enabling rendering based on this texture. This flood effect rendering process avoids the frequent switching of rendering targets caused by Gaussian blurring of multiple sampled textures, significantly reducing the number of texture samples and render passes required for the entire flood effect rendering process, thereby reducing performance overhead. When upsampling layer by layer, the blending of the upsampled texture of the lower layer with the downsampled texture of the current layer can achieve a softer bloom effect. While saving performance overhead, it can achieve a bloom effect similar to that of Gaussian blur processing. It achieves a good bloom effect with low performance overhead, which is convenient for rendering bloom effects on mobile devices.
[0017] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0018] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0019] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0020] Figure 1 A flowchart of a floodlight effect rendering method provided in one embodiment of the present invention;
[0021] Figure 2A flowchart of the step of extracting pixels of the highlight area in the first initial texture to obtain the second initial texture in the floodlight effect rendering method provided in an embodiment of the present invention;
[0022] Figure 3 This is a flowchart illustrating texture processing in a floodlight effect rendering method provided in an embodiment of the present invention.
[0023] Figure 4 This is a structural block diagram of a floodlight effect rendering device provided in one embodiment of the present invention;
[0024] Figure 5 This is a structural block diagram of an electronic device provided in one embodiment of the present invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] Bloom effect is a common and fundamental post-processing effect in game scenes. On desktop, game engines produce a relatively soft bloom effect, meaning the bloom effect is quite good. To achieve a good bloom effect, desktop game engines typically use multiple layers of rendered texture maps and apply a corresponding Gaussian blur to each layer. This rendering process requires a large number of texture samples and render passes overall. While this approach can achieve a good bloom effect on mobile devices, the bandwidth overhead is enormous. Therefore, the above approach, including Gaussian blur processing, cannot be directly used for bloom effect rendering on mobile devices.
[0027] To reduce bandwidth overhead, other blurring methods can be used instead of Gaussian blur, such as Kawase Blur or Dual Filter Blur. However, while Kawase Blur or Dual Filter Blur reduces bandwidth, the final flood effect is significantly different from that achieved with Gaussian blur, resulting in unsatisfactory visual effects. Therefore, a flood effect rendering solution is needed that balances flood effect with performance overhead, achieving good flood effect while reducing performance costs.
[0028] Based on this, the present invention provides a flood effect rendering method, apparatus, electronic device and machine-readable storage medium that achieves a good flood effect while reducing performance overhead, making it easy to apply to mobile devices for flood effect rendering.
[0029] The floodlight effect rendering method in one embodiment of the present invention can run on a client device or a server. When the floodlight effect rendering method runs on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0030] In some alternative implementations, various cloud applications, such as cloud gaming, can run under the cloud interaction system. Taking cloud gaming as an example, cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game program and the game screen presentation are separated. The storage and execution of the bloom effect rendering method are completed on the cloud gaming server. The client device is used for data reception, transmission, and game screen presentation. For example, the client device can be a display device with data transmission capabilities located close to the user, such as a mobile terminal, television, computer, or PDA; however, the information processing is performed by the cloud gaming server in the cloud. When playing the game, the player operates the client device to send operation commands to the cloud gaming server. The cloud gaming server runs the game according to the operation commands, encodes and compresses the game screen and other data, returns it to the client device via the network, and finally, the client device decodes and outputs the game screen.
[0031] In some alternative implementations, taking a game as an example, the local terminal device stores the game program and is used to display the game screen. The local terminal device is used to interact with the player through a graphical user interface (GUI), i.e., conventionally downloading, installing, and running the game program via an electronic device. The local terminal device can provide the GUI to the player in various ways, such as rendering it on the terminal's display screen or providing it to the player via holographic projection. For example, the local terminal device can include a display screen for displaying the GUI, which includes game screens, and a processor for running the game, generating the GUI, and controlling the display of the GUI on the display screen.
[0032] In one possible implementation, this invention provides a method for rendering a floodlight effect. A graphical user interface (GUI) is provided via a terminal device, which can be either a local terminal device or a client device within a cloud interaction system. This GUI can display interface content based on the type of application being launched, such as game scene visuals, communication interaction windows, game map data, etc.
[0033] To facilitate understanding of this embodiment, a detailed description of the floodlight effect rendering method disclosed in this embodiment of the invention will be provided first. Figure 1 This is a flowchart illustrating a floodlight effect rendering method according to an embodiment of the present invention. In this embodiment, the floodlight effect rendering method includes steps S110 to S150.
[0034] In step S110, the first initial texture to be floodlighted is obtained.
[0035] In step S120, pixels of the highlight areas in the first initial texture are extracted to obtain the second initial texture.
[0036] Figure 2 The flowchart of the step of extracting the pixels of the highlight area in the first initial texture to obtain the second initial texture in the flood effect rendering method provided by an embodiment of the present invention is as follows: In some embodiments, step S120 of extracting the pixels of the highlight area in the first initial texture to obtain the second initial texture includes steps S121 and S122.
[0037] In step S121, the first initial texture is filtered by a preset filter to remove the first pixel whose brightness value is less than the preset brightness threshold, and retain the second pixel whose brightness value is greater than or equal to the preset brightness threshold.
[0038] In step S122, a second initial texture is obtained based on all the second pixels.
[0039] Specifically, in some embodiments, step S122, which obtains a second initial texture based on all second pixels, may include: forming a third initial texture with the same texture size as the first initial texture using all second pixels; and reducing the texture size of the third initial texture by a preset reduction ratio to obtain the second initial texture. For example, if the preset reduction ratio is 1 / 2, reducing the texture size of the third initial texture to 1 / 2 results in a second initial texture with a texture size that is 1 / 2 of the first initial texture. In this embodiment, reducing the texture size of the third initial texture by a preset reduction ratio also means reducing the resolution of the third initial texture by a preset reduction ratio.
[0040] Figure 3This is a flowchart illustrating the texture processing in a floodlight effect rendering method provided in one embodiment of the present invention. Figure 3 In the brackets, the characters are used to identify the texture size of the corresponding texture. Specifically, the characters in the brackets indicate the ratio of the texture size of the texture to the texture size of the first initial texture. For example, the second initial texture corresponds to "1 / 2RT" in the brackets, which means that the texture size of the second initial texture is 1 / 2 of the texture size of the first initial texture.
[0041] like Figure 1 In step S130, the second initial texture is used as the topmost downsampled object, and downsampling is performed layer by layer to obtain the downsampled texture of each layer. The downsampled object of the lower layer is the downsampled texture obtained by the upper layer sampling, and the downsampled texture corresponding to the lower layer is smaller than the downsampled texture corresponding to the upper layer.
[0042] In this embodiment, texture layers are divided according to texture size or resolution. Textures within the same layer have the same texture size or resolution, while textures in different layers have different texture sizes or resolutions. In this embodiment, "upper layer" and "lower layer" refer to two adjacent texture layers, with the larger texture size being the upper layer and the smaller texture size being the lower layer. For example, Figure 3 In the middle, "downsampled texture (1 / 4RT)" and "downsampled texture (1 / 8RT)" are two adjacent layers, with the upper layer being "downsampled texture (1 / 4RT)" and the lower layer being "downsampled texture (1 / 8RT)".
[0043] In some embodiments, the total number of downsampling operations during layer-by-layer downsampling is 4 to 8. In this embodiment, a total of 5 downsampling operations during layer-by-layer downsampling is used as an example. That is, in step S130, based on the second initial texture, 5 downsampling operations are performed layer by layer to obtain 5 corresponding downsampled textures, with the texture size of the 5 downsampled textures decreasing layer by layer. In this embodiment, a 2:1 downsampling ratio is used as an example. That is, in step S130, each downsampling operation yields a sampled texture with a texture size reduced by 2:1. In this embodiment, each downsampling operation yields a downsampled texture with a texture size reduced by a preset ratio, which also means that each downsampling operation yields a downsampled texture with a resolution reduced by a preset ratio.
[0044] In step S140, starting from the bottom layer, and using the downsampled texture of the bottom layer as the upsampled object of the current layer, upsampling is performed on the upsampled object of each layer to obtain the upsampled texture of each layer. The upsampled object of each layer, except the bottom layer, is the result of a blend of the upsampled texture of the lower layer and the downsampled texture of the current layer. In this embodiment, the blending result of the upsampled texture of the lower layer and the downsampled texture of the current layer is the result obtained by merging the channels of the upsampled texture of the lower layer and the downsampled texture of the current layer.
[0045] In this embodiment, the sampling ratio is 1:2 as an example. That is, in step S140, the ratio of the texture size of the upsampled object to the texture size of the corresponding upsampled texture is 1:2.
[0046] In some embodiments, the total number of upsampling operations during layer-by-layer upsampling is equal to the total number of downsampling operations during layer-by-layer downsampling. In this case, the texture size of the resulting texture with a bloom effect is the same as the texture size of the second initial texture, and the bloom effect of the texture with a bloom effect is better.
[0047] In some embodiments, the total number of upsampling operations when performing upsampling layer by layer is one or two fewer than the total number of downsampling operations when performing downsampling layer by layer. Each upsampling operation mixes the upsampled texture of the lower layer with the downsampled texture of the current layer, which can achieve a relatively soft flood effect. While saving performance overhead, it can achieve a flood effect similar to that of using Gaussian blur processing.
[0048] In this embodiment, as mentioned above, we will take a total of 5 downsampling times and 4 upsampling times as an example. That is, the total number of upsampling times is less than the total number of downsampling times. Under the premise of achieving a relatively soft floodlight effect, we reduce the performance overhead caused by one upsampling time and further save performance overhead.
[0049] In step S150, a texture with a bloom effect is obtained based on the topmost upsampled texture, and rendering is performed based on the texture with the bloom effect.
[0050] like Figure 1 In this embodiment, the flood effect rendering method further includes step S160. In step S160, the texture with the flood effect is superimposed on the first initial texture, and the flood effect is obtained at the highlight area of the first initial texture.
[0051] In some embodiments, the texture size of the texture with the flood effect may be smaller than the texture size of the first initial texture. The step of superimposing the texture with the flood effect onto the first initial texture to obtain the flood effect at the highlight area of the first initial texture may include: when it is confirmed that the texture size of the texture with the flood effect is smaller than the texture size of the first initial texture, enlarging the texture size of the texture with the flood effect by a preset magnification ratio to be equal to the texture size of the first initial texture, and superimposing it onto the first initial texture.
[0052] According to the flood effect rendering method of this invention, pixels of the highlight areas in a first initial texture are extracted to obtain a second initial texture. This second initial texture is then used as the topmost downsampling object, and downsampling is performed layer by layer to obtain downsampled textures for each layer. Next, starting from the bottommost layer, and using the bottommost downsampled texture as the upsampling object for the current layer, upsampling is performed layer by layer on the upsampled object to obtain upsampled textures for each layer. The upsampled object for each layer, except the bottommost layer, is a mixture of the upsampled texture of the lower layer and the downsampled texture of the current layer. Based on this topmost upsampled texture, a texture with a flood effect is obtained, enabling rendering based on this texture. This flood effect rendering process avoids the frequent switching of rendering targets caused by Gaussian blurring of multiple sampled textures, significantly reducing the number of texture samples and rendering channels required for the entire flood effect rendering process, thereby reducing performance overhead. When upsampling layer by layer, the blending of the upsampled texture of the lower layer with the downsampled texture of the current layer can achieve a softer bloom effect. While saving performance overhead, it can achieve a bloom effect similar to that of Gaussian blur processing. It achieves a good bloom effect with low performance overhead, which is convenient for rendering bloom effects on mobile devices.
[0053] This invention also provides a floodlight effect rendering device. Figure 4 This is a structural block diagram of a flood effect rendering device according to an embodiment of the present invention. The flood effect rendering device includes a first initial texture acquisition module 110, a second initial texture acquisition module 120, a downsampling module 130, an upsampling module 140, and a flood effect texture acquisition module 150.
[0054] The first initial texture acquisition module 110 is used to acquire a first initial texture to be processed by floodlighting. The second initial texture acquisition module 120 is used to extract the pixels of the highlight areas in the first initial texture to obtain the second initial texture.
[0055] The downsampling module 130 is used to take the second initial texture as the top-level downsampling object and perform downsampling layer by layer to obtain the downsampling texture of each layer. The downsampling object of the lower layer is the downsampling texture obtained by the upper layer sampling, and the downsampling texture corresponding to the lower layer is smaller than the downsampling texture corresponding to the upper layer.
[0056] The upsampling module 140 is used to upsample the upsampling objects of each layer, starting from the bottom layer and using the downsampled texture of the bottom layer as the upsampling object of the current layer, to obtain the upsampled texture of each layer. The upsampled object of each layer except the bottom layer is the result of the mixture of the upsampled texture of the lower layer and the downsampled texture of the current layer.
[0057] The flood effect texture acquisition module 150 is used to obtain a texture with a flood effect based on the top-level upsampled texture, and then render based on the texture with the flood effect.
[0058] According to the flood effect rendering apparatus of the present invention, the second initial texture acquisition module 120 extracts pixels of the highlight areas in the first initial texture to obtain the second initial texture. The downsampling module 130 uses the second initial texture as the topmost downsampling object and performs downsampling layer by layer to obtain the downsampled texture of each layer. Then, the upsampling module 140 starts from the bottommost layer and uses the bottommost downsampled texture as the upsampling object of the current layer, and performs upsampling layer by layer on the upsampled object of each layer to obtain the upsampled texture of each layer. Among them, the upsampled object of each layer except the bottommost layer is the mixture result of the upsampled texture of the lower layer and the downsampled texture of the current layer. The flood effect texture acquisition module 150 obtains a texture with a flood effect based on the topmost upsampled texture, so that rendering can be performed based on the texture with a flood effect. The above flood effect rendering process avoids the frequent switching of rendering targets caused by Gaussian blur processing of multiple sampled textures. The number of texture samples and rendering channels required for the entire flood effect rendering process is significantly reduced, thereby reducing performance overhead. When upsampling layer by layer, the blending of the upsampled texture of the lower layer with the downsampled texture of the current layer can achieve a softer bloom effect. While saving performance overhead, it can achieve a bloom effect similar to that of Gaussian blur processing. It achieves a good bloom effect with low performance overhead, which is convenient for rendering bloom effects on mobile devices.
[0059] In some embodiments, the flood effect rendering apparatus further includes a flood effect overlay module 160, which is used to overlay a texture with a flood effect onto a first initial texture to obtain a flood effect at the highlight area of the first initial texture.
[0060] In some embodiments, the second initial texture acquisition module 120 includes a filter unit and a pixel synthesis unit. The filter unit is used to filter the first initial texture using a preset filter, removing first pixels with brightness values less than a preset brightness threshold, and retaining second pixels with brightness values greater than or equal to the preset brightness threshold. The pixel synthesis unit is used to obtain the second initial texture based on all the second pixels.
[0061] In some embodiments, the pixel synthesis unit is configured to: compose a third initial texture with the same texture size as the first initial texture by using all the second pixels; and reduce the texture size of the third initial texture by a preset reduction ratio to obtain a second initial texture.
[0062] In some embodiments, the total number of downsampling operations when downsampling layer by layer is 4 to 8.
[0063] Optionally, the total number of upsampling operations when performing upsampling layer by layer is equal to the total number of downsampling operations when performing downsampling layer by layer.
[0064] Optionally, the total number of upsampling operations when performing layer-by-layer upsampling is one or two fewer than the total number of downsampling operations when performing layer-by-layer downsampling.
[0065] In some embodiments, the flood effect overlay module 160 is configured to: when it is confirmed that the texture size of the texture with the flood effect is smaller than the texture size of the first initial texture, enlarge the texture size of the texture with the flood effect to be equal to the texture size of the first initial texture according to a preset magnification ratio, and overlay it onto the first initial texture.
[0066] This embodiment also provides an electronic device, including a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-described floodlight effect rendering method. This electronic device can be a server or a terminal device.
[0067] Figure 5 The present invention provides a structural block diagram of an electronic device, which includes a processor 901 and a memory 902. The memory 902 stores machine-executable instructions that can be executed by the processor 901. The processor 901 executes the machine-executable instructions to implement the above-described floodlight effect rendering method.
[0068] The flood effect rendering method includes: obtaining a first initial texture to be flooded; extracting pixels from the highlight areas of the first initial texture to obtain a second initial texture; using the second initial texture as the topmost downsampling object, downsampling is performed layer by layer to obtain a downsampled texture for each layer, wherein the downsampled object of the lower layer is the downsampled texture obtained from the upper layer, and the downsampled texture corresponding to the lower layer is smaller than the downsampled texture corresponding to the upper layer; starting from the bottommost layer, and using the downsampled texture of the bottommost layer as the upsampled object of the current layer, upsampling is performed layer by layer on the upsampled object of each layer to obtain an upsampled texture for each layer, wherein the upsampled object of each layer except the bottommost layer is the blending result of the upsampled texture of the lower layer and the downsampled texture of the current layer; obtaining a texture with flood effect based on the upsampled texture of the topmost layer, and rendering is performed based on the texture with flood effect.
[0069] Furthermore, the electronic device may also include a communication interface 903 and a bus 904, with the processor 901, communication interface 903 and memory 902 connected via the bus 904.
[0070] The memory 902 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 903 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network. The bus 904 may be an ISA bus, PCI bus, or EISA bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, a bus is represented by only a single bidirectional arrow in the accompanying drawings, but this does not imply that there is only one bus or one type of bus.
[0071] The processor 901 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 901 or by instructions in software form. The processor 901 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 902. Processor 901 reads information from memory 902 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.
[0072] In some embodiments, the flood effect rendering method further includes: overlaying a texture with a flood effect onto a first initial texture to obtain a flood effect at the highlight area of the first initial texture.
[0073] In some embodiments, the step of extracting pixels of the highlight region in the first initial texture to obtain the second initial texture includes: filtering the first initial texture through a preset filter to remove first pixels with a brightness value less than a preset brightness threshold and retaining second pixels with a brightness value greater than or equal to the preset brightness threshold; and obtaining the second initial texture based on all the second pixels.
[0074] In some embodiments, the step of obtaining a second initial texture based on all second pixels includes: forming a third initial texture with the same texture size as a first initial texture using all second pixels; and reducing the texture size of the third initial texture according to a preset reduction ratio to obtain the second initial texture.
[0075] In some embodiments, the total number of downsampling operations when downsampling layer by layer is 4 to 8.
[0076] Optionally, the total number of upsampling operations when performing upsampling layer by layer is equal to the total number of downsampling operations when performing downsampling layer by layer.
[0077] Optionally, the total number of upsampling operations when performing upsampling layer by layer is one or two fewer than the total number of downsampling operations when performing downsampling layer by layer.
[0078] In some embodiments, the step of superimposing a texture with a flood effect onto a first initial texture to obtain a flood effect at the highlight area of the first initial texture includes: when it is confirmed that the texture size of the texture with the flood effect is smaller than the texture size of the first initial texture, the texture size of the texture with the flood effect is enlarged to be equal to the texture size of the first initial texture according to a preset magnification ratio, and superimposed onto the first initial texture.
[0079] An electronic device according to an embodiment of the present invention includes a processor 901 and a memory 902. When the processor 901 executes machine-executable instructions to implement the above-described flood effect rendering method, it extracts pixels of the highlight areas in a first initial texture to obtain a second initial texture. The second initial texture is used as the topmost downsampling object, and downsampling is performed layer by layer to obtain downsampled textures for each layer. Then, starting from the bottommost layer, and using the bottommost downsampled texture as the current layer's upsampling object, upsampling is performed layer by layer on the upsampled object to obtain upsampled textures for each layer. The upsampled object for each layer, except the bottommost layer, is a mixture of the upsampled texture of the lower layer and the downsampled texture of the current layer. Based on the topmost upsampled texture, a texture with a flood effect is obtained, enabling rendering based on this texture. The above-described flood effect rendering process avoids the frequent switching of rendering targets caused by Gaussian blurring of multiple sampled textures. The number of texture samples and rendering channels required for the entire flood effect rendering process is significantly reduced, thereby reducing performance overhead. When upsampling layer by layer, the blending of the upsampled texture of the lower layer with the downsampled texture of the current layer can achieve a softer bloom effect. While saving performance overhead, it can achieve a bloom effect similar to that of Gaussian blur processing. It achieves a good bloom effect with low performance overhead, which is convenient for rendering bloom effects on mobile devices.
[0080] This embodiment also provides a machine-readable storage medium that stores machine-executable instructions. When the machine-executable instructions are called and executed by the processor, the machine-executable instructions cause the processor to implement the above-described floodlight effect rendering method.
[0081] The flood effect rendering method includes: obtaining a first initial texture to be flooded; extracting pixels from the highlight areas of the first initial texture to obtain a second initial texture; using the second initial texture as the topmost downsampling object, downsampling is performed layer by layer to obtain a downsampled texture for each layer, wherein the downsampled object of the lower layer is the downsampled texture obtained from the upper layer, and the downsampled texture corresponding to the lower layer is smaller than the downsampled texture corresponding to the upper layer; starting from the bottommost layer, and using the downsampled texture of the bottommost layer as the upsampled object of the current layer, upsampling is performed layer by layer on the upsampled object of each layer to obtain an upsampled texture for each layer, wherein the upsampled object of each layer except the bottommost layer is the blending result of the upsampled texture of the lower layer and the downsampled texture of the current layer; obtaining a texture with flood effect based on the upsampled texture of the topmost layer, and rendering is performed based on the texture with flood effect.
[0082] In some embodiments, the flood effect rendering method further includes: overlaying a texture with a flood effect onto a first initial texture to obtain a flood effect at the highlight area of the first initial texture.
[0083] In some embodiments, the step of extracting pixels of the highlight region in the first initial texture to obtain the second initial texture includes: filtering the first initial texture through a preset filter to remove first pixels with a brightness value less than a preset brightness threshold and retaining second pixels with a brightness value greater than or equal to the preset brightness threshold; and obtaining the second initial texture based on all the second pixels.
[0084] In some embodiments, the step of obtaining a second initial texture based on all second pixels includes: forming a third initial texture with the same texture size as a first initial texture using all second pixels; and reducing the texture size of the third initial texture according to a preset reduction ratio to obtain the second initial texture.
[0085] In some embodiments, the total number of downsampling operations when downsampling layer by layer is 4 to 8.
[0086] Optionally, the total number of upsampling operations when performing upsampling layer by layer is equal to the total number of downsampling operations when performing downsampling layer by layer.
[0087] Optionally, the total number of upsampling operations when performing upsampling layer by layer is one or two fewer than the total number of downsampling operations when performing downsampling layer by layer.
[0088] In some embodiments, the step of superimposing a texture with a flood effect onto a first initial texture to obtain a flood effect at the highlight area of the first initial texture includes: when it is confirmed that the texture size of the texture with the flood effect is smaller than the texture size of the first initial texture, the texture size of the texture with the flood effect is enlarged to be equal to the texture size of the first initial texture according to a preset magnification ratio, and superimposed onto the first initial texture.
[0089] According to an embodiment of the present invention, a machine-readable storage medium stores machine-executable instructions. When these machine-executable instructions are called and executed by a processor, they cause the processor to implement the above-described flood effect rendering method. Specifically, pixels of the highlight regions in a first initial texture are extracted to obtain a second initial texture. The second initial texture is used as the topmost downsampling object, and downsampling is performed layer by layer to obtain downsampled textures for each layer. Then, starting from the bottommost layer, and using the bottommost downsampled texture as the upsampling object for the current layer, upsampling is performed layer by layer on the upsampled object to obtain upsampled textures for each layer. The upsampled object for each layer, except the bottommost layer, is a mixture of the upsampled texture of the lower layer and the downsampled texture of the current layer. Based on the topmost upsampled texture, a texture with a flood effect is obtained, enabling rendering based on this texture. The above-described flood effect rendering process avoids the frequent switching of rendering targets caused by Gaussian blurring of multiple sampled textures. The number of texture samples and rendering channels required for the entire flood effect rendering process is significantly reduced, thereby reducing performance overhead. When upsampling layer by layer, the blending of the upsampled texture of the lower layer with the downsampled texture of the current layer can achieve a softer bloom effect. While saving performance overhead, it can achieve a bloom effect similar to that of Gaussian blur processing. It achieves a good bloom effect with low performance overhead, which is convenient for rendering bloom effects on mobile devices.
[0090] The floodlight effect rendering method, apparatus, electronic device, and computer program product of machine-readable storage medium provided in the embodiments of the present invention include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.
[0091] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0092] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.
[0093] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0094] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0095] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for rendering a floodlight effect, characterized in that, include: Obtain the first initial texture to be processed for floodlighting; Extract the pixels of the highlight areas from the first initial texture to obtain the second initial texture; The second initial texture is used as the top-level downsampling object, and downsampling is performed layer by layer to obtain the downsampled texture of each layer. The downsampled object of the lower layer is the downsampled texture obtained by the upper layer sampling, and the downsampled texture corresponding to the lower layer is smaller than the downsampled texture corresponding to the upper layer. Starting from the bottom layer, and taking the downsampled texture of the bottom layer as the upsampled object of the current layer, upsample the upsampled object of each layer layer by layer to obtain the upsampled texture of each layer. Among them, the upsampled object of each layer except the bottom layer is the result of the mixture of the upsampled texture of the lower layer and the downsampled texture of the current layer. Based on the topmost upsampled texture, a texture with a bloom effect is obtained, and rendering is performed based on the texture with the bloom effect. The step of extracting the pixels of the highlight regions in the first initial texture to obtain the second initial texture includes: The first initial texture is filtered by a preset filter to remove the first pixel whose brightness value is less than the preset brightness threshold, and retain the second pixel whose brightness value is greater than or equal to the preset brightness threshold. A third initial texture with the same texture size as the first initial texture is formed by using all the second pixels; The texture size of the third initial texture is reduced according to a preset reduction ratio to obtain the second initial texture.
2. The floodlight effect rendering method according to claim 1, characterized in that, Also includes: The texture with the flood effect is superimposed on the first initial texture to obtain the flood effect in the highlight area of the first initial texture.
3. The floodlight effect rendering method according to claim 1, characterized in that, The total number of downsampling operations when downsampling layer by layer is 4 to 8.
4. The floodlight effect rendering method according to claim 1, characterized in that, The total number of upsampling operations when performing upsampling layer by layer is equal to the total number of downsampling operations when performing downsampling layer by layer.
5. The floodlight effect rendering method according to claim 1, characterized in that, The total number of upsampling operations when performing upsampling layer by layer is one or two fewer than the total number of downsampling operations when performing downsampling layer by layer.
6. The floodlight effect rendering method according to claim 2, characterized in that, The step of overlaying the texture with the flood effect onto the first initial texture to obtain the flood effect in the highlight areas of the first initial texture includes: When it is confirmed that the texture size of the texture with the flood effect is smaller than the texture size of the first initial texture, the texture size of the texture with the flood effect is enlarged according to a preset magnification ratio until it is equal to the texture size of the first initial texture, and then superimposed on the first initial texture.
7. A floodlight effect rendering device, characterized in that, include: The first initial texture acquisition module is used to acquire the first initial texture to be processed by floodlight; The second initial texture acquisition module is used to extract the pixels of the highlight areas in the first initial texture to obtain the second initial texture; The downsampling module is used to take the second initial texture as the top-level downsampling object and downsample layer by layer to obtain the downsampled texture of each layer. The downsampled object of the lower layer is the downsampled texture obtained by the upper layer sampling, and the downsampled texture corresponding to the lower layer is smaller than the downsampled texture corresponding to the upper layer. The upsampling module is used to upsample the upsampling objects of each layer, starting from the bottom layer and using the downsampled texture of the bottom layer as the upsampling object of the current layer, to obtain the upsampled texture of each layer. The upsampled object of each layer other than the bottom layer is the result of the mixture of the upsampled texture of the lower layer and the downsampled texture of the current layer. The flood effect texture acquisition module is used to obtain a texture with a flood effect based on the topmost upsampled texture, and to render based on the texture with the flood effect. The second initial texture acquisition module is further configured to perform a filtering operation on the first initial texture through a preset filter, remove the first pixel whose brightness value is less than a preset brightness threshold, and retain the second pixel whose brightness value is greater than or equal to the preset brightness threshold; form a third initial texture with the same texture size as the first initial texture by using all the second pixels; and reduce the texture size of the third initial texture according to a preset reduction ratio to obtain the second initial texture.
8. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the floodlight effect rendering method according to any one of claims 1-6.
9. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the floodlight effect rendering method according to any one of claims 1-6.
Citation Information
Patent Citations
Image-based HDR (high-dynamic range) illumination rendering method
CN104157005A
Method and system for rendering optimization of glow effect
CN112184877A