Light rendering method, device, storage medium, electronic device and computer program product
By introducing target transformation parameters in the ray travel calculation, controlling step size adaptation and ray morphology transformation, the problem of difficulty in balancing accuracy and performance of ray rendering in the prior art is solved, and efficient and accurate ray rendering effect is achieved.
Patent Information
- Application Number
- CN202411784631.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-04-04
AI Technical Summary
Existing ray rendering technologies are difficult to achieve ideal frame rates in real-time rendering scenes, and when ray traveling technologies improve rendering accuracy, the computing cost and resource requirements are too high, making it difficult to balance rendering accuracy and performance.
By introducing target transformation parameters in ray travel calculation, the step size adaptive transformation and ray morphological transformation in ray travel calculation are controlled, thereby achieving higher precision ray rendering.
The step size adaptation and ray morphology transformation of ray travel calculation are realized at a lower cost to set the target transformation parameters, thereby improving the accuracy and performance of ray rendering, and solving the problem that ray rendering is difficult to balance rendering accuracy and rendering performance in the ray rendering solution.
Smart Images

Figure CN119762656A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a light rendering method, device, storage medium, electronic device and computer program product. Background Art
[0002] In the field of computer graphics technology, it is common to render light in a virtual scene. To this end, related technologies mainly use ray tracing technology and ray marching technology to achieve ray rendering.
[0003] However, ray tracing technology often involves complex mathematical calculations (such as calculating the intersection points between rays and calculating reflections, refractions, and shadows in the scene), which brings huge computational overhead and places extremely high demands on graphics processors and memory, making it difficult to achieve the ideal frame rate in real-time rendering scenes. Ray marching technology relies on a progressive approximation sampling strategy, and insufficient sampling accuracy can easily lead to a decrease in the quality of rendered images (such as artifacts, loss of details, etc.), and as the complexity of the scene increases, the amount of resources required to ensure high-precision rendering increases dramatically. In other words, existing ray marching technology is difficult to achieve a balance between rendering accuracy and rendering performance.
[0004] As can be seen from the above, how to improve the quality of light rendering at a lower computational cost has become one of the important technical issues in the relevant technical field. Currently, no effective solution has been proposed for the above problems.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] At least some embodiments of the present application provide a ray rendering method, apparatus, storage medium, electronic device and computer program product to at least solve the technical problem that ray rendering solutions in related technologies are difficult to achieve a balance between rendering accuracy and rendering performance.
[0007] According to one embodiment of the present application, a ray rendering method is provided, including: obtaining initial ray marching information in a virtual scene; performing ray marching calculations based on the initial ray marching information and target transformation parameters to obtain target calculation results, wherein the target transformation parameters are used to control step size adaptive transformation and ray morphology transformation in the ray marching calculations; rendering the target calculation results to obtain a target ray rendering result of the virtual scene.
[0008] According to one embodiment of the present application, a light rendering device is also provided, including: an acquisition module, used to acquire initial light marching information in a virtual scene; a calculation module, used to perform light marching calculations based on the initial light marching information and target transformation parameters to obtain target calculation results, wherein the target transformation parameters are used to control the step size adaptive transformation and light morphology transformation in the light marching calculations; a rendering module, used to render the target calculation results to obtain a target light rendering result of the virtual scene.
[0009] According to one embodiment of the present application, a computer-readable storage medium is further provided, in which a computer program is stored, wherein the computer program is configured to execute any of the above-mentioned light rendering methods when running.
[0010] According to one embodiment of the present application, an electronic device is also provided, including: a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute any of the above-mentioned light rendering methods.
[0011] According to one embodiment of the present application, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the computer program implements any of the above-mentioned light rendering methods.
[0012] In at least some embodiments of the present application, initial ray marching information in a virtual scene is obtained; ray marching calculations are performed based on the initial ray marching information and target transformation parameters to obtain target calculation results, wherein the target transformation parameters are used to control the step adaptive transformation and ray morphology transformation in the ray marching calculations; the target calculation results are rendered to obtain target ray rendering results of the virtual scene. Therefore, the present application combines the parameter control of the step adaptive transformation and the parameter control of the ray morphology transformation in the ray marching calculations. Compared with the ray tracing technology with high computational complexity or the ray marching technology with a fixed step size, the present application achieves the purpose of setting the target transformation parameters at a lower cost to control the step adaptive and ray morphology transformation of the ray marching calculations to achieve higher-precision ray rendering, and achieves the technical effect of achieving high-precision ray rendering at a lower cost, thereby solving the technical problem that the ray rendering schemes of the related technologies are difficult to achieve a balance between rendering accuracy and rendering performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0014] Figure 1 It is a hardware structure block diagram of a mobile terminal of a light rendering method according to one embodiment of the present application;
[0015] Figure 2 is a flow chart of a light rendering method according to one embodiment of the present application;
[0016] Figure 3 is a schematic diagram of an optional parameter setting interface according to one embodiment of the present application;
[0017] Figure 4 is a schematic diagram of an optional light rendering result according to one embodiment of the present application;
[0018] Figure 5 is a schematic diagram of another optional light rendering result according to one embodiment of the present application;
[0019] Figure 6 is a structural block diagram of a light rendering device according to one embodiment of the present application;
[0020] Figure 7 is a schematic diagram of an electronic device according to one embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in 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. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] It should be noted that, in the specification of the present application, the word "for example" is used to mean "used as an example, illustration or description". Any embodiment described as "for example" in the present application is not necessarily interpreted as being more preferred or more advantageous than other embodiments. In order to enable any technician in the field to implement and use the present application, the following description is given. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present application can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid unnecessary details that make the description of the present application obscure. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest range of principles and features disclosed in the present application.
[0024] In the process of describing the embodiments of the present application, some nouns or terms appearing are applicable to the following interpretations:
[0025] Ray Tracing: refers to a rendering technology that simulates the propagation of light. In a virtual scene, color and lighting information is obtained by calculating the intersection of light and objects. Ray tracing technology can generate highly realistic scene images, but the computational complexity of ray tracing technology is extremely high, especially when dealing with complex scene rendering and real-time rendering.
[0026] Ray Marching: A variant of ray tracing technology, it samples along the direction of light in the virtual scene in a piecewise progressive manner, thereby achieving continuous sampling and rendering of the virtual scene. Ray marching technology can be used to render volumetric effects and fractal images. Compared with traditional ray tracing technology, ray marching technology can handle complex and dynamic scenes more efficiently due to its progressive sampling characteristics.
[0027] Fractal: refers to a geometric shape defined by recursion. Fractals can generate complex and varied patterns. Fractals can be used to simulate natural landscapes and textures. Fractal technology combined with ray marching technology can generate visual effects with high complexity and detail.
[0028] Domain Warping: refers to a technique that achieves texture distortion or geometric shape change by changing the sampling coordinate system. By distorting the sampling coordinate system, diverse and nonlinear visual effects can be generated. This application combines domain warping technology with ray marching technology and fractal technology to generate richer ray rendering visual effects while ensuring high ray rendering efficiency.
[0029] In a possible implementation of the present application, with respect to the ray tracing technology or traditional ray marching technology commonly used in the application background of virtual scene ray rendering in the field of computer technology, after practice and careful research, the inventor still found that it is difficult to balance the technical problem of rendering accuracy and rendering performance. Based on this, the embodiment of the present application proposes an improved ray rendering method based on ray marching technology, which adopts the technical concept of obtaining the ray rendering result by controlling the step size adaptive transformation and ray shape transformation by parameters in the ray marching calculation process, thereby achieving the purpose of setting the target transformation parameters at a lower cost to control the step size adaptation and ray shape transformation of the ray marching calculation to achieve higher-precision ray rendering, and achieving the technical effect of achieving high-precision ray rendering at a lower cost, thereby solving the technical problem that the ray rendering scheme of the related technology is difficult to achieve a balance between rendering accuracy and rendering performance.
[0030] The above method embodiments involved in this application can be executed in a terminal device (for example, a mobile terminal, a computer terminal or a similar computing device). Taking running on a mobile terminal as an example, the mobile terminal can be a smart phone, a tablet computer, a PDA, a mobile Internet device, a game console and other terminal devices.
[0031] Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal according to a light rendering method in one embodiment of the present application. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 (only one is shown in the figure) processor 102, memory 104, transmission device 106, input / output device 108 and display device 110. Taking the light rendering method applied to an electronic game scene through the mobile terminal as an example, the processor 102 calls and runs the computer program stored in the memory 104 to execute the light rendering method, and the light rendering result in the generated electronic game scene is transmitted to the input / output device 108 and / or the display device 110 through the transmission device 106, and then the light rendering result is provided to the player.
[0032] Still like Figure 1As shown, the processor 102 may include but is not limited to: a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microcontroller unit (MCU), a programmable logic device (Field Programmable Gate Array, FPGA), a neural network processor (Neural-Network Processing Unit, NPU), a tensor processor (Tensor Processing Unit, TPU), an artificial intelligence (Artificial Intelligence, AI) type processor and other processing devices.
[0033] Those skilled in the art will understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0034] In some optional embodiments mainly based on game scenarios, the above-mentioned terminal device can also provide a human-computer interaction interface with a touch-sensitive surface, which can sense finger contact and / or gestures to perform human-computer interaction with a graphical user interface (Graphical User Interface, GUI). The human-computer interaction function may include the following interactions: creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interface, playing digital videos, playing digital music and / or web browsing, etc. The executable instructions for executing the above-mentioned human-computer interaction functions are configured / stored in a computer program product or readable storage medium executable by one or more processors.
[0035] The above method embodiments involved in this application can also be executed in a server. Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Taking the application of the light rendering method to an electronic game scene through an electronic game server as an example, the electronic game server can generate a light rendering result in the electronic game scene based on the light rendering method, and provide the light rendering result to the player (for example, it can be rendered and displayed on the display screen of the player's terminal, or provided to the player through holographic projection, etc.).
[0036] According to one embodiment of the present application, an embodiment of a light rendering method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0037] In this embodiment, a light rendering method running on the above mobile terminal is provided. Figure 2 is a flow chart of a light rendering method according to one embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0038] Step S21, obtaining initial light marching information in the virtual scene;
[0039] Step S22, performing ray marching calculation based on the initial ray marching information and the target transformation parameters to obtain a target calculation result, wherein the target transformation parameters are used to control the step size adaptive transformation and the ray morphology transformation in the ray marching calculation;
[0040] Step S23, rendering the target calculation result to obtain the target light rendering result of the virtual scene.
[0041] The above-mentioned virtual scene can be a two-dimensional scene, a three-dimensional scene or a higher-dimensional scene involving a light rendering process in the field of computer technology and image processing. For example, the virtual scene can be a virtual exhibition hall, a virtual classroom, a virtual conference room, a virtual game scene, a virtual city scene, etc. In particular, the game types corresponding to the above-mentioned virtual game scene can be: action (for example: first-person or third-person shooting games, two-dimensional or three-dimensional fighting games, war action games and sports action games, etc.), adventure (for example: exploration games, collection games, puzzle games, etc.), simulation (for example: simulation sandbox games, simulation development games, strategy simulation games, city construction simulation games, business simulation games, etc.), role-playing and leisure (for example: chess and card table games, casual competitive games, music rhythm games, dress-up development games, etc.), etc.
[0042] The initial light marching information can be used to determine the initial state and / or initial properties of the light marching in the virtual scene. For example, the initial light marching information is used to determine the starting position, marching direction, initial color, initial brightness, etc. of the light marching.
[0043] In the application scenario, the initial light marching information is determined by the virtual camera position and the viewing direction of the virtual camera in the virtual scene. In addition, the initial light marching information can also be determined by the light source information of multiple light sources (such as the sun, moon, lanterns, luminous props, etc.) set in the virtual scene.
[0044] The target transformation parameters can be used to control the adaptive step size of the light marching, and can also be used to control the light morphology transformation during the light marching process. For example, the light morphology transformation includes domain distortion transformation, fractal transformation and color mapping transformation.
[0045] In the ray marching calculation, the initial ray marching information is considered to determine the starting point and direction of the ray marching, the target transformation parameters are considered, an adaptive step size is introduced for the ray marching calculation to adapt to the detail changes in the virtual scene, and a rich variety of light morphological transformations (such as domain distortion and fractals) are introduced for the ray marching calculation, which further enables the ray rendering results to include more complex lighting effects and textures.
[0046] Furthermore, through rendering, the target calculation results are converted into intuitive visual outputs, and the obtained light rendering results can be static pictures, dynamic pictures, animations, etc. In the rendering process, the accumulated lighting information and color data in the light marching calculation are mapped to multiple pixels, and the visual effect is enhanced through visual post-processing technology (such as dynamic range compression, color correction, etc.), so that the light rendering results can maintain realism while also having artistic beauty.
[0047] Specifically, the above-mentioned light rendering method may also include other method steps, which can be referred to the further introduction of the embodiments of the present application below, and will not be described in detail here.
[0048] In at least some embodiments of the present application, initial ray marching information in a virtual scene is obtained; ray marching calculations are performed based on the initial ray marching information and target transformation parameters to obtain target calculation results, wherein the target transformation parameters are used to control the step adaptive transformation and ray morphology transformation in the ray marching calculations; the target calculation results are rendered to obtain target ray rendering results of the virtual scene. Therefore, the present application combines the parameter control of the step adaptive transformation and the parameter control of the ray morphology transformation in the ray marching calculations. Compared with the ray tracing technology with high computational complexity or the ray marching technology with a fixed step size, the present application achieves the purpose of setting the target transformation parameters at a lower cost to control the step adaptive and ray morphology transformation of the ray marching calculations to achieve higher-precision ray rendering, and achieves the technical effect of achieving high-precision ray rendering at a lower cost, thereby solving the technical problem that the ray rendering schemes of the related technologies are difficult to achieve a balance between rendering accuracy and rendering performance.
[0049] The above method of the embodiment of the present application is further introduced below.
[0050] Optionally, the initial light marching information includes: a starting position and a direction of the light marching in the virtual scene, and the target transformation parameter includes a step count threshold; in step S22, performing a light marching calculation based on the initial light marching information and the target transformation parameter to obtain a target calculation result may include the following execution steps:
[0051] Step S221, performing a plurality of step-by-step iterative calculations of the light march based on the step number threshold, the starting position and the marching direction, to obtain a light accumulated color value;
[0052] Step S222, using the light accumulated color value to determine the target calculation result.
[0053] In the above initial ray marching information, the starting position can be regarded as the starting point of the ray (RayOrigin) in the virtual scene, denoted as ro; the marching direction can be regarded as the ray direction (Ray Direction) in the virtual scene, denoted as rd. In the application scenario, the starting position can be the position of the virtual camera, and the marching direction can be the direction vector starting from the viewing direction of the virtual camera. In addition, the above marching direction can also be defined by the angle between the viewing direction and multiple coordinate directions of the virtual scene.
[0054] In the above target transformation parameters, the step count threshold (referred to as raystep) can be used to control the maximum number of iterative calculations in the ray march calculation. That is to say, in the ray march calculation, when the number of marching iterative calculations reaches the step count threshold, the ray march calculation is terminated. By setting the step count threshold, infinite loops or over-calculations in the ray march iterations can be avoided. The setting of the step count threshold affects the accuracy and rendering efficiency of the ray march. Therefore, the accurate setting of the step count threshold can help balance the rendering effect and the computational cost.
[0055] The above light cumulative color value (denoted as col) can accumulate and update the light color value during the light marching iterative calculation process. During the light marching iterative calculation process, the above target calculation result can be determined at any time (at any iteration that does not exceed the step count threshold) based on the current light cumulative color value.
[0056] In the application scenario, during the iterative calculation of the ray march, the color information of each scene point encountered by the ray will be accumulated into the above-mentioned ray cumulative color value. The above-mentioned ray cumulative color value combines the color information and lighting information on the ray march path, and is the basis of the ray rendering effect.
[0057] The above ray marching iterative calculation process describes a multi-step process in which the ray advances in a specific direction (i.e., the direction of travel) in the virtual scene and samples color information. In each step, the ray advances a short distance and detects the scene information at the current position, such as color, texture, and lighting, and then accumulates this information for subsequent rendering calculations.
[0058] In the application scenario, after determining the starting position, the direction of travel, and the step number threshold, the ray marching calculation process of multiple steps can be started, that is, in the first step of the multiple steps, the ray marching calculation is started from the starting position along the direction of travel, and further, in the multiple steps except the first step, the ray marching calculation is continued along the direction of travel from the end position of the ray marching in the previous step until the number of iterations of the ray marching iterative calculation reaches the step number threshold, or the ray intersects with the surface of an object in the virtual scene, and the target calculation result is determined based on the accumulated color value of the ray after the iterative calculation of the ray is completed.
[0059] The target calculation result is the final output of the iterative calculation of the light march, that is, the final mixed result of the color information collected by the light during the march. The target calculation result will be used for rendering output and displayed as an image in the virtual scene.
[0060] Through the above-mentioned steps S221 to S222, the embodiment of the present application performs multiple-step light marching iterative calculations based on the starting position and travel direction of the light in the virtual scene, and determines the final target calculation result for rendering through color accumulation, thereby realizing dynamic calculation of light in the virtual scene and improving the accuracy of light rendering.
[0061] Optionally, the target transformation parameter includes a step length; in step S221, performing a plurality of step ray marching iterative calculations based on a step number threshold, a starting position, and a marching direction to obtain a light accumulated color value may include the following execution steps:
[0062] Step S223, for a target step among the multiple steps, determining the light travel amount corresponding to the target step based on the travel step length;
[0063] Step S224, determining the first step position corresponding to the target step according to the starting position, the travel direction and the travel amount of the light;
[0064] Step S225, based on the first step position and the time factor corresponding to the virtual scene, calling the target transformation function to calculate and update the color sampling value corresponding to the target step;
[0065] Step S226: Based on the color sampling value, the light accumulated color value is cumulatively updated.
[0066] The above-mentioned step size (denoted as stepsize) is used to determine the distance that the light travels in each step. The above-mentioned ray travel amount (denoted as t) is used to characterize the actual distance that the light travels in each step. The ray travel amount is affected by the step size and can also be dynamically adjusted according to the calculation results of each step to achieve step size adaptive transformation.
[0067] The target step may be each step in the plurality of steps. That is, in the iterative calculation of the ray marching of the plurality of steps, for each step, the ray march amount corresponding to the current step is determined based on the marching step length. Further, the first step position corresponding to the current step (denoted as pos1) is determined based on the starting position, the marching direction and the ray march amount corresponding to the current step. The first step position may be used to determine the sampling coordinates in the light morphology transformation.
[0068] The time factor corresponding to the above virtual scene can be obtained by performing trigonometric function transformation on the time parameter of the virtual scene. For example, the time factor sctime is obtained by performing trigonometric function calculation results sin(Time) and cos(Time) corresponding to the time parameter time of the virtual scene and then performing preset function transformation.
[0069] In each step, based on the first step position and time factor, the target transformation function is called for calculation, and the calculated color sampling value is used to update the current color sampling value. Furthermore, based on the color sampling value of the current step, the light cumulative color value (col) in the ray marching iterative calculation is cumulatively updated. In other words, the light cumulative color value can represent the color value accumulated in the current step and all steps before the current step.
[0070] The target transformation function is used to perform domain distortion transformation of the sampling coordinates of each step and multiple rounds of fractal transformation, thereby making the sampled color values of each step more diverse.
[0071] Through the above steps S223 to S226, in each step of the iterative calculation of ray marching, the embodiment of the present application first adaptively determines the ray march amount corresponding to each step, and then determines the first step position corresponding to the current step. Further, the target transformation function is called to update the color sampling value. Since the time factor is introduced in the target transformation function, the above color sampling value has a dynamic effect, so that the light rendering result can contain richer dynamic visual effects. In addition, the target transformation function also introduces domain distortion transformation and fractal transformation controlled by the target transformation parameters, which can further enrich the diversity of color sampling values and the meticulousness of visual expression.
[0072] Optionally, the above light rendering method may further include the following execution steps:
[0073] Step S24, for the first step among the multiple steps, the light travel amount is initialized based on the preset initial step length, the color sampling value is initialized based on the preset sampling value, and the light accumulated color value is initialized based on the preset initial color.
[0074] The above preset initial step size can be recorded as one3. Since the marching step size can be a vector parameter, that is, the marching step size can include marching step size components in multiple coordinate directions, the preset initial step size can also be an initial step size vector, such as float(1.,1.,1.). The preset initial step size can be determined by the technician or the caller of the ray rendering method (such as a program or thread) according to the application scenario requirements. After the ray marching iterative calculation starts, before the first step calculation, the ray march amount is initialized to the preset initial step size.
[0075] Similarly, the preset sampling value can be determined by the preset initial step size. Before the first step calculation, the color sampling value is initialized to the preset sampling value. In this example, the preset sampling value can be determined to be 0 (i.e., one3*0). The preset sampling value can be determined by a technician or a caller of the light rendering method (such as a program or thread) according to the application scenario requirements.
[0076] Similarly, the preset initial color can be determined by a technician or the caller of the light rendering method (such as a program or thread) according to the application scenario requirements. For example, in this example, the preset initial color can be float(0.0,0.0,0.0). Before the first step calculation, the light accumulated color value is initialized to the preset initial color.
[0077] Through the above-mentioned step S24, the embodiment of the present application initializes the light travel amount, color sampling value and light accumulated color value before the first step calculation of multiple steps begins, thereby ensuring the correctness of the light marching iterative calculation and further ensuring the accuracy of light rendering.
[0078] Optionally, the target transformation parameter further includes a first color interpolation coefficient; in step S223, based on the travel step length, determining the light travel amount corresponding to the target step may include the following execution steps:
[0079] Step S2231, performing exponential calculation based on the product of the first color interpolation coefficient and the color sampling value to obtain a first calculation result, wherein the first color interpolation coefficient is used to control the color gradient rate between multiple steps;
[0080] Step S2232: accumulatively update the light travel distance using the product of the travel step length and the first calculation result.
[0081] The first color interpolation coefficient (denoted as ColorLerp) can be used to control the color gradient rate between multiple steps.
[0082] In each step calculation of the multiple steps, an exponential calculation is performed based on the product of the first color interpolation coefficient and the color sampling value to obtain a first calculation result. Specifically, the first color interpolation coefficient ColorLerp is multiplied by the current color sampling value c (for the first step, c is a preset sampling value; for other steps, c is obtained by calling the target transformation function in the previous step calculation of the current step), and an exponential calculation is performed with the base of the natural logarithm (i.e., e) to obtain the above-mentioned first calculation result, which can be expressed as exp(-colorlerp*c).
[0083] Furthermore, the light travel distance is cumulatively updated using the product obtained by multiplying the travel step size stepsize by the first calculation result, which is expressed in code as: t+=stepsize*exp(-colorlerp*c).
[0084] Through the above steps S2231 to S2232, the embodiment of the present application uses the continuously changing color sampling values in multiple steps and the first color interpolation coefficient in the target transformation parameters to determine the light travel amount of the current step, thereby realizing the step size adaptive transformation during the light travel process. In addition, the first color interpolation coefficient in the target transformation parameters can be exposed to support the user or caller to control the color gradient rate between multiple steps by adjusting the value of the first color interpolation coefficient, thereby improving the controllability and flexibility of the light rendering method.
[0085] Optionally, the target transformation parameters further include a fractal number threshold; in step S225, based on the first step position and the time factor, calling the target transformation function to calculate and update the color sampling value corresponding to the target step may include the following execution steps:
[0086] Step S2251, using the time factor, performing domain distortion coordinate transformation on the first step position to obtain a second step position;
[0087] Step S2252, performing multiple rounds of fractal iterative calculations based on the fractal number threshold, the first step position, and the second step position to obtain a cumulative fractal value;
[0088] Step S2253, determining the color sampling value according to the accumulated fractal value.
[0089] In the ray marching iterative calculation, when the target transformation parameters are called in each step to calculate the color sampling value, the time factor is first used to perform a domain warping coordinate transformation on the first step position of the current step to obtain the above-mentioned second step position.
[0090] Specifically, the first step position is recorded as pos1, the components of the first step position in the x direction and the y direction are recorded as pos1.xy, the component of the first step position in the x direction is recorded as pos1.x, and the component of the first step position in the y direction is recorded as pos1.y. The second step position is recorded as pos2, and correspondingly, the components of the second step position in the x direction and the y direction are recorded as pos2.xy. Based on this, the above domain distortion coordinate table can be expressed as: pos2.xy = pos1.xy*sctime.x+float2(pos1.y,pos1.x)*sctime.y. Among them, sctime.x represents the component of the time factor in the x direction, and sctime.y represents the component of the time factor in the y direction. float2() represents the conversion function of the preset floating point format.
[0091] Through the domain distortion coordinate transformation associated with the time factor, the dynamic effect of the second step position can be associated with the time passage of the virtual scene. Using the second step position as the sampling position corresponding to the fractal transformation can make the color sampling result more complex and rich.
[0092] Specifically, multiple rounds of fractal iterative calculations are performed based on the above fractal number threshold, the first step position and the second step position to obtain a cumulative fractal value. The above fractal number threshold (denoted as mapstep) can be the maximum number of iterations of fractal iterative calculations performed in the target transformation function called in each step, that is, when the number of rounds corresponding to the fractal iterative calculation reaches the fractal number threshold, it is determined that the fractal transformation corresponding to the current step is completed. Based on the cumulative fractal value obtained after the fractal transformation is completed, the color sampling value of the current step is determined.
[0093] Through the above-mentioned steps S2251 to S2253, the embodiment of the present application introduces domain distortion transformation and fractal transformation (that is, fractal iterative calculation) controlled by target transformation parameters in each step calculation in the ray marching iterative calculation, thereby improving the pattern complexity at a lower cost, increasing the richness and dynamic effect of color sampling, and thus enhancing the quality of the light rendering results.
[0094] Optionally, in step S2252, performing multiple rounds of fractal iterative calculations based on the fractal number threshold, the first step position and the second step position to obtain a cumulative fractal value may include the following execution steps:
[0095] Step S2254, in a target round among the multiple rounds, performing a nonlinear transformation mapping on the first step position to obtain a first mapping position;
[0096] Step S2255, performing a complex square calculation on the target component of the first mapping position to determine the second mapping position;
[0097] Step S2256, performing coordinate rotation on the second mapping position according to a preset rotation direction to obtain a third mapping position;
[0098] Step S2257: Based on the third mapping position and the second stepping position, the accumulated fractal value is updated by exponential decay accumulation.
[0099] The target round can be each round of multiple rounds, that is, in the fractal iterative calculation of each round, the first step position pos1 is nonlinearly transformed and mapped to obtain the first mapping position (recorded as pos3). Specifically, the nonlinear transformation mapping can be expressed as pos3 = 0.7*abs(pos1) / dot(pos1,pos1)-0.7. Specifically, the absolute value of the first step position pos1 is first taken to obtain abs(pos1); the absolute value is then normalized to obtain the normalized result abs(pos1) / dot(pos1,pos1); the normalized result is multiplied by 0.7 for scaling, and then subtracted by 0.7 to obtain the first mapping position pos3.
[0100] Further, a preset complex square calculation function is called to calculate the target component of the first mapping position to obtain the second mapping position. Specifically, the target component may be a yz component. The yz component of the first mapping position is denoted as pos3.yz, and the complex square calculation function is denoted as csqr(). Based on this, the yz component of the second mapping position (denoted as pos4) can be expressed as pos4.yz=csqr(pos3.yz).
[0101] Exemplarily, the above complex number square calculation function can be defined as:
[0102] float2 csqr(float2 a){return float2(ax*ax-ay*ay,2.*ax*ay);}.
[0103] Furthermore, the preset rotation direction may be: moving the z component to the position of the x component, moving the x component to the position of the y component, and moving the y component to the position of the z component. The second mapping position pos4 is rotated by the coordinates corresponding to the preset rotation direction to obtain a third mapping position (denoted as pos5).
[0104] In the current fractal iteration calculation, after the third mapping position pos5 is determined, the accumulated fractal value (referred to as res) is updated exponentially based on the third mapping position and the second step position pos2. Specifically, the exponential decay cumulative update can be expressed as:
[0105] res+=exp(-19.*abs(dot(pos5,pos2))).
[0106] That is, in the process of updating the cumulative fractal value, the dot product of the third mapping position pos5 and the second step position pos2 is calculated, and then res is updated by exponential decay accumulation in combination with the exp function. After multiple rounds of fractal iterations, the cumulative fractal value res after cumulative update is obtained.
[0107] Through the above-mentioned steps S2254 to S2257, the embodiment of the present application introduces nonlinear transformation, scaling transformation, coordinate rotation transformation and exponential decay superposition in the fractal iterative calculation, which can make rich and varied cumulative fractal values at a lower cost, thereby helping to generate highly complex and detailed patterns.
[0108] Optionally, in step S2253, determining the color sampling value according to the accumulated fractal value may include the following execution steps:
[0109] Step S2258, calculating the mean of the accumulated fractal values to obtain an average fractal value;
[0110] Step S2259, performing color sampling based on the average fractal value to obtain a color sampling value.
[0111] The above average calculation can be a bisection average calculation, that is, after obtaining the cumulative fractal value res, the cumulative fractal value is divided by 2 to obtain the average fractal value res / 2. Then, color sampling is performed based on the above average fractal value to obtain the color sampling value corresponding to the current step in the ray marching iterative calculation.
[0112] In the application scenario, in addition to calculating the mean of the cumulative fractal values, the cumulative fractal values can also be normalized, smoothed, or calculated using mathematical functions (such as exponential, logarithmic, sine, etc.) to adjust the dynamic range or distribution characteristics of the fractal values, and convert the fractal values into a numerical range suitable for color mapping. The fractal value processing results obtained in this way can also be used for color sampling.
[0113] The process of color sampling based on the average fractal value may include mapping the average fractal value to a color space through a lookup table, color gradient or color function, and then combining the color information of the color space with the illumination and material to obtain the color sampling value. In the above mapping process, the average fractal value is converted into a specific color value (such as color information in RGB color or HSV color space). In the above mapping process, the final visual effect can also be affected by adjusting the details and parameters of the color mapping (such as the brightness, saturation, contrast, etc. of the color).
[0114] Through the above-mentioned steps S2258 to S2259, the embodiment of the present application calculates the mean of the cumulative fractal values and then determines the color sampling value, which can not only smooth and optimize the visual effect, but also reduce the complexity of subsequent calculations, control the consumption of computing resources, and enhance computing stability.
[0115] Optionally, the target transformation parameter further includes a second color interpolation coefficient; in step S226, based on the color sampling value, the light accumulated color value is cumulatively updated, which may include the following execution steps:
[0116] Step S2261, performing multiplication calculation on the color sampling value and the second color interpolation coefficient to obtain a second calculation result, wherein the second color interpolation coefficient is used to control the color accumulation intensity between multiple steps;
[0117] Step S2262: Utilize the second calculation result to cumulatively update the light accumulated color value.
[0118] The second color interpolation coefficient (denoted as lerppower) can be used to control the color accumulation intensity between multiple steps. The color sampling value (denoted as c) is multiplied by the second color interpolation coefficient to obtain a second calculation result, and the second calculation result is further used to accumulate and update the light accumulation color value (denoted as col). The above process can be expressed as: col = 0.99*col + lerppower*c*c*c.
[0119] It should be noted that the above color sampling value may include three color components, which are respectively represented as cx, cy and cz. For each color component, the target transformation function is called to calculate based on the corresponding component of the first step position. For example, the above target transformation function is represented by map(), then cx=map(pos1.x,sctime), where pos1.x=ro-tx*rd. Similarly, cy=map(pos1.y,sctime), cz=map(pos1.z,sctime). On this basis, in the above process of accumulating and updating the accumulated color value of the light, c*c*c represents the element-wise multiplication of the color sampling value c (vector), that is, each color component of the color sampling value c is multiplied by itself to obtain a new three-dimensional vector. In the above calculation result of c*c*c, the first result component is cx*cx*cx, the second result component is cy*cy*cy, and the third result component is cz*cz*cz.
[0120] Through the above steps S2261 to S2262, the embodiment of the present application updates the accumulated color value of the light by using the color sampling value of the current step and the second color interpolation coefficient in each step of the ray marching iterative calculation, thereby realizing the image realism and detail expression brought by the gradual accumulation of colors in the ray marching technology, and improving the anti-artifact and anti-aliasing capabilities of the ray rendering results. In addition, it can also optimize the utilization of computing resources, enhance the real-time rendering performance of dynamic scenes, simplify the debugging and optimization process, and provide technical support for achieving advanced rendering effects.
[0121] Optionally, the target transformation parameter also includes a color mixing coefficient; in step S222, the target calculation result is determined by using the light accumulated color value, which may include the following execution steps:
[0122] Step S2221, using the color mixing coefficient to mix multiple color components of the light accumulated color value to obtain a target calculation result.
[0123] The color mixing coefficients may include three mixing coefficient components corresponding to the three color components. For example, the mixing coefficient component c0 corresponding to the x component col.x of the light accumulation color value, the mixing coefficient component c1 corresponding to the y component col.y of the light accumulation color value, and the mixing coefficient component c2 corresponding to the z component col.z of the light accumulation color value. In this regard, the target calculation result cr obtained by mixing multiple color components of the light accumulation color value can be expressed as:
[0124] cr=c0*col.x+c1*col.y+c2*col.z.
[0125] It should be noted that the mixing coefficient components in the above color mixing coefficients can all be floating-point coefficients, and the typical value of each mixing coefficient component is between 0 and 1. The above color mixing coefficients are used to determine the mixing ratio of multiple color components of the light accumulated color value. By adjusting the color mixing coefficients, the color characteristics of the rendered image can be changed. For example, increasing the value of c0 will make the rendered image biased towards the col.x color value.
[0126] Through the above-mentioned step S2221, the embodiment of the present application mixes multiple components of the accumulated color value of light by setting the color mixing coefficient, which can not only enhance the visual hierarchy and details of the image and optimize the efficiency and effect of rendering, but also achieve artistic style rendering, improve the performance of dynamic lighting and shadows, simplify parameter adjustment and debugging processes, and support more complex lighting models.
[0127] Based on the above light rendering method of the embodiment of the present application, the following can be provided: Figure 3 A parameter setting interface as shown in FIG. Figure 3 As shown, the target transformation parameters involved in the embodiments of the present application are divided into global scalar parameter values and global vector parameter values. For example, the global scalar parameter value may (at least partially) include a fractal number threshold, a travel number threshold, and a second color interpolation parameter; the global vector parameter value may (at least partially) include a basic color, a first color interpolation parameter, and a travel step length.
[0128] Still like Figure 3 As shown, for each target transformation parameter, the user can adjust the current setting value of the parameter through the parameter value setting box and reset button after the parameter, for example, Figure 3 It shows that the user determines the current setting value of the fractal number threshold to be 8.0. The user can increase or decrease the current setting value by controlling the up button or down button in the parameter value setting box, and the user can also control the parameter to be reset to the initial value by controlling the reset button behind the parameter value setting box.
[0129] Still like Figure 3As shown, for each target transformation parameter, the user can control the application of the current setting value of the parameter in the light rendering calculation of the virtual scene by checking the check box in front of the parameter.
[0130] In particular, for global vector parameter values, the parameter value setting box can be a slider component or other more detailed parameter value setting components. For each vector parameter value, the user can control the parameter setting interface to collapse or expand the component information of the vector parameter value by clicking the collapse / expand button in front of the check box of the parameter.
[0131] Based on Figure 3 The parameter setting interface shown in the figure allows users to easily and intuitively adjust the target transformation parameters to control the visual performance of the light rendering results. For example, in the application scenario, users can adjust different parameter values to obtain the following Figure 4 and Figure 5 The two different light rendering results are shown in Figure 2. Figure 4 and Figure 5 As shown in the figure, the light rendering results can show the complex, rich and detailed light morphology patterns brought by domain distortion transformation and fractal transformation (actually a dynamic effect that follows the time changes of the virtual scene), but due to different parameter settings, Figure 4 and Figure 5 The light rendering results shown in the figure vary in the detail effects.
[0132] In summary, the embodiment of the present application introduces adaptive step size and detail parameter control in the ray marching calculation, balances the conflict between computational complexity and rendering accuracy, ensures that unnecessary computational overhead is significantly reduced under the premise of obtaining high-quality rendered images, and thus improves the efficiency of the entire rendering process. Secondly, the above scheme of the embodiment of the present application can support real-time rendering strategies, combined with parallel computing and hardware acceleration technology, so that the generation of ray marching and domain distortion effects is not only limited to high-end hardware, but also can maintain high frame rate smooth performance in real-time applications (such as fast-paced electronic games or interactive virtual reality experiences), greatly expanding the scope of application of the technology. Furthermore, the embodiment of the present application introduces high-precision floating-point operations and anti-artifact technology, which effectively improves the quality of light rendering images in complex scenes, avoids detail loss or visual defects, and ensures the consistency and fidelity of the rendering effect. Finally, the embodiment of the present application can also support the provision of an intuitive and easy-to-use parameter adjustment interface, and cooperates with targeted debugging tools to make the generation process of fractal patterns and domain distortion effects more controllable and predictable, reduce the difficulty of development, and accelerate the realization of high-quality rendering effects.
[0133] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a disk, an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0134] In this embodiment, a light rendering device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0135] Figure 6 is a structural block diagram of a light rendering device according to one embodiment of the present application, such as Figure 6 As shown, the device includes: an acquisition module 601, which is used to acquire initial light marching information in a virtual scene; a calculation module 602, which is used to perform light marching calculations based on the initial light marching information and target transformation parameters to obtain target calculation results, wherein the target transformation parameters are used to control the step size adaptive transformation and light morphology transformation in the light marching calculations; a rendering module 603, which is used to render the target calculation results to obtain target light rendering results of the virtual scene.
[0136] Optionally, the initial light marching information includes: the starting position and travel direction of the light in the virtual scene, and the target transformation parameters include a step number threshold; the above-mentioned calculation module 602 is also used to: perform multiple step light marching iterative calculations based on the step number threshold, the starting position and the travel direction to obtain the light accumulated color value; use the light accumulated color value to determine the target calculation result.
[0137] Optionally, the target transformation parameters include a step length; the above-mentioned calculation module 602 is also used to: for a target step among multiple steps, determine the amount of light traveled corresponding to the target step based on the step length; determine the first step position corresponding to the target step according to the starting position, the travel direction and the amount of light travel; based on the first step position and the time factor corresponding to the virtual scene, call the target transformation function to calculate and update the color sampling value corresponding to the target step; based on the color sampling value, cumulatively update the accumulated color value of the light.
[0138] Optionally, in addition to all the above-mentioned modules, the above-mentioned light rendering device also includes: an initialization module, which is used to initialize the light travel amount based on a preset initial step length, initialize the color sampling value based on a preset sampling value, and initialize the light accumulated color value based on a preset initial color for the first step among multiple steps.
[0139] Optionally, the target transformation parameters also include a first color interpolation coefficient; the above-mentioned calculation module 602 is also used to: perform exponential calculation based on the product of the first color interpolation coefficient and the color sampling value to obtain a first calculation result, wherein the first color interpolation coefficient is used to control the color gradient rate between multiple steps; and use the product of the travel step length and the first calculation result to cumulatively update the light travel amount.
[0140] Optionally, the target transformation parameters also include a fractal number threshold; the above-mentioned calculation module 602 is also used to: use the time factor to perform a domain distortion coordinate transformation on the first step position to obtain a second step position; perform multiple rounds of fractal iterative calculations based on the fractal number threshold, the first step position and the second step position to obtain a cumulative fractal value; determine the color sampling value based on the cumulative fractal value.
[0141] Optionally, the above-mentioned calculation module 602 is also used to: in a target round in multiple rounds, perform a nonlinear transformation mapping on the first step position to obtain a first mapping position; perform a complex square calculation on the target component of the first mapping position to determine the second mapping position; perform coordinate rotation on the second mapping position according to a preset rotation direction to obtain a third mapping position; based on the third mapping position and the second step position, perform an exponentially decayed cumulative update on the accumulated fractal value.
[0142] Optionally, the calculation module 602 is further used to: perform mean calculation on the accumulated fractal values to obtain an average fractal value; and perform color sampling based on the average fractal value to obtain a color sampling value.
[0143] Optionally, the target transformation parameters also include a second color interpolation coefficient; the above-mentioned calculation module 602 is also used to: multiply the color sampling value and the second color interpolation coefficient to obtain a second calculation result, wherein the second color interpolation coefficient is used to control the color accumulation intensity between multiple steps; and use the second calculation result to accumulate and update the light accumulated color value.
[0144] Optionally, the target transformation parameters also include a color mixing coefficient; the calculation module 602 is further used to: use the color mixing coefficient to mix multiple color components of the light accumulated color value to obtain a target calculation result.
[0145] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0146] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0147] Optionally, in this embodiment, the above-mentioned computer-readable storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0148] Optionally, in this embodiment, the computer-readable storage medium may be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.
[0149] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0150] S1, obtaining the initial light marching information in the virtual scene;
[0151] S2, performing ray marching calculation based on the initial ray marching information and the target transformation parameters to obtain a target calculation result, wherein the target transformation parameters are used to control the step size adaptive transformation and the ray morphology transformation in the ray marching calculation;
[0152] S3, rendering the target calculation result to obtain the target light rendering result of the virtual scene.
[0153] Optionally, the computer-readable storage medium is further configured to store program code for executing the following steps: initial light marching information includes: the starting position and direction of travel of the light in the virtual scene, and the target transformation parameters include a step count threshold; performing multiple step light marching iterative calculations based on the step count threshold, the starting position and the direction of travel to obtain the light accumulated color value; and determining the target calculation result using the light accumulated color value.
[0154] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: the target transformation parameters include a step length; for a target step among multiple steps, based on the step length, determining the amount of light traveled corresponding to the target step; determining a first step position corresponding to the target step according to the starting position, the travel direction and the amount of light traveled; based on the first step position and the time factor corresponding to the virtual scene, calling the target transformation function to calculate and update the color sampling value corresponding to the target step; based on the color sampling value, accumulatively updating the accumulated color value of the light.
[0155] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: for a first step among multiple steps, initializing the light travel amount based on a preset initial step length, initializing the color sampling value based on a preset sampling value, and initializing the light accumulated color value based on a preset initial color.
[0156] Optionally, the computer-readable storage medium is further configured to store program code for executing the following steps: the target transformation parameters also include a first color interpolation coefficient; an exponential calculation is performed based on the product of the first color interpolation coefficient and the color sampling value to obtain a first calculation result, wherein the first color interpolation coefficient is used to control the color gradient rate between multiple steps; and the light travel amount is cumulatively updated using the product of the travel step length and the first calculation result.
[0157] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: the target transformation parameters also include a fractal number threshold; the first step position is subjected to a domain distortion coordinate transformation using a time factor to obtain a second step position; multiple rounds of fractal iterative calculations are performed based on the fractal number threshold, the first step position, and the second step position to obtain a cumulative fractal value; and a color sampling value is determined based on the cumulative fractal value.
[0158] Optionally, the computer-readable storage medium is also configured to store program codes for executing the following steps: in a target round in multiple rounds, performing a nonlinear transformation mapping on the first step position to obtain a first mapping position; performing a complex square calculation on a target component of the first mapping position to determine a second mapping position; performing a coordinate rotation on the second mapping position according to a preset rotation direction to obtain a third mapping position; and performing an exponentially decayed cumulative update on the accumulated fractal value based on the third mapping position and the second step position.
[0159] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: calculating the mean of the accumulated fractal values to obtain an average fractal value; and performing color sampling based on the average fractal value to obtain a color sampling value.
[0160] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: the target transformation parameters also include a second color interpolation coefficient; the color sampling value is multiplied by the second color interpolation coefficient to obtain a second calculation result, wherein the second color interpolation coefficient is used to control the color accumulation intensity between multiple steps; and the light accumulated color value is cumulatively updated using the second calculation result.
[0161] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: the target transformation parameters also include color mixing coefficients; and multiple color components of the light accumulated color value are mixed using the color mixing coefficients to obtain a target calculation result.
[0162] In the computer-readable storage medium of the above-mentioned embodiment, a technical solution for implementing a ray rendering method is provided. Initial ray marching information in a virtual scene is obtained; ray marching calculations are performed based on the initial ray marching information and target transformation parameters to obtain target calculation results, wherein the target transformation parameters are used to control the step adaptive transformation and ray morphology transformation in the ray marching calculations; the target calculation results are rendered to obtain target ray rendering results of the virtual scene. Therefore, the present application combines the parameter control of the step adaptive transformation and the parameter control of the ray morphology transformation in the ray marching calculations. Compared with the ray tracing technology with high computational complexity or the ray marching technology with a fixed step size, the present application achieves the purpose of setting target transformation parameters at a lower cost to control the step adaptive and ray morphology transformation of the ray marching calculations to achieve higher-precision ray rendering, and achieves the technical effect of achieving high-precision ray rendering at a lower cost, thereby solving the technical problem that the ray rendering schemes of the related technologies are difficult to achieve a balance between rendering accuracy and rendering performance.
[0163] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation method of the present application can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation method of the present application.
[0164] In an exemplary embodiment of the present application, a program product capable of implementing the above method of the present embodiment is stored on a computer-readable storage medium. In some possible implementations, various aspects of the embodiments of the present application can also be implemented in the form of a program product, which includes a program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary implementations of the present application described in the above "Exemplary Method" section of the present embodiment.
[0165] According to the program product for implementing the above method in the embodiment of the present application, it can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the embodiment of the present application is not limited thereto. In the embodiment of the present application, the computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0166] The program product may be in any combination of one or more computer-readable media. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive) of computer-readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0167] It should be noted that the program code contained in the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0168] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0169] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0170] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0171] S1, obtaining the initial light marching information in the virtual scene;
[0172] S2, performing ray marching calculation based on the initial ray marching information and the target transformation parameters to obtain a target calculation result, wherein the target transformation parameters are used to control the step size adaptive transformation and the ray morphology transformation in the ray marching calculation;
[0173] S3, rendering the target calculation result to obtain the target light rendering result of the virtual scene.
[0174] Optionally, the processor may also be configured to execute the following steps through a computer program: initial light marching information includes: a starting position and a direction of travel of the light in the virtual scene, and a target transformation parameter includes a step count threshold; performing multiple step light marching iterative calculations based on the step count threshold, the starting position, and the direction of travel to obtain a light cumulative color value; and determining a target calculation result using the light cumulative color value.
[0175] Optionally, the processor may also be configured to perform the following steps through a computer program: the target transformation parameters include a step length; for a target step among multiple steps, based on the step length, determining the amount of light traveled corresponding to the target step; determining the first step position corresponding to the target step according to the starting position, the direction of travel and the amount of light traveled; based on the first step position and the time factor corresponding to the virtual scene, calling the target transformation function to calculate and update the color sampling value corresponding to the target step; based on the color sampling value, accumulatively updating the accumulated color value of the light.
[0176] Optionally, the processor can also be configured to perform the following steps through a computer program: for the first step among multiple steps, initialize the light travel amount based on a preset initial step length, initialize the color sampling value based on a preset sampling value, and initialize the light accumulated color value based on a preset initial color.
[0177] Optionally, the processor may also be configured to execute the following steps through a computer program: the target transformation parameters also include a first color interpolation coefficient; an exponential calculation is performed based on the product of the first color interpolation coefficient and the color sampling value to obtain a first calculation result, wherein the first color interpolation coefficient is used to control the color gradient rate between multiple steps; and the light travel amount is cumulatively updated using the product of the travel step length and the first calculation result.
[0178] Optionally, the processor can also be configured to perform the following steps through a computer program: the target transformation parameters also include a fractal number threshold; the first step position is subjected to a domain distortion coordinate transformation using a time factor to obtain a second step position; multiple rounds of fractal iterative calculations are performed based on the fractal number threshold, the first step position, and the second step position to obtain a cumulative fractal value; and a color sampling value is determined based on the cumulative fractal value.
[0179] Optionally, the processor can also be configured to execute the following steps through a computer program: in a target round in multiple rounds, performing a nonlinear transformation mapping on the first step position to obtain a first mapping position; performing a complex square calculation on the target component of the first mapping position to determine the second mapping position; performing a coordinate rotation on the second mapping position according to a preset rotation direction to obtain a third mapping position; and performing an exponentially decayed cumulative update on the accumulated fractal value based on the third mapping position and the second step position.
[0180] Optionally, the processor may also be configured to execute the following steps through a computer program: performing mean calculation on the accumulated fractal values to obtain an average fractal value; and performing color sampling based on the average fractal value to obtain a color sampling value.
[0181] Optionally, the processor may also be configured to perform the following steps through a computer program: the target transformation parameters also include a second color interpolation coefficient; the color sampling value is multiplied by the second color interpolation coefficient to obtain a second calculation result, wherein the second color interpolation coefficient is used to control the color accumulation intensity between multiple steps; and the light accumulated color value is cumulatively updated using the second calculation result.
[0182] Optionally, the processor may also be configured to perform the following steps through a computer program: the target transformation parameters also include a color mixing coefficient; and the color mixing coefficient is used to mix multiple color components of the light accumulated color value to obtain a target calculation result.
[0183] In the electronic device of the above-mentioned embodiment, a technical solution for implementing a ray rendering method is provided. Initial ray marching information in a virtual scene is obtained; ray marching calculations are performed based on the initial ray marching information and target transformation parameters to obtain target calculation results, wherein the target transformation parameters are used to control the step adaptive transformation and ray morphology transformation in the ray marching calculations; the target calculation results are rendered to obtain target ray rendering results of the virtual scene. Therefore, the present application combines the parameter control of the step adaptive transformation and the parameter control of the ray morphology transformation in the ray marching calculations. Compared with the ray tracing technology with high computational complexity or the ray marching technology with a fixed step size, the present application achieves the purpose of setting target transformation parameters at a lower cost to control the step adaptive and ray morphology transformation of the ray marching calculations to achieve higher-precision ray rendering, and achieves the technical effect of achieving high-precision ray rendering at a lower cost, thereby solving the technical problem that the ray rendering schemes of the related technologies are difficult to achieve a balance between rendering accuracy and rendering performance.
[0184] Figure 7 is a schematic diagram of an electronic device according to one embodiment of the present application. Figure 7As shown, the electronic device 700 is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0185] like Figure 7 As shown, the electronic device 700 is in the form of a general computing device. The components of the electronic device 700 may include but are not limited to: at least one processor 710, at least one memory 720, a bus 730 connecting different system components (including the memory 720 and the processor 710), and a display 740.
[0186] The memory 720 stores program codes, which can be executed by the processor 710, so that the processor 710 executes the steps described in the method part of the embodiment of the present application according to various exemplary implementations of the present application.
[0187] The memory 720 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 7201 and / or a cache memory unit 7202, and may further include a read-only memory unit (ROM) 7203, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0188] In some examples, the memory 720 may also include a program / utility 7204 having a set (at least one) of program modules 7205, such program modules 7205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include the implementation of a network environment. The memory 720 may further include a memory remotely disposed relative to the processor 710, and these remote memories may be connected to the electronic device 700 via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0189] Bus 730 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a local bus of processor 710, or any of a variety of bus architectures.
[0190] The display 740 may be, for example, a touch screen liquid crystal display (LCD), which may enable a user to interact with a user interface of the electronic device 700 .
[0191] Optionally, the electronic device 700 may also communicate with one or more external devices 800 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 700, and / or any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 750. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 760. Figure 7 As shown, the network adapter 760 communicates with other modules of the electronic device 700 via the bus 730. It should be understood that although Figure 7 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) systems, tape drives, and data backup storage systems.
[0192] The electronic device 700 may further include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply and / or a camera.
[0193] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only and does not limit the structure of the above electronic device. Figure 7 More or fewer components as shown, or with Figure 7 The memory 720 may be used to store computer programs and corresponding data, such as the computer programs and corresponding data corresponding to the light rendering method in the embodiment of the present application. The processor 710 executes various functional applications and data processing by running the computer programs stored in the memory 720, that is, implementing the above-mentioned light rendering method.
[0194] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0195] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0196] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0197] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0198] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0199] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform 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 read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0200] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A light rendering method, characterized in that: include: Get initial ray marching information in the virtual scene; Performing a ray marching calculation based on the initial ray marching information and a target transformation parameter to obtain a target calculation result, wherein the target transformation parameter is used to control a step size adaptive transformation and a ray morphology transformation in the ray marching calculation; The target calculation result is rendered to obtain a target light rendering result of the virtual scene.
2. The light rendering method according to claim 1, characterized in that: The initial light marching information includes: the starting position and the marching direction of the light in the virtual scene, and the target transformation parameter includes a step count threshold; performing light marching calculation based on the initial light marching information and the target transformation parameter, and obtaining the target calculation result includes: Performing a plurality of step-by-step iterative calculations of the light march based on the step number threshold, the starting position and the marching direction to obtain a light accumulated color value; The target calculation result is determined by using the light accumulated color value.
3. The light rendering method according to claim 2, characterized in that: The target transformation parameters include the step length; Performing a plurality of step-by-step iterative calculations of the light march based on the step number threshold, the starting position, and the marching direction to obtain the light accumulated color value includes: For a target step among the multiple steps, determining a light travel amount corresponding to the target step based on the travel step length; Determining a first step position corresponding to the target step according to the starting position, the travel direction and the travel amount of the light; Based on the first step position and the time factor corresponding to the virtual scene, calling a target transformation function to calculate and update the color sampling value corresponding to the target step; Based on the color sampling value, the light accumulated color value is cumulatively updated.
4. The light rendering method according to claim 3, characterized in that: The light rendering method further comprises: For a first step among the multiple steps, the light travel amount is initialized based on a preset initial step length, the color sampling value is initialized based on a preset sampling value, and the light accumulated color value is initialized based on a preset initial color.
5. The light rendering method according to claim 4, characterized in that: The target transformation parameter further includes a first color interpolation coefficient; based on the marching step length, determining the light march amount corresponding to the target marching step includes: Performing exponential calculation based on the product of the first color interpolation coefficient and the color sampling value to obtain a first calculation result, wherein the first color interpolation coefficient is used to control the color gradient rate between the multiple steps; The light travel amount is cumulatively updated using the product of the travel step length and the first calculation result.
6. The light rendering method according to claim 3, characterized in that: The target transformation parameter also includes a fractal number threshold; based on the first step position and the time factor, calling the target transformation function to calculate and update the color sampling value corresponding to the target step includes: Using the time factor, performing domain warping coordinate transformation on the first step position to obtain a second step position; Perform multiple rounds of fractal iterative calculations based on the fractal number threshold, the first step position, and the second step position to obtain a cumulative fractal value; The color sampling value is determined according to the accumulated fractal value.
7. The light rendering method according to claim 6, characterized in that: Performing multiple rounds of fractal iterative calculations based on the fractal number threshold, the first step position, and the second step position to obtain the cumulative fractal value includes: In a target round among the multiple rounds, performing a nonlinear transformation mapping on the first step position to obtain a first mapping position; Performing a complex square calculation on the target component of the first mapping position to determine a second mapping position; Performing coordinate rotation on the second mapping position according to a preset rotation direction to obtain a third mapping position; Based on the third mapping position and the second stepping position, the accumulated fractal value is updated by exponential decay accumulation.
8. The light rendering method according to claim 6, characterized in that: Determining the color sampling value according to the accumulated fractal value includes: Calculating the mean of the accumulated fractal values to obtain an average fractal value; Color sampling is performed based on the average fractal value to obtain the color sampling value.
9. The light rendering method according to claim 3, characterized in that: The target transformation parameters also include a second color interpolation coefficient; Based on the color sampling value, cumulatively updating the light accumulated color value includes: Performing multiplication calculation on the color sampling value and the second color interpolation coefficient to obtain a second calculation result, wherein the second color interpolation coefficient is used to control the color accumulation intensity between the multiple steps; The light accumulated color value is cumulatively updated using the second calculation result.
10. The light rendering method according to claim 2, characterized in that: The target transformation parameters also include a color mixing coefficient; using the light accumulated color value, determining the target calculation result includes: The color mixing coefficient is used to mix multiple color components of the light accumulated color value to obtain the target calculation result.
11. A light rendering device, characterized in that: include: An acquisition module, used to acquire initial light marching information in a virtual scene; A calculation module, configured to perform a ray marching calculation based on the initial ray marching information and a target transformation parameter to obtain a target calculation result, wherein the target transformation parameter is used to control a step size adaptive transformation and a ray morphology transformation in the ray marching calculation; The rendering module is used to render the target calculation result to obtain the target light rendering result of the virtual scene.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the light rendering method according to any one of claims 1 to 10 when executed by a processor.
13. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the light rendering method described in any one of claims 1 to 10.
14. A computer program product, characterized in that The invention comprises a computer program, which implements the light rendering method described in any one of claims 1 to 10 when being executed by a processor.