Flame special effect rendering method and device, readable storage medium and electronic device
By acquiring and processing multiple target sequence frame textures and wind speed field maps of the flame effect, the problem of poor interactivity between the flame effect and the virtual scene was solved, achieving more realistic flame effect rendering and reducing memory consumption and texture storage space.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2023-10-27
- Publication Date
- 2026-06-09
Smart Images

Figure CN119896851B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer image processing, and more specifically, to a method and apparatus for rendering flame effects, a readable storage medium, and an electronic device. Background Technology
[0002] Currently, in games, to represent fire effects in a specific location, third-party digital graphics simulation software is used to simulate and render fire effects within a certain area of the virtual scene. The rendered result is then saved as a sequence of frame animations as a texture map. To display a particular frame, the corresponding texture map can be directly retrieved and displayed. By continuously switching frames, i.e., continuously switching the sampling area of the texture, the effect of playing texture animation is achieved. However, such fire effects are all pre-recorded fire animation frames, which cannot change with environmental changes in the game scene, resulting in poor interactivity between the fire effects and the virtual scene.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This disclosure provides at least some embodiments of a method and apparatus for rendering flame effects, a readable storage medium, and an electronic device, to at least solve the technical problem of poor interactivity between flame effects and virtual scenes.
[0005] According to one embodiment of this disclosure, a method for rendering flame effects is provided, comprising: acquiring multiple target sequence frame textures corresponding to the flame effect, and acquiring a wind speed field map, wherein the wind speed field map is used to characterize the wind speed at different locations in a virtual scene; offsetting the original texture coordinates of the target sequence frame textures based on the wind speed field map to obtain target texture coordinates of the target sequence frame textures; sampling the target sequence frame textures based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame textures; and rendering the flame model based on the multiple target sampling information to generate flame effects.
[0006] According to one embodiment of this disclosure, a rendering apparatus for flame effects is also provided, comprising: a loading module, configured to acquire multiple target sequence frame textures corresponding to the flame effect and acquire a wind speed field map, wherein the wind speed field map is used to characterize the wind speed at different locations in a virtual scene; an offset module, configured to offset the original texture coordinates of the target sequence frame textures based on the wind speed field map to obtain target texture coordinates of the target sequence frame textures; a sampling module, configured to sample the target sequence frame textures based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame textures; and a rendering module, configured to render the flame model based on the multiple target sampling information to generate flame effects.
[0007] According to one embodiment of the present disclosure, a computer-readable storage medium is also provided, which stores a computer program, wherein the computer program is configured to execute the rendering method of the flame effect in any of the preceding claims when running.
[0008] According to one embodiment of this disclosure, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the rendering method of the flame effects described in any of the preceding claims.
[0009] In at least some embodiments of this disclosure, multiple target sequence frame textures corresponding to the flame effect are obtained, and a wind speed field map is also obtained. The original texture coordinates of the target sequence frame textures are offset based on the wind speed field map to obtain the target texture coordinates of the target sequence frame textures. The target sequence frame textures are sampled based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame textures. The flame model is rendered based on the multiple target sampling information to generate the flame effect. It should be noted that the multiple target sequence frame textures corresponding to the flame effect are obtained, wherein the sequence frame textures consist of a large number of image frames, and compressing the sequence frame textures can reduce memory consumption. Furthermore, by offsetting the original texture coordinates of the target sequence frame texture based on the wind speed field map, the target texture coordinates of the target sequence frame texture are obtained. Then, the target sequence frame texture is sampled according to the target texture coordinates, which enables the target sequence frame texture of the flame to be integrated with the wind field in the virtual scene, reflecting the influence of the wind field on the flame. This achieves the goal of improving the interactivity between the flame effect and the wind field in the virtual scene, thus solving the technical problem of matching the flame effect with the virtual scene and enhancing the visual effect, thereby achieving the technical effect of improving the interactivity between the flame effect and the virtual scene. Attached Figure Description
[0010] The accompanying drawings, which are included to provide a further understanding of this disclosure and form part of this application, illustrate exemplary embodiments of this disclosure and are used to explain this disclosure, but do not constitute an undue limitation of this disclosure. In the drawings:
[0011] Figure 1 This is a hardware structure block diagram of a mobile terminal for rendering a flame effect according to an embodiment of the present disclosure.
[0012] Figure 2 This is a flowchart of a method for rendering flame effects according to one embodiment of the present disclosure;
[0013] Figure 3 This is a schematic diagram of obtaining the texture of a target sequence frame according to one optional embodiment of the present disclosure;
[0014] Figure 4This is a schematic diagram of a conventional interactive flame according to one optional embodiment of the present disclosure;
[0015] Figure 5 This is a schematic diagram of the size of a flame effect according to one alternative embodiment of the present disclosure;
[0016] Figure 6 This is a schematic diagram of a flame effect according to one optional embodiment of the present disclosure;
[0017] Figure 7 This is a schematic diagram illustrating the acquisition of target texture coordinates according to one optional embodiment of the present disclosure;
[0018] Figure 8 This is a schematic diagram illustrating the acquisition of target sampling information according to one optional embodiment of the present disclosure;
[0019] Figure 9 This is a flowchart of an optional method for rendering flame effects according to an embodiment of the present disclosure;
[0020] Figure 10 This is a schematic diagram of flame effects obtained according to one optional embodiment of the present disclosure;
[0021] Figure 11 This is a structural block diagram of an apparatus for generating a trailing effect result according to one optional embodiment of the present disclosure;
[0022] Figure 12 This is a schematic diagram of an electronic device according to an embodiment of the present disclosure. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present disclosure, the technical solutions of the present disclosure will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present disclosure, and not all embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present disclosure.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] In one possible implementation, addressing the technical problem of poor interactivity between flame effects and virtual scenes, a common issue in computer image processing, which the inventors, after practical experience and careful research, have persisted. Therefore, this disclosure proposes a flame effect rendering method. The method involves acquiring multiple target sequence frame textures corresponding to the flame effect and obtaining a wind speed field map. Based on the wind speed field map, the original texture coordinates of the target sequence frame textures are offset to obtain the target texture coordinates. The target sequence frame textures are then sampled based on these coordinates to obtain target sampling information. Finally, the flame model is rendered based on this target sampling information to generate the flame effect. It should be noted that the multiple target sequence frame textures corresponding to the flame effect are acquired, where each sequence frame texture consists of a large number of image frames. Compression of the sequence frame textures can reduce memory consumption. Furthermore, by offsetting the original texture coordinates of the target sequence frame texture based on the wind speed field map, the target texture coordinates of the target sequence frame texture are obtained. Then, the target sequence frame texture is sampled according to the target texture coordinates, which enables the target sequence frame texture of the flame to be integrated with the wind field in the virtual scene, reflecting the influence of the wind field on the flame. This achieves the goal of improving the interactivity between the flame effect and the wind field in the virtual scene, thus solving the technical problem of matching the flame effect with the virtual scene and enhancing the visual effect, thereby achieving the technical effect of improving the interactivity between the flame effect and the virtual scene.
[0026] The methods and embodiments described above in this disclosure can be executed on mobile terminals, computer terminals, or similar computing devices. Taking a mobile terminal as an example, the mobile terminal can be a smartphone, tablet computer, PDA, mobile internet device, PAD (Portable Android Device), game console, or other terminal device. Figure 1This is a hardware structure block diagram of a mobile terminal for a flame effect rendering method according to an embodiment of this disclosure. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. Processor 102 (processor 102 may include, but is not limited to, a central processing unit (CPU), graphics processing unit (GPU), digital signal processing (DSP) chip, microprocessor (MCU), programmable logic device (FPGA), neural network processor (NPU), tensor processor (TPU), artificial intelligence (AI) type processor, etc.) and memory 104 for storing data. In one embodiment of this disclosure, it may also include: input / output device 108 and display device 110.
[0027] Those skilled in the art will understand that Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0028] According to one embodiment of this disclosure, an embodiment of a method for rendering flame effects is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0029] Figure 2 This is a flowchart of a method for rendering flame effects according to one embodiment of the present disclosure, such as... Figure 2 As shown, the method includes the following steps:
[0030] Step S202: Obtain multiple target sequence frame textures corresponding to the flame effect, and obtain the wind speed field map, wherein the wind speed field map is used to represent the wind speed at different locations in the virtual scene.
[0031] The aforementioned flame effects can be special effects used in the animation production process to make the animation more attractive, expressive, and visually impactful, thereby enhancing the audience's visual experience and emotional resonance.
[0032] The aforementioned target sequence frame texture can be a texture composed of a series of consecutive animation frame images, which can be arranged in a fixed order to form a continuous animation effect. It can be, but is not limited to, a dual-channel sequence frame texture, wherein the dual channels can be two channels composed of luminance (Value, abbreviated as V) and transparency (A) information.
[0033] The wind speed field map described above can be used to visualize a speed field, where the speed field refers to the distribution of velocity vectors at each point in space or on a plane. By representing the speed field in graphical form, its characteristics and changes can be observed and analyzed more intuitively.
[0034] The original sequence frame texture mentioned above can be a sequence frame texture that has not undergone clustering compression, and can be, but is not limited to, a four-channel sequence frame texture, wherein the four channels can be red-green-blue plus transparency (Red-Green-Blue-Alpha, abbreviated as RGBA).
[0035] The aforementioned virtual scene can be a simulated environment created using computer technology and virtual reality technology.
[0036] In one optional embodiment, a clustering algorithm is used to compress the original colors in the flame effect. Specifically, the four channels containing red (R), green (G), blue (B), and alpha (A) information in the original sequence frame texture are compressed into only two channels containing luminance (V) and alpha (A) information. Then, computer graphics image processing (Mipmap) is performed on the original sequence frame texture to generate an M*N image, obtaining the target sequence frame texture. Simultaneously, based on the changes in the velocity field caused by actions such as game character movement or skill activation in the virtual scene, and considering factors such as fluid velocity, direction, and intensity, factors that can cause changes in the velocity field are added to the velocity field. The velocity divergence and pressure are calculated to obtain a new velocity field, which is then output to the texture map to generate a wind speed field texture.
[0037] In another optional embodiment, the original sequence frame texture can be three-channel or four-channel. The three-channel texture can be the three primary colors (Red-Green-Blue, or RGB), which generally have similar color variations and relatively simple color types. A clustering algorithm is used to compress the pixels representing colors in the original sequence frame texture until the sum of the distances from each compressed pixel to the center point is minimized. These compressed pixels are then sorted to obtain a color lookup table. Based on this table, the position of each pixel in the original sequence frame texture is determined, thus mapping the original color to the lookup table and obtaining dual channels of floating-point value (V) and transparency (A) information, thereby acquiring the target sequence frame texture. Simultaneously, the movement of the current game character and the wind field information generated by skill activation are determined based on the virtual scene and output to the texture map to determine the wind speed field texture. Figure 3 This is a schematic diagram illustrating the acquisition of a target sequence frame texture according to one optional embodiment of the present disclosure, such as... Figure 3As shown, a clustering algorithm is used to cluster the colors of each pixel in the original sequence frame texture, compressing the four channels into two channels, and sorting the color codes to obtain a color lookup table. Then, channel segmentation is performed to store the floating-point value (V) and transparency (A) of each frame in the four channels respectively, and the storage is compressed, thus allowing the storage of twice the number of frames.
[0038] In another alternative embodiment, the RGB three colors are represented as a set of multiple clusters of points in three-dimensional space, and the centers of these clusters are calculated such that the sum of the distances of these RGB points from the center point is small. The coordinates of these center points are the primary colors of the sequence frame. Then, the primary colors are sorted according to their RGB Luminance values, thus obtaining a one-dimensional color lookup table (ColorLUT). This further determines which two primary colors the color of a pixel in the original sequence frame texture is located between, minimizing the error of interpolation fitting between the two primary colors. This records the position of the pixel in the original sequence frame texture in the color lookup table, and then the RGB three colors can be mapped to a floating-point value V. Combined with the transparency (A) in the original sequence frame texture, the compressed target sequence frame texture is obtained. Furthermore, to integrate the wind field information in the virtual scene with the flame effects, the NS fluid simulation module with an Euler perspective was first used. To calculate the 2D velocity map, the Navier-Stokes (NS) equations were decomposed into four stages: AddForce, Advance, Divergence, Pressure, and SubtractGradient. In the AddForce stage, the velocity generated by interactive components was determined based on the movement of the character in the game and the use of various skills, and added as an external force to the velocity field, changing the velocity in the corresponding area. In the Advance stage, the global velocity advection was calculated. The Divergence stage was used to obtain the velocity divergence for use in subsequent stages. The Pressure stage combined the velocity divergence and used the Jacobi iteration method to calculate the pressure in the field. Finally, combining the velocity and pressure, the updated velocity field was calculated in the SubtractGradient stage and output to a texture map, thus obtaining the wind velocity field texture after interaction with the scene.
[0039] It's worth noting that in the game's graphics pipeline, textures are typically generated using MipMap. For an M x N image, it's continuously generated in a binary fashion, creating sizes like 0.5M*0.5N, 0.25M*0.25N, until it can't be reduced any further. Different texture sizes are used for loading at different distances in the game. To fully utilize the four channels of the texture and reduce space loss during MipMap generation in the graphics pipeline, the compressed sequence of frame animations (VA) can be stored separately. The V and A of each frame are stored in the RGBA four channels respectively. This way, the RGBA storage space that originally used the size of one frame can store twice the number of frames.
[0040] Step S204: Offset the original texture coordinates of the target sequence frame texture based on the wind speed field map to obtain the target texture coordinates of the target sequence frame texture.
[0041] The aforementioned original texture coordinates can be a set of two-dimensional coordinates used in texture mapping to determine the position of a specific point on the texture. The texture coordinates can be sampled to map the target sequence frame texture to a relative position, thereby achieving a more realistic rendering effect.
[0042] The target texture coordinates mentioned above can be texture coordinates used to achieve the final flame effect, or they can be...
[0043] In one optional embodiment, during playback of the target sequence frame texture, the wind speed field map is sampled in world coordinates to obtain the velocity of the current playback area of the target sequence frame texture in world coordinates. This velocity in world coordinates is then mapped onto the local coordinate system of the target sequence frame texture to obtain the velocity in the local coordinate system. Furthermore, the original texture coordinates of the target sequence frame texture and the velocity vector of each pixel are obtained. Each velocity vector is multiplied by a time step to determine the offset of the texture coordinates. This offset is then added to the original texture coordinates to obtain the target texture coordinates. This enhances the realism of the target sequence frame texture, making its motion changes more natural and coherent.
[0044] Step S206: Sample the target sequence frame texture based on the target texture coordinates to obtain the target sampling information corresponding to the target sequence frame texture.
[0045] The aforementioned target sampling information can be texture information sampled from the texture of the target sequence frame.
[0046] In one optional embodiment, the position of the target sequence frame texture to be sampled is determined based on the target texture coordinates, and then a suitable texture sampling method is selected at the sampling position to sample the color and transparency in the target sequence frame texture according to the requirements, thereby obtaining the target sampling information.
[0047] Step S208: Render the flame model based on multiple target sampling information to generate flame effects.
[0048] The aforementioned flame model can be a model that is pre-set according to specific circumstances to render flame effects from the original sampled information.
[0049] In one alternative embodiment, linear interpolation is performed on two adjacent original sample data from multiple original sample data sets to make the motion changes more natural and coherent. This is then used to render the flame model, resulting in smoother flame effects.
[0050] In this embodiment of the invention, multiple target sequence frame textures corresponding to the flame effect are obtained, and a wind speed field map is also obtained. The original texture coordinates of the target sequence frame textures are offset based on the wind speed field map to obtain the target texture coordinates of the target sequence frame textures. The target sequence frame textures are sampled based on the target texture coordinates to obtain the target sampling information corresponding to the target sequence frame textures. The flame model is rendered based on the multiple target sampling information to generate the flame effect. It should be noted that the multiple target sequence frame textures corresponding to the flame effect are obtained, where each sequence frame texture consists of a large number of image frames. Compressing the sequence frame textures can reduce memory consumption. Furthermore, offsetting the original texture coordinates of the target sequence frame textures based on the wind speed field map to obtain the target texture coordinates, and then sampling the target sequence frame textures based on these target texture coordinates, enables the target sequence frame textures of the flame to be integrated with the wind field in the virtual scene, reflecting the influence of the wind field on the flame. This achieves the goal of improving the interactivity between the flame effect and the wind field in the virtual scene, thus solving the technical problem of matching the flame effect with the virtual scene and enhancing the visual effect, thereby achieving the technical effect of improving the interactivity between the flame effect and the virtual scene.
[0051] It should be noted that, Figure 4 This is a schematic diagram of a conventional interactive flame according to one optional embodiment of the present disclosure, such as... Figure 4 As shown, in traditional fire effects production, the use of color channels in sequence frame textures is very limited, which is not fully utilized and wastes a certain amount of texture storage space. Particle-interactive fire also results in a large number of triangles being drawn in the particle system, leading to high system performance overhead. Figure 5 This is a schematic diagram showing the size of a flame effect according to one optional embodiment of this disclosure. Figure 6 This is a schematic diagram of a flame effect according to one optional embodiment of the present disclosure, such as... Figure 5 , 6As shown, the image size of the flame was reduced from 26,836KB to 7,374KB, then to 6,465KB, until it could no longer be reduced to 9KB. The sequence frame texture in this solution can fully utilize the four RGBA color channels, reducing the storage consumption of the sequence frame texture space. At the same time, for interactive flames, only a single square patch needs to be drawn, reducing the performance consumption of rendering.
[0052] Optionally, offsetting the original texture coordinates of the target sequence frame texture based on the wind speed field map to obtain the target texture coordinates of the target sequence frame texture includes: determining the world coordinates corresponding to the target sequence frame texture, wherein the world coordinates are used to represent the coordinates in the world coordinate system corresponding to the virtual scene; sampling the wind speed field map based on the world coordinates to obtain the target sampling velocity corresponding to the target sequence frame texture; and offsetting the original texture coordinates based on the target sampling velocity to obtain the target texture coordinates.
[0053] The world coordinates mentioned above can also refer to the world coordinates of pixels in the texture of the target sequence frame during playback. They can be a coordinate system representing an object or position in three-dimensional space, used in computer graphics and computer animation to determine the position and orientation of an object within a scene. This can be, but is not limited to, a Cartesian coordinate system. In the world coordinate system, the origin is usually the center of the scene, while the direction of the axes depends on the specific application. The world coordinate system can be used to describe the absolute position of an object, independent of the observer's perspective.
[0054] The target sampling rate mentioned above can be the sampling rate in the corresponding virtual scene, used to interact with the speed in the virtual scene and the flame effect to make the flame effect more realistic.
[0055] In one optional embodiment, during the playback of the sequence frames, the world coordinates of each pixel in the target sequence frame texture are determined, and the pixel width and height of the wind speed field map are simultaneously acquired. A sampling range is then determined, and the wind speed field map is sampled according to the sampling range and world coordinates to obtain the target sampling velocity corresponding to the target sequence frame texture. The target sequence frame texture, after offsetting the original texture coordinates based on the wind speed field map, can enhance animation effects and realism by simulating the motion effects of objects, the feel of fluidity, and natural changes.
[0056] In another alternative embodiment, during sequence frame playback, the world coordinates of each pixel in the target sequence frame texture are determined and converted into texture coordinates. This can be achieved by mapping the world coordinates to values between 0 and 1 within the texture range. Simultaneously, the pixel width and height of the wind speed field texture are acquired to determine the sampling range. Then, based on the converted texture coordinates, sampling is performed at the corresponding positions in the wind speed field texture using methods such as bilinear interpolation. Further, based on the sampled values, the velocity vector corresponding to the world coordinates is calculated as the target sampling velocity. Since the offset is the product of the target sampling velocity and time, where the offset is the offset value applied to the original texture coordinates, the sampling velocity is a constant representing the offset per second, and the time is the time from the start of sampling to the present. After obtaining the offset, adding the offset to the original texture coordinates yields the target texture coordinates. Figure 7 This is a schematic diagram illustrating the acquisition of target texture coordinates according to one optional embodiment of the present disclosure, such as... Figure 7 As shown, after obtaining the wind speed field map through fluid simulation, the target sampling velocity corresponding to the target sequence frame texture in world coordinates is obtained and projected onto the local coordinate system to obtain the transformed sampling velocity, thereby offsetting the original texture coordinates to obtain the target texture coordinates.
[0057] Optionally, sampling the wind speed field map based on world coordinates to obtain the target sampling velocity corresponding to the target sequence frame texture includes: sampling the wind speed field map based on world coordinates to obtain the initial sampling velocity; converting the initial sampling velocity from the world coordinate system to the local coordinate system corresponding to the flame model to obtain the transformed sampling velocity; and projecting the transformed sampling velocity onto the flame model to obtain the target sampling velocity.
[0058] The initial sampling speed mentioned above can be the speed sampled from the wind speed field map, or it can be the speed in the world coordinates of the current sequence frame playback area during sequence frame playback.
[0059] The aforementioned local coordinate system can be a coordinate system established on the sequence frame patch.
[0060] The aforementioned conversion sampling rate can be the velocity in the local coordinate system corresponding to the initial sampling rate.
[0061] In one optional embodiment, velocity sampling is performed on the wind speed field map according to world coordinates to obtain the initial sampled velocity. A known point in the world coordinate system is selected, which can be a specific point on the model or a fixed point in the scene, and is marked as a reference point. The local coordinate system corresponding to the flame model is determined, and the coordinates of the reference point in the local coordinate system of the flame model are calculated according to the transformation relationship between the local coordinate system of the flame model and the world coordinate system. Thus, for each sampled velocity vector, the coordinates of the reference point in the local coordinate system of the flame model are subtracted to convert the initial sampled velocity from the world coordinate system to the local coordinate system corresponding to the flame model, obtaining the converted sampled velocity. Furthermore, the converted sampled velocity is projected onto the flame model to obtain the target sampled velocity within the flame model, thereby making the flame effects more integrated with the flame model and the flame effects more realistic.
[0062] Optionally, the method further includes: obtaining a preset wind speed generated in the virtual scene; adding the preset wind speed to the initial velocity field to obtain a target velocity field; and generating a wind speed field texture based on the target velocity field.
[0063] The aforementioned preset wind speed can be the speed of the wind field in the virtual scene that is set in advance according to needs, or it can be the speed generated by the player's movement or the activation of skills in the game.
[0064] The aforementioned initial velocity field can be a velocity field in a virtual scene that does not change based on the speed generated by the movement of the game character or the activation of skills.
[0065] The aforementioned target velocity field can be the velocity field after the speed of the corresponding area changes due to the movement of the game character or the activation of skills.
[0066] In one optional embodiment, a preset wind speed generated in the virtual scene is obtained, and this preset wind speed is superimposed on an initial velocity field. The velocity field of the corresponding area within the initial velocity field is then changed to obtain a target velocity field. A wind speed field texture is then generated according to the target velocity field. When generating the wind speed field texture, appropriate visualization methods and parameters are selected based on the characteristics and requirements of the data. This allows the speed generated by game character movement or skill activation to be added to the velocity field, thereby influencing the swaying of flame effects with the preset wind speed, enhancing the realism of the flame effects.
[0067] Optionally, the target sequence frame texture includes: a color texture and a transparency texture, wherein the color texture is used to represent the compressed color obtained after clustering and compressing the original color of the original sequence frame texture, and the transparency texture is used to represent the original transparency of the original sequence frame texture. The target sequence frame texture is sampled based on the target texture coordinates to obtain the target sampling information corresponding to the target sequence frame texture, including: sampling the color texture based on the target texture coordinates to obtain the sampled color; sampling the transparency texture based on the target texture coordinates to obtain the sampled transparency; and obtaining the target sampling information based on the sampled color and the sampled transparency.
[0068] The aforementioned color texture can be the primary color of the center point coordinates after clustering and compressing the original color of each pixel in the original sequence frame texture. The original color can be the pixel color without any processing or modification; it is color information directly obtained from the original sequence frame texture and reflects the colors in the current scene. It can typically be represented as the three primary colors of red, green, and blue, or the three primary colors of printing (Cyan-Magenta-Yellow-key / blacK, abbreviated as CMYK). Compressed color can be the color displayed after compressing the colors of each point in three-dimensional space into a multi-cluster point set.
[0069] The aforementioned transparency texture can be the original transparency of each pixel in the original sequence frame texture, where the original transparency can be the transparency of each pixel in the original sequence frame texture.
[0070] The sampled color mentioned above can be the sampling result of sampling the color of pixels in the color texture.
[0071] The aforementioned sampled transparency can be the result of sampling the transparency of pixels in the transparency texture.
[0072] The target sampling information mentioned above can be sampling information obtained by sampling the color and transparency of the target sequence frame.
[0073] In one optional embodiment, the color texture encoding format is determined. Common compressed color encoding formats include DXT and ETC, each with different decoding and sampling methods. According to the target texture coordinates and the requirements of the color encoding format, the target texture coordinates are converted into the index of the corresponding compressed color block. Then, based on the index of the compressed color block and the target texture coordinates, the corresponding color value is found in the decoded compressed color block and sampled to obtain the sampled color. Simultaneously, the RGBA color value is obtained based on the target texture coordinates, and the corresponding alpha channel value is extracted to obtain the sampled transparency. The sampled color and sampled transparency are then defined as the target sampling information. This facilitates subsequent rendering of the flame effect.
[0074] Figure 8 This is a schematic diagram illustrating the acquisition of target sampling information according to one optional embodiment of this disclosure, such as... Figure 8 As shown, in the game, when playing the fire effect, after loading the compressed target sequence frame texture and ColorLUT, the current target sequence frame, i.e. the frame range of the current sequence frame, is first calculated. Then, in conjunction with the interaction module, the target sequence frame is offset to obtain the offset target sequence frame. Then, the target sequence frame is sampled to obtain V and A values. Then, based on the V value, the ColorLUT is sampled to restore the RGB values of the color. The RGBA values are merged to obtain the single-frame sequence frame image information, thus obtaining the target sampling information.
[0075] Optionally, the method further includes: clustering and compressing the colors of the original sequence frame texture to obtain the target sequence frame texture; rendering the flame model based on multiple target sampling information to generate flame effects, including: decompressing the target sampling information to obtain the original sampling information corresponding to the target sequence frame texture; and rendering the flame model based on multiple original sampling information to generate flame effects.
[0076] The aforementioned raw sampling information can be the sampling information of the original sequence frame texture corresponding to the target sampling information.
[0077] In one optional embodiment, to fully utilize the RGBA four channels and reduce space loss during image processing of the original sequence frame texture, the colors of the original sequence frame texture need to be clustered and compressed. The V and A values in the compressed target sequence frame texture are stored separately, with the V and A values of each frame stored in the RGBA four channels respectively. This allows the RGBA storage space, which originally used the size of one frame, to store twice the number of frames. When rendering the flame model using multiple target sampling information, only the target sampling information needs to be decompressed to obtain the original sampling information corresponding to the target sequence frame texture. Specifically, after sampling the color and transparency of the target sequence frame texture, the floating-point value V is restored to the color RGB according to the color lookup table, and then merged with the transparency A to obtain RGBA. If the RGBA matches the color of the original sequence frame texture, the current RGBA is determined to be the original sampling information; if the RGBA does not match the color of the original sequence frame texture, the colors adjacent to the current RGBA are linearly interpolated according to the color lookup table to reduce color error and are determined to be the original sampling information, thus smoothing the transition effect. Therefore, the flame model is rendered based on multiple original sampling information to obtain flame effects. While reducing space consumption, it improves the rendering efficiency of fire effects.
[0078] Optionally, the target sampling information is decompressed to obtain the original sampling information corresponding to the target sequence frame texture, including: decompressing the sampled colors contained in the target sampling information to obtain the target original color; and merging the target original color and the sampled transparency contained in the target sampling information to obtain the original sampling information.
[0079] The target original color mentioned above can be the original color of the original sequence frame texture corresponding to the sampled color.
[0080] In one optional embodiment, the floating-point value V and transparency A in the sampled color are decompressed to RGB to obtain the target original color. Then, the transparency A is merged with the target original color to obtain the image information of the single-frame target sequence frame texture of RGBA, which more intuitively represents the transparency of the color and does not require an additional transparency channel, making the image more realistic.
[0081] Optionally, the sampled colors contained in the target sampling information are decompressed to obtain the target original color, including: determining the target cluster color corresponding to the sampled color from a preset mapping relationship, wherein the preset mapping relationship is used to characterize the mapping relationship between different cluster colors and different compressed colors of the original sequence frame texture, and different cluster colors are colors obtained by clustering different original colors in the original sequence frame texture; in response to the number of target cluster colors being one, determining the target cluster color as the target original color; in response to the number of target cluster colors being multiple, interpolating and fitting multiple target cluster colors to obtain the target original color.
[0082] The aforementioned preset mapping relationship can be a mapping relationship between different clustered colors and different compressed colors in the original sequence frame texture, which is set in advance according to specific circumstances, or it can be a color lookup table (ColorLUT).
[0083] The target clustering color mentioned above can be the clustering color corresponding to the sampled color in the color correspondence table, or it can be the main color of the multi-cluster point set.
[0084] The target original color mentioned above can be the original color of the corresponding pixel in the original sequence frame texture, or it can be the color before compression.
[0085] In one optional embodiment, the target cluster color corresponding to the sampled color is determined according to a preset mapping relationship. If there is only one target cluster color, it is determined as the target original color. If there are multiple target cluster colors, two adjacent target cluster colors are found, where Euclidean distance or other distance metrics can be used to determine adjacent colors. Interpolation is then performed according to the ratio between the two target cluster colors until multiple target cluster colors have been interpolated and fitted. The interpolated color is then compared with the original color, and the closest original color is selected as the target original color, thereby reducing color error.
[0086] Optionally, the colors of the original sequence frame texture are clustered and compressed to obtain the target sequence frame texture: the original colors of the original sequence frame texture are clustered to obtain multiple cluster colors; compressed colors corresponding to the multiple cluster colors are obtained based on the brightness of the multiple cluster colors; a preset mapping relationship is generated based on the compressed colors corresponding to the multiple cluster colors; compressed colors corresponding to other colors are obtained based on the color error between other colors in the original colors and two adjacent cluster colors in the preset mapping relationship, wherein the other colors are used to represent colors other than cluster colors in the original colors; a color texture is generated based on the compressed colors corresponding to the cluster colors and the compressed colors corresponding to other colors; a transparency texture is generated based on the original transparency of the original sequence frame texture; the color texture and the transparency texture are summarized to obtain the target sequence frame texture.
[0087] In one optional embodiment, the color features of the original sequence frame texture are acquired and normalized to better compare different features in subsequent clustering analysis. The normalized color features are then input into a clustering algorithm for analysis. The clustering algorithm clusters colors based on feature similarity, forming different color clusters and obtaining multiple cluster colors. Each pixel in the image is assigned to the nearest cluster center. For each cluster center, its corresponding brightness is calculated, and the cluster centers with the highest brightness are selected as compressed colors based on the required number of colors to be compressed. The cluster colors are paired with the compressed colors to generate a preset mapping relationship. The color error between other colors in the original color and adjacent cluster colors in the preset mapping relationship is compared to determine the compressed color. The color with the smallest color error can be selected as the compressed color, or a weighted average can be used to calculate an intermediate color as the compressed color, thus obtaining the compressed colors corresponding to other colors. A color texture is generated based on the compressed colors corresponding to the cluster colors and the compressed colors corresponding to other colors. A transparency texture is also generated based on the original transparency of the original sequence frame texture.
[0088] Optionally, based on the color error between other colors in the original color and two adjacent cluster colors in the preset mapping relationship, the compressed color corresponding to other colors is obtained, including: interpolating and fitting two adjacent cluster colors to obtain a fitted color; determining two adjacent target cluster colors based on the color error between the fitted color and other colors, wherein the color error between the fitted color corresponding to two adjacent target cluster colors and other colors is smaller than the color error between the fitted color corresponding to two other adjacent cluster colors and other colors; and determining the compressed color corresponding to two adjacent target cluster colors as the compressed color corresponding to other colors.
[0089] The fitted color mentioned above can be the color after fitting the compressed color, or it can be the fused color of two clustered colors.
[0090] The aforementioned color error can be the difference between the fitted color and other colors in image processing.
[0091] In one optional embodiment, interpolation fitting is performed on two adjacent cluster colors to obtain fitted colors, making the color transition natural. The fitted colors are compared with other colors, the color error between the fitted colors and other colors is calculated, and two adjacent target cluster colors are determined. Then, the compressed colors corresponding to the two adjacent target cluster colors are determined to be the compressed colors corresponding to other colors, thereby reducing the color error.
[0092] Optionally, the flame model is rendered based on multiple target sampling information to generate flame effects, including: performing linear interpolation on two adjacent target sampling information in the multiple target sampling information to obtain transition information; and rendering the flame model based on the multiple target sampling information and the transition information to generate flame effects.
[0093] The aforementioned transition information can be the result of linear interpolation of two adjacent original sampled information.
[0094] In one optional embodiment, before outputting the flame effect, two adjacent original sample information from multiple original sample information are linearly interpolated to make the animation transition smooth and coherent. This allows the multiple original sample information and transition information to render the flame model and generate the flame effect, making the flame effect more natural, realistic, and coherent.
[0095] Figure 9 This is a flowchart of an optional flame effect rendering method according to an embodiment of the present disclosure, such as... Figure 9 As shown, the steps of this method are as follows:
[0096] Step S901: Compress the flame effect to obtain the target sequence frame texture and wind speed field map.
[0097] Step S902: Convert the world coordinates in the target sequence frame texture into a local coordinate system.
[0098] Step S903: Sample the wind speed field map according to the local coordinate system to obtain the target sampling velocity.
[0099] Step S904: Offset the original texture coordinates according to the target sampling rate to obtain the target texture coordinates.
[0100] Step S905: Sample the texture of the target sequence frame to obtain the sampled color and sampled transparency.
[0101] Step S906: Decompress the sampled color and sampled transparency to obtain the original sampled information.
[0102] Step S907: Interpolate and fit the texture of the target sequence frame based on the original sampling information to generate flame effects.
[0103] Step S908: Output flame effects.
[0104] It should be noted that, Figure 10 This is a schematic diagram of flame effects obtained according to one optional embodiment of the present disclosure, such as... Figure 10 As shown, the target sequence frame texture is acquired during the asset processing stage. During the game stage, when the game character moves or uses skills in the virtual scene and affects the wind field, the target sequence frame is sampled, and interpolation fitting is performed on adjacent target sequence frame textures among multiple targets to generate fire effects, which are then output.
[0105] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they 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 this disclosure, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this disclosure.
[0106] This embodiment also provides a flame effect rendering device, which is used to implement the above embodiments and preferred embodiments, and will not be repeated as already described. As used below, the terms "unit" and "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0107] Figure 11 This is a structural block diagram of a flame effect rendering apparatus according to one embodiment of the present disclosure, such as... Figure 11 As shown, the device includes: a loading module 111, used to acquire multiple target sequence frame textures corresponding to the flame effect and acquire a wind speed field map, wherein the wind speed field map is used to represent the wind speed at different locations in the virtual scene; an offset module 112, used to offset the original texture coordinates of the target sequence frame textures based on the wind speed field map to obtain the target texture coordinates of the target sequence frame textures; a sampling module 113, used to sample the target sequence frame textures based on the target texture coordinates to obtain the target sampling information corresponding to the target sequence frame textures; and a rendering module 114, used to render the flame model based on the multiple target sampling information to generate the flame effect.
[0108] Optionally, the offset module includes: a first determining unit, used to determine the world coordinates corresponding to the target sequence frame texture, wherein the world coordinates are used to represent the coordinates in the world coordinate system corresponding to the virtual scene; a first sampling unit, used to sample the wind speed field map based on the world coordinates to obtain the target sampling velocity corresponding to the target sequence frame texture; and an offset unit, used to offset the original texture coordinates based on the target sampling velocity to obtain the target texture coordinates.
[0109] Optionally, the first sampling unit includes: a first sampling subunit, used to sample the wind speed field map based on world coordinates to obtain an initial sampling velocity; a coordinate transformation subunit, used to transform the initial sampling velocity from the world coordinate system to the local coordinate system corresponding to the flame model to obtain a transformed sampling velocity; and a velocity projection subunit, used to project the transformed sampling velocity onto the flame model to obtain a target sampling velocity.
[0110] Optionally, the first sampling unit further includes: a first acquisition subunit, used to acquire a preset wind speed generated in the virtual scene; a speed addition subunit, used to add the preset wind speed to the initial speed field to obtain a target speed field; and a first generation subunit, used to generate a wind speed field texture based on the target speed field.
[0111] Optionally, the sampling module includes: a second sampling unit for sampling the color texture based on the target texture coordinates to obtain the sampled color; a third sampling unit for sampling the transparency texture based on the target texture coordinates to obtain the sampled transparency; and a first acquisition unit for obtaining target sampling information based on the sampled color and the sampled transparency.
[0112] Optionally, the device includes: a clustering compression module for clustering and compressing the colors of the original sequence frame texture to obtain the target sequence frame texture; and a flame rendering module for rendering a flame model based on multiple target sampling information to generate flame effects. The flame rendering module includes: a first decompression unit for decompressing the target sampling information to obtain the original sampling information corresponding to the target sequence frame texture; and a first rendering unit for rendering the flame model based on multiple original sampling information to generate flame effects.
[0113] Optionally, the decompression module includes: a second decompression unit for decompressing the sampled colors contained in the target sampling information to obtain the original target color; and a merging unit for merging the original target color and the sampled transparency contained in the target sampling information to obtain the original sampling information.
[0114] Optionally, the second decompression unit includes: a first determining subunit, configured to determine the target cluster color corresponding to the sampled color from a preset mapping relationship, wherein the preset mapping relationship is used to characterize the mapping relationship between different cluster colors of the original sequence frame texture and different compressed colors, and the different cluster colors are colors obtained by clustering different original colors in the original sequence frame texture; a second determining subunit, configured to determine the target cluster color as the target original color in response to the number of target cluster colors being one; and a first interpolation fitting subunit, configured to perform interpolation fitting on the multiple target cluster colors in response to the number of target cluster colors being multiple, to obtain the target original color.
[0115] Optionally, the sampling module further includes: a clustering unit for clustering the original colors of the original sequence frame texture to obtain multiple cluster colors; a second acquisition unit for obtaining compressed colors corresponding to the multiple cluster colors based on the brightness of the multiple cluster colors; a first generation unit for generating a preset mapping relationship based on the compressed colors corresponding to the multiple cluster colors; a third acquisition unit for obtaining compressed colors corresponding to other colors based on the color error between other colors in the original colors and two adjacent cluster colors in the preset mapping relationship, wherein the other colors are used to represent colors other than cluster colors in the original colors; a second generation unit for generating a color texture based on the compressed colors corresponding to the cluster colors and the compressed colors corresponding to other colors; a third generation unit for generating a transparency texture based on the original transparency of the original sequence frame texture; and a summarization unit for summarizing the color texture and the transparency texture to obtain the target sequence frame texture.
[0116] Optionally, the third acquisition unit includes: a second interpolation fitting subunit, used to perform interpolation fitting on two adjacent cluster colors to obtain a fitted color; a third determination subunit, used to determine two adjacent target cluster colors based on the color error between the fitted color and other colors, wherein the color error between the fitted color corresponding to two adjacent target cluster colors and other colors is less than the color error between the fitted color corresponding to other two adjacent cluster colors and other colors; and a fourth determination subunit, used to determine the compressed color corresponding to two adjacent target cluster colors as the compressed color corresponding to other colors.
[0117] Optionally, the rendering module includes: a linear interpolation unit for linearly interpolating two adjacent target sampling information from multiple target sampling information to obtain transition information; and a second rendering unit for rendering the flame model based on the multiple target sampling information and the transition information to generate flame effects.
[0118] It should be noted that the above-mentioned units and modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but not limited to these: all the above-mentioned units and modules are located in the same processor; or, the above-mentioned units and modules are located in different processors in any combination.
[0119] Embodiments of this disclosure also provide a computer-readable storage medium storing a computer program configured to perform the steps in any of the above method embodiments when executed.
[0120] Optionally, in this embodiment, the computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0121] Optionally, in this embodiment, the computer-readable storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0122] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0123] Step S1: Obtain multiple target sequence frame textures corresponding to the flame effect, and obtain the wind speed field map, wherein the wind speed field map is used to represent the wind speed at different locations in the virtual scene;
[0124] Step S2: Offset the original texture coordinates of the target sequence frame texture based on the wind speed field map to obtain the target texture coordinates of the target sequence frame texture;
[0125] Step S3: Sample the target sequence frame texture based on the target texture coordinates to obtain the target sampling information corresponding to the target sequence frame texture;
[0126] Step S4: Render the flame model based on multiple target sampling information to generate flame effects.
[0127] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: determining the world coordinates corresponding to the target sequence frame texture, wherein the world coordinates are used to characterize the coordinates in the world coordinate system corresponding to the virtual scene; sampling the wind speed field map based on the world coordinates to obtain the target sampling velocity corresponding to the target sequence frame texture; and offsetting the original texture coordinates based on the target sampling velocity to obtain the target texture coordinates.
[0128] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: sampling the wind speed field map based on world coordinates to obtain an initial sampling velocity; converting the initial sampling velocity from the world coordinate system to the local coordinate system corresponding to the flame model to obtain a transformed sampling velocity; and projecting the transformed sampling velocity onto the flame model to obtain a target sampling velocity.
[0129] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: obtaining a preset wind speed generated in a virtual scene; adding the preset wind speed to an initial velocity field to obtain a target velocity field; and generating a wind speed field texture based on the target velocity field.
[0130] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: color texture and transparency texture, sampling a target sequence frame texture based on target texture coordinates to obtain target sampling information corresponding to the target sequence frame texture, including: sampling a color texture based on target texture coordinates to obtain a sampled color; sampling a transparency texture based on target texture coordinates to obtain a sampled transparency; and obtaining target sampling information based on the sampled color and sampled transparency.
[0131] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: clustering and compressing the colors of the original sequence frame texture to obtain the target sequence frame texture; rendering the flame model based on multiple target sampling information to generate flame effects, including: decompressing the target sampling information to obtain the original sampling information corresponding to the target sequence frame texture; and rendering the flame model based on multiple original sampling information to generate flame effects.
[0132] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: decompressing the sampled color contained in the target sampling information to obtain the target original color; merging the target original color and the sampled transparency contained in the target sampling information to obtain the original sampling information.
[0133] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: determining the target cluster color corresponding to the sampled color from a preset mapping relationship, wherein the preset mapping relationship is used to characterize the mapping relationship between different cluster colors and different compressed colors of the original sequence frame texture, and the different cluster colors are colors obtained by clustering different original colors in the original sequence frame texture; determining the target cluster color as the target original color in response to the number of target cluster colors being one; and interpolating and fitting the multiple target cluster colors to obtain the target original color in response to the number of target cluster colors being multiple.
[0134] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: clustering the original colors of the original sequence frame texture to obtain multiple cluster colors; obtaining compressed colors corresponding to the multiple cluster colors based on the brightness of the multiple cluster colors; generating a preset mapping relationship based on the compressed colors corresponding to the multiple cluster colors; obtaining compressed colors corresponding to other colors based on the color error between other colors in the original colors and two adjacent cluster colors in the preset mapping relationship, wherein the other colors are used to represent colors other than cluster colors in the original colors; generating a color texture based on the compressed colors corresponding to the cluster colors and the compressed colors corresponding to other colors; generating a transparency texture based on the original transparency of the original sequence frame texture; and summarizing the color texture and the transparency texture to obtain the target sequence frame texture.
[0135] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: interpolating and fitting two adjacent cluster colors to obtain fitted colors; determining two adjacent target cluster colors based on the color error between the fitted color and other colors, wherein the color error between the fitted color corresponding to two adjacent target cluster colors and other colors is less than the color error between the fitted color corresponding to other two adjacent cluster colors and other colors; and determining the compressed color corresponding to two adjacent target cluster colors as the compressed color corresponding to other colors.
[0136] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: linearly interpolating two adjacent original sample information from multiple original sample information to obtain transition information; rendering a flame model based on multiple original sample information and transition information to generate flame effects.
[0137] This embodiment provides a technical solution for rendering flame effects in a computer-readable storage medium. The method involves acquiring multiple target sequence frame textures corresponding to the flame effect and obtaining a wind speed field map; offsetting the original texture coordinates of the target sequence frame textures based on the wind speed field map to obtain the target texture coordinates of the target sequence frame textures; sampling the target sequence frame textures based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame textures; and rendering the flame model based on the multiple target sampling information to generate the flame effect. It should be noted that the multiple target sequence frame textures corresponding to the flame effect are acquired, wherein the sequence frame textures consist of a large number of image frames, and compressing the sequence frame textures can reduce memory consumption. Furthermore, by offsetting the original texture coordinates of the target sequence frame texture based on the wind speed field map, the target texture coordinates of the target sequence frame texture are obtained. Then, the target sequence frame texture is sampled according to the target texture coordinates, which enables the target sequence frame texture of the flame to be integrated with the wind field in the virtual scene, reflecting the influence of the wind field on the flame. This achieves the goal of improving the interactivity between the flame effect and the wind field in the virtual scene, thus solving the technical problem of matching the flame effect with the virtual scene and enhancing the visual effect, thereby achieving the technical effect of improving the interactivity between the flame effect and the virtual scene.
[0138] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0139] In exemplary embodiments of this application, a computer-readable storage medium stores a program product capable of implementing the methods described above in this embodiment. In some possible implementations, various aspects of the embodiments of this disclosure may also be implemented as a program product including program code, which, when the program product is run on a terminal device, causes the terminal device to perform the steps according to various exemplary embodiments of this disclosure described in the "Exemplary Methods" section above.
[0140] The program product for implementing the above-described method according to embodiments of the present disclosure may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the embodiments of the present disclosure is not limited thereto. In the embodiments of the present disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0141] The aforementioned program product may take the form of any combination of one or more computer-readable media. Such computer-readable storage media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples (not exhaustive) of computer-readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0142] It should be noted that the program code contained on the computer-readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0143] Embodiments of this disclosure also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0144] 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.
[0145] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0146] Step S1: Obtain multiple target sequence frame textures corresponding to the flame effect, and obtain the wind speed field map, wherein the wind speed field map is used to represent the wind speed at different locations in the virtual scene;
[0147] Step S2: Offset the original texture coordinates of the target sequence frame texture based on the wind speed field map to obtain the target texture coordinates of the target sequence frame texture;
[0148] Step S3: Sample the target sequence frame texture based on the target texture coordinates to obtain the target sampling information corresponding to the target sequence frame texture;
[0149] Step S4: Render the flame model based on multiple target sampling information to generate flame effects.
[0150] Optionally, the processor may also be configured to perform the following steps via a computer program: determining the world coordinates corresponding to the target sequence frame texture, wherein the world coordinates are used to represent the coordinates in the world coordinate system corresponding to the virtual scene; sampling the wind speed field map based on the world coordinates to obtain the target sampling velocity corresponding to the target sequence frame texture; and offsetting the original texture coordinates based on the target sampling velocity to obtain the target texture coordinates.
[0151] Optionally, the processor can also be configured to perform the following steps via a computer program: sampling the wind speed field map based on world coordinates to obtain an initial sampling velocity; converting the initial sampling velocity from the world coordinate system to the local coordinate system corresponding to the flame model to obtain a transformed sampling velocity; and projecting the transformed sampling velocity onto the flame model to obtain a target sampling velocity.
[0152] Optionally, the processor may also be configured to perform the following steps via a computer program: obtain a preset wind speed generated in a virtual scene; add the preset wind speed to an initial velocity field to obtain a target velocity field; and generate a wind speed field texture based on the target velocity field.
[0153] Optionally, the processor may also be configured to perform the following steps via a computer program: color texture and transparency texture, sampling the target sequence frame texture based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame texture, including: sampling the color texture based on the target texture coordinates to obtain the sampled color; sampling the transparency texture based on the target texture coordinates to obtain the sampled transparency; and obtaining target sampling information based on the sampled color and sampled transparency.
[0154] Optionally, the processor may also be configured to perform the following steps via a computer program: clustering and compressing the colors of the original sequence frame texture to obtain the target sequence frame texture; rendering the flame model based on multiple target sampling information to generate flame effects, including: decompressing the target sampling information to obtain the original sampling information corresponding to the target sequence frame texture; and rendering the flame model based on multiple original sampling information to generate flame effects.
[0155] Optionally, the processor may also be configured to perform the following steps via a computer program: decompressing the sampled colors contained in the target sampling information to obtain the original target color; merging the original target color and the sampled transparency contained in the target sampling information to obtain the original sampling information.
[0156] Optionally, the processor may also be configured to perform the following steps via a computer program: determining the target cluster color corresponding to the sampled color from a preset mapping relationship, wherein the preset mapping relationship is used to characterize the mapping relationship between different cluster colors and different compressed colors of the original sequence frame texture, and the different cluster colors are colors obtained by clustering different original colors in the original sequence frame texture; determining the target cluster color as the target original color in response to the number of target cluster colors being one; and interpolating and fitting multiple target cluster colors to obtain the target original color in response to the number of target cluster colors being multiple.
[0157] Optionally, the processor described above can also be configured to perform the following steps via a computer program: clustering the original colors of the original sequence frame texture to obtain multiple cluster colors; obtaining compressed colors corresponding to the multiple cluster colors based on the brightness of the multiple cluster colors; generating a preset mapping relationship based on the compressed colors corresponding to the multiple cluster colors; obtaining compressed colors corresponding to other colors based on the color error between other colors in the original colors and two adjacent cluster colors in the preset mapping relationship, wherein the other colors are used to represent colors other than cluster colors in the original colors; generating a color texture based on the compressed colors corresponding to the cluster colors and the compressed colors corresponding to other colors; generating a transparency texture based on the original transparency of the original sequence frame texture; and summarizing the color texture and the transparency texture to obtain the target sequence frame texture.
[0158] Optionally, the processor may also be configured to perform the following steps via a computer program: interpolating and fitting two adjacent cluster colors to obtain fitted colors; determining two adjacent target cluster colors based on the color error between the fitted colors and other colors, wherein the color error between the fitted colors corresponding to two adjacent target cluster colors and other colors is less than the color error between the fitted colors corresponding to other two adjacent cluster colors and other colors; and determining the compressed colors corresponding to two adjacent target cluster colors as the compressed colors corresponding to other colors.
[0159] Optionally, the processor may also be configured to perform the following steps via a computer program: linearly interpolating two adjacent original sample information from multiple original sample information to obtain transition information; and rendering the flame model based on the multiple original sample information and the transition information to generate flame effects.
[0160] In this embodiment of the electronic device, a technical solution for rendering flame effects is provided. The method involves acquiring multiple target sequence frame textures corresponding to the flame effect and acquiring a wind speed field map; offsetting the original texture coordinates of the target sequence frame textures based on the wind speed field map to obtain the target texture coordinates of the target sequence frame textures; sampling the target sequence frame textures based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame textures; and rendering the flame model based on the multiple target sampling information to generate the flame effect. It should be noted that the multiple target sequence frame textures corresponding to the flame effect are acquired, wherein the sequence frame textures consist of a large number of image frames, and compressing the sequence frame textures can reduce memory consumption. Furthermore, by offsetting the original texture coordinates of the target sequence frame texture based on the wind speed field map, the target texture coordinates of the target sequence frame texture are obtained. Then, the target sequence frame texture is sampled according to the target texture coordinates, which enables the target sequence frame texture of the flame to be integrated with the wind field in the virtual scene, reflecting the influence of the wind field on the flame. This achieves the goal of improving the interactivity between the flame effect and the wind field in the virtual scene, thus solving the technical problem of matching the flame effect with the virtual scene and enhancing the visual effect, thereby achieving the technical effect of improving the interactivity between the flame effect and the virtual scene.
[0161] Figure 12 This is a schematic diagram of an electronic device according to an embodiment of the present disclosure. Figure 12 As shown, the electronic device 1200 is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0162] like Figure 12 As shown, the electronic device 1200 is presented in the form of a general-purpose computing device. The components of the electronic device 1200 may include, but are not limited to: at least one processor 1210, at least one memory 1220, a bus 1230 connecting different system components (including memory 1220 and processor 1210), and a display 1240.
[0163] The memory 1220 stores program code that can be executed by the processor 1210, causing the processor 1210 to perform the steps described in the method section of the embodiments of this application according to various exemplary implementations of this disclosure.
[0164] The memory 1220 may include a readable medium in the form of volatile memory cells, such as random access memory (RAM) 12201 and / or cache memory 12202, and may further include read-only memory (ROM) 12203, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0165] In some instances, memory 1220 may also include programs / utilities 12204 having a set (at least one) of program modules 12205, including but not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Memory 1220 may further include memory remotely located relative to processor 1210, which can be connected to electronic device 1200 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0166] Bus 1230 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, peripheral bus, graphics acceleration port, processor 1210, or a local bus using any of the various bus structures.
[0167] The display 1240 may be, for example, a touch screen liquid crystal display (LCD) that allows a user to interact with the user interface of the electronic device 1200.
[0168] Optionally, the electronic device 1200 can also communicate with one or more external devices 1300 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 1200, and / or any device that enables the electronic device 1200 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via the input / output (I / O) interface 1250. Furthermore, the electronic device 1200 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via the network adapter 1260. Figure 12 As shown, network adapter 1260 communicates with other modules of electronic device 1200 via bus 1230. It should be understood that, although... Figure 12 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 1200, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0169] The aforementioned electronic device 1200 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.
[0170] Those skilled in the art will understand that Figure 12The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 1200 may also include components that are more... Figure 12 The more or fewer components shown, or having the same Figure 1 Different configurations are shown. The memory 1220 can be used to store computer programs and corresponding data, such as the computer program and corresponding data corresponding to the flame effect rendering method in this embodiment. The processor 1210 executes various functional applications and data processing by running the computer program stored in the memory 1220, thereby realizing the aforementioned flame effect rendering method.
[0171] The sequence numbers of the embodiments disclosed above are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0172] In the above embodiments of this disclosure, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0173] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0174] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0175] Furthermore, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0176] If the integrated unit is implemented as 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 this disclosure, in essence, or 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0177] The above description is only a preferred embodiment of this disclosure. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principles of this disclosure, and these improvements and modifications should also be considered within the scope of protection of this disclosure.
Claims
1. A method for rendering flame effects, characterized in that, include: Obtain the target sequence frame texture corresponding to the flame effect and obtain the wind speed field map. The wind speed field map is used to represent the wind speed at different locations in the virtual scene. The target sequence frame texture is obtained by summarizing the color texture and the transparency texture. The transparency texture is used to represent the original transparency of the original sequence frame texture, and the color texture is used to represent the compressed color obtained after clustering and compressing the original color of the original sequence frame texture. The target texture coordinates of the target sequence frame texture are obtained by offsetting the original texture coordinates of the target sequence frame texture based on the wind speed field map. Based on the target texture coordinates, the target sequence frame texture is sampled to obtain target sampling information corresponding to the target sequence frame texture. The target sampling information is constructed based on the sampled color and sampled transparency. The sampled transparency is obtained by sampling the transparency texture based on the target texture coordinates. The sampled color is obtained by sampling the color texture based on the index of the compressed color block and the target texture coordinates. The index of the compressed color block is obtained by converting the target texture coordinates according to the requirements of the target texture coordinates and color encoding format. The flame model is rendered based on the sampling information of multiple targets to generate the flame effect.
2. The method according to claim 1, characterized in that, The target texture coordinates of the target sequence frame texture are obtained by offsetting the original texture coordinates of the target sequence frame texture based on the wind speed field map, including: Determine the world coordinates corresponding to the target sequence frame texture, wherein the world coordinates are used to represent the coordinates in the world coordinate system corresponding to the virtual scene; Based on the world coordinates, the wind speed field map is sampled to obtain the target sampling velocity corresponding to the target sequence frame texture; The original texture coordinates are offset based on the target sampling rate to obtain the target texture coordinates.
3. The method according to claim 2, characterized in that, Based on the world coordinates, the wind speed field map is sampled to obtain the target sampling velocity corresponding to the target sequence frame texture, including: The wind speed field map is sampled based on the world coordinates to obtain the initial sampling velocity. The initial sampling velocity is converted from the world coordinate system to the local coordinate system corresponding to the flame model to obtain the converted sampling velocity; The target sampling velocity is obtained by projecting the conversion sampling velocity onto the flame model.
4. The method according to claim 2, characterized in that, The method further includes: Obtain the preset wind speed generated in the virtual scene; The preset wind speed is added to the initial velocity field to obtain the target velocity field; Based on the target velocity field, the wind speed field texture is generated.
5. The method according to claim 1, characterized in that, The method further includes: The target sequence frame texture is obtained by clustering and compressing the colors of the original sequence frame texture; The flame model is rendered based on multiple target sampling information to generate the flame effect, including: The target sampling information is decompressed to obtain the original sampling information corresponding to the target sequence frame texture; The flame model is rendered based on multiple sets of original sampling information to generate the flame effect.
6. The method according to claim 5, characterized in that, The target sampling information is decompressed to obtain the original sampling information corresponding to the target sequence frame texture, including: The sampled colors contained in the target sampling information are decompressed to obtain the original target color; The original target color and the sampling transparency contained in the target sampling information are merged to obtain the original sampling information.
7. The method according to claim 6, characterized in that, The sampled colors contained in the target sampling information are decompressed to obtain the original target color, including: The target cluster color corresponding to the sampled color is determined from the preset mapping relationship, wherein the preset mapping relationship is used to characterize the mapping relationship between different cluster colors and different sampled colors of the original sequence frame texture, and the different cluster colors are colors obtained by clustering different original colors in the original sequence frame texture; In response to the fact that the number of target cluster colors is one, the target cluster color is determined to be the target original color; In response to the fact that there are multiple target cluster colors, interpolation fitting is performed on the multiple target cluster colors to obtain the target original color.
8. The method according to claim 5, characterized in that, The method further includes: The original colors of the original sequence frame texture are clustered to obtain multiple clustered colors; Based on the brightness of the multiple cluster colors, the compressed colors corresponding to the multiple cluster colors are obtained; Based on the compressed colors corresponding to the multiple clustered colors, a preset mapping relationship is generated; Based on the color error between other colors in the original color and two adjacent cluster colors in the preset mapping relationship, the compressed color corresponding to the other colors is obtained, wherein the other colors are used to represent colors in the original color other than the cluster colors.
9. The method according to claim 8, characterized in that, Based on the color error between other colors in the original colors and two adjacent clustered colors in the preset mapping relationship, the compressed colors corresponding to the other colors are obtained, including: Interpolate and fit the colors of two adjacent clusters to obtain the fitted colors; Based on the color error between the fitted color and the other colors, two adjacent target cluster colors are determined, wherein the color error between the fitted color and the other colors corresponding to the two adjacent target cluster colors is smaller than the color error between the fitted color and the other colors corresponding to the other two adjacent cluster colors; The compressed color corresponding to the two adjacent target cluster colors is determined to be the compressed color corresponding to the other colors.
10. The method according to claim 1, characterized in that, The flame model is rendered based on multiple target sampling information to generate the flame effect, including: Linear interpolation is performed on two adjacent target sampling information from multiple target sampling information to obtain transition information; The flame model is rendered based on multiple target sampling information and the transition information to generate the flame effect.
11. A rendering device for flame effects, characterized in that, include: The loading module is used to obtain the target sequence frame texture corresponding to the flame effect and to obtain the wind speed field map. The wind speed field map is used to represent the wind speed at different locations in the virtual scene. The target sequence frame texture is obtained by summarizing the color texture and the transparency texture. The transparency texture is used to represent the original transparency of the original sequence frame texture, and the color texture is used to represent the compressed color obtained after clustering and compressing the original color of the original sequence frame texture. The offset module is used to offset the original texture coordinates of the target sequence frame texture based on the wind speed field map to obtain the target texture coordinates of the target sequence frame texture. A sampling module is used to sample the target sequence frame texture based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame texture. The target sampling information is constructed based on the sampled color and sampled transparency. The sampled transparency is obtained by sampling the transparency texture based on the target texture coordinates. The sampled color is obtained by sampling the color texture based on the index of the compressed color block and the target texture coordinates. The index of the compressed color block is obtained by converting the target texture coordinates according to the requirements of the target texture coordinates and the color encoding format. The rendering module is used to render the flame model based on multiple target sampling information to generate the flame effect.
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 method described in any one of claims 1 to 10 when run by a processor.
13. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method as described in any one of claims 1 to 10.