Sky effect rendering method and device, electronic equipment and computer readable storage medium
By employing a multi-layer fractal iteration algorithm and a dynamic time offset mechanism, the high cost and computational complexity issues in sky effect generation are resolved, enabling dynamic visual effects and richly detailed sky rendering, suitable for real-time applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-04-10
AI Technical Summary
Existing technologies suffer from high production costs, large storage overhead, and a lack of dynamism and detail when generating sky effects. In particular, the computational complexity is high in real-time applications, making it difficult to achieve smooth rendering effects.
A multi-layer fractal iterative algorithm is adopted, combined with a time dynamic offset mechanism. By obtaining the view vector of each pixel, multi-layer iterative calculation is performed based on the fractal starting point and basic brightness data. The sky effect is rendered by combining hue data, reducing the dependence on pre-stored textures.
It generates sky images with dynamic visual effects and rich details without relying on pre-stored texture maps, reduces computational complexity, improves real-time rendering efficiency, reduces storage overhead, and supports the generation of diverse sky effects.
Smart Images

Figure CN121837474A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer graphics, in particular to a sky effect rendering method and device, electronic equipment and computer readable storage medium. BACKGROUND
[0002] In the field of computer graphics and real-time rendering, constructing a virtual environment with immersion is one of the core goals to achieve high-quality visual experience. Among them, the skybox as a widely used background rendering technology in game engines, virtual reality (VR), augmented reality (AR) and three-dimensional simulation systems, undertakes the important function of simulating the distant environment (such as sky, cloud layer, starry sky, etc.). It effectively enhances the sense of reality and depth of space by providing a wrap-around visual boundary for the scene.
[0003] The traditional skybox implementation mainly relies on pre-rendered texture maps. Specifically, developers use six images to map onto the six inner surfaces of a cube, forming a 360-degree seamless surrounding visual background. These images are usually hand-drawn by art designers or generated by offline rendering tools. However, this method has several significant defects: However, this method of relying on artificial design and external resources has obvious limitations: 1. High production cost and long cycle: each set of sky effect needs to be specially drawn, making it difficult to quickly iterate or generate in batches; 2. Large storage overhead: high-resolution textures occupy a large amount of video memory and disk space, especially when multiple weather states or multiple time point changes need to be supported; 3. Lack of dynamic and variability: pre-rendered images are essentially static and cannot achieve natural evolution processes such as cloud flow, day-night transition or star rotation, limiting interactivity and immersion experience.
[0004] In order to overcome the above problems, in recent years, procedural skybox technology has emerged. This type of method does not rely on external image resources, but generates sky patterns pixel by pixel in the pixel shader through the execution of mathematical functions or noise algorithms at runtime. For example, based on physical atmospheric scattering models, or using raymarching combined with noise functions to simulate dynamic phenomena such as clouds and fog. However, these existing technical solutions still have the following obvious shortcomings: Firstly, procedural skyboxes based on simple noise (such as Perlin noise, Simplex noise) often have difficulty in presenting sufficient detail levels and morphological diversity when generating complex visual elements such as cloud layers and nebulae. The generated results are prone to pattern repetition, single structure or excessive smoothing, resulting in a lack of realism and uniqueness in visual effects, which is difficult to meet the needs of high-simulation virtual scenes.
[0005] Secondly, existing procedural skyboxes generally rely on raymarching methods to step along the line of sight for sampling when dealing with complex volume effects such as clouds and fog, and usually need to combine multi-layer noise superposition to improve details. This process involves a large number of sampling point calculations and texture queries, especially under the requirements of high resolution and multiple detail levels, which will result in extremely high computational complexity and rendering load, making it difficult to maintain a smooth frame rate in real-time applications, especially on mobile platforms or performance-limited environments.
[0006] Therefore, there is an urgent need for a skybox implementation scheme that can significantly reduce computational complexity and improve real-time rendering efficiency while ensuring the realism and richness of visual effects. SUMMARY
[0007] The purpose of the present application is to provide a sky effect rendering method, device, electronic equipment and computer readable storage medium to improve the problems existing in the prior art.
[0008] Embodiments of the present application can be implemented as follows: In a first aspect, the present application provides a sky effect rendering method, comprising: obtaining a view vector of each pixel point in a sky region of a current camera field of view; based on the current time and a first preset period, performing initial offset processing on each view vector to obtain a fractal starting point corresponding to each pixel point; for each pixel point, based on the fractal starting point corresponding to the pixel point, user-specified base value data and a preset number of iterations, determining the comprehensive value of the pixel point by using a multi-layer fractal iteration method; based on user-specified hue data and the comprehensive value of each pixel point, determining the target color data of each pixel point; based on the target color data of each pixel point, rendering the sky effect of the current game frame.
[0009] In an optional implementation, the step of performing initial offset processing on each view vector based on the current time and the first preset period to obtain a fractal starting point corresponding to each pixel point comprises: calculating the ratio of the current time to the first preset period, and substituting the ratio into a sinusoidal mapping function to obtain an initial offset; Superimpose the three-axis components of each of the view vectors with the initial offset and a fixed constant respectively to obtain a fractal starting point corresponding to each pixel point.
[0010] In optional embodiments, the base lightness data includes a first layer and a second layer of respective base lightness; Based on the fractal starting point corresponding to the pixel point, the user-specified base lightness data, and a preset number of iterations, the comprehensive lightness of the pixel point is determined in a multi-layer fractal iteration manner, including: Taking the fractal starting point of the pixel point as an iteration starting point of the first layer, and offsetting the iteration starting point of the first layer based on the current time and a second preset period to obtain an iteration starting point of the second layer; For each iteration starting point of a layer, the iteration starting point of the layer is subjected to multiple fractal iterations based on the preset number of iterations, and the iteration lightness of the layer is determined in combination with the base lightness of the layer; Superimpose the iteration lightness of each layer and map it to a fixed lightness interval to obtain the comprehensive lightness of the pixel point.
[0011] In optional embodiments, the step of determining the iteration lightness of the layer in combination with the base lightness of the layer after the iteration starting point of the layer is subjected to multiple fractal iterations based on the preset number of iterations, includes: Taking the iteration starting point of the layer as a current point; Calculating the square of the length of the current point to obtain an observation value of the current iteration; Calculating the absolute value of the difference between the observation value of the current iteration and the observation value of the last iteration to obtain an observation change of the current iteration; wherein the observation change of the first iteration is equal to the observation value of the first iteration; Inputting the current point and the observation value of the current iteration into a transformation function to obtain a transformed point after the current iteration; If the number of iterations is not equal to the preset number of iterations, the transformed point after the current iteration obtained in the current iteration is taken as a new current point, and the step of calculating the square of the length of the current point to obtain an observation value of the current iteration is returned; If the number of iterations is equal to the preset number of iterations, the observation changes of multiple iterations are obtained; Inputting the observation changes of multiple iterations and the base lightness of the layer into a cumulative function to obtain the iteration lightness of the layer.
[0012] In optional embodiments, the formula of the transformation function is:
[0013] In the formula, represents the coordinates of the transformed point , and represents the current point coordinates of the point, denotes taking absolute value, denotes dot product, denotes the current point the square of the length of the point, denotes the coordinates of a random point ; the formula of the cumulative function is:
[0014] wherein, denotes the iteration lightness, denotes the preset iteration number, denotes the th weighting coefficient, presents exponential decay or increment, denotes the decay factor, denotes the th iteration observation change amount; denotes the weight coefficient of the base lightness .
[0015] In an optional embodiment, the hue data includes initial hue and terminal hue of each of the first layer and the second layer; The step of determining the target color data of each pixel point based on the user-specified hue data and the comprehensive lightness of each pixel point includes: The scale change between the comprehensive lightness of each pixel point is adjusted by using a Gaussian smoothing processing manner to obtain the latest comprehensive lightness of each pixel point; For each layer, the color data of each pixel point in the layer is determined by using a linear interpolation manner based on the latest comprehensive lightness of each pixel point, the initial hue and the terminal hue of the layer; The color data of each pixel point in the first layer and the second layer are superimposed to obtain the target color data of each pixel point.
[0016] In an optional embodiment, the step of adjusting the scale change between the comprehensive lightness of each pixel point by using a Gaussian smoothing processing manner includes: At least one isolated pixel point is selected from all the pixel points based on a preset lightness difference and the comprehensive lightness of each pixel point; the difference between the comprehensive lightness of the isolated pixel point and the comprehensive lightness of each pixel point around the isolated pixel point is greater than the preset lightness difference; For each isolated pixel point, Gaussian smoothing processing is performed on the comprehensive lightness of the isolated pixel point and each pixel point around the isolated pixel point.
[0017] In a second aspect, the present application provides a sky effect rendering device, comprising: The acquisition module is configured to acquire a view vector of each pixel point in a sky region of a current camera field of view. The time sequence offset module is configured to perform initial offset processing on each view vector based on a current time and a first preset period to obtain a fractal starting point corresponding to each pixel point. The brightness calculation module is configured to determine, for each pixel point, a comprehensive brightness of the pixel point by using a multi-layer fractal iteration manner based on the fractal starting point corresponding to the pixel point, user-specified basic brightness data, and a preset iteration number. The color calculation module is configured to determine target color data of each pixel point based on user-specified hue data and the comprehensive brightness of each pixel point. The rendering module is configured to render a sky effect of a current game frame based on the target color data of each pixel point.
[0018] In a third aspect, the present application provides an electronic device, comprising a memory and a processor, the memory stores a software program, and the processor executes the software program to implement the sky effect rendering method according to the first aspect.
[0019] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the sky effect rendering method according to the first aspect.
[0020] Compared with the prior art, the sky effect rendering method, device, electronic device, and computer readable storage medium provided by the present application first acquire a view vector of each pixel point in a sky region of a current camera field of view, perform initial offset processing on each view vector based on a current time and a first preset period to obtain a fractal starting point corresponding to each pixel point, determine, for each pixel point, a comprehensive brightness of the pixel point by using a multi-layer fractal iteration manner based on the fractal starting point corresponding to the pixel point, user-specified basic brightness data, and a preset iteration number, determine target color data of each pixel point based on user-specified hue data and the comprehensive brightness of each pixel point, and render a sky effect of a current game frame based on the target color data of each pixel point. The present application introduces a fractal mathematical model in pixel-level calculation, and combines a time dynamic offset mechanism and multi-layer fractal iteration calculation, so that a sky picture with dynamic visual effects and visual levels can be generated without relying on pre-stored texture maps, thereby effectively solving the problems of large storage overhead, lack of dynamic change ability, and insufficient detail expression in the prior art. BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be considered as limiting the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.
[0022] Figure 1 One of the flow diagrams of the sky effect rendering method provided by the embodiments of the present application.
[0023] Figure 2 The second flow diagram of the sky effect rendering method provided by the embodiments of the present application.
[0024] Figure 3 The third flow diagram of the sky effect rendering method provided by the embodiments of the present application.
[0025] Figure 4 The structural diagram of the sky effect rendering device provided by the embodiments of the present application.
[0026] Figure 5 The structural diagram of the electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solutions and advantages of the embodiments of the present application more clear, the following will combine the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, but not all the embodiments. The components of the embodiments of the present application described and shown in the drawings can be arranged and designed in various different configurations.
[0028] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of the present application.
[0029] It should be noted that: similar labels and letters represent similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0030] In addition, if the terms "first", "second" and the like are used, they are only used to distinguish description, and cannot be understood as indicating or implying relative importance.
[0031] It should be noted that the features in the embodiments of the present application can be combined with each other without conflict.
[0032] The related terms explained in the present application include: In the HSV color space, it is divided into the following three dimensions: 1、H channel (hue): represents the color category (such as red, green, blue), the value range is 0-179 (because OpenCV uses 8-bit integer storage, the hue ring of 0-360° is compressed to 0-179, saving storage space); 2、S channel (saturation): represents the color brightness, the value range is 0-255 (0 is gray, 255 is pure color); 3、V channel (lightness): represents the color lightness, the value range is 0-255 (0 is black, 255 is the brightest).
[0033] Please refer to Figure 1 , Figure 1 A flowchart of a sky effect rendering method provided by an embodiment of the present application is shown. The execution subject of the method can be, but is not limited to, a smart phone, a personal notebook, a personal computer, a server, and the like. The method can include the following steps S101-S105.
[0034] S101, obtain the view vector of each pixel point in the sky area of the current camera field of view.
[0035] In this embodiment, after the rendering of the previous game frame is completed, the view vector corresponding to each pixel point used to constitute the sky area in the current camera field of view can be obtained from the pixel shader by the graphics rendering pipeline. Each view vector represents a view line vector from the virtual camera position to the pixel point position, and the value is determined by the position of the pixel in the screen space.
[0036] S102, based on the current time and the first preset period, performing initial offset processing on each view vector to obtain the fractal starting point corresponding to each pixel point.
[0037] In this embodiment, the initial offset processing is performed by introducing a time dimension variable, so that the spatial starting point participating in the fractal calculation is regularly offset in each frame rendering, and the slowly evolving behavior characteristics of the sky structure are given, such as cloud layer flow or star field rotation, so as to ensure that the rendered sky effect presents dynamic effect.
[0038] S103, for each pixel point, based on the fractal starting point of the pixel point, the user-specified basic lightness data, and the preset iteration number, the comprehensive lightness of the pixel point is determined by using a multi-layer fractal iteration method.
[0039] In the embodiment, for each pixel point, the system takes the corresponding fractal starting point as the starting point, combines the user-specified basic lightness data and the preset iteration number set uniformly, and starts a multi-layer fractal iteration process to determine the comprehensive lightness of the pixel point.
[0040] In the embodiment, based on the user-specified hue data and the comprehensive lightness of each pixel point, color mapping can be performed to finally determine the target color data of each pixel point.
[0041] In the embodiment, based on the user-specified hue data and the comprehensive lightness of each pixel point, color mapping can be performed to finally determine the target color data of each pixel point.
[0042] S105, based on the target color data of each pixel point, rendering the sky effect of the current game frame.
[0043] In the embodiment, the target color data of each pixel point is written into the frame buffer of the current game frame, and the drawing of the entire sky picture is completed. Since the entire calculation process is executed in parallel pixel by pixel in the pixel shader of the GPU, the real-time rendering effect can be achieved by quickly updating each frame. The final presented sky not only has a complex organic form, but also supports real-time adjustment of parameters such as color, speed, and hierarchical distribution, and is suitable for various stylized visual performance requirements.
[0044] The sky effect rendering method provided by the embodiment of the application can combine the time dynamic offset mechanism and the multi-layer fractal iteration calculation, and can render a sky picture with dynamic visual effects and visual hierarchical sense without relying on pre-stored texture maps, thereby effectively solving the problems of large storage overhead, lack of dynamic change ability, and insufficient detail expression in the prior art.
[0045] The traditional procedural texture generation technology often relies on a static noise field or a fixed parameter configuration, resulting in a lack of continuous change ability in the time dimension of the generated picture, which is easy to present repetitive and stiff visual features, and is difficult to simulate complex phenomena with space-time evolution characteristics such as cloud flow and star cloud rotation in nature.
[0046] However, the application applies a time-related offset processing to the view vector of each pixel point in the sky area, so that the same spatial direction corresponds to different iteration starting points at different frame moments, thereby driving the overall visual effect to have a smooth evolution behavior. That is, the implementation process of the above step S102 includes sub-steps S1021-S1022.
[0047] S1021, calculating the ratio of the current moment to the first preset period, and substituting the ratio into a sine mapping function to obtain an initial offset.
[0048] In the embodiment, the initial offset The calculation method is: , represents the current time, represents the first preset period. As time goes on, is a value that periodically oscillates in the limited interval [-1, 1], and since the sine function has the characteristics of continuity and smooth transition, the generated initial offset will not mutate, which helps to avoid flickering or jumping phenomenon.
[0049] wherein, The size of can be flexibly set based on the flow speed or transformation speed requirement of the sky effect, for example, can be set to 10 seconds or 20 seconds, etc., if you want to change slowly (for example, to achieve the effect of the clouds being blown by the wind), can be set larger, and vice versa can be set slightly smaller.
[0050] S1022, superimpose the three-axis components of each view vector on the initial offset and the fixed constant respectively to obtain the fractal starting point corresponding to each pixel point.
[0051] In this embodiment, the three-axis components of each view vector are superimposed on the initial offset and the fixed constant (for example, 0.2 or 0.4), which is essentially to apply a uniform and slowly changing disturbance to the original view vector in space, so that the subsequent fractal iteration process based on the fractal starting point starts from different starting points. The existence of the fixed constant is used to break the symmetry and prevent the structure from being highly similar between different frames due to the consistent initial phase, further enhancing the visual diversity.
[0052] The present application generates a dynamic offset by combining the current time with the first preset period and mapping it through a sine function, and applies it to the three-axis components of the view vector together with the fixed constant, which realizes the controllable disturbance of the initial input condition. This processing method not only retains the direction information of the original view angle, but also introduces the time evolution ability, which provides differentiated starting state for subsequent multi-layer fractal iteration, and further supports the natural flow and gradual change of the sky effect in the time dimension.
[0053] In the generation process of the programmed sky effect, the richness of the visual hierarchy depends largely on whether the rendering system can simultaneously present structure components with different spatial scales and dynamic characteristics in the same picture. If all pixel points are calculated by a single path of fractal, the generated pattern often lacks foreground and background relationship and detail contrast, resulting in a flat overall visual experience.
[0054] To improve the visual level of the rendered sky effect, in the step S203, for each pixel point, the iteration brightness of each layer can be determined based on the corresponding fractal starting point, and the iteration brightness of multiple layers can be superimposed to determine the comprehensive brightness of the pixel point. The present application derives multiple independent iteration starting points based on one fractal starting point to perform fractal iteration of each layer to achieve a richer sense of depth of field and visual level. The following describes the calculation process of the comprehensive brightness of a pixel point in the sky region by taking two-layer fractal iteration as an example.
[0055] When two-layer fractal iteration is performed, the user-specified base brightness data can include the base brightness of the first layer and the base brightness of the second layer. Figure 1 Based on the above, Figure 2 The implementation of the step S103 includes the following steps S1031-S1033.
[0056] S1031, the fractal starting point of the pixel point is taken as the iteration starting point of the first layer, and the iteration starting point of the first layer is offset based on the current time and the second preset period to obtain the iteration starting point of the second layer.
[0057] In the embodiment, the process of offsetting the iteration starting point of the first layer can include: (1) calculating the ratio of the current time to the second preset period, and substituting the ratio into a sine mapping function to obtain a cross-layer offset; That is, the cross-layer offset , represents the second preset period, The size of the second preset period can be close to but different from the size of the first preset period. For example, the first preset period is 5, and the second preset period is 7. It should be noted that the examples are only for illustration and are not limited herein.
[0058] (2) superimposing the three-axis components of the iteration starting point of the first layer with the cross-layer offset to obtain the iteration starting point of the second layer.
[0059] It can be understood that if more layers of analysis iteration are performed, the iteration starting point of the second layer needs to be offset in the same way to obtain the iteration starting point of the third layer, and so on.
[0060] S1032, for each layer of iteration starting point, the iteration starting point of the layer is subjected to multiple fractal iterations based on the preset iteration number, and the iteration brightness of the layer is determined in combination with the base brightness of the layer.
[0061] In this embodiment, the square of the modulus of each iteration during multiple fractal iterations is used as the observation value to calculate the change in the observation value between adjacent iterations. Finally, the calculated changes in each observation value are accumulated to determine the iteration brightness of the layer, thereby obtaining rich high-frequency details with fewer iterations (e.g., a preset number of iterations = 10). Compared with methods that require a large number of samples or adaptive raymarching, this significantly reduces computational resource consumption.
[0062] Therefore, in Figure 2 Based on this, please refer to Figure 3 The implementation of step S1032 above may include the following sub-steps a1 to a6.
[0063] Step a1: Take the iteration start point of this layer as the current point.
[0064] Step a2: Calculate the square of the modulus of the current point to obtain the observation value for the current iteration.
[0065] Step a3: Calculate the absolute value of the difference between the observation value of the current iteration and the observation value of the previous iteration to obtain the change in observation value of the current iteration.
[0066] Specifically, the change in observations during the first iteration is equal to the observed value during the first iteration. That is, the formula for calculating the change in observations is:
[0067]
[0068] In the formula, Indicates the first The observed changes at the next iteration; Indicates the first The observation at the next iteration Indicates the first The observation at the next iteration Represents the dot product. Indicates the first The square of the modulus of the current point at the next iteration. Indicates the first The current point at the next iteration.
[0069] Step a4: Input the current point and the observation value of the current iteration into the transformation function to obtain the transformed point after the current iteration.
[0070] In this embodiment, the formula for the transformation function is:
[0071] In the formula, Represents the transformation point coordinates denotes the coordinate of the current point, denotes taking absolute value, denotes dot product, denotes the square of the length of the current point, denotes the coordinate of the random point F. For example, the random point F can be .
[0072] Step a5, if the number of iterations is not equal to the preset number of iterations, the transformed point obtained in this iteration is taken as a new current point, and then the step a2 is executed.
[0073] Step a6, if the number of iterations is equal to the preset number of iterations, the observation change quantity in multiple iterations is obtained, and the observation change quantity in multiple iterations and the base lightness input cumulative function of the layer are input to obtain the iteration lightness of the layer.
[0074] In the embodiment, the formula of the cumulative function is:
[0075] In the formula, denotes the iteration lightness, denotes the preset number of iterations (n can be 10 or 12), denotes the m-th weighting coefficient, presents exponential decay or increment, denotes the decay factor, denotes the observation change quantity in the n-th iteration; denotes the weight coefficient of the base lightness, for example, 0.25.
[0076] S1033, the iteration lightness of each layer is superimposed and mapped to a fixed lightness interval to obtain the comprehensive lightness of the pixel point.
[0077] In the embodiment, the iteration lightness generated by each layer is superimposed and processed, so that the brightness contribution from different calculation paths jointly acts on the final output. The superimposed result is further mapped to a fixed lightness interval (i.e. the value range of the V channel is 0~255) to meet the requirements of the pixel brightness range of the graphics rendering pipeline. The mapping process ensures that the synthesized value has good display compatibility and avoids picture distortion caused by value overflow. The final output comprehensive lightness is the overall brightness expression of the pixel point under the whole multi-layer fractal structure, which carries the information fusion result from multiple levels.
[0078] Or, for a pixel point, the iterative brightness of each layer can also be directly weighted and averaged to obtain the comprehensive brightness of the pixel point.
[0079] In the generation process of the procedural sky effect, it is difficult to completely express the rich and varied visual features only by using the brightness information. The color distribution plays an important role in simulating natural phenomena such as dawn and dusk lighting, star cloud transition and atmospheric scattering. If the color mapping process lacks consideration of spatial continuity and hierarchical difference, it may cause problems such as abrupt boundaries, color block breaks or poor foreground and background fusion in the picture.
[0080] To improve the visual coordination and artistic expression of the final image, the comprehensive brightness of each pixel point obtained above is combined with the hue data specified by the user to realize fine color synthesis.
[0081] When performing two-layer fractal iteration, the hue data includes the initial hue and the terminal hue of each of the first layer and the second layer. For example, assuming that it is desired to present a fire cloud effect in the sky, the initial hue and the terminal hue can be red and orange respectively, which is only an example. Based on the two-layer hue setting specified by the user, the implementation process of the above step S104 can include the following sub-steps S1041-S1043.
[0082] S1041, the scale change between the comprehensive brightness of each pixel point is adjusted by using a Gaussian smoothing processing method to obtain the latest comprehensive brightness of each pixel point.
[0083] It can be understood that the initial hue and the terminal hue specified by the user jointly define the starting point and the ending point of the color transition within a layer, forming a gradient path that can be used for linear interpolation. On this basis, the comprehensive brightness of each pixel point needs to be subjected to Gaussian smoothing processing to adjust the steepness of the brightness change between adjacent pixels.
[0084] The reason for performing Gaussian smoothing processing is that although fractal algorithms can generate highly complex visual structures, in some local areas, the numerical sensitivity in the iteration process may cause unexpected mutations in the brightness distribution. Such mutations are manifested as a significant difference in brightness between individual pixel points and their neighborhood, forming isolated bright or dark points, which destroys the continuity and natural transition of the overall pattern. This phenomenon is particularly disadvantageous in sky rendering scenarios, as it is easily identified by the visual system as a noise or artifact, affecting the sense of immersion.
[0085] Optionally, the implementation manner of "adjusting the scale change between the comprehensive brightness of each pixel point by using a Gaussian smoothing processing method" in step S1041 can include steps b1-b2.
[0086] Step b1, based on the preset lightness difference value and the comprehensive lightness of each pixel point, at least one isolated island pixel point is selected from all pixel points.
[0087] The difference between the comprehensive lightness of the isolated island pixel point and the comprehensive lightness of each pixel point around it is greater than the preset lightness difference value; for example, the preset lightness difference value can be 100 or 50. That is, for each pixel point, the actual lightness comprehensive lightness can be compared with the actual lightness comprehensive lightness of each adjacent pixel point in its spatial neighborhood, and if the lightness difference between the pixel point and each pixel point around it is greater than the preset lightness difference value, it is determined to be an isolated island pixel point.
[0088] Step b2, for each isolated island pixel point, the comprehensive lightness of the isolated island pixel point and each pixel point around it are subjected to Gaussian smoothing processing.
[0089] The existence of isolated island pixel points represents outliers that lack gradual transition in a local range, which may interfere with the visual consistency of subsequent color mapping, therefore, the lightness values of the center point and the neighborhood point can be weighted and averaged by introducing a Gaussian kernel weight, so that the extreme value of the isolated island pixel point tends to the surrounding trend, and the lightness of the surrounding pixels is also adjusted accordingly to maintain local coordination.
[0090] The present application provides a way of Gaussian smoothing processing to apply weighted average operation to the lightness values of over-bright or over-dark pixels in the local area, suppress isolated mutation points generated by fractal iteration, and make the lightness transition more natural and coherent, thereby providing a more stable input basis for subsequent color mapping, and obtaining the latest comprehensive lightness of each pixel point.
[0091] S1042, for each layer, based on the latest comprehensive lightness of each pixel point, the initial hue and the terminal hue of the layer, the color data of each pixel point in the layer is determined by linear interpolation; In this embodiment, for the first layer, a gradient range can be constructed based on the initial hue and the terminal hue corresponding to the layer, and the latest comprehensive lightness of the pixel point associated with the layer is used as the interpolation weight, and the color data of each pixel point under the layer is determined by linear interpolation. Similarly, for the second layer, the color data of the layer is also calculated based on the initial hue and the terminal hue of the layer and the latest comprehensive lightness of each pixel point.
[0092] Since the two layers use different hue configurations, the color data generated by them can present obvious differences in hue tendency and saturation distribution, which helps to reflect the visual separation between the foreground and the background.
[0093] S1043, superimpose the color data of each pixel point in the first layer and the second layer to obtain the target color data of each pixel point.
[0094] In the embodiment, the color data obtained in the first layer and the second layer of each pixel point is superimposed, and the superimposition operation can make the color contributions from different layers jointly act on the final output to form an overall color performance of fusing foreground details and background atmosphere. By controlling the relative intensity and mixing mode of the color data of each layer, a three-dimensional space effect such as a warm cloud cluster floating in a cold star field in the distance can be simulated. The target color data can be in the form of an HSV color space.
[0095] It should be noted that the execution order of each step in the above method embodiment is not limited by the drawings and step numbers, and the execution order of each step is subject to actual application conditions.
[0096] The sky effect generated by the fractal iteration algorithm has a complex, organic, and high-detail structure, far exceeding the method based on simple noise, and can simulate realistic cloud layers, nebulae, or abstract cosmic space. Compared with the prior art, the embodiment has the following beneficial effects: (1) Strong real-time performance: the algorithm is executed in a pixel shader, and the calculation amount is controllable, which is suitable for application in a real-time rendering engine.
[0097] (2) Less resource occupation: no large texture map needs to be stored, and only a small amount of code and parameters are needed, which significantly reduces the storage space occupation.
[0098] (3) Parameterizable: the user can easily generate various sky effects, such as nebulae of different colors and dynamically flowing cloud clusters, by adjusting parameters such as the first preset period, the second preset period, the initial hue, the terminal hue, and the basic brightness of different layers.
[0099] In order to execute the corresponding steps in the above method embodiment and each possible implementation manner, an implementation manner of a sky effect rendering device is given below.
[0100] Please refer to Figure 4 , Figure 4 A structure schematic diagram of a sky effect rendering device provided by the embodiment is shown. The sky effect rendering device 200 includes an acquisition module 210, a time sequence offset module 220, a brightness calculation module 230, a color calculation module 240, and a rendering module 250.
[0101] The acquisition module 210 is configured to acquire a view vector of each pixel point in a sky region of a current camera field of view. The time sequence offset module 220 is configured to perform initial offset processing on each view vector based on a current time and a first preset period to obtain a fractal starting point corresponding to each pixel point. The luminance calculation module 230 is configured to determine, for each pixel point, a comprehensive luminance of the pixel point based on a fractal starting point corresponding to the pixel point, user-specified base luminance data, and a preset number of iterations, by using a multi-layer fractal iteration manner. The color calculation module 240 is configured to determine target color data of each pixel point based on user-specified hue data and the comprehensive luminance of each pixel point. The rendering module 250 is configured to render a sky effect of a current game frame based on the target color data of each pixel point.
[0102] Optionally, the timing offset module 220 can be specifically configured to: calculate a ratio of a current time to a first preset period, and input the ratio into a sine mapping function to obtain an initial offset; and add the three-axis components of each view vector to the initial offset and a fixed constant respectively to obtain the fractal starting point corresponding to each pixel point.
[0103] Optionally, the base luminance data includes base luminance of the first layer and the second layer. The luminance calculation module 230 can be specifically configured to: take the fractal starting point of the pixel point as an iteration starting point of the first layer, and offset the iteration starting point of the first layer based on a current time and a second preset period to obtain an iteration starting point of the second layer; for the iteration starting point of each layer, determine iteration luminance of the layer based on the preset number of iterations, by performing fractal iteration on the iteration starting point of the layer multiple times and combining the base luminance of the layer; and map the iteration luminance of each layer to a fixed luminance interval after superimposing the iteration luminance of each layer to obtain the comprehensive luminance of the pixel point.
[0104] Optionally, the luminance calculation module 230 can be specifically configured to: take the iteration starting point of the layer as a current point; calculate the square of the length of the current point to obtain an observation value of the current iteration; calculate an absolute value of a difference between the observation value of the current iteration and an observation value of a previous iteration to obtain an observation change of the current iteration; wherein the observation change of the first iteration is equal to the observation value of the first iteration; input the current point and the observation value of the current iteration into a transformation function to obtain a transformed point after the current iteration; if the number of iterations is not equal to the preset number of iterations, take the transformed point after the current iteration obtained in the current iteration as a new current point, and return to execute the step of calculating the square of the length of the current point to obtain the observation value of the current iteration; if the number of iterations is equal to the preset number of iterations, obtain the observation changes of multiple iterations; and input the observation changes of multiple iterations and the base luminance of the layer into an accumulation function to obtain the iteration luminance of the layer.
[0105] Optionally, the hue data comprises initial hue and terminal hue of each of the first layer and the second layer. The color calculation module 240 can be specifically configured to: adjust the scale change between the integrated brightness of each pixel point by using a Gaussian smoothing processing manner, to obtain the latest integrated brightness of each pixel point; determine the color data of each pixel point in each layer by using a linear interpolation manner based on the latest integrated brightness of each pixel point, the initial hue and the terminal hue of the layer; and superimpose the color data of each pixel point in the first layer and the second layer to obtain the target color data of each pixel point.
[0106] Optionally, the color calculation module 240 can be specifically configured to: select at least one island pixel point from all the pixel points based on a preset brightness difference value and the integrated brightness of each pixel point; the difference between the integrated brightness of the island pixel point and the integrated brightness of each pixel point around the island pixel point is greater than the preset brightness difference value; and perform Gaussian smoothing processing on the integrated brightness of each island pixel point and each pixel point around the island pixel point.
[0107] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the sky effect rendering device 200 described above can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0108] Please refer to Figure 5 , Figure 5 A structural schematic diagram of an electronic device is provided in the embodiments of the present application. The electronic device 300 comprises a processor 310, a memory 320 and a bus 330, the processor 310 is connected with the memory 320 through the bus 330.
[0109] The memory 320 can be used to store software programs, for example, the software programs corresponding to the sky effect rendering device 200 provided in the embodiments of the present application. The processor 310 performs various function applications and data processing by running the software programs stored in the memory 320, so as to realize the sky effect rendering method provided in the embodiments of the present application.
[0110] The memory 320 can be, but is not limited to, a RAM (Random Access Memory), a ROM (Read Only Memory), a FLASH, a PROM (Programmable Read-Only Memory), an EPROM (Erasable Programmable Read-Only Memory), an EEPROM (Electric Erasable Programmable Read-Only Memory), and the like.
[0111] The processor 310 can be an integrated circuit chip with signal processing capability. The processor 310 can be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), a SoC (System on Chip), and the like; and can also be a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0112] It can be understood that, Figure 5 The structure shown is only schematic, and the electronic device 300 can further include more or fewer components than those shown in the figures, or have a different configuration from that shown in the figures. Figure 5 The components shown in the figures can be realized in hardware, software, or a combination thereof. Figure 5 The components shown in the figures can be realized in hardware, software, or a combination thereof. Figure 5 The components shown in the figures can be realized in hardware, software, or a combination thereof.
[0113] The embodiment of the present application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program. The computer program is run by a processor to implement the sky effect rendering method disclosed in the above embodiment. The computer readable storage medium can be, but is not limited to, a U disk, a mobile hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a FLASH disk, or an optical disk, and various media that can store program codes.
[0114] To sum up, the embodiment of the present application provides a sky effect rendering method and device, electronic equipment and computer readable storage medium, first, the view vector of each pixel point in the sky area of the current camera field of view is obtained; based on the current time and the first preset period, each view vector is subjected to initial offset processing to obtain the fractal starting point corresponding to each pixel point; for each pixel point, based on the fractal starting point of the pixel point, the user-specified basic value data and the preset iteration number, the comprehensive value of the pixel point is determined by using the multi-layer fractal iteration mode; based on the user-specified hue data and the comprehensive value of each pixel point, the target color data of each pixel point is determined; based on the target color data of each pixel point, the sky effect of the current game frame is rendered. The fractal mathematical model is introduced in the pixel-level calculation, and the time dynamic offset mechanism and the multi-layer fractal iteration calculation are combined, so that the sky picture with dynamic visual effect and visual level can be generated without relying on the pre-stored texture map, thereby effectively solving the problems of large storage overhead, lack of dynamic change ability and insufficient detail expression in the prior art.
[0115] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A sky effect rendering method, characterized by, The method comprises: obtaining a view vector of each pixel point in a sky region of a current camera view field; based on the current time and the first preset period, performing initial offset processing on each view vector to obtain a fractal starting point corresponding to each pixel point; for each pixel point, based on the fractal starting point corresponding to the pixel point, the user-specified basic lightness data and the preset iteration number, the comprehensive lightness of the pixel point is determined by using a multi-layer fractal iteration method; based on the user-specified hue data and the comprehensive lightness of each pixel point, determining the target color data of each pixel point; based on the target color data of each pixel point, rendering the sky effect of the current game frame.
2. The sky effect rendering method of claim 1, wherein, The step of performing initial offset processing on each view vector based on the current time and the first preset period to obtain a fractal starting point corresponding to each pixel point comprises: calculating the ratio of the current time to the first preset period, and substituting the ratio into a sine mapping function to obtain an initial offset; adding the three-axis components of each view vector to the initial offset and a fixed constant respectively to obtain the fractal starting point corresponding to each pixel point.
3. The sky effect rendering method of claim 1, wherein, The basic lightness data includes the basic lightness of the first layer and the second layer respectively; The step of determining the comprehensive lightness of the pixel point by using a multi-layer fractal iteration method based on the fractal starting point corresponding to the pixel point, the user-specified basic lightness data and the preset iteration number comprises: taking the fractal starting point of the pixel point as the iteration starting point of the first layer, and performing offset processing on the iteration starting point of the first layer based on the current time and the second preset period to obtain the iteration starting point of the second layer; for the iteration starting point of each layer, based on the preset iteration number, the iteration starting point of the layer is subjected to multiple fractal iterations, and the iteration lightness of the layer is determined by combining the basic lightness of the layer; mapping the iteration lightness of each layer to a fixed lightness interval after superimposition to obtain the comprehensive lightness of the pixel point.
4. The sky effect rendering method of claim 3, wherein, The step of determining the iteration lightness of the layer by combining the basic lightness of the layer after multiple fractal iterations of the iteration starting point of the layer based on the preset iteration number comprises: taking the iteration starting point of the layer as a current point; calculating the square of the modulus of the current point to obtain the observation value of the current iteration; calculating the absolute value of the difference between the observation value of the current iteration and the observation value of the last iteration to obtain the observation change quantity of the current iteration; wherein the observation change quantity of the first iteration is equal to the observation value of the first iteration; inputting the current point and the observation value of the current iteration into a transformation function to obtain a transformed point after the current iteration; if the iteration number is not equal to the preset iteration number, the transformed point after the current iteration obtained in the current iteration is taken as a new current point, and the step of calculating the square of the modulus of the current point to obtain the observation value of the current iteration is executed again; if the iteration number is equal to the preset iteration number, the observation change quantity of multiple iterations is obtained; inputting the observation change quantity of multiple iterations and the basic lightness of the layer into a cumulative function to obtain the iteration lightness of the layer.
5. The sky effect rendering method of claim 4, wherein, The formula of the transformation function is: wherein denotes the coordinates of the transformation point , denotes the coordinates of the current point , denotes the absolute value denotes the dot product denotes the square of the length of the current point , denotes the coordinates of the random point ; The formula of the cumulative function is: wherein represents the iteration luminance, represents the preset iteration number, represents the first weighting coefficient, exponential decay or increment, represents the decay factor, represents the first observation change quantity of the iteration; represents the weight coefficient of the base luminance .
6. The sky effect rendering method of claim 3, wherein, The hue data includes the initial hue and the terminal hue of the first layer and the second layer respectively; The steps for determining the target color data for each pixel based on user-specified hue data and the overall brightness of each pixel include: Gaussian smoothing is used to adjust the scale variation between the overall brightness of each pixel to obtain the latest overall brightness of each pixel. For each layer, the color data of each pixel in that layer is determined by linear interpolation based on the latest comprehensive brightness of each pixel, the initial hue and the final hue of that layer. The color data of each pixel is superimposed on the color data of the first and second layers to obtain the target color data of each pixel.
7. The sky effect rendering method of claim 6, wherein, The steps for adjusting the scale variation of the overall brightness of each pixel using Gaussian smoothing include: Based on a preset brightness difference and the overall brightness of each pixel, at least one isolated pixel is selected from all pixels; the difference between the overall brightness of the isolated pixel and the overall brightness of its surrounding pixels is greater than the preset brightness difference. For each isolated pixel, Gaussian smoothing is applied to the overall brightness of the isolated pixel and each of its surrounding pixels.
8. A sky effect rendering apparatus characterized by comprising: include: The acquisition module is used to acquire the view vector of each pixel within the sky region of the current camera's field of view; The temporal offset module is used to perform initial offset processing on each view vector based on the current time and the first preset period to obtain the fractal starting point corresponding to each pixel. The brightness calculation module is used to determine the overall brightness of each pixel by using a multi-layer fractal iteration method based on the fractal starting point of the pixel, the basic brightness data specified by the user and the preset number of iterations. The color calculation module is used to determine the target color data for each pixel based on the hue data specified by the user and the comprehensive brightness of each pixel. The rendering module is used to render the sky effect of the current game frame based on the target color data of each pixel.
9. An electronic device, comprising: include: The electronic device includes a memory and a processor, wherein the memory stores a software program, and the processor executes the software program to implement the sky effect rendering method as described in any one of claims 1-7 when the electronic device is running.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the sky effect rendering method according to any one of claims 1-7.