Flame special effect rendering method and device, readable storage medium and electronic device
By obtaining and processing the texture and wind speed field maps of flame special effects, the problem of poor interactivity between flame special effects and virtual scenes is solved, and a more realistic matching between flame special effects and virtual scenes is achieved.
Patent Information
- Application Number
- CN202311412446.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-27
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2043-10-27
AI Technical Summary
In the prior art, the interactive nature of the flame special effects and the virtual scene is poor and cannot match the environment changes in the game scene, resulting in poor visual effects.
By obtaining multiple target sequence frame textures and wind velocity field maps corresponding to the flame special effects, offset the original texture coordinates of the target sequence frame texture based on the wind velocity field map, obtain the target texture coordinates of the target sequence frame texture, and sample the target sequence frame texture based on the target texture coordinates to generate the flame special effects.
It improves the interactivity between the flame special effects and the wind field in the virtual scene, makes the flame special effects more match the virtual scene, and enhances the visual effect.
Smart Images

Figure CN119896851A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer image processing, and in particular to a method and device for rendering flame special effects, a readable storage medium, and an electronic device. Background Art
[0002] At present, in order to show the flame special effects in a certain place in the game, a third-party graphic digital simulation software is used to simulate and render the flame special effects within a certain range of the virtual scene; and the rendering result is saved in the form of a sequence frame animation as a texture map. If you want to display the result of a certain frame, you can directly obtain the corresponding texture map for display, so as to achieve the effect of playing texture animation by constantly switching frames, that is, constantly switching the texture sampling area. However, such flame special effects are all pre-recorded flame animation frames, which cannot change with the environment in the game scene, resulting in poor interactivity between the flame special effects and the virtual scene.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] At least some embodiments of the present disclosure provide a method and device for rendering flame special effects, a readable storage medium, and an electronic device to at least solve the technical problem of poor interactivity between flame special effects and virtual scenes.
[0005] According to one embodiment of the present disclosure, a method for rendering a flame special effect is provided, comprising: obtaining a plurality of target sequence frame textures corresponding to the flame special effect, and obtaining a wind velocity field map, wherein the wind velocity field map is used to characterize the speed of wind at different positions in a virtual scene; offsetting the original texture coordinates of the target sequence frame texture based on the wind velocity field map to obtain target texture coordinates of the target sequence frame 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; rendering a flame model based on the plurality of target sampling information to generate a flame special effect.
[0006] According to one embodiment of the present disclosure, a rendering device for flame special effects is also provided, including: a loading module, used to obtain multiple target sequence frame textures corresponding to the flame special effect, and obtain a wind velocity field map, wherein the wind velocity field map is used to characterize the speed of wind at different positions in the virtual scene; an offset module, used to offset the original texture coordinates of the target sequence frame texture based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture; a sampling module, 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; a rendering module, used to render the flame model based on the multiple target sampling information to generate the flame special effect.
[0007] According to one embodiment of the present disclosure, a computer-readable storage medium is further provided, in which a computer program is stored, wherein the computer program is configured to execute any of the above-mentioned methods for rendering flame special effects when running.
[0008] According to one embodiment of the present disclosure, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute any of the above-mentioned methods for rendering flame special effects.
[0009] In at least some embodiments of the present disclosure, multiple target sequence frame textures corresponding to the flame special effect are obtained, and a wind velocity field map is obtained; the original texture coordinates of the target sequence frame texture are offset based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture; the target sequence frame texture is sampled based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame texture; the flame model is rendered based on the multiple target sampling information to generate the flame special effect. It should be noted that multiple target sequence frame textures corresponding to the flame special effect are obtained, wherein the sequence frame texture is composed of a large number of image frames, and compressing the sequence frame texture can reduce memory consumption. And based on the wind velocity field map, the original texture coordinates of the target sequence frame texture are offset to obtain the target texture coordinates of the target sequence frame texture, and then the target sequence frame texture is sampled according to the target texture coordinates, so that the target sequence frame texture of the flame can be integrated with the wind field in the virtual scene to reflect the influence of the wind field on the flame, so as to achieve the purpose of improving the interactivity of the flame special effect and the wind field in the virtual scene, thereby solving the technical problem of matching the flame special effect with the virtual scene and enhancing the visual effect, and thus achieving the technical effect of improving the interactivity of the flame special effect with the virtual scene. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present application. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:
[0011] Figure 1 It is a hardware structure block diagram of a mobile terminal of a method for rendering flame special effects according to an embodiment of the present disclosure;
[0012] Figure 2 is a flow chart of a method for rendering flame special effects according to one embodiment of the present disclosure;
[0013] Figure 3 is a schematic diagram of obtaining a target sequence frame texture according to one optional embodiment of the present disclosure;
[0014] Figure 4is a schematic diagram of a traditional interactive flame according to one optional embodiment of the present disclosure;
[0015] Figure 5 is a schematic diagram of the size of the flame special effect according to one optional embodiment of the present disclosure;
[0016] Figure 6 is a schematic diagram of a flame special effect according to one optional embodiment of the present disclosure;
[0017] Figure 7 is a schematic diagram of obtaining target texture coordinates according to one optional embodiment of the present disclosure;
[0018] Figure 8 is a schematic diagram of obtaining target sampling information according to one optional embodiment of the present disclosure;
[0019] Fig. 9 is a flow chart of an optional method for rendering flame special effects according to an embodiment of the present disclosure;
[0020] Fig.10 is a schematic diagram of flame special effects acquisition according to one optional embodiment of the present disclosure;
[0021] Fig.11 is a structural block diagram of a device for generating a tailing performance result according to one optional embodiment of the present disclosure;
[0022] Fig.12 is a schematic diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the scheme of the present disclosure, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without creative work 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 and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0025] In a possible implementation, the inventor has practiced and carefully studied the technical problem of poor interactivity between flame special effects and virtual scenes, which is commonly used in the background of computer image processing. Based on this, the game scenes applied by the embodiments of the present disclosure can be role-playing games, adventure games, etc. The game types targeted are generally games with storylines and characters. A rendering method for flame special effects is proposed. The technical concept adopted is to obtain multiple target sequence frame textures corresponding to the flame special effects, and obtain the wind velocity field map; offset the original texture coordinates of the target sequence frame texture based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture; 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; render the flame model based on the multiple target sampling information to generate flame special effects. It should be noted that multiple target sequence frame textures corresponding to the flame special effects are obtained, wherein the sequence frame texture is composed of a large number of image frames, and compressing the sequence frame texture can reduce memory consumption. And based on the wind velocity field map, the original texture coordinates of the target sequence frame texture are offset to obtain the target texture coordinates of the target sequence frame texture, and then the target sequence frame texture is sampled according to the target texture coordinates, so that the target sequence frame texture of the flame can be integrated with the wind field in the virtual scene to reflect the influence of the wind field on the flame, so as to achieve the purpose of improving the interactivity of the flame special effect and the wind field in the virtual scene, thereby solving the technical problem of matching the flame special effect with the virtual scene and enhancing the visual effect, and thus achieving the technical effect of improving the interactivity of the flame special effect with the virtual scene.
[0026] The above method embodiments involved in the present disclosure can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, the mobile terminal can be a smart phone, a tablet computer, a handheld computer, a mobile Internet device, a PAD (Portable Android Device), a game console and other terminal devices. Figure 1FIG. 1 is a hardware structure block diagram of a mobile terminal of a method for rendering a flame special effect according to an embodiment of the present disclosure. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 The processor 102 (only one is shown) may include, but is not limited to, a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a field-programmable logic device (FPGA), a neural network processor (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, etc.) and a memory 104 for storing data. In one embodiment of the present disclosure, it may also include: an input / output device 108 and a display device 110.
[0027] Those skilled in the art will understand that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0028] According to one embodiment of the present disclosure, an embodiment of a method for rendering a flame special effect is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] Figure 2 is a flowchart of a method for rendering flame special effects according to one embodiment of the present disclosure, such as Figure 2 As shown, the method comprises the following steps:
[0030] Step S202, obtaining a plurality of target sequence frame textures corresponding to the flame special effect, and obtaining a wind velocity field map, wherein the wind velocity field map is used to represent the speed of wind at different positions in the virtual scene.
[0031] The above-mentioned flame special effects can be special effects used in the animation production process, so as to make the animation pictures more attractive, expressive and visually impactful, so as to enhance the audience's visual experience and emotional resonance.
[0032] The above-mentioned target sequence frame texture can be a texture composed of a series of continuous animation frame images, which can be arranged in a fixed order to form a continuous animation effect. It can be but not limited to: a dual-channel sequence frame texture, wherein the dual channels can be two channels composed of brightness (Value, abbreviated as V) and transparency (A) information.
[0033] The wind velocity field map described above can be an image used to visualize the velocity field, where the velocity field refers to the distribution of the velocity vector at each point in space or on a plane. By representing the velocity field in the form of an image, the characteristics and changes of the velocity field can be more intuitively observed and analyzed.
[0034] The original sequence frame texture may be a sequence frame texture that has not been subjected to clustering compression, and may be, but is not limited to, a four-channel sequence frame texture, wherein the four channels may be red-green-blue-alpha (RGBA for short).
[0035] The above-mentioned virtual scene can be a simulated environment created by computer technology and virtual reality technology.
[0036] In an optional embodiment, the original color in the flame special effect is compressed using a clustering algorithm, wherein the four channels of red (Red, referred to as R), green (Green, referred to as G), blue (Blue, referred to as B) and transparency (Alpha, referred to as A) information contained in the original sequence frame texture are compressed into two channels containing only brightness (V) and transparency (A) information. Then, the original sequence frame texture is subjected to computer graphics image processing (Mipmap) to generate an M*N picture to obtain the target sequence frame texture. At the same time, according to the changes in the velocity field caused by the movement of the game character or the sending of skills in the virtual scene, the speed, direction, intensity and other factors of the fluid are comprehensively considered, and the factors that can cause the change of the velocity field are added to the velocity field, and the divergence and pressure of the velocity are calculated to obtain a new velocity field, which is output to the map to generate a wind velocity field map.
[0037] In another optional embodiment, since the original sequence frame texture can be three-channel or four-channel, wherein the three channels can be the three primary colors of red, green and blue (Red-Green-Bule, referred to as RGB), they generally have the characteristics of similar color changes and relatively single color types. A clustering algorithm is used to compress the points used to represent the colors of each pixel in the original sequence frame texture until the sum of the distances of the compressed points of each pixel from the center point is minimized, and the points are sorted to obtain a color lookup table, and the positions of each pixel in the original sequence frame texture are determined based on the color lookup table, thereby mapping the original color to the color lookup table to obtain a dual channel of floating point value (V) and transparency (A) information, thereby obtaining the target sequence frame texture. At the same time, the movement of the current game character and the wind field information generated by launching skills are determined according to the virtual scene, and output to the map to determine the wind velocity field map. Among them, Figure 3 is a schematic diagram of obtaining 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 perform color clustering on each pixel in the original sequence frame texture, four channels are compressed into two channels, and the color codes are sorted to obtain a color lookup table, so as to perform channel segmentation. The floating point value (V) and transparency (A) of each frame are stored in four channels respectively and compressed, so that double the number of frames can be stored.
[0038] In another optional embodiment, the RGB colors are represented as points separated into multiple clusters in a three-dimensional space, and the centers of the multiple clusters are calculated so that the sum of the distances of these RGB points from the center point is small, and the coordinates of these center points are the main colors of the sequence frame; then the main colors are sorted according to their RGB Luminance values, so that a one-dimensional color lookup table (ColorLUT) is obtained, and it is further determined that the color of the pixel in the original sequence frame texture is between which two main colors, so that the error of interpolation fitting between the two main colors is minimized, thereby recording the position of the midpoint of the pixel in the original sequence frame texture in the color lookup table, and then the RGB colors can be mapped into a floating point value V, and combined with the transparency (A) in the original sequence frame texture, the compressed target sequence frame texture is obtained. Furthermore, in order to integrate the wind field information in the virtual scene with the flame special effects, the NS fluid simulation module of the Euler perspective is first used. In order to calculate the 2D velocity map, the Navier-Stokes (NS) equation is decomposed into four stages: the AddForce stage, the Advect stage, the Divergence stage, the Pressure stage, and the SubtractGradient stage. In the AddForce stage, according to the movement of the characters in the game and the sending of various skills, the speed generated by the interactive component is determined, and added to the velocity field as an external force to change the speed of the corresponding area; in the Advect stage, the global velocity advection is calculated, the Divergence stage is used to obtain the velocity divergence, which is convenient for the use of subsequent stages, and the Pressure stage combines the velocity divergence and uses the Jacobi iteration method to calculate the pressure in the field; finally, the updated velocity field is calculated in the SubtractGradient stage by combining the velocity and pressure, and output to a map, so as to obtain the wind velocity field map after interaction with the scene.
[0039] It should be noted that in the game graphics pipeline, MipMap is generally generated for textures. For an M x N image, 0.5M*0.5N and 0.25M*0.25N will be continuously generated in the form of binary size until it can no longer be reduced. Different levels of size are used as texture loading at different distances in the game. In order to make full use of the four channels of the texture and reduce the space loss when MipMap is generated in the graphics pipeline, the compressed sequence frame animation VA can be stored separately, and the V and A of each frame are stored in the RGBA four channels respectively. In this way, the RGBA storage space originally used for one frame can store twice the number of frames.
[0040] Step S204 , offsetting the original texture coordinates of the target sequence frame texture based on the wind velocity field map to obtain target texture coordinates of the target sequence frame texture.
[0041] The above-mentioned original texture coordinates can be a set of two-dimensional coordinates used to determine the position of a specific point on the texture in texture mapping. 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 above-mentioned target texture coordinates may be texture coordinates used to realize the final flame special effect, or may be.
[0043] In an optional embodiment, when the target sequence frame texture is played, the wind velocity field map is sampled in the world coordinates to obtain the velocity of the target sequence frame texture in the current playback area in the world coordinates, and the velocity in the world coordinates is mapped to the local coordinate system of the target sequence frame texture to obtain the velocity in the local coordinate system, and the original texture coordinates of the target sequence frame texture and the velocity vector of each pixel are further obtained, and each velocity vector is multiplied by a time step to determine the offset of the texture coordinates; the offset of the texture coordinates is added to the original texture coordinates to obtain the target texture coordinates. The realism of the target sequence frame texture is enhanced, and the movement change of the target sequence frame texture is made more natural and coherent.
[0044] Step S206: sampling the target sequence frame texture based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame texture.
[0045] The above-mentioned target sampling information may be texture information sampled from the target sequence frame texture.
[0046] In an optional embodiment, the position of the target sequence frame texture to be sampled is determined according to the target texture coordinates, and then a suitable texture sampling method is selected at the sampling position according to the requirements to sample the color and transparency in the target sequence frame texture, thereby obtaining target sampling information.
[0047] Step S208: Rendering the flame model based on the multiple target sampling information to generate flame special effects.
[0048] The flame model mentioned above may be a model that is pre-set according to specific circumstances and is used to render the original sampling information to generate flame special effects.
[0049] In an optional embodiment, two adjacent pieces of original sampling information among the plurality of original sampling information are linearly interpolated to make the motion change more natural and coherent, and then the flame model is rendered to make the flame special effect smoother.
[0050] In an embodiment of the present invention, multiple target sequence frame textures corresponding to the flame special effect are obtained, and a wind velocity field map is obtained; the original texture coordinates of the target sequence frame texture are offset based on the wind velocity field map to obtain the target texture coordinates of the target 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; the flame model is rendered based on the multiple target sampling information to generate the flame special effect. It should be noted that multiple target sequence frame textures corresponding to the flame special effect are obtained, wherein the sequence frame texture is composed of a large number of image frames, and compressing the sequence frame texture can reduce memory consumption. And the original texture coordinates of the target sequence frame texture are offset based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture, and then the target sequence frame texture is sampled according to the target texture coordinates, so that the target sequence frame texture of the flame can be integrated with the wind field in the virtual scene, reflecting the influence of the wind field on the flame, so as to achieve the purpose of improving the interactivity of the flame special effect with the wind field in the virtual scene, thereby solving the technical problem of matching the flame special effect with the virtual scene and enhancing the visual effect, and thus achieving the technical effect of improving the interactivity of the flame special effect with the virtual scene.
[0051] It should be noted that Figure 4 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 the figure, when traditionally making flame effects, the color channels used in sequence frame textures are very limited, which are not fully utilized and waste a certain amount of texture storage space. Particle interactive flames also lead to a large number of drawn triangles in the particle system, resulting in high system performance overhead. Figure 5 is a schematic diagram of the size of the flame special effect according to one optional embodiment of the present disclosure, Figure 6 is a schematic diagram of a flame effect according to one optional embodiment of the present disclosure, such as Figure 5 , 6As shown in the figure, the size of the flame image is reduced from 26,836KB to 7,374KB, then to 6,465KB, and finally to 9KB. The sequence frame texture in this solution can make full use of the four RGBA color channels, reducing the storage consumption of the sequence frame texture space. At the same time, for the interactive flame, only one square patch is needed for drawing, reducing the performance consumption of drawing.
[0052] Optionally, the original texture coordinates of the target sequence frame texture are offset based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture, including: 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 velocity field map based on the world coordinates to obtain the target sampling speed corresponding to the target sequence frame texture; and offsetting the original texture coordinates based on the target sampling speed to obtain the target texture coordinates.
[0053] The above-mentioned world coordinates may also be the world coordinates of the pixels in the target sequence frame texture when the sequence frame is played. It may be a coordinate system representing an object or position in three-dimensional space, which is used to determine the position and direction of an object in a scene in computer graphics and computer animation. It may be, but is not limited to, a Cartesian coordinate system. In the world coordinate system, the origin is usually the center point of the scene, and the direction of the axis depends on the specific application. The world coordinate system can be used to describe the absolute position of an object, regardless of the observer's perspective.
[0054] The above-mentioned target sampling speed may be a speed corresponding to sampling in a virtual scene, and is used to interact the speed in the virtual scene with the flame special effect to make the flame special effect more realistic.
[0055] In an optional embodiment, when the sequence frame is played, the world coordinates of each pixel in the target sequence frame texture are determined, and the pixel width and height of the wind velocity field map are obtained at the same time, and the sampling range is determined. The wind velocity field map is sampled according to the sampling range and the world coordinates to obtain the target sampling speed corresponding to the target sequence frame texture. The target sequence frame texture after the original texture coordinates are offset according to the wind velocity field map can enhance the animation effect and realism by simulating the motion effect, fluid feeling, natural change and other characteristics of the object.
[0056] In another optional embodiment, when the sequence frame is played, the world coordinates of each pixel in the target sequence frame texture are determined, and the world coordinates are converted to map coordinates. This can be achieved by mapping the world coordinates to a value between 0 and 1 within the map range. At the same time, the pixel width and height of the wind velocity field map are obtained to determine the sampling range. Thereby, according to the converted map coordinates, the corresponding positions in the wind velocity field map are sampled using methods such as bilinear interpolation. Further, based on the sampling value, the speed vector corresponding to the world coordinate is calculated as the target sampling speed. Since the offset is the product of the target sampling speed and time, where the offset is the offset value that needs to be applied to the original texture coordinates, the sampling speed is a constant, which represents the offset per second, and the time is the time from the start of sampling to the present. After obtaining the offset, the offset is added to the original texture coordinates to obtain the target texture coordinates. Among them, Figure 7 is a schematic diagram of obtaining target texture coordinates according to one optional embodiment of the present disclosure, such as Figure 7 As shown, after obtaining the wind velocity field map through fluid simulation, the target sampling speed corresponding to the target sequence frame texture in the world coordinates is obtained and projected to the local coordinate system to obtain the converted sampling speed, thereby offsetting the original texture coordinates to obtain the target texture coordinates.
[0057] Optionally, the wind velocity field map is sampled based on the world coordinates to obtain a target sampling speed corresponding to the target sequence frame texture, including: sampling the wind velocity field map based on the world coordinates to obtain an initial sampling speed; converting the initial sampling speed from the world coordinate system to a local coordinate system corresponding to the flame model to obtain a converted sampling speed; projecting the converted sampling speed onto the flame model to obtain a target sampling speed.
[0058] The above-mentioned initial sampling speed may be the speed sampled from the wind speed field map, or may be the speed in the world coordinates of the current sequence frame playback area when the sequence frame is played.
[0059] The above-mentioned local coordinate system may be a coordinate system established on the sequence frame patches.
[0060] The above-mentioned conversion sampling speed may be the speed in the local coordinate system corresponding to the initial sampling speed.
[0061] In an optional embodiment, speed sampling is performed in the wind speed field map according to the world coordinates to obtain an initial sampling speed. A point known 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 recorded 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 conversion relationship between the local coordinate system of the flame model and the world coordinate system. Thus, for each sampling speed vector, the coordinates of the reference point in the local coordinate system of the flame model are subtracted, and the initial sampling speed can be converted from the world coordinate system to the local coordinate system corresponding to the flame model to obtain the conversion sampling speed. Further, the conversion sampling speed is projected into the flame model to obtain the target sampling speed in the flame model, so that the flame special effects are more integrated with the flame model, and the flame special effects are more realistic.
[0062] Optionally, the method further includes: acquiring a preset wind speed generated in the virtual scene; adding the preset wind speed to the initial speed field to obtain a target speed field; and generating a wind speed field map based on the target speed field.
[0063] The above-mentioned preset wind speed can be the speed of the wind field in the virtual scene set in advance according to needs, or it can be the speed generated by the player moving or launching skills in the game.
[0064] The above-mentioned initial velocity field may be a velocity field in the virtual scene that is not changed based on the velocity generated by the movement or activation of skills of the game character.
[0065] The target speed field mentioned above may be a speed field after the speed of the corresponding area is changed due to the movement of the game character or the activation of a skill.
[0066] In an optional embodiment, a preset wind speed generated in a virtual scene is obtained, the preset wind speed is overlapped with the initial speed field, and the speed field of the corresponding area in the initial speed field is changed to obtain a target speed field. Then, a wind speed field map is generated according to the target speed field. When generating a wind speed field map, a suitable visualization method and parameters should be selected according to the characteristics and requirements of the data. The speed generated by the movement of the game character or the activation of skills in the game can be added to the speed field, so that the preset wind speed affects the swing of the flame special effect, thereby improving the realism of the flame special effect.
[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 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 color texture mentioned above can be the main color of the center point coordinate after clustering and compressing the original color of each pixel in the original sequence frame texture, wherein the original color can be the pixel color without any processing or modification, and is the color information directly obtained in the original sequence frame texture, which can reflect the color in the current scene and can usually be represented as the three primary colors of red, green and blue or the three primary colors of printing (Cyan-Magenta-Yellow-key / blacK, referred to as CMYK). The compressed color can be the color displayed after the color of each point in the three-dimensional space is compressed into a multi-cluster point set.
[0069] The above transparency texture may be the original transparency of each pixel in the original sequence frame texture, wherein the original transparency may be the transparency of each pixel in the original sequence frame texture.
[0070] The above-mentioned sampled color may be a sampling result of sampling the color of a pixel in a color texture.
[0071] The sampled transparency mentioned above may be a sampling result of sampling the transparency of pixels in the transparency texture.
[0072] The target sampling information mentioned above may be sampling information obtained by sampling the color and transparency of the target sequence frame.
[0073] In an optional embodiment, the encoding format of the color texture is determined, wherein common compressed color encoding formats include DXT, ETC, etc., and different encoding formats have different decoding methods and sampling methods. According to the requirements of the target texture coordinates and the color encoding format, the target texture coordinates are converted into the index of the corresponding compressed color block. Then, according to the index of the compressed color block and the target texture coordinates, the corresponding color value is found in the decoded compressed color block for sampling to obtain the sampled color. At the same time, the RGBA color value is obtained according to the target texture coordinates, and the value of the transparency Alpha channel corresponding to the RGBA color value is extracted to obtain the sampling transparency. Then the sampling color and sampling transparency are determined as the target sampling information. It provides convenience for the subsequent rendering of the flame special effects.
[0074] Figure 8 is a schematic diagram of obtaining target sampling information according to one optional embodiment of the present disclosure, such as Figure 8 As shown, in the game, when playing the flame special effect, after loading the compressed target sequence frame texture and ColorLUT, first calculate the current target sequence frame, that is, the frame range of the current sequence frame, and then combine the interactive module to offset the target sequence frame to obtain the offset target sequence frame, and then sample the target sequence frame to obtain the V and A values; then sample the ColorLUT based on the V value to restore the RGB value of the color, merge RGBA to obtain the sequence frame picture information of a single frame, and obtain the target sampling information.
[0075] Optionally, the method also 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 special effects, including: decompressing the target sampling information to obtain the original sampling information corresponding to the target sequence frame texture; rendering the flame model based on multiple original sampling information to generate flame special effects.
[0076] The above original sampling information can be the sampling information of the original sequence frame texture corresponding to the target sampling information
[0077] In an optional embodiment, in order to make full use of the RGBA four-channel and reduce the space loss when the original sequence frame texture is processed, the color of the original sequence frame texture needs to be clustered and compressed, and the V and A in the compressed target sequence frame texture are stored separately, and the V and A of each frame are stored in the RGBA four-channel, so that the RGBA storage space originally used for one frame can store double the number of frames. When rendering the flame model using multiple target sampling information, it is only necessary to decompress the target sampling information 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 merged with the transparency A to obtain RGBA. If the color of RGBA is consistent with that of the original sequence frame texture, the current RGBA is determined to be the original sampling information; if the color of RGBA is inconsistent with that of the original sequence frame texture, the color adjacent to the current RGBA is linearly interpolated according to the color lookup table to reduce the color error and determine it as the original sampling information, thereby achieving a smooth transition effect. Thus, the flame model is rendered according to multiple original sampling information to obtain flame special effects. While reducing space loss, the rendering efficiency of flame special effects is improved.
[0078] Optionally, the target sampling information is decompressed to obtain original sampling information corresponding to the target sequence frame texture, including: decompressing the sampling color contained in the target sampling information to obtain the target original color; merging the target original color and the sampling transparency contained in the target sampling information to obtain the original sampling information.
[0079] The above-mentioned target original color may be the original color of the original sequence frame texture corresponding to the sampled color.
[0080] In an optional embodiment, decompression is performed according to the floating-point value V and transparency A in the sampled color, and the floating-point value V is decompressed into RGB to obtain the target original color, thereby merging the transparency A with the target original color to obtain the picture information of a single-frame target sequence frame texture of RGBA, which more intuitively represents the transparency of the color without the need for an additional transparency channel, making the image more realistic.
[0081] Optionally, the sampling color included in the target sampling information is decompressed to obtain the target original color, including: determining a target cluster color corresponding to the sampling 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; in response to the number of target cluster colors being one, determining the target cluster color to be the target original color; in response to the number of target cluster colors being multiple, interpolating and fitting the multiple target cluster colors to obtain the target original color.
[0082] The above-mentioned preset mapping relationship may be a mapping relationship between different cluster colors and different compressed colors in the original sequence frame texture that is preset according to specific circumstances, or may be a color lookup table ColorLUT.
[0083] The target cluster color mentioned above may be the cluster color corresponding to the sampled color in the color correspondence table, or may be the main color of the multi-cluster point set.
[0084] The above-mentioned target original color may be the original color of the corresponding pixel in the original sequence frame texture, or may be the color before compression.
[0085] In an optional embodiment, the target cluster color corresponding to the sampled color is determined according to the preset mapping relationship. If there is only one target cluster color, the target cluster color is determined to be the target original color; if there are multiple target cluster colors, two adjacent target cluster colors are found, wherein the Euclidean distance or other distance metrics can be used to determine the adjacent colors. Thus, interpolation is performed according to the ratio between the two target cluster colors until multiple target cluster colors are interpolated and fitted, thereby comparing the interpolated color with the original color, and selecting the closest original color as the target original color, thereby reducing the color error.
[0086] Optionally, the colors of the original sequence frame texture are clustered and compressed to obtain a target sequence frame texture: the original colors of the original sequence frame texture are clustered to obtain multiple cluster colors; based on the brightness of the multiple cluster colors, compressed colors corresponding to the multiple cluster colors are obtained; based on the compressed colors corresponding to the multiple cluster 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, compressed colors corresponding to other colors are obtained, wherein the other colors are used to characterize colors in the original color other than the cluster colors; based on the compressed colors corresponding to the cluster colors and the compressed colors corresponding to the other colors, a color texture is generated; based on the original transparency of the original sequence frame texture, a transparency texture is generated; the color texture and the transparency texture are summarized to obtain the target sequence frame texture.
[0087] In an optional embodiment, the color features of the original sequence frame texture are obtained, and the color features are normalized so that different features can be better compared in the subsequent cluster analysis. Then the normalized color features are input into the clustering algorithm for analysis. The clustering algorithm clusters the colors according to the similarity of the features to form different color clusters and obtain multiple cluster colors. Each pixel in the image is assigned to the nearest cluster center, and for each cluster center, the corresponding brightness is calculated, so that the first few cluster centers with the highest brightness are selected as compressed colors according to the 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 two adjacent cluster colors in the preset mapping relationship is calculated, so as to determine the compressed color according to the color error, wherein the color with the smallest color error can be selected as the compressed color, or an intermediate color can be calculated as the compressed color by weighted average, so as to obtain the compressed colors corresponding to other colors. A color texture is generated according to the compressed colors corresponding to the cluster colors and the compressed colors corresponding to other colors. And a transparency texture is generated according to 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 a preset mapping relationship, compressed colors corresponding to other colors are obtained, including: performing interpolation fitting on two adjacent cluster colors to obtain a fitted color; based on the color error between the fitted color and the other color, determining two adjacent target cluster colors, wherein the color error between the fitted color corresponding to the two adjacent target cluster colors and the other color is smaller than the color error between the fitted color corresponding to the other two adjacent cluster colors and the other color; and determining that the compressed colors corresponding to the two adjacent target cluster colors are the compressed colors corresponding to other colors.
[0089] The above-mentioned fitting color may be a color obtained by fitting the compressed color, or may be a fusion color of two cluster colors.
[0090] The color error mentioned above may be the difference between the fitted color and other colors in image processing.
[0091] In an optional embodiment, interpolation fitting is performed on two adjacent cluster colors to obtain a fitting color so that the color transition is natural. The fitting color is compared with other colors, and the color error between the fitting color and the other colors is calculated to determine the two adjacent target cluster colors. Then, the compressed colors corresponding to the two adjacent target cluster colors are determined as the compressed colors corresponding to other colors to reduce the color error.
[0092] Optionally, rendering the flame model based on multiple target sampling information to generate flame special effects includes: performing linear interpolation on two adjacent target sampling information in the multiple target sampling information to obtain transition information; rendering the flame model based on the multiple target sampling information and the transition information to generate flame special effects.
[0093] The above transition information may be a result of linear interpolation of two adjacent original sampling information.
[0094] In an optional embodiment, before outputting the flame special effect, two adjacent original sampling information among multiple original sampling information are linearly interpolated to make the animation transition smooth and coherent, so that the flame model is rendered with multiple original sampling information and transition information to generate flame special effects, making the flame special effects more natural, realistic and coherent.
[0095] Fig. 9 is a flowchart of an optional method for rendering flame special effects according to an embodiment of the present disclosure, such as Fig. 9 As shown, the steps of this method are as follows:
[0096] Step S901, compressing the flame special effect to obtain the target sequence frame texture and wind velocity 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 velocity field map according to the local coordinate system to obtain a target sampling velocity.
[0099] Step S904: offset the original texture coordinates according to the target sampling speed to obtain the target texture coordinates.
[0100] Step S905: sampling the target sequence frame texture to obtain the sampled color and sampled transparency.
[0101] Step S906: decompress the sampled color and the sampled transparency to obtain original sampling information.
[0102] Step S907, performing interpolation fitting on the target sequence frame texture according to the original sampling information to generate a flame special effect.
[0103] Step S908, outputting flame special effects.
[0104] It should be noted that Fig.10 is a schematic diagram of flame special effects acquisition according to one optional embodiment of the present disclosure, such as Fig.10 As shown, the target sequence frame texture is obtained in the asset processing stage. In the game stage, when the game character moves or launches skills in the virtual scene and affects the wind field, the target sequence frame is sampled, and the adjacent target sequence frame textures in multiple target sequence frame textures are interpolated and fitted to generate flame special effects, and the flame special effects are output.
[0105] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present disclosure.
[0106] In this embodiment, a rendering device for flame special effects is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the terms "unit" and "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0107] Fig.11 is a structural block diagram of a rendering device for flame special effects according to one embodiment of the present disclosure, such as Fig.11 As shown, the device includes: a loading module 111, which is used to obtain multiple target sequence frame textures corresponding to the flame special effect, and obtain a wind velocity field map, wherein the wind velocity field map is used to characterize the speed of the wind at different positions in the virtual scene; an offset module 112, which is used to offset the original texture coordinates of the target sequence frame texture based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture; a sampling module 113, which is used to 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; a rendering module 114, which is used to render the flame model based on the multiple target sampling information to generate the flame special effect.
[0108] Optionally, the offset module includes: a first determination 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 velocity field map based on the world coordinates to obtain the target sampling speed corresponding to the target sequence frame texture; and an offset unit, used to offset the original texture coordinates based on the target sampling speed to obtain the target texture coordinates.
[0109] Optionally, the first sampling unit includes: a first sampling subunit, used to sample the wind velocity field map based on the world coordinate system to obtain an initial sampling speed; a coordinate conversion subunit, used to convert the initial sampling speed from the world coordinate system to a local coordinate system corresponding to the flame model to obtain a converted sampling speed; and a speed projection subunit, used to project the converted sampling speed onto the flame model to obtain a target sampling speed.
[0110] Optionally, the first sampling unit also includes: a first acquisition subunit, used to acquire a preset wind speed generated in the virtual scene; a speed adding subunit, used to add the preset wind speed to the initial velocity field to obtain a target velocity field; and a first generation subunit, used to generate a wind velocity field map based on the target velocity field.
[0111] Optionally, the sampling module includes: a second sampling unit, used to sample the color texture based on the target texture coordinates to obtain the sampled color; a third sampling unit, used to sample the transparency texture based on the target texture coordinates to obtain the sampled transparency; and a first acquisition unit, used to obtain target sampling information based on the sampled color and the sampled transparency.
[0112] Optionally, the device includes: a cluster compression module, used to cluster and compress the colors of the original sequence frame texture to obtain the target sequence frame texture; a flame rendering module, used to render the flame model based on multiple target sampling information to generate flame special effects, wherein the flame rendering module includes: a first decompression unit, used to decompress the target sampling information to obtain the original sampling information corresponding to the target sequence frame texture; a first rendering unit, used to render the flame model based on multiple original sampling information to generate flame special effects.
[0113] Optionally, the decompression module includes: a second decompression unit, used to decompress the sampling color included in the target sampling information to obtain the target original color; and a merging unit, used to merge the target original color and the sampling transparency included in the target sampling information to obtain the original sampling information.
[0114] Optionally, the second decompression unit includes: a first determination subunit, used 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 determination subunit, used 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, used to perform interpolation fitting on 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 also includes: a clustering unit, which is used to cluster the original colors of the original sequence frame texture to obtain multiple cluster colors; a second acquisition unit, which is used to obtain compressed colors corresponding to multiple cluster colors based on the brightness of the multiple cluster colors; a first generation unit, which is used to generate a preset mapping relationship based on the compressed colors corresponding to the multiple cluster colors; a third acquisition unit, which is used to obtain compressed colors corresponding to other colors based on the color error between other colors in the original color and two adjacent cluster colors in the preset mapping relationship, wherein the other colors are used to characterize the colors in the original color other than the cluster colors; the second generation unit, which is used to generate a color texture based on the compressed colors corresponding to the cluster colors and the compressed colors corresponding to the other colors; the third generation unit, which is used to generate a transparency texture based on the original transparency of the original sequence frame texture; and a summary unit, which is used to summarize 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 fitting color; a third determination subunit, used to determine two adjacent target cluster colors based on the color error between the fitting color and other colors, wherein the color error between the fitting color corresponding to the two adjacent target cluster colors and the other color is smaller than the color error between the fitting color corresponding to the other two adjacent cluster colors and the other color; and a fourth determination subunit, used to determine that the compressed color corresponding to the two adjacent target cluster colors is 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 among the 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 special effects.
[0118] It should be noted that the above-mentioned units and modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above-mentioned units and modules are all located in the same processor; or, the above-mentioned units and modules are located in different processors in any combination.
[0119] An embodiment of the present disclosure further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0120] Optionally, in this embodiment, the above-mentioned computer-readable storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0121] Optionally, in this embodiment, the computer-readable storage medium may be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.
[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, obtaining a plurality of target sequence frame textures corresponding to the flame special effect, and obtaining a wind velocity field map, wherein the wind velocity field map is used to represent the speed of wind at different positions in the virtual scene;
[0124] Step S2, offsetting the original texture coordinates of the target sequence frame texture based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture;
[0125] Step S3, sampling the target sequence frame texture based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame texture;
[0126] Step S4, rendering the flame model based on the multiple target sampling information to generate flame special effects.
[0127] Optionally, the computer-readable storage medium is also configured to store program codes for executing the following steps: 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 velocity field map based on the world coordinates to obtain the target sampling speed corresponding to the target sequence frame texture; offsetting the original texture coordinates based on the target sampling speed to obtain the target texture coordinates.
[0128] Optionally, the computer-readable storage medium is also configured to store program codes for executing the following steps: sampling the wind velocity field map based on the world coordinate system to obtain an initial sampling speed; converting the initial sampling speed from the world coordinate system to a local coordinate system corresponding to the flame model to obtain a converted sampling speed; and projecting the converted sampling speed onto the flame model to obtain a target sampling speed.
[0129] Optionally, the computer-readable storage medium is also configured to store program codes for executing 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 velocity field map based on the target velocity field.
[0130] Optionally, the computer-readable storage medium is also configured to store program codes for executing the following steps: color texture and transparency texture, sampling the target sequence frame texture based on the target texture coordinates, and obtaining 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; obtaining the target sampling information based on the sampled color and the sampled transparency.
[0131] Optionally, the computer-readable storage medium is further configured to store program codes for executing 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 special effects, including: decompressing the target sampling information to obtain the original sampling information corresponding to the target sequence frame texture; rendering the flame model based on multiple original sampling information to generate flame special effects.
[0132] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: decompressing the sampling color contained in the target sampling information to obtain the target original color; and merging the target original color and the sampling transparency contained in the target sampling information to obtain the original sampling information.
[0133] Optionally, the computer-readable storage medium is also configured to store program code for executing the following steps: determining a target cluster color corresponding to a sampled color from a preset mapping relationship, wherein the preset mapping relationship is used to characterize a mapping relationship between different cluster colors of an original sequence frame texture and different compressed colors, 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 to be a target original color; in response to the number of target cluster colors being multiple, performing interpolation fitting on multiple target cluster colors to obtain a target original color.
[0134] Optionally, the above-mentioned computer-readable storage medium is also configured to store program codes for executing the following steps: clustering the original colors of the original sequence frame texture to obtain multiple cluster colors; based on the brightness of the multiple cluster colors, obtaining compressed colors corresponding to the multiple cluster colors; generating a preset mapping relationship based on the compressed colors corresponding to the multiple cluster colors; based on the color error between other colors in the original color and two adjacent cluster colors in the preset mapping relationship, obtaining compressed colors corresponding to other colors, wherein the other colors are used to characterize the colors in the original color other than the cluster colors; generating a color texture based on the compressed colors corresponding to the cluster colors and the compressed colors corresponding to the other colors; generating a transparency texture based on the original transparency of the original sequence frame texture; summarizing the color texture and the transparency texture to obtain the target sequence frame texture.
[0135] Optionally, the computer-readable storage medium is also configured to store program codes for executing the following steps: performing interpolation fitting on two adjacent cluster colors to obtain a fitted color; determining two adjacent target cluster colors based on a color error between the fitted color and other colors, wherein a color error between the fitted color corresponding to the two adjacent target cluster colors and other colors is smaller than a color error between the fitted color corresponding to the other two adjacent cluster colors and other colors; and determining that the compressed color corresponding to the two adjacent target cluster colors is the compressed color corresponding to the other colors.
[0136] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: linearly interpolating two adjacent original sampling information among multiple original sampling information to obtain transition information; rendering a flame model based on the multiple original sampling information and the transition information to generate flame special effects.
[0137] In the computer-readable storage medium of this embodiment, a technical solution for a method for rendering flame special effects is provided. The method adopts the steps of obtaining multiple target sequence frame textures corresponding to the flame special effects and obtaining a wind velocity field map; offsetting the original texture coordinates of the target sequence frame texture based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture; sampling the target sequence frame texture based on the target texture coordinates to obtain the target sampling information corresponding to the target sequence frame texture; rendering the flame model based on the multiple target sampling information to generate the flame special effects. It should be noted that multiple target sequence frame textures corresponding to the flame special effects are obtained, wherein the sequence frame textures are composed of a large number of image frames, and compressing the sequence frame textures can reduce memory consumption. And based on the wind velocity field map, the original texture coordinates of the target sequence frame texture are offset to obtain the target texture coordinates of the target sequence frame texture, and then the target sequence frame texture is sampled according to the target texture coordinates, so that the target sequence frame texture of the flame can be integrated with the wind field in the virtual scene to reflect the influence of the wind field on the flame, so as to achieve the purpose of improving the interactivity of the flame special effect and the wind field in the virtual scene, thereby solving the technical problem of matching the flame special effect with the virtual scene and enhancing the visual effect, and thus achieving the technical effect of improving the interactivity of the flame special effect with the virtual scene.
[0138] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0139] In an exemplary embodiment of the present application, a program product capable of implementing the above method of the present embodiment is stored on a computer-readable storage medium. In some possible implementations, various aspects of the embodiments of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps described in the above "Exemplary Method" section of the present embodiment according to various exemplary implementations of the present disclosure.
[0140] According to the program product for implementing the above method in the embodiment of the present disclosure, it can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the embodiment of the present disclosure is not limited to this. In the embodiment of the present disclosure, the computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0141] The program product may be in any combination of one or more computer-readable media. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive) of computer-readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0142] It should be noted that the program code contained in the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0143] An embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[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 may be configured to perform the following steps through a computer program:
[0146] Step S1, obtaining a plurality of target sequence frame textures corresponding to the flame special effect, and obtaining a wind velocity field map, wherein the wind velocity field map is used to represent the speed of wind at different positions in the virtual scene;
[0147] Step S2, offsetting the original texture coordinates of the target sequence frame texture based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture;
[0148] Step S3, sampling the target sequence frame texture based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame texture;
[0149] Step S4, rendering the flame model based on the multiple target sampling information to generate flame special effects.
[0150] Optionally, the above-mentioned processor can also be configured to perform the following steps through a computer program: 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; sample the wind velocity field map based on the world coordinates to obtain the target sampling speed corresponding to the target sequence frame texture; offset the original texture coordinates based on the target sampling speed to obtain the target texture coordinates.
[0151] Optionally, the processor can also be configured to perform the following steps through a computer program: sampling the wind velocity field map based on the world coordinate system to obtain an initial sampling speed; converting the initial sampling speed from the world coordinate system to a local coordinate system corresponding to the flame model to obtain a converted sampling speed; and projecting the converted sampling speed onto the flame model to obtain a target sampling speed.
[0152] Optionally, the processor may also be configured to perform the following steps through a computer program: obtaining a preset wind speed generated in a virtual scene; adding the preset wind speed to an initial speed field to obtain a target speed field; and generating a wind speed field map based on the target speed field.
[0153] Optionally, the above-mentioned processor can also be configured to perform the following steps through a computer program: color texture and transparency texture, sampling the target sequence frame texture based on the target texture coordinates, and obtaining 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; obtaining the target sampling information based on the sampled color and the sampled transparency.
[0154] Optionally, the processor may also be configured to perform the following steps through a computer program: clustering and compressing the colors of the original sequence frame texture to obtain a target sequence frame texture; rendering a flame model based on multiple target sampling information to generate a flame special effect, including: decompressing the target sampling information to obtain the original sampling information corresponding to the target sequence frame texture; rendering the flame model based on multiple original sampling information to generate a flame special effect.
[0155] Optionally, the processor may also be configured to perform the following steps through a computer program: decompressing the sampling color included in the target sampling information to obtain the target original color; and merging the target original color and the sampling transparency included in the target sampling information to obtain the original sampling information.
[0156] Optionally, the processor can also be configured to perform the following steps through a computer program: determining a target cluster color corresponding to a sampled color from a preset mapping relationship, wherein the preset mapping relationship is used to characterize a mapping relationship between different cluster colors of an original sequence frame texture and different compressed colors, 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 to be the target original color; in response to the number of target cluster colors being multiple, performing interpolation fitting on multiple target cluster colors to obtain the target original color.
[0157] Optionally, the processor can also be configured to perform the following steps through 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 color and two adjacent cluster colors in the preset mapping relationship, wherein the other colors are used to characterize the colors in the original color other than the cluster colors; generating a color texture based on the compressed colors corresponding to the cluster colors and the compressed colors corresponding to the 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 can also be configured to execute the following steps through a computer program: interpolate and fit two adjacent cluster colors to obtain a fitted color; determine two adjacent target cluster colors based on a color error between the fitted color and other colors, wherein a color error between the fitted color corresponding to the two adjacent target cluster colors and other colors is smaller than a color error between the fitted color corresponding to the other two adjacent cluster colors and other colors; and determine that the compressed color corresponding to the two adjacent target cluster colors is the compressed color corresponding to the other colors.
[0159] Optionally, the processor may also be configured to execute the following steps through a computer program: linearly interpolate two adjacent original sampling information among the multiple original sampling information to obtain transition information; and render the flame model based on the multiple original sampling information and the transition information to generate flame special effects.
[0160] In the electronic device of this embodiment, a technical solution for a method for rendering flame special effects is provided. Multiple target sequence frame textures corresponding to the flame special effect are obtained, and a wind velocity field map is obtained; the original texture coordinates of the target sequence frame texture are offset based on the wind velocity field map to obtain the target texture coordinates of the target 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; the flame model is rendered based on the multiple target sampling information to generate the flame special effect. It should be noted that multiple target sequence frame textures corresponding to the flame special effect are obtained, wherein the sequence frame texture is composed of a large number of image frames, and compressing the sequence frame texture can reduce memory consumption. And based on the wind velocity field map, the original texture coordinates of the target sequence frame texture are offset to obtain the target texture coordinates of the target sequence frame texture, and then the target sequence frame texture is sampled according to the target texture coordinates, so that the target sequence frame texture of the flame can be integrated with the wind field in the virtual scene to reflect the influence of the wind field on the flame, so as to achieve the purpose of improving the interactivity of the flame special effect and the wind field in the virtual scene, thereby solving the technical problem of matching the flame special effect with the virtual scene and enhancing the visual effect, and thus achieving the technical effect of improving the interactivity of the flame special effect with the virtual scene.
[0161] Fig.12 is a schematic diagram of an electronic device according to an embodiment of the present disclosure. Fig.12 As shown, the electronic device 1200 is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0162] like Fig.12 As shown, the electronic device 1200 is in the form of a general 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 the memory 1220 and the processor 1210), and a display 1240.
[0163] The memory 1220 stores program codes, which can be executed by the processor 1210, so that the processor 1210 executes the steps described in the method section of the embodiment of the present application according to various exemplary embodiments of the present disclosure.
[0164] The memory 1220 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 12201 and / or a cache memory unit 12202, and may further include a read-only memory unit (ROM) 12203, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0165] In some examples, the memory 1220 may also include a program / utility 12204 having a set (at least one) of program modules 12205, such program modules 12205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include the implementation of a network environment. The memory 1220 may further include a memory remotely disposed relative to the processor 1210, and these remote memories may be connected to the electronic device 1200 via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0166] The bus 1230 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a local bus of the processor 1210, or a bus using any of a variety of bus architectures.
[0167] The display 1240 may be, for example, a touch screen type liquid crystal display (LCD) that enables a user to interact with a user interface of the electronic device 1200 .
[0168] Optionally, the electronic device 1200 may also communicate with one or more external devices 1300 (e.g., keyboards, pointing devices, Bluetooth devices, 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., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 1250. Furthermore, the electronic device 1200 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 1260. Fig.12 As shown, the network adapter 1260 communicates with other modules of the electronic device 1200 via the bus 1230. It should be understood that although Fig.12 Not shown, other hardware and / or software modules may be used in conjunction with the 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 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] It can be understood by those skilled in the art that Fig.12The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig.12 More or fewer components as shown, or with Figure 1 The memory 1220 may be used to store computer programs and corresponding data, such as the computer programs and corresponding data corresponding to the method for rendering the flame special effect in the embodiment of the present disclosure. The processor 1210 executes various functional applications and data processing by running the computer programs stored in the memory 1220, that is, implementing the method for rendering the flame special effect.
[0171] The serial numbers of the above-mentioned embodiments of the present disclosure are only for description and do not represent the advantages or disadvantages of the embodiments.
[0172] In the above embodiments of the present disclosure, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made 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. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0174] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0175] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0176] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially 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, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0177] The above is only a preferred embodiment of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present disclosure. These improvements and modifications should also be regarded as the scope of protection of the present disclosure.
Claims
1. A method for rendering flame special effects, characterized in that: include: Obtaining a target sequence frame texture corresponding to the flame special effect, and obtaining a wind velocity field map, wherein the wind velocity field map is used to represent the speed of wind at different positions in the virtual scene; Based on the wind velocity field map, the original texture coordinates of the target sequence frame texture are offset to obtain the target texture coordinates of the target sequence frame 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; The flame model is rendered based on the plurality of target sampling information to generate the flame special effect.
2. The method according to claim 1, characterized in that The original texture coordinates of the target sequence frame texture are offset based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture, 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; Sampling the wind velocity field map based on the world coordinates to obtain a target sampling velocity corresponding to the target sequence frame texture; The original texture coordinates are offset based on the target sampling speed to obtain the target texture coordinates.
3. The method according to claim 2, characterized in that Sampling the wind velocity field map based on the world coordinates to obtain the target sampling velocity corresponding to the target sequence frame texture includes: Sampling the wind velocity field map based on the world coordinates to obtain an initial sampling velocity; Converting the initial sampling speed from the world coordinate system to a local coordinate system corresponding to the flame model to obtain a converted sampling speed; The converted sampling speed is projected onto the flame model to obtain the target sampling speed.
4. The method according to claim 2, characterized in that: The method further comprises: Obtaining a preset wind speed generated in the virtual scene; Adding the preset wind speed to the initial speed field to obtain a target speed field; The wind velocity field map is generated based on the target velocity field.
5. The method according to claim 1, characterized in that The target sequence frame texture includes: a color texture and a transparency 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 a sampled color; Sampling the transparency texture based on the target texture coordinates to obtain a sampled transparency; The target sampling information is obtained based on the sampling color and the sampling transparency.
6. The method according to claim 1, characterized in that The method further comprises: Performing clustering compression on the colors of the original sequence frame texture to obtain the target sequence frame texture; Rendering the flame model based on the plurality of target sampling information to generate the flame special effect includes: Decompressing the target sampling information to obtain original sampling information corresponding to the target sequence frame texture; The flame model is rendered based on the plurality of original sampling information to generate the flame special effect.
7. The method according to claim 6, characterized in that Decompressing the target sampling information to obtain the original sampling information corresponding to the target sequence frame texture includes: Decompressing the sampled color included in the target sampling information to obtain the target original color; The target original color and the sampling transparency included in the target sampling information are combined to obtain the original sampling information.
8. The method according to claim 7, characterized in that Decompressing the sampled color included in the target sampling information to obtain the target original color, including: Determining a target cluster color corresponding to the sampled color from a preset mapping relationship, wherein the preset mapping relationship is used to characterize a mapping relationship between different cluster colors of the original sequence frame texture and different sampled colors, and the different cluster colors are colors obtained by clustering different original colors in the original sequence frame texture; In response to the number of the target cluster colors being one, determining the target cluster color to be the target original color; In response to the number of the target cluster colors being multiple, interpolation fitting is performed on the multiple target cluster colors to obtain the target original color.
9. The method according to claim 6, characterized in that Clustering and compressing the colors of the original sequence frame texture to obtain the target sequence frame texture includes: Clustering the original colors of the original sequence frame texture to obtain a plurality of clustered colors; Based on the brightness of the multiple cluster colors, obtaining compressed colors corresponding to the multiple cluster colors; Generate a preset mapping relationship based on the compressed colors corresponding to the multiple cluster colors; Based on the color error between other colors in the original color and two adjacent cluster colors in the preset mapping relationship, a compressed color corresponding to the other colors is obtained, wherein the other colors are used to represent the colors in the original color other than the cluster colors; Generate a color texture based on the compressed color corresponding to the cluster color and the compressed colors corresponding to the other colors; Generate a transparency texture based on the original transparency of the original sequence frame texture; The color texture and the transparency texture are aggregated to obtain the target sequence frame texture.
10. The method according to claim 9, characterized in that Based on the color errors between other colors in the original colors and two adjacent cluster colors in the preset mapping relationship, obtaining compressed colors corresponding to the other colors includes: Performing interpolation fitting on the two adjacent cluster colors to obtain a fitting color; Based on the color error between the fitting color and the other colors, determining two adjacent target cluster colors, wherein the color error between the fitting color corresponding to the two adjacent target cluster colors and the other colors is smaller than the color error between the fitting color corresponding to other two adjacent cluster colors and the other colors; Determine that the compressed colors corresponding to the two adjacent target cluster colors are the compressed colors corresponding to the other colors.
11. The method according to claim 1, characterized in that: Rendering the flame model based on the plurality of target sampling information to generate the flame special effect includes: Performing linear interpolation on two adjacent target sampling information among the plurality of target sampling information to obtain transition information; The flame model is rendered based on the plurality of target sampling information and the transition information to generate the flame special effect.
12. A flame special effect rendering device, characterized in that: include: A loading module is used to obtain the target sequence frame texture corresponding to the flame special effect and obtain a wind velocity field map, wherein the wind velocity field map is used to represent the speed of wind at different positions in the virtual scene; An offset module, used for offsetting the original texture coordinates of the target sequence frame texture based on the wind velocity field map to obtain the target texture coordinates of the target sequence frame texture; A sampling module, used for sampling the target sequence frame texture based on the target texture coordinates to obtain target sampling information corresponding to the target sequence frame texture; A rendering module is used to render the flame model based on the plurality of target sampling information to generate the flame special effect.
13. 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 according to any one of claims 1 to 11 when executed by a processor.
14. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Three-dimensional flame dynamic simulation method based on particle system
CN110310348A
Method and device for adding flame special effect in picture
CN114004920A
Generation method and device of wind field effect picture, storage medium and computer equipment
CN114768251A
Methods of applying virtual world elements into augmented reality
WO2020191337A1