Volumetric cloud rendering method, device, electronic device and storage medium
By fixing the number of iterations in the light stepping algorithm and combining noise and lighting processing, the problem of low rendering efficiency in the existing technology is solved, and a more efficient volumetric cloud rendering effect is achieved.
Patent Information
- Application Number
- CN202011541155.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-23
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2040-12-23
AI Technical Summary
When rendering sea of clouds or fog in the existing technology, the light stepping algorithm renders based on the distance between the pixel and the sea of clouds, resulting in an uncertain number of iterations. Especially when the distance is long or the step length is short, the rendering efficiency is low.
By obtaining the rendering parameters of the volumetric cloud, a light stepping algorithm is used to fix the number of iterations for each pixel, noise sampling and lighting processing are performed based on noise parameters and lighting parameters, the shape and lighting effects of the volumetric cloud are adjusted, and a configuration interface is provided to adjust Number of iterations.
It ensures a fixed number of iterations for each pixel, improves the rendering efficiency of volumetric clouds, and improves the rendering effect through noise and lighting processing.
Smart Images

Figure CN112669432B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and more specifically, to a volumetric cloud rendering method, device, electronic device, and storage medium. Background Art
[0002] Currently, when rendering clouds or fog in virtual scenes, ray marching is typically performed using a preset step length based on the distance between a pixel and the cloud in the world coordinate system. The number of ray marches determines the density of the cloud.
[0003] However, since the distance between different pixels and the sea of clouds is affected by many factors, this distance affects the specific number of iterations required. When this distance is long or the preset step length is short, there is a problem of poor rendering efficiency. Summary of the Invention
[0004] In a first aspect, embodiments of the present application provide a method for determining the color of a volumetric cloud, applied to an electronic device, the method comprising:
[0005] Get the rendering parameters of volumetric clouds;
[0006] For each pixel in a target pixel area, iterating a preset number of times through a ray marching algorithm according to the rendering parameters to obtain a target color of the pixel, wherein the target pixel area is used to display the volumetric cloud;
[0007] Render the target color to the pixel.
[0008] In a possible implementation, the rendering parameters include noise parameters, and obtaining the target color of the pixel by iterating a preset number of times through a ray marching algorithm according to the rendering parameters includes:
[0009] For each iterative process, noise sampling is performed on the intermediate color according to the noise parameter, wherein the target color is the iterative result of the intermediate color, and the noise sampling is used to adjust the shape of the volumetric cloud.
[0010] In one possible implementation, the rendering parameters include noise parameters and lighting parameters, and obtaining the target color of the pixel by iterating a preset number of times through a ray marching algorithm according to the rendering parameters includes:
[0011] For each iterative process, noise sampling is performed on the intermediate color according to the noise parameter, and illumination processing is performed on the sampling result of the intermediate color according to the illumination parameter, wherein the target color is the iterative result of the intermediate color.
[0012] In a possible implementation, for each pixel in the target pixel area, before obtaining the target color of the pixel by iterating a preset number of times through a ray marching algorithm according to the rendering parameters, the parameter acquisition module is further configured to:
[0013] Providing a configuration interface;
[0014] Detecting an iteration number adjustment operation in the configuration interface;
[0015] In response to the iteration number adjustment operation, the preset number is obtained.
[0016] In a second aspect, an embodiment of the present application provides a volumetric cloud rendering device, the volumetric cloud rendering device comprising:
[0017] Parameter acquisition module, used to obtain the rendering parameters of volumetric clouds;
[0018] a color calculation module configured to obtain, for each pixel in a target pixel area, a target color of the pixel point by iterating a preset number of times through a ray marching algorithm according to the rendering parameters, wherein the target pixel area is used to display the volumetric cloud;
[0019] A color rendering module is used to render the target color to the pixel point.
[0020] In a possible implementation, the rendering parameter includes a noise parameter; and the color calculation module is specifically configured to:
[0021] For each iterative process, noise sampling is performed on the intermediate color according to the noise parameter, wherein the target color is the iterative result of the intermediate color, and the noise sampling is used to adjust the shape of the volumetric cloud.
[0022] In a possible implementation, the rendering parameters include noise parameters and illumination parameters, and the color calculation module is specifically configured to:
[0023] For each iterative process, noise sampling is performed on the intermediate color according to the noise parameter, and illumination processing is performed on the sampling result of the intermediate color according to the illumination parameter, wherein the target color is the iterative result of the intermediate color.
[0024] In a possible implementation, for each pixel in the target pixel area, before obtaining the target color of the pixel by iterating a preset number of times through a ray marching algorithm according to the rendering parameters, the parameter acquisition module is further configured to:
[0025] Providing a configuration interface;
[0026] Detecting an iteration number adjustment operation in the configuration interface;
[0027] In response to the iteration number adjustment operation, the preset number is obtained.
[0028] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when computer executable instructions corresponding to the computer program are executed by the processor, the volumetric cloud rendering method is implemented.
[0029] In a fourth aspect, an embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, and when computer executable instructions corresponding to the computer program are executed by a processor, the volumetric cloud rendering method is implemented.
[0030] Compared with the prior art, this application has the following beneficial effects:
[0031] In the volumetric cloud rendering method, apparatus, electronic device, and storage medium provided in embodiments of the present application, when rendering a volumetric cloud using a ray marching algorithm, the electronic device performs the same number of iterations for each pixel, thereby limiting the number of iterations. Because the number of iterations is fixed, the rendering efficiency of the volumetric cloud can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0033] Figure 1 A schematic diagram illustrating the principle of the ray stepping algorithm provided in an embodiment of the present application;
[0034] Figure 2 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0035] Figure 3 This is a schematic diagram of the steps of the volumetric cloud rendering method provided in an embodiment of the present application;
[0036] Figure 4 This is a second flowchart of the volumetric cloud rendering method provided in an embodiment of the present application;
[0037] Figure 5 The third step flow diagram of the volumetric cloud rendering method provided in the embodiment of the present application;
[0038] Figure 6 A schematic diagram of the structure of a volumetric cloud rendering device provided in an embodiment of the present application.
[0039] Icons: 100 - camera; 110 - screen; 120 - sea of clouds; 210 - volumetric cloud rendering device; 220 - memory; 230 - processor; 2101 - parameter acquisition module; 2102 - color calculation module; 2103 - color rendering module. DETAILED DESCRIPTION
[0040] To make the objectives, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Generally, the components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.
[0041] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for protection, but merely represents selected embodiments of the present application. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments in the present application without creative work are within the scope of protection of the present application.
[0042] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0043] In related technologies, a ray marching algorithm is used to render the sea of clouds using a preset step length. Because the distance between different pixels and the sea of clouds is affected by various factors, this distance affects the number of required iterations. When this distance is long or the preset step length is short, rendering efficiency is poor.
[0044] Please refer to Figure 1 , is a schematic diagram of the principle of the above-mentioned related technology provided in the embodiment of this application. Figure 1 As shown, it includes a camera 100, a screen 110, and a sea of clouds 120, wherein the screen 110 includes a plurality of pixels. When rendering the sea of clouds 120, the electronic device needs to determine the distance between each pixel and the sea of clouds 120 along the viewing direction of the camera 100.
[0045] Then, for each pixel, the color of the pixel is iterated according to the preset step length based on the distance between the pixel and the sea of clouds 120. In this method, the specific number of iterations is uncertain. When the number of iterations is large, the rendering efficiency will be seriously affected.
[0046] In view of this, and to at least partially alleviate the aforementioned drawbacks, embodiments of the present application provide a volumetric cloud rendering method, applied to an electronic device. When rendering a volumetric cloud, the electronic device limits the number of iterations to a preset number, thereby improving rendering efficiency. The sea of clouds 120 described in the aforementioned related art is a specific example of a volumetric cloud.
[0047] In addition, the electronic device may be, but is not limited to, a smart phone, a personal computer (PC), a tablet computer, a personal digital assistant (PDA), a mobile internet device (MID), etc.
[0048] Please refer to Figure 2 , is a possible structural diagram of the above electronic equipment. Figure 2 As shown, the electronic device includes a volumetric cloud rendering device 210 , a memory 220 and a processor 230 .
[0049] The memory 220, processor 230, and other components are electrically connected, directly or indirectly, to each other to enable data transmission or interaction. For example, these components may be electrically connected via one or more communication buses or signal lines. The volumetric cloud rendering device 210 includes at least one software functional module that can be stored in the memory 220 in the form of software or firmware, or embedded in the operating system (OS) of the electronic device.
[0050] The processor 230 is configured to execute executable modules stored in the memory 220, such as software function modules and computer programs included in the volumetric cloud rendering apparatus 210. When the computer-executable instructions corresponding to the volumetric cloud rendering apparatus 210 are processed and executed, the above-described volumetric cloud rendering method is implemented.
[0051] The memory 220 may be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory 220 is used to store a program, and the processor 230 executes the program after receiving an execution instruction.
[0052] The processor 230 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0053] Please refer to Figure 3 , Figure 3 For application Figure 2 The flowchart of a volumetric cloud rendering method for an electronic device is shown. The method including various steps will be described in detail below.
[0054] Step S101: Obtain rendering parameters of the volumetric cloud.
[0055] Step S105 , for each pixel in the target pixel area, iterate a preset number of times through a ray marching algorithm according to the rendering parameters to obtain a target color of the pixel.
[0056] The target pixel area is used to display the volumetric cloud. That is, in the embodiment of the present application, the same number of iterations are performed when determining the color of each pixel point used to display the volumetric cloud using the ray marching algorithm, thereby achieving the purpose of limiting the number of iterations.
[0057] Step S106: Render the target color to the pixel.
[0058] This shows that when the electronic device uses the ray marching algorithm to render the volumetric cloud, it iterates the same number of times for each pixel, thereby limiting the number of iterations. Since the number of iterations is fixed, the rendering efficiency of the volumetric cloud can be improved.
[0059] In addition, in one possible implementation of the present application, when rendering volumetric clouds, the specific morphology of the sea of clouds is also simulated. Therefore, the rendering parameters include a noise parameter, wherein the noise parameter is used for noise sampling to simulate the morphology of the sea of clouds.
[0060] Please refer to Figure 4 , the above step S102 includes the following sub-steps:
[0061] S105-1A, for each iterative process, performing noise sampling on the intermediate color according to the noise parameter, wherein the target color is the iterative result of the intermediate color, and the noise sampling is used to adjust the shape of the volumetric cloud.
[0062] That is, in the embodiment of the present application, in each iteration process, noise sampling is performed on the intermediate color based on the noise, and the final iteration result of the intermediate color is used as the target color. The specific method of the above noise sampling can be a 3D noise map.
[0063] In another possible implementation of the embodiment of the present application, when rendering the volumetric cloud, the specific shape of the sea of clouds and the lighting effect of the sea of clouds are also considered. Therefore, the rendering parameters include noise parameters and lighting parameters. Figure 5 , the above step S102 includes the following sub-steps:
[0064] S105-1B, for each iterative process, performing noise sampling on the intermediate color according to the noise parameter, and performing illumination processing on the sampling result of the intermediate color according to the illumination parameter.
[0065] Among them, the target color is the iterative result of the intermediate color.
[0066] Through the above steps, the electronic device performs noise sampling and lighting processing on the intermediate colors during the iterative process, so that the visual effect of the processed colors is more realistic.
[0067] In addition, the embodiment of the present application takes into account the different computing capabilities of different platforms and can appropriately adjust the preset number of iterations according to the usage scenario. Therefore, in the embodiment of the present application, a corresponding configuration interface is provided for the user to customize the preset number of iterations.
[0068] So, please parameter again Figure 4 or Figure 5 , the volumetric cloud rendering method further includes:
[0069] Step S102, providing a configuration interface;
[0070] Step S103, detecting the iteration number adjustment operation in the configuration interface;
[0071] Step S104: In response to the iteration number adjustment operation, a preset number of times is obtained.
[0072] Through the above steps of the volumetric cloud rendering method, users can customize the number of iterations when rendering the volumetric cloud according to their needs. It should be understood that the greater the number of iterations, the more realistic the rendered volumetric cloud will be, but the more computational effort will be required.
[0073] Based on the same inventive concept, the present embodiment also provides a volumetric cloud rendering device 210. Figure 6 , the volumetric cloud rendering device 210 includes:
[0074] The parameter acquisition module 2101 is used to obtain the rendering parameters of the volumetric cloud.
[0075] In the embodiment of the present application, when the computer executable instructions corresponding to the parameter acquisition module 2101 are executed by the processor, Figure 3 For a detailed description of the parameter acquisition module 2101 , please refer to the detailed description of step S101 .
[0076] The color calculation module 2102 is configured to obtain a target color for each pixel in a target pixel area for displaying a volumetric cloud by iterating a preset number of times through a ray marching algorithm according to rendering parameters.
[0077] In the embodiment of the present application, when the computer executable instructions corresponding to the color calculation module 2102 are executed by the processor, Figure 3 For a detailed description of the color calculation module 2102, please refer to the detailed description of step S105.
[0078] The color rendering module 2103 is used to render the target color to the pixel point.
[0079] In the embodiment of the present application, when the computer executable instructions corresponding to the color rendering module 2103 are executed by the processor, Figure 3 For a detailed description of the color rendering module 2103 , please refer to the detailed description of step S106 .
[0080] Optionally, the rendering parameters include noise parameters; the color calculation module 2102 is specifically configured to:
[0081] For each iteration, noise sampling is performed on the intermediate color according to the noise parameter, where the target color is the iterative result of the intermediate color, and the noise sampling is used to adjust the shape of the volumetric cloud.
[0082] Optionally, the rendering parameters include noise parameters and illumination parameters, and the color calculation module 2102 is specifically configured to:
[0083] For each iterative process, noise sampling is performed on the intermediate color according to the noise parameter, and the sampling result of the intermediate color is illuminated according to the illumination parameter, wherein the target color is the iterative result of the intermediate color.
[0084] Optionally, for each pixel point in the target pixel area, iterating a preset number of times through a ray marching algorithm according to rendering parameters to obtain the target color of the pixel point, the method further includes:
[0085] Providing a configuration interface;
[0086] Adjust the number of iterations in the detection configuration interface;
[0087] In response to the iteration number adjustment operation, a preset number of times is obtained.
[0088] An embodiment of the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and a volumetric cloud rendering method is implemented when computer executable instructions corresponding to the computer program are executed by the processor.
[0089] An embodiment of the present application further provides a storage medium storing a computer program. When computer executable instructions corresponding to the computer program are executed by a processor, a volumetric cloud rendering method is implemented.
[0090] In summary, the volumetric cloud rendering method, apparatus, electronic device, and storage medium provided in the embodiments of the present application enable the electronic device to perform the same number of iterations for each pixel when rendering the volumetric cloud using a ray marching algorithm, thereby limiting the number of iterations. This fixed number of iterations improves the rendering efficiency of the volumetric cloud.
[0091] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions.
[0092] In addition, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0093] If the functions are implemented in the form of software function modules 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 the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0094] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0095] The above descriptions are merely examples of various embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any modifications or substitutions that can be readily conceived by a person skilled in the art within the technical scope disclosed in the present application should be included within the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A volumetric cloud rendering method, It is characterized in that Applied to electronic equipment, the method comprises: Providing a configuration interface; Detecting an iteration number adjustment operation in the configuration interface; In response to the iteration number adjustment operation, obtaining a preset number of times; Get the rendering parameters of volumetric clouds; For each pixel point in a target pixel area, iterating a preset number of times through a ray-stepping algorithm according to the rendering parameters to obtain a target color of the pixel point, wherein the target pixel area is used to display the volumetric cloud; Render the target color to the pixel.
2. The volumetric cloud rendering method according to claim 1, It is characterized in that The rendering parameters include noise parameters, and obtaining the target color of the pixel by iterating a preset number of times through a ray stepping algorithm according to the rendering parameters includes: For each iteration process, noise sampling is performed on the intermediate color according to the noise parameter, wherein the target color is the iteration result of the intermediate color, and the noise sampling is used to adjust the shape of the volumetric cloud.
3. The volumetric cloud rendering method according to claim 1, It is characterized in that The rendering parameters include noise parameters and illumination parameters, and obtaining the target color of the pixel by iterating a preset number of times through a ray stepping algorithm according to the rendering parameters includes: For each iteration process, noise sampling is performed on the intermediate color according to the noise parameter, and illumination processing is performed on the sampling result of the intermediate color according to the illumination parameter, wherein the target color is the iterative result of the intermediate color.
4. A volumetric cloud rendering device, It is characterized in that The volumetric cloud rendering device comprises: The parameter acquisition module is used to: Providing a configuration interface; Detecting an iteration number adjustment operation in the configuration interface; In response to the iteration number adjustment operation, obtaining a preset number of times; The parameter acquisition module is also used to obtain the rendering parameters of the volumetric cloud; A color calculation module, configured to obtain a target color of each pixel point in a target pixel area by iterating a preset number of times through a ray stepping algorithm according to the rendering parameters, wherein the target pixel area is used to display the volumetric cloud; A color rendering module is used to render the target color to the pixel point.
5. The volumetric cloud rendering device according to claim 4, It is characterized in that The rendering parameters include noise parameters; the color calculation module is specifically used for: For each iteration process, noise sampling is performed on the intermediate color according to the noise parameter, wherein the target color is the iteration result of the intermediate color, and the noise sampling is used to adjust the shape of the volumetric cloud.
6. The volumetric cloud rendering device according to claim 4, It is characterized in that The rendering parameters include noise parameters and illumination parameters, and the color calculation module is specifically used for: For each iterative process, noise sampling is performed on the intermediate color according to the noise parameter, and illumination processing is performed on the sampling result of the intermediate color according to the illumination parameter, wherein the target color is the iterative result of the intermediate color.
7. An electronic device, It is characterized in that The electronic device includes a processor and a memory, the memory stores a computer program, and when the computer executable instructions corresponding to the computer program are executed by the processor, the volumetric cloud rendering method according to any one of claims 1 to 3 is implemented.
8. A storage medium, It is characterized in that The storage medium stores a computer program, and when the computer executable instructions corresponding to the computer program are executed by the processor, the volumetric cloud rendering method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Volume light rendering method and device, electronic equipment and storage medium
CN111968215A
Volume cloud shadow rendering method and device, electronic equipment and storage medium
CN111968216A
Direct volume rendering in virtual and / or augmented reality
US20190272027A1
