Method, device, equipment and storage medium for generating lightning special effects in virtual scenes

By obtaining the line of sight direction and ground projection position in the virtual scene, generating and splitting line segments to form a topological structure, and performing grid processing, the problem of a single form of lightning special effects in the existing technology is solved, and dynamic adjustment and dynamic adjustment of lightning special effects are realized. Rich forms improve user experience.

CN114367106BActive Publication Date: 2025-01-24TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210028513.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-11
Publication Date
2025-01-24
Estimated Expiration
2042-01-11

AI Technical Summary

Technical Problem

The lightning special effects in the prior art have a single form and lack effective simulation of the realism of the lightning process.

Method used

Determine the reference plane by obtaining the sight direction of the virtual object and the ground projection location of the lightning special effects; the line segment that is released and the end position is released, and random division of the line segments based on the division parameters. ; Grid processing of topology, generate lightning special effects models, and draw lightning special effects through rendering programs.

Benefits of technology

The dynamic adjustment of the Lightning Effective Form has enriched the lightning special effects in the virtual scene and enhanced the user's immersive experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114367106B_ABST
    Figure CN114367106B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, electronic device, computer-readable storage medium and computer program product for generating lightning special effects in a virtual scene; the method includes: obtaining the sight direction of a virtual object and the ground projection position of a lightning special effect to be generated, determining a reference plane for drawing the lightning special effect in the virtual scene according to the sight direction and the ground projection position; obtaining the release start position and release end position set for the lightning special effect in the reference plane, generating a line segment passing through the release start position and the release end position; obtaining the splitting parameters set for the lightning special effect, performing random splitting processing on the line segment based on the splitting parameters, and obtaining a topological structure including a trunk and multiple branches; performing gridding processing on the topological structure to obtain a lightning special effect model; calling a rendering program based on the lightning special effect model, so that the rendering program draws the lightning special effect in the reference plane. Through the present application, the form of the lightning special effect can be dynamically adjusted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a method, device, electronic device and computer-readable storage medium for generating lightning special effects in a virtual scene. Background Art

[0002] With the continuous development of hardware technology and Internet technology, weather systems have become standard in virtual scenes (such as games). Among them, lightning effects are an important element in the weather system to enrich the performance of rainy days. The effects of lightning and thunder on rainy days will make the scene more realistic.

[0003] However, in the solutions provided by the related art, the lightning special effects are usually prepared as fixed models, which are placed at designated positions in the scene when needed and differentiated by adjusting the size and rotation. Alternatively, the preset maps on the sky box are directly used, and the lightning process is simulated by changing the shader.

[0004] It can be seen that the solutions provided by related technologies lack realistic simulation of the lightning process, and the form of lightning special effects is relatively simple. Summary of the invention

[0005] The embodiments of the present application provide a method, device, electronic device, computer-readable storage medium and computer program product for generating lightning special effects in a virtual scene, which can dynamically adjust the form of lightning special effects, enrich the form of lightning special effects in the virtual scene, and adapt to the needs of different weather performances.

[0006] The technical solution of the embodiment of the present application is implemented as follows:

[0007] The present application embodiment provides a method for generating lightning special effects in a virtual scene, comprising:

[0008] Acquire the sight line direction of the virtual object and the ground projection position of the lightning special effect to be generated, and determine the reference plane for drawing the lightning special effect in the virtual scene according to the sight line direction and the ground projection position;

[0009] Acquire a release start position and a release end position set for the lightning special effect in the reference plane, and generate a line segment passing through the release start position and the release end position;

[0010] Acquire a splitting parameter set for the lightning special effect, and perform random splitting processing on the line segment based on the splitting parameter to obtain a topological structure including a trunk and multiple branches;

[0011] Performing mesh processing on the topological structure to obtain a lightning special effects model;

[0012] A rendering program is called based on the lightning special effect model, so that the rendering program draws the lightning special effect in the reference plane.

[0013] The embodiment of the present application provides a device for generating lightning special effects in a virtual scene, comprising:

[0014] An acquisition module, used to acquire the sight line direction of the virtual object and the ground projection position of the lightning special effect to be generated;

[0015] A determination module, used to determine a reference plane for drawing the lightning special effect in a virtual scene according to the sight line direction and the ground projection position;

[0016] The acquisition module is further used to acquire a release start position and a release end position set for the lightning special effect in the reference plane;

[0017] A generating module, used for generating a line segment passing through the release starting position and the release ending position;

[0018] The acquisition module is further used to acquire the splitting parameters set for the lightning special effect;

[0019] A splitting module, used for performing random splitting processing on the line segment based on the splitting parameter to obtain a topological structure including a trunk and multiple branches;

[0020] A meshing module, used for meshing the topological structure to obtain a lightning special effects model;

[0021] The drawing module is used to call a rendering program based on the lightning special effect model, so that the rendering program draws the lightning special effect in the reference plane.

[0022] In the above scheme, the splitting module is also used to randomly determine multiple splitting points on the line segment based on the splitting parameters; generate the main trunk based on the release start position, the release end position, and the multiple splitting points; and randomly split the multiple branches on the multiple splitting points according to the set splitting probability.

[0023] In the above scheme, the splitting module is also used to iteratively perform the following processing until the number of splitting points is greater than or equal to the number threshold: randomly determine a first splitting point on the line segment based on the splitting parameter; offset the first splitting point, and generate a first sub-line segment of the first splitting point after the release start position and the offset processing, and a second sub-line segment of the first splitting point after the offset processing and the release end position; randomly determine a second splitting point on the first sub-line segment based on the splitting parameter, and randomly determine a third splitting point on the second sub-line segment; offset the second splitting point and the third splitting point respectively; generate a third sub-line segment of the second splitting point after the release start position and the offset processing, a fourth sub-line segment of the second splitting point after the offset processing and the first splitting point after the offset processing, a fifth sub-line segment of the first splitting point after the offset processing and the third splitting point after the offset processing, and a sixth sub-line segment of the third splitting point after the offset processing and the release end position.

[0024] In the above scheme, the splitting module is also used to randomly determine a first offset value corresponding to the first splitting point from a set offset range; according to the first offset value, the first splitting point is moved in a direction perpendicular to the line segment; and is used to randomly determine a second offset value corresponding to the second splitting point and a third offset value corresponding to the third splitting point from a set offset range; according to the second offset value, the second splitting point is moved in a direction perpendicular to the first sub-line segment, and according to the third offset value, the third splitting point is moved in a direction perpendicular to the second sub-line segment.

[0025] In the above scheme, the splitting module is also used to perform the following processing for each splitting point: obtain the level at which the splitting point is located on the trunk; determine the splitting probability corresponding to the splitting point based on the level and the splitting conditions of other splitting points on the trunk that are adjacent to the splitting point; when the splitting probability is greater than the probability threshold, split a corresponding branch at the splitting point.

[0026] In the above scheme, the splitting module is also used to randomly determine a splitting angle value from a set splitting angle range; randomly determine a splitting length value from a set splitting length range; and use the splitting point after offset processing as the starting point to generate a branch extending along the splitting angle value and with a length equal to the splitting length value.

[0027] In the above scheme, the meshing module is also used to cover the topological structure with polygonal patches, and adjust the positions of common vertices of two adjacent polygonal patches corresponding to the connection of any two branches included in the topological structure to obtain the lightning special effects model.

[0028] In the above scheme, the acquisition module is also used to obtain the depth ratio information, level information, and transparency information corresponding to the multiple branches respectively; the device also includes a normalization module, which is used to normalize the depth ratio information, level information, and transparency information; the device also includes a storage module, which is used to store the normalized depth ratio information, level information, and transparency information in the three channels of color information included in the lightning special effects model.

[0029] In the above scheme, the drawing module is also used to pass the vertex coordinates of each polygonal face included in the lightning special effects model into the vertex shader, so that the vertex shader performs primitive assembly processing on the vertex coordinates according to the programmable rendering pipeline to generate corresponding primitives; pass the primitives into the fragment shader, so that the fragment shader generates fragments after rasterizing the primitives, and update the color and transparency of the fragments according to the set shading strategy.

[0030] In the above scheme, the acquisition module is also used to obtain the performance parameters of the terminal device used to display the virtual scene; determine the splitting parameters that match the performance parameters from multiple groups of pre-configured candidate splitting parameters, wherein the complexity of the lightning special effects corresponding to the splitting parameters that match the performance parameters is positively correlated with the performance parameters.

[0031] In the above scheme, the acquisition module is also used to obtain lightning data of real lightning in nature; the device also includes a prediction module, which is used to perform predictive processing on the lightning data based on a machine learning model to obtain the fractal rules and numerical relationships of the real lightning; the determination module is also used to determine the splitting parameters of the lightning special effects based on the fractal rules and numerical relationships.

[0032] An embodiment of the present application provides an electronic device, including:

[0033] A memory for storing executable instructions;

[0034] The processor is used to implement the method for generating lightning special effects in a virtual scene provided in an embodiment of the present application when executing the executable instructions stored in the memory.

[0035] An embodiment of the present application provides a computer-readable storage medium storing executable instructions for causing a processor to execute instructions to implement a method for generating lightning special effects in a virtual scene provided by an embodiment of the present application.

[0036] An embodiment of the present application provides a computer program product, including a computer program or instructions, which are used to cause a processor to execute and implement the method for generating lightning special effects in a virtual scene provided by the embodiment of the present application.

[0037] The embodiments of the present application have the following beneficial effects:

[0038] Based on the splitting parameters of the lightning special effect, the line segments passing through the release start position and the release end position are randomly split to obtain the topological structure corresponding to the lightning special effect, and the topological structure is gridded. Subsequently, the lightning special effect is drawn based on the lightning special effect model obtained after the gridding process. In this way, since the topological structure corresponding to the lightning special effect is obtained by randomly splitting the line segments based on the splitting parameters, the shape of the lightning special effect drawn in the virtual scene is different during each lightning process, that is, the shape of the lightning special effect can be dynamically adjusted based on the splitting parameters, enriching the shape of the lightning special effect in the virtual scene to adapt to the needs of different weather performances, while also enhancing the user's immersive experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a schematic diagram of the architecture of a lightning special effect generation system in a virtual scene provided by an embodiment of the present application;

[0040] Figure 2 is a schematic diagram of the structure of a terminal device 400 provided in an embodiment of the present application;

[0041] Figure 3 It is a flowchart of a method for generating lightning special effects in a virtual scene provided by an embodiment of the present application;

[0042] Figure 4 It is a schematic diagram of the principle of determining a reference plane for drawing lightning special effects in a virtual scene provided by an embodiment of the present application;

[0043] Figure 5 It is a flowchart of a method for generating lightning special effects in a virtual scene provided by an embodiment of the present application;

[0044] Figure 6 It is a schematic diagram of the splitting point generation principle provided in an embodiment of the present application;

[0045] Figure 7 It is a schematic diagram of the branch generation principle provided in the embodiment of the present application;

[0046] Figure 8It is a flowchart of a method for generating lightning special effects in a virtual scene provided by an embodiment of the present application;

[0047] 9A to 9D It is a schematic diagram of a lightning special effect generated in a virtual scene provided by an embodiment of the present application;

[0048] Fig.10 It is a flowchart of a method for generating lightning special effects in a virtual scene provided by an embodiment of the present application;

[0049] Fig.11 It is a schematic diagram of constructing a lightning special effect generation plane provided in an embodiment of the present application;

[0050] Fig.12 It is a schematic diagram of the trunk splitting principle provided in an embodiment of the present application;

[0051] Fig.13 This is a schematic diagram of a lightning structure after adding branches provided in an embodiment of the present application;

[0052] Fig.14A and Fig. 14B It is a schematic diagram of a lightning special effect model provided by the relevant technology;

[0053] Fig. 14C It is a schematic diagram of a lightning special effects model provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0055] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0056] In the following description, the terms "first\second\..." involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\..." can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0057] In the following description, the term "plurality" referred to means at least two.

[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0059] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0060] 1) Weather system (TOD, Time Of Day): A dynamic system commonly used in virtual scenes (such as games) to simulate game environments and lighting changes under different weather conditions, such as the transition between sunny and rainy weather, and the alternation of day and night. Among them, lightning effects are an important element in the weather system to enrich the performance of rainy days.

[0061] 2) Linear lightning: Different from ball lightning and chain lightning, linear lightning has a clear structure of trunk and branches (also known as twigs).

[0062] 3) Shader: refers to an editable program used to implement image rendering to replace the fixed rendering pipeline, including vertex shader and fragment shader. The vertex shader implements vertex operations such as space conversion, color, texture coordinates, lighting, etc. through programming; the fragment shader is mainly used in the process of controlling the color display on the screen through programming. This stage mainly processes independent fragments generated after rasterization, and uses the shader to calculate the final color of the fragment and its depth value.

[0063] 4) Topological structure: Topology refers to a method of abstracting entities into points that are independent of their size and shape, and abstracting the lines connecting entities into lines, and then representing the relationship between these points and lines in the form of a graph, the purpose of which is to study the connection between these points and lines. The graph representing the relationship between points and lines is called a topological structure graph. In the embodiment of the present application, the basic structure of the lightning special effect obtained by randomly splitting the line segments passing through the release start position and the release end position based on the splitting parameters is called a topological structure.

[0064] 5) Fractal: A mathematical concept, referring to a rough or fragmentary geometric shape that can be divided into several parts, and each part is (at least approximately) a reduced shape of the whole. In other words, fractal images have the property of self-similarity.

[0065] 6) Rasterization: refers to the process of converting a primitive into a two-dimensional image. Each point on the two-dimensional image contains color, depth and texture data, and the point and related information are called a fragment.

[0066] 7) Virtual scene: It is the scene displayed (or provided) when the application is running on the terminal device. The scene can be a simulation environment of the real world, a semi-simulation and semi-fictitious environment, or a purely fictitious virtual environment. The virtual scene can be any one of a two-dimensional virtual scene, a 2.5-dimensional virtual scene, or a three-dimensional virtual scene. The embodiment of the present application does not limit the dimension of the virtual scene. For example, the virtual scene may include the sky, land, ocean, etc. The land may include environmental elements such as deserts and cities, and users can control virtual objects to move in the virtual scene.

[0067] 8) Virtual objects: images of various people and objects that can interact in a virtual scene, or movable objects in a virtual scene. The movable objects can be virtual characters, virtual animals, cartoon characters, etc., such as characters and animals displayed in a virtual scene. The virtual object can be a virtual image in a virtual scene that represents a user. A virtual scene can include multiple virtual objects, each of which has its own shape and volume in the virtual scene and occupies a part of the space in the virtual scene.

[0068] The embodiments of the present application provide a method, device, electronic device, computer-readable storage medium, and computer program product for generating lightning special effects in a virtual scene, which can dynamically adjust the form of lightning special effects, enrich the form of lightning special effects in the virtual scene, and adapt to the needs of different weather performances. The following describes an exemplary application of the electronic device provided by the embodiments of the present application. The electronic device provided by the embodiments of the present application can be implemented as various types of terminal devices, can also be implemented as a server, and can also be implemented by a terminal device and a server in collaboration.

[0069] For example, see Figure 1 , Figure 1 It is a schematic diagram of the architecture of the lightning special effects generation system 100 in the virtual scene provided in the embodiment of the present application. In order to realize the application of supporting the form of lightning special effects in a rich virtual scene, the terminal device 400 is connected to the server 200 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.

[0070] In some embodiments, taking the electronic device as a terminal device as an example, the method for generating lightning special effects in a virtual scene provided by the embodiment of the present application can be implemented by the terminal device alone. For example, when it is necessary to generate lightning special effects in a virtual scene (for example, the weather system controls the weather in the virtual scene to change from sunny to rainy), it can be achieved by Figure 1 The terminal device 400 shown in the figure separately obtains the sight direction (e.g., the current orientation of the game character) of the virtual object (e.g., the game character controlled by the current user in the virtual scene) displayed in the human-computer interaction interface of the client 410 (e.g., the stand-alone / offline mode game application) and the ground projection position of the lightning special effect to be generated, and determines the reference plane for drawing the lightning special effect in the virtual scene according to the sight direction and the ground projection position; then the terminal device 400 obtains the release start position and release end position set for the lightning special effect in the reference plane (e.g., the game planner sets the release start position and release end position for the lightning special effect in the reference plane). The terminal device 400 can then obtain the splitting parameters set for the lightning special effect (for example, the splitting parameters set by the game planner for the lightning special effect), and randomly split the line segment based on the splitting parameters to obtain a topological structure including a main trunk and multiple branches. Finally, the terminal device 400 can grid the obtained topological structure to obtain a lightning special effect model, and call the rendering program based on the lightning special effect model to enable the rendering program to draw the lightning special effect in the reference plane.

[0071] In some other embodiments, the method for generating lightning special effects in a virtual scene provided in the embodiment of the present application can also be performed by Figure 1The terminal device 400 and the server 200 shown in the figure are implemented in collaboration. For example, a client 410 (such as a network version of a game application) is running on the terminal device 400. When it is necessary to generate a lightning effect in a virtual scene (for example, the weather system controls the weather in the virtual scene to change from sunny to rainy), the client 410 sends the sight line direction of the virtual object to the server 200 through the network 300, so that the server 200 determines the reference plane for drawing the lightning effect in the virtual scene according to the received sight line direction of the virtual object and the ground projection position of the lightning effect to be generated. Then, the server 200 obtains the release start position and release end position set for the lightning effect in the reference plane, and generates a line segment passing through the release start position and the release end position. Then, the server 200 can also obtain the segment set for the lightning effect. Split parameters (for example, game planners can pre-configure multiple groups of split parameters for lightning special effects and upload them to server 200, so that server 200 can select an adaptive group of split parameters from multiple groups of split parameters according to the performance parameters of terminal device 400), and randomly split the line segments based on the split parameters to obtain a topological structure including a trunk and multiple branches; finally, server 200 meshes the obtained topological structure to obtain a lightning special effects model, and returns the obtained lightning special effects model and the reference plane used to draw the lightning special effects in the virtual scene to client 410, so that client 410 can call the rendering program based on the lightning special effects model returned by server 200, so that the rendering program draws the lightning special effects in the reference plane.

[0072] In some embodiments, the embodiments of the present application can be implemented with the help of cloud technology (Cloud Technology). Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and network within a wide area network or a local area network to achieve data calculation, storage, processing, and sharing.

[0073] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources.

[0074] For example, Figure 1The server 200 shown in the figure can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms. The terminal device 400 can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited to this. The terminal device 400 and the server 200 can be directly or indirectly connected by wired or wireless communication, which is not limited in the embodiments of the present application.

[0075] In other embodiments, the terminal device 400 or the server 200 can implement the lightning special effects generation method in the virtual scene provided by the embodiment of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a native application (APP, Application), that is, a program that needs to be installed in the operating system to run, such as a game application (corresponding to the client 410 above); it can also be a small program, that is, a program that can be run only after being downloaded to a browser environment; it can also be a small program that can be embedded in any APP, such as a small program component embedded in a game application, wherein the small program component can be controlled to run or closed by the user. In short, the above-mentioned computer program can be an application, module or plug-in in any form.

[0076] The structure of the electronic device provided in the embodiment of the present application is described below. Taking the electronic device provided in the embodiment of the present application as a terminal device as an example, it can be understood that in the case where the electronic device is a server, Figure 2 Some of the structures shown in FIG. 1 (such as the user interface, the presentation module, and the input processing module) may be omitted. Figure 2 , Figure 2 is a schematic diagram of the structure of a terminal device 400 provided in an embodiment of the present application, Figure 2 The terminal device 400 shown includes: at least one processor 420, a memory 460, at least one network interface 430 and a user interface 440. The various components in the terminal device 400 are coupled together via a bus system 450. It is understood that the bus system 450 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 450 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 450 is not shown in FIG. Figure 2 Various buses are labeled as bus system 450 .

[0077] The processor 420 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0078] The user interface 440 includes one or more output devices 441 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 440 also includes one or more input devices 442, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.

[0079] The memory 460 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard drives, optical drives, etc. The memory 460 may optionally include one or more storage devices that are physically remote from the processor 420.

[0080] The memory 460 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 460 described in the embodiments of the present application is intended to include any suitable type of memory.

[0081] In some embodiments, memory 460 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.

[0082] Operating system 461, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;

[0083] A network communication module 462, used to reach other electronic devices via one or more (wired or wireless) network interfaces 430, exemplary network interfaces 430 include: Bluetooth, Wireless Compatibility Authentication (WiFi), and Universal Serial Bus (USB), etc.;

[0084] a presentation module 463 for enabling presentation of information via one or more output devices 441 (e.g., display screen, speaker, etc.) associated with the user interface 440 (e.g., a user interface for operating peripherals and displaying content and information);

[0085] The input processing module 464 is used to detect one or more user inputs or interactions from one of the one or more input devices 442 and translate the detected inputs or interactions.

[0086] In some embodiments, the lightning special effects generating device in the virtual scene provided in the embodiments of the present application can be implemented in a software manner. Figure 2 The lightning special effect generating device 465 in the virtual scene stored in the memory 460 is shown, which can be software in the form of programs and plug-ins, including the following software modules: acquisition module 4651, determination module 4652, generation module 4653, splitting module 4654, gridding module 4655, drawing module 4656, normalization module 4657, storage module 4658 and prediction module 4659. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. It should be pointed out that in Figure 2 For the sake of convenience, all the above modules are shown at once. In actual applications, it is not ruled out that the lightning special effect generating device 465 in the virtual scene only includes the implementation of the acquisition module 4651, the determination module 4652, the generation module 4653, the splitting module 4654, the gridding module 4655 and the drawing module 4656. The functions of each module will be explained below.

[0087] In other embodiments, the lightning special effect generating device in the virtual scene provided by the embodiments of the present application can be implemented in hardware. As an example, the lightning special effect generating device in the virtual scene provided by the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the lightning special effect generating method in the virtual scene provided by the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs) or other electronic components.

[0088] The following will illustrate the method for generating lightning special effects in a virtual scene provided by the embodiment of the present application in combination with the exemplary application and implementation of the electronic device provided above in the embodiment of the present application. As mentioned above, the method for generating lightning special effects in a virtual scene described below can be implemented by a terminal device or a server alone, or by a terminal device and a server in collaboration, and will not be repeated.

[0089] See also Figure 3 , Figure 3 is a flow chart of a method for generating lightning special effects in a virtual scene provided by an embodiment of the present application, which will be combined with Figure 3 The steps shown are explained.

[0090] In step 101, the sight line direction of the virtual object and the ground projection position of the lightning special effect to be generated are obtained, and a reference plane for drawing the lightning special effect in the virtual scene is determined according to the sight line direction and the ground projection position.

[0091] In some embodiments, when it is necessary to generate lightning effects in a virtual scene, the sight line direction of the virtual object displayed in the virtual scene (such as the virtual object currently controlled by the user) and the ground projection position of the lightning effects to be generated can be obtained. Subsequently, the reference plane for drawing the lightning effects in the virtual scene can be determined based on the obtained sight line direction and ground projection position of the virtual object. For example, since the location where the lightning effects are generated is usually very far from the combat area of ​​the virtual object controlled by the user, it is impossible for the user to rotate the viewing angle over a large range in a short period of time. Therefore, the plane perpendicular to the sight line direction of the virtual object (such as the current direction of the virtual object controlled by the user) can be used as a reference plane for drawing the lightning effects. In this way, the number of subsequent patches that need to be drawn can be reduced to a certain extent, thereby improving performance.

[0092] For example, see Figure 4 , Figure 4 is a schematic diagram of the principle of determining a reference plane for drawing lightning special effects in a virtual scene provided by an embodiment of the present application, such as Figure 4 As shown, a reference plane 404 for drawing lightning effects in a virtual scene can be determined based on a sight line direction 402 of a virtual object 401 (e.g., a virtual object currently controlled by a user) and a ground projection position 403 of the lightning effects to be generated transmitted by a weather system. For example, a plane in the virtual scene that passes through the ground projection position 403 and is perpendicular to the sight line direction 402 of the virtual object 401 can be used as a reference plane 404 for drawing lightning effects in the virtual scene.

[0093] For example, taking a virtual scene as a game, when the weather system controls the weather scene in the game to change from other weather (such as a sunny day) to a rainy day, the line of sight direction of the game character currently controlled by the user (such as the current orientation of the game character controlled by the user) and the ground projection position of the lightning special effect to be generated can be obtained, and the reference plane for drawing the lightning special effect in the game can be determined according to the line of sight direction of the game character and the ground projection position (such as a plane perpendicular to the line of sight direction of the game character).

[0094] The following is an explanation of the weather conversion process in the game.

[0095] For example, the condition for the weather system to control the weather scenario in the game to change from sunny to rainy can be the arrival of the set weather change time, and the weather change time can be pre-set by the game planner. For example, assuming that an event with special requirements for the weather scenario (for example, it must be a rainy day) is held in the game, and the event will start at a certain time, then the start time of the event can be determined as the weather change time, that is, when the weather change time is reached, the weather system will control the weather in the game to change from sunny to rainy, and start executing the above-mentioned step 101.

[0096] For example, the condition for the weather system to control the weather scene in the game to change from sunny to rainy can also be that the game scene has changed, and the target weather corresponding to the changed game scene is rainy. For example, assuming that the game includes multiple different maps, and different maps can correspond to different weathers. For example, assuming that the game character controlled by the user is currently in map A (assuming that the weather corresponding to map A is sunny), when the user controls the game character to move from map A to map B (assuming that the weather corresponding to map B is rainy), since the weather corresponding to map B is rainy, it can be determined that lightning effects need to be generated in the game, and the above step 101 can be executed at this time.

[0097] For example, the condition for the weather system to control the weather scenario in the game to change from sunny to rainy can also be receiving a weather conversion instruction triggered by the user, and the target weather indicated by the weather conversion instruction is a rainy day. For example, buttons corresponding to different weather conditions are displayed in the game. When the user clicks on the rainy day button, the weather system will control the weather in the game to change from sunny to rainy, and start executing the above step 101.

[0098] In step 102, a release start position and a release end position set for the lightning special effect in a reference plane are obtained, and a line segment passing through the release start position and the release end position is generated.

[0099] In some embodiments, after determining the reference plane for drawing lightning special effects in the virtual scene based on the line of sight direction and the ground projection position, the release start position and the release end position set for the lightning special effects in the reference plane can be further obtained (for example, the release start position and the release end position set by the planner for the lightning special effects in the reference plane can be transmitted through the weather system), and a line segment passing through the release start position and the release end position (i.e., the original line segment of the lightning special effect) is generated.

[0100] In step 103, the splitting parameters set for the lightning special effect are obtained, and the line segments are randomly split based on the splitting parameters to obtain a topological structure including a main trunk and multiple branches.

[0101] In some embodiments, after generating a line segment passing through the release start position and the release end position, it is possible to further obtain splitting parameters set for the lightning special effect (for example, splitting parameters pre-configured by planners for the lightning special effect), and randomly split the line segment based on the splitting parameters to obtain a topological structure including a main trunk and multiple branches (i.e., the basic structure of the lightning special effect).

[0102] For example, you can use Figure 5 Steps 1031 to 1033 shown in the figure implement the above-mentioned random splitting process on the line segment based on the splitting parameter, and obtain a topological structure including a trunk and multiple branches. Figure 5 The steps shown are explained.

[0103] In step 1031 , a plurality of splitting points are randomly determined on the line segment based on the splitting parameter.

[0104] In some embodiments, the splitting parameter includes a threshold value for the number of splitting points, and step 1031 may be implemented in the following manner: iteratively perform the following processing until the number of splitting points obtained is greater than or equal to the threshold value: randomly determine a first splitting point on the line segment based on the splitting parameter; perform offset processing on the first splitting point, and generate a first sub-line segment of the first splitting point after the release start position and the offset processing, and a second sub-line segment of the first splitting point after the offset processing and the release end position; randomly determine a second splitting point on the first sub-line segment based on the splitting parameter, and randomly determine a third splitting point on the second sub-line segment; perform offset processing on the second splitting point and the third splitting point respectively; generate a third sub-line segment of the second splitting point after the release start position and the offset processing, a fourth sub-line segment of the second splitting point after the offset processing and the first splitting point after the offset processing, a fifth sub-line segment of the first splitting point after the offset processing and the third splitting point after the offset processing, and a sixth sub-line segment of the third splitting point after the offset processing and the release end position.

[0105] In other embodiments, the splitting parameters may further include an offset range set for the lightning effect, and the above-mentioned offset processing of the first splitting point may be implemented in the following manner: randomly determining a first offset value corresponding to the first splitting point from the set offset range; according to the first offset value, moving the first splitting point in a direction perpendicular to the line segment; similarly, the above-mentioned offset processing of the second splitting point and the third splitting point may be implemented in the following manner: randomly determining a second offset value corresponding to the second splitting point and a third offset value corresponding to the third splitting point from the set offset range; according to the second offset value, moving the second splitting point in a direction perpendicular to the first sub-line segment, and according to the third offset value, moving the third splitting point in a direction perpendicular to the second sub-line segment.

[0106] For example, see Figure 6 , Figure 6 is a schematic diagram of the principle of generating splitting points provided in an embodiment of the present application, such as Figure 6 As shown, after obtaining the number threshold of split points and the offset range set for the lightning effect, the release start position (i.e. Figure 6 Point A shown in FIG. 1 ) and the release end position (i.e. Figure 6 The line segment composed of the point B) shown in FIG. 1 (which can be recorded as line segment AB) is iterated multiple times to obtain multiple splitting points. The specific process is as follows:

[0107] First, a splitting point (i.e., the first splitting point mentioned above, such as splitting point C) is randomly determined on line segment AB based on the splitting parameter, and an offset value (i.e., the first offset value corresponding to the first splitting point mentioned above, such as offset value 1 corresponding to splitting point C) is randomly determined from a set offset range. For example, the splitting parameter may include a position value range set for the splitting point. For example, in order to make the generated lightning special effect more realistic, a splitting point may be randomly determined from a mid-segment position range of line segment AB (e.g., a position range of 0.4 to 0.6 of line segment AB).

[0108] Then, according to the offset value 1, the split point C is moved in the direction perpendicular to the line segment AB to obtain the split point C ′ (i.e., split point C after moving), and generate a release start position (i.e., point A) and split point C ′ The line segment AC ′ (i.e. the first sub-segment mentioned above), and passing through the splitting point C ′ and the line segment C at the release end position (i.e. point B) ′For example, assuming that the offset range set for the lightning effect is (-6, 6), where a negative number indicates an offset to the left of the line segment and a positive number indicates an offset to the right of the line segment, and assuming that the offset value 1 corresponding to the splitting point C randomly determined from the offset range (-6, 6) is 3, then the splitting point C can be moved 3 cm to the right of the line segment AB in a direction perpendicular to the line segment AB to obtain the splitting point C. ′ .

[0109] Then, it is detected whether the number of the current splitting points is greater than or equal to the set number threshold. When the number of the splitting points is less than the set number threshold, the splitting parameters can be continued on the line segment AC. ′ A split point (i.e., the second split point mentioned above, such as split point D) is randomly determined on the line segment C. ′ A splitting point is randomly determined on line segment B (i.e., the third splitting point mentioned above, for example, splitting point E), and an offset value 2 corresponding to splitting point D (i.e., the second offset value corresponding to the second splitting point mentioned above, for example, assuming that the value of offset value 2 is -1) and an offset value 3 corresponding to splitting point E (i.e., the third offset value corresponding to the third splitting point mentioned above, for example, assuming that the value of offset value 3 is 1) are randomly determined from the set offset range. Then, splitting point D can be moved along the line segment perpendicular to line segment AC. ′ direction, and toward line segment AC ′ Move 1 cm to the left to get the split point D ′ (i.e. the split point D after the moving process); similarly, the split point E can be moved along the line perpendicular to the line segment C ′ B, and towards line segment C ′ Move 1 cm to the right of B to get the split point E ′ (i.e. split point E after moving), and generate passing point A and split point D ′ The line segment AD ′ (i.e. the third sub-segment mentioned above), passing through the splitting point D ′ and split point C ′ Line segment D ′ C ′ (i.e. the fourth sub-segment mentioned above), passing through the split point C ′ and split point E ′ Line segment C ′ E ′ (i.e. the fifth sub-segment mentioned above), and passing through the splitting point E ′ Line segment E and point B ′B (i.e., the sixth sub-segment mentioned above). Finally, it is detected again whether the number of the current splitting points is greater than or equal to the number threshold. When the number of splitting points still does not reach the set number threshold, the above process is iterated until the number of splitting points reaches the set number threshold, thereby obtaining multiple splitting points.

[0110] It should be noted that, in actual applications, the above-mentioned iterative processing process can also be stopped when the number of iterations is greater than or equal to the number threshold, and the embodiment of the present application does not specifically limit the stopping time of the iterative processing.

[0111] In step 1032 , a trunk is generated based on the release start position, the release end position, and a plurality of split points.

[0112] In some embodiments, after obtaining multiple splitting points based on step 1031, the main body of the lightning special effect can be generated based on the release start position, the release end position, and the multiple splitting points. For example, the release start position set for the lightning special effect can be used as the starting point, and multiple splitting points can be connected in sequence from top to bottom until the release end position set for the lightning special effect, so as to obtain the main body of the lightning special effect. Of course, the release end position can also be used as the starting point, and multiple splitting points can be connected in sequence from bottom to top until the release start position, so as to obtain the main body of the lightning special effect. The embodiment of the present application does not specifically limit the connection method.

[0113] In step 1033, multiple branches are randomly split at multiple splitting points according to the set splitting probability.

[0114] In some embodiments, step 1033 can be implemented in the following manner: performing the following processing for each split point: obtaining the level at which the split point is located on the trunk; determining the split probability corresponding to the split point based on the level and the splitting conditions of other splitting points on the trunk that are adjacent to the split point; when the splitting probability is greater than the probability threshold, splitting a corresponding branch at the split point.

[0115] In other embodiments, the splitting parameters may also include a splitting angle range and a splitting length range, and the above-mentioned splitting of a corresponding branch at the splitting point may be achieved in the following ways: randomly determining a splitting angle value from the splitting angle range set for the lightning special effect; randomly determining a splitting length value from the splitting length range set for the lightning special effect; taking the splitting point after the offset processing as the starting point, generating a branch extending along the splitting angle value and with a length equal to the determined splitting length value.

[0116] For example, see Figure 7 , Figure 7 Schematic diagram of the branch generation principle provided in the embodiment of the present application. Figure 7 As shown, with the split point C′ (i.e., the split point C after the moving process) is taken as an example, the split point C can be obtained first. ′ The level on the trunk (e.g. split point C ′ The position on the trunk); then based on the level, and the position on the trunk with the split point C ′ Other split points at adjacent locations (for example, at split point C ′ The upper split point D ′ and at the split point C ′ The split point E below ′ ) split situation, determine the split point C ′ The corresponding split probability; then determine the split point C ′ Whether the corresponding split probability is greater than the probability threshold, when the split point C ′ When the corresponding split probability is greater than the probability threshold (e.g., 50%), the split point C is determined. ′ A corresponding branch is split off from the top; when the split point C ′ When the corresponding split probability is less than the probability threshold, it is determined that the split point C is not ′ Perform splitting (i.e. not at split point C ′ The specific process of adding branches is as follows: first, a splitting angle value (for example, assuming that it is 20°) is randomly determined from the splitting angle range set for the lightning special effect (for example, assuming that the splitting angle range is 10° to 45°), and a splitting length value (for example, assuming that the splitting length range is [0.6, 0.9] times the trunk length) is randomly determined from the splitting length range set for the lightning special effect (for example, assuming that the trunk length is 10 cm, and the randomly determined multiple is 0.7 times, then the splitting length value is 7 cm). Then, the splitting point C ′ The position where the split point is located is taken as the starting point, and the generated value is extended along the 20° direction (for example, the split point C ′ The right side of is defined as 0°, and downward is positive and upward is negative. When the randomly determined angle value is 20°, we can move toward the split point C. ′ , and extends 20° downwards), and a branch with a length of 7 cm (i.e. Figure 7 The line segment C shown in ′ F), in this way, since the splitting probability corresponding to the current splitting point is determined based on the level of the current splitting point on the trunk and the splitting conditions of other splitting points at adjacent positions, for example, when the splitting point is located in the middle of the trunk and there are no branches on other splitting points at adjacent positions, the splitting probability corresponding to the current splitting point is larger (that is, the possibility of splitting branches at the current splitting point is greater), so that the shape of the final generated lightning special effect can be more in line with the actual situation.

[0117] It should be noted that in actual applications, in order to make the final generated lightning special effect more realistic, further iterative processing can be performed on each branch. For example, the end point of the branch can be used as a new starting point, and at least one sub-branch can be randomly split from the branch. Then, the next level of sub-branches can be further split from each sub-branch until the number of iterative processing reaches a threshold number. In this way, the shape of the subsequently generated lightning special effects can be further enriched, thereby improving the user's immersive experience.

[0118] For example, we still take the split point C ′ For example, based on step 1033 at the split point C ′ After a corresponding branch (for example, branch 1) is split off, the end point of branch 1 can be used as a new starting point to split off at least one sub-branch on branch 1 (the generation method of the sub-branch is similar to that of branch 1, and can be implemented by referring to the generation method of branch 1, and the embodiments of the present application will not be repeated here). For example, assuming that two sub-branches are split off from branch 1, namely sub-branch 2 and sub-branch 3, the end points of sub-branch 2 and sub-branch 3 can be further used as the current latest starting point, and then the next level of sub-branches can be split off from sub-branch 2 and sub-branch 3. The above-mentioned iterative processing process is continuously executed until the number of iterative processing times reaches a threshold number. In this way, a lightning special effect with a more complex structure can be generated, thereby providing the user with a more realistic lightning effect.

[0119] In some embodiments, the generation process of the topological structure corresponding to the above-mentioned lightning special effect can also be realized by a multi-layer fractal algorithm (for example, based on the splitting parameters set for the lightning special effect, the line segments passing through the release start position and the release end position can be fractal processed to obtain the topological structure corresponding to the lightning special effect). Many objects in nature, such as plants and waves, conform to the laws of fractal algorithms, and so does lightning. Therefore, by setting the splitting parameters and using the fractal algorithm, a topological structure corresponding to the lightning special effect that conforms to the laws of nature and has diversity can be generated.

[0120] In other embodiments, when executing Figure 3 Before step 103 shown, the following processing can also be performed: obtain lightning data of real lightning in nature; perform predictive processing on the lightning data based on a machine learning model to obtain fractal rules and numerical relationships of real lightning (such as the position range of the splitting point on the trunk, the ratio of the branch length to the trunk length, etc.); based on the fractal rules and numerical relationships, determine the splitting parameters of the lightning special effects.

[0121] For example, in order to generate a more realistic lightning effect in a virtual scene, reinforcement learning (RL) can also be used to find the fractal rules and numerical relationships of real lightning in nature, and based on the found fractal rules and numerical relationships, determine the splitting parameters for the lightning special effects. In this way, since the splitting parameters are determined based on the fractal rules and numerical relationships of real lightning, the subsequent lightning special effects determined based on the splitting parameters can also be more realistic and credible, thereby further enhancing the user's immersive experience.

[0122] It should be noted that in actual applications, the above-mentioned machine learning model can be a neural network model (such as a convolutional neural network, a deep convolutional neural network, or a fully connected neural network, etc.), a decision tree model, a gradient boosting tree, a multi-layer perceptron, and a support vector machine, etc. The embodiment of the present application does not specifically limit the type of machine learning model.

[0123] In some embodiments, the above-mentioned acquisition of splitting parameters set for lightning special effects can also be achieved in the following manner: obtaining performance parameters of a terminal device used to display a virtual scene (for example, it may include operating environment characteristics of the client, capabilities of the terminal device, and network environment characteristics corresponding to the terminal device, etc., wherein the operating environment characteristics of the client may be memory usage information of the terminal device when running the client, central processing unit (CPU, Central Processing Unit) usage information, etc., and the capabilities of the terminal device may be relevant information used when parsing, processing or displaying a virtual scene, such as the resolution of the display screen of the terminal device, the graphics processing unit (GPU, Graphics Processing Unit) in the terminal device, etc. Unit), etc., and the network environment characteristics may be network congestion, remaining bandwidth and other related information); determine the splitting parameters that match the performance parameters from a plurality of pre-configured groups of candidate splitting parameters (the splitting parameters may include the above-mentioned threshold value of the number of splitting points, the range of splitting angles, at least one of the upper and lower limits of the splitting length range, and the number of iterative processing times of the branches, etc.), wherein the complexity of the lightning special effects corresponding to the splitting parameters that match the performance parameters is positively correlated with the performance parameters (for example, the better the performance of the terminal device determined based on the performance parameters, the higher the complexity of the corresponding lightning special effects, thereby making full use of the performance of the terminal device; and when the performance of the terminal device determined based on the performance parameters is poor, the complexity of the corresponding lightning special effects is also low, thereby ensuring that the lightning special effects can be displayed smoothly on terminal devices with poor performance).

[0124] For example, the performance parameters corresponding to different terminal devices can be pre-acquired and classified. For example, the terminal devices can be divided into three levels of "high", "medium" and "low" according to the performance parameters, and then a corresponding set of splitting parameters is pre-configured for each level. For example, for the "high" level, the corresponding configured splitting parameter is splitting parameter 1; for the "medium" level, the corresponding configured splitting parameter is splitting parameter 2; for the "low" level, the corresponding configured splitting parameter is splitting parameter 3, wherein different groups of splitting parameters include different thresholds for the number of splitting points, splitting angle ranges, and the number of iterative processing times of branches. For example, the threshold for the number of splitting points included in splitting parameter 1 is the largest (for example, 50), the threshold for the number of splitting points included in splitting parameter 2 is the second largest (for example, 30), and the threshold for the number of splitting points included in splitting parameter 3 is the smallest (for example, 20). That is to say, the complexity of the lightning special effect obtained based on splitting parameter 1 is the highest, the complexity of the lightning special effect obtained based on splitting parameter 2 is the second largest, and the complexity of the lightning special effect obtained based on splitting parameter 3 is the lowest. At the same time, assuming that the level corresponding to the performance parameters of the terminal device currently used to display the virtual scene is "medium" (for example, the level corresponding to the terminal device can be comprehensively determined based on memory usage information, the resolution of the terminal device's display screen, and network environment characteristics), then the splitting parameter 2 of the three pre-configured splitting parameters can be used as the splitting parameter adapted to the current terminal device, and the topological structure corresponding to the lightning special effect can be generated according to the splitting parameter 2. In this way, it is ensured that the lightning special effects generated in the virtual scene can be displayed smoothly on different types of terminal devices.

[0125] It should be noted that the above classification of terminal devices into three levels of "high", "medium" and "low" according to performance parameters is only a possible example. In actual applications, terminal devices can also be divided into level 1, level 2, level 3, etc. according to performance parameters. The embodiments of the present application do not make specific limitations on this.

[0126] In step 104, the topological structure is meshed to obtain a lightning special effects model.

[0127] In some embodiments, step 104 can be implemented in the following manner: the topological structure is covered with polygonal patches (such as triangular patches), and the positions of the common vertices of two adjacent polygonal patches corresponding to the connection of any two branches included in the topological structure are adjusted to obtain a lightning special effects model.

[0128] For example, after obtaining the topological structure, a mesh structure entity is also required for rendering. Therefore, the topological structure can be covered with triangle patches, and the positions of the common vertices of the two adjacent triangle patches corresponding to the connection of any two branches included in the topological structure can be adjusted to obtain a lightning special effects model with smooth connections.

[0129] In other embodiments, after obtaining the lightning special effects model, the following processing can also be performed: obtain the depth scale information, level information, and transparency information corresponding to multiple branches respectively; normalize the depth scale information, level information, and transparency information (for example, normalize to the interval of 0 to 255), and store the normalized depth scale information, level information, and transparency information in the three channels of color information included in the lightning special effects model (for example, RGB three channels). For example, the depth scale information can be stored in the red (R, Red) channel, the level information can be stored in the green (G, Green) channel, and the transparency information can be stored in the blue (B, Blue) channel. In this way, the stored depth scale information, level information, and transparency information can be used in the vertex shader stage of the rendering pipeline to draw the lightning special effects, thereby further improving the display effect of the lightning special effects.

[0130] In step 105 , a rendering program is called based on the lightning special effect model, so that the rendering program draws the lightning special effect in the reference plane.

[0131] In some embodiments, the rendering program may include a vertex shader and a fragment shader, which may be Figure 8 Steps 1051 to 1052 shown in FIG. Figure 3 Step 105 shown combines Figure 8 The steps shown are explained.

[0132] In step 1051, the vertex coordinates of each polygonal facet included in the lightning special effect model are transmitted to the vertex shader, so that the vertex shader performs primitive assembly processing on the vertex coordinates according to the programmable rendering pipeline to generate corresponding primitives.

[0133] In some embodiments, after obtaining the lightning special effects model, the vertex coordinates of each polygonal face (such as a triangle face) included in the lightning special effects model can first be organized into a two-dimensional array, and the two-dimensional array can be converted into a floating-point array through an application programming interface (API) and passed into a vertex shader. Subsequently, the vertex shader can perform primitive assembly processing on the passed-in vertex coordinates according to the programmable rendering pipeline (for example, the passed-in vertex coordinates can be converted through a 4*4 matrix) to generate corresponding multiple primitives.

[0134] In step 1052, the primitive is passed to the fragment shader, so that the fragment shader generates a fragment after rasterizing the primitive, and updates the color and transparency of the fragment according to the set shading strategy.

[0135] In some embodiments, after obtaining the primitives based on step 1051, the generated multiple primitives can be sequentially passed into the fragment shader, so that the fragment shader converts the passed primitives into pixels, and according to the preset vertex color information, a linearized calculation method is used to calculate the linearized color value of each pixel, thereby assigning colors to the pixels, that is, completing the process of rasterizing the image to generate fragments. After the fragments are generated, the color and transparency of the fragments can also be updated according to the set coloring strategy (for example, the closer the fragment is to the trunk, the higher the color brightness; the higher the level of the branch, the faster the boundary color brightness decays), so as to achieve the effect of dynamically displaying the lightning special effects.

[0136] The method for generating lightning special effects in a virtual scene provided in an embodiment of the present application randomly splits the line segments passing through the release start position and the release end position based on the splitting parameters of the lightning special effects to obtain a topological structure corresponding to the lightning special effect, and grids the topological structure. Subsequently, the lightning special effect is drawn based on the lightning special effects model obtained after the gridding process. In this way, since the topological structure corresponding to the lightning special effect is obtained by randomly splitting the line segments based on the splitting parameters, the shape of the lightning special effects drawn in the virtual scene is different during each lightning process, that is, the shape of the lightning special effects can be dynamically adjusted based on the splitting parameters, thereby enriching the shape of the lightning special effects in the virtual scene to adapt to the needs of different weather performances, while also enhancing the user's immersive experience.

[0137] The following is an explanation of an exemplary application of the embodiments of the present application in a practical application scenario.

[0138] With the continuous development of hardware equipment and the continuous improvement of gamers' tastes, the weather system has become a standard feature of games. In the weather system, rainy days are an important scene. How to realistically show the lightning effect on rainy days is crucial to improving the visual experience of players.

[0139] However, the solutions provided by related technologies usually use pre-made fixed models. When it is necessary to show lightning effects in the game, the model is placed at a specified position in the scene, and differentiated by adjusting the size and rotation of the model, or the preset map on the sky box is directly used to simulate the lightning process through changes in the shader.

[0140] It can be seen that the solution provided by the relevant technology has certain advantages in performance due to its simple implementation, but it lacks in the simulation of the realism of the lightning process, and the form of the lightning special effects displayed in the game is also relatively simple, that is, there is a lack of diversity in the form of lightning special effects.

[0141] In view of this, the embodiment of the present application provides a method for generating lightning special effects in a virtual scene, which can dynamically generate linear lightning effects when it rains in a weather system, wherein the trunk generation of the lightning special effects can be implemented based on a multi-layer fractal algorithm (many objects in nature, such as plants, waves, etc., conform to the laws of fractal algorithms, and the same is true for lightning. Therefore, on this theoretical basis, by setting splitting parameters (such as the splitting probability of branches, the length range of branches, etc.), it is possible to achieve lightning morphological expressions that are both in line with natural laws and have diversity), and generate the topological structure of the lightning special effects model in real time through the fractal algorithm, and can also support the dynamic generation of lightning special effects of different forms by adjusting the splitting parameters to meet the needs of different weather performances. In addition, the embodiment of the present application can also automatically adjust the splitting parameters to match the computing power of different terminal devices, thereby meeting the performance requirements of different types of terminal devices (such as different models).

[0142] In some embodiments, the function of generating lightning special effects can be inserted into the weather system as part of the rainy day effect performance. Game planners can select rainy day scenes in the weather system according to needs, set a timeline for changes in rainfall amount, and configure splitting parameters (also called initial parameters) for generating lightning effects corresponding to different rainfall amounts, so that lightning effects corresponding to different splitting parameters can be previewed in the lightning test scene.

[0143] For example, see 9A to 9D , 9A to 9D is a schematic diagram of a lightning special effect generated in a virtual scene provided by an embodiment of the present application, such as 9A to 9D As shown in Figure 1, by configuring different splitting parameters, different forms of lightning effects can be generated in the virtual scene, such as Fig. 9A The lightning effect 901 shown is generated based on the splitting parameter 1. Fig. 9B The lightning effect 902 shown is generated based on the splitting parameter 2. Fig. 9C The lightning effect 903 shown is generated based on the splitting parameter 3. Fig.9D The lightning special effect 904 shown is generated based on the splitting parameter 4, that is, different forms of lightning special effects can be generated by adjusting the splitting parameters, so that game planners can preview and adjust them in the lightning test scene.

[0144] The splitting parameters provided in the embodiments of the present application are described below.

[0145] In some embodiments, the splitting parameters may include the color of the lightning special effect, wherein the color of the lightning special effect is mainly divided into two layers of inner and outer colors, and generally speaking, the brightness of the inner color is higher; in addition, the splitting parameters may also include the shape of the lightning special effect, wherein the shape of the lightning special effect is mainly determined by factors such as the thickness of the trunk, the probability of splitting, the position of splitting, the range of splitting angles, the range of splitting lengths, and the attenuation coefficients of the branches. Furthermore, the splitting parameters may also include relevant information involved in the power-on process of the lightning special effect body: two parameters are involved, one is the brightness of the branch (referring to the ratio of the light intensity of the light source to the area of ​​the light source, that is, the luminous intensity per unit projection area) during the conduction and lighting of the current from the trunk to the branch (also called branch); the second is the brightness change of the overall lightning special effect during the whole process, including the initial conduction and several ground lightning processes.

[0146] In other embodiments, the splitting parameters may also include the lighting of the lightning special effects, such as the global light, color and intensity generated that change over time, and the lighting intensity (referring to the luminous flux of visible light received per unit area) parameter is in a certain proportional relationship with the intensity of the previous lightning power-on process. In addition, the splitting parameters may further include factors such as the total number of branches of the lightning special effects, the number of branch iterations, and the minimum length of the branches, so that by adjusting these factors, the complexity of the topological structure of the lightning special effects can be dynamically adjusted, thereby affecting the efficiency of the lightning special effects model generation and the number of triangle facets required for the actual rendering of the lightning special effects model. By pre-configuring multiple sets of splitting parameters for terminal devices of specified performance levels, they are dynamically switched during runtime according to the current performance requirements of the terminal devices, thereby ensuring smooth operation on different models.

[0147] The method for generating lightning special effects in a virtual scene provided in an embodiment of the present application can locate the trunk of the lightning special effect according to the release start position and release end position of the lightning special effect transmitted by the weather system, and dynamically generate the shape and topological structure of the entire lightning special effect according to preset splitting parameters, and finally use a predefined shader (Shader) for drawing.

[0148] Combine the following Fig.10 The method for generating lightning special effects in a virtual scene provided in an embodiment of the present application is described in detail.

[0149] For example, see Fig.10 , Fig.10 FIG. 1 is a flow chart of a method for generating lightning special effects in a virtual scene provided in an embodiment of the present application. Fig.10As shown, the entire lightning special effect generation process can be divided into four steps: weather system (TOD) input position information, topology structure generation, lightning special effect model generation and lightning special effect drawing, which are explained below respectively.

[0150] (I) Weather system (TOD) incoming location information

[0151] In some embodiments, the weather system (TOD) determines the current weather scenario in the game and the position of the scene where lightning effects need to be generated. Because the location where lightning effects are generated is usually very far from the player's combat area, it is unlikely that the player will rotate the viewing angle over a large range in a short period of time. Therefore, the lightning effects can be considered to be generated on a plane perpendicular to the line of sight from the player's point of view, which can reduce the number of triangles required for subsequent drawing to a certain extent and improve performance.

[0152] For example, see Fig.11 , Fig.11 is a schematic diagram of constructing a lightning special effect generation plane (corresponding to the above-mentioned reference plane) provided in an embodiment of the present application, such as Fig.11 As shown, based on the player's line of sight (for example, the current orientation of the game character controlled by the player, i.e., the viewpoint position information) and the generation position of the lightning special effects transmitted by the weather system (i.e., the generation position information), the normal of the generation plane of the lightning special effects (corresponding to the above-mentioned reference plane) in the XY direction can be obtained, and then an upward positive direction can be superimposed to form a coordinate system for generating lightning special effects.

[0153] 2. Topological structure generation

[0154] In some embodiments, the main body (ie, topological structure) of the lightning special effect may be generated using a fractal algorithm, which is divided into two parts: trunk splitting and branch generation.

[0155] For example, see Fig.12 , Fig.12 Schematic diagram of the trunk splitting principle provided in the embodiment of the present application. Fig.12 As shown, the trunk splitting is to find a splitting point on the original line segment (i.e., the line segment composed of the release start position and the release end position), and then displace the splitting point along the normal of the original line segment by a certain distance to form two line segments, and then find a splitting point on each of the two newly formed line segments, and displace the two splitting points along the normal direction of the line segments where they are located by a certain distance to form four line segments, and repeat the above process until the number of splitting points reaches the quantity threshold.

[0156] For example, see Fig.13 , Fig.13 is a schematic diagram of a lightning structure after adding branches provided in an embodiment of the present application, such as Fig.13As shown in Fig.12 The split point shown randomly splits into a branch according to the set split probability. The split probability greatly affects the complexity of the final generated lightning special effect.

[0157] In some embodiments, the following rules for constraining the splitting shape of lightning special effects can be obtained based on real lightning in nature: for example, the splitting point is close to the middle of the main trunk (for example, [0.4, 0.6]); the normal offset distance of the splitting point is [0.4, 0.6] times the length of the main trunk; the length of the generated branch is [0.6, 0.9] times the remaining length of the main trunk; the offset direction of the generated branch and the direction of the second half after the split need to be at both ends of the extension line of the first half, so that the generated lightning special effect will look more balanced; the splitting angle is between [10°, 45°].

[0158] It should be noted that in actual applications, all values ​​in the above rules are open for adjustment, and planners can adjust them according to actual conditions.

[0159] In addition, it should be noted that the splitting parameters used in the above fractal algorithm are manually set by the game planner or game designer, and the generation process is highly random. The performance of lightning effects under certain random values ​​may deviate from the real lightning in nature. Therefore, in order to obtain a more realistic lightning effect, the reinforcement learning method can also be used to find the fractal rules and numerical relationships of real lightning in nature, and generate the above topological structure based on the found fractal rules and quantitative relationships, so that a more realistic and feasible dynamic lightning effect can be achieved.

[0160] (III) Lightning special effects model generation

[0161] In some embodiments, after obtaining the topological structure of the lightning special effect (i.e., the basic linear lightning structure), the lightning special effect needs to be drawn in the previously determined generation plane. At this time, a mesh structure entity is also required for rendering. For example, triangular faces can be used to cover all the branch structures obtained previously, and after processing the topological relationship of the connection and adjusting the vertex positions of the line segment intersections, a smoothly connected lightning special effects model can be obtained.

[0162] For example, the fractal algorithm can only generate the topological structure of the lightning effect. The lightning effect ultimately needs to be represented by vertices and faces, and some additional information (such as depth scale information, level information, etc.) must be submitted to the rendering program. Among them, the topological relationship of each branch mainly includes: the split level (which determines the thickness of the branch face and the color of subsequent rendering, etc.), the serial number of the preceding branch, the serial number of the subsequent branch, the serial number of the parent branch, the height ratio under the current branch, and the height ratio under the trunk of the entire lightning effect. Generally speaking, the drawing of each branch requires the use of two triangular faces, and each triangular face is composed of three vertices, of which two vertices are shared by two adjacent triangular faces, so there are always four vertices. However, if adjacent branches use their own vertices respectively, the following will appear. Fig.14A The connection problem shown (i.e., the gap 1401 between adjacent branches).

[0163] In addition, the topological relationship of the connection is to know the previous and next branches when building the model, and share the adjacent connected vertices. In this way, each branch will actually only add two vertices and two facets (so two vertices are reused from the previous branch). When processing the position of adjacent vertices, if the vertex position of the previous branch is directly reused, the following will appear: Fig. 14B In the situation shown, when the angle of rotation is relatively large, deformity 1402 of the connecting surface may appear.

[0164] In view of this, the solution provided in the embodiment of the present application is for the newly added branch. In addition to calculating the information of the two newly generated vertices and the facets, the position of the common vertices of the previous segment is adjusted according to the segment orientation of the branch itself, so that the following can be obtained: Fig. 14C The smoothly connected lightning special effects model shown ensures the smoothness of the lightning special effects model.

[0165] In other embodiments, in addition to the lightning special effects model, because the lightning special effects need to have a power-on process from top to bottom when finally displayed, each branch can additionally save depth scale information (LengthScale); in addition, the overall brightness of the lightning special effects has a hierarchical attenuation process, so additional hierarchical information (BranchDepth) can be saved; further, each independent branch of the lightning special effects can have a fading process in color, and the closer to the end, the higher the transparency, so additional vertex transparency information (BranchTransparancy) can be saved.

[0166] After obtaining the above three data, normalization processing may be performed first. For example, the above three data may be normalized to the interval [0, 255], and then the normalized data may be stored in the three channels of the color information of the vertex of the lightning special effect model.

[0167] It should be noted that the lightning special effects model used for rendering here is stored in vertex and triangle patch information. Therefore, the three data involved above can be stored in the vertex information of the lightning special effects model. Subsequently, in the vertex shader stage of the rendering pipeline, the lightning special effects can be drawn based on the three stored data.

[0168] (IV) Lightning special effects drawing

[0169] In some embodiments, the drawing of lightning special effects can achieve the effect of dynamically displaying the lightning special effects by modifying the color (Emissive Color) and transparency (Opacity) of the fragment through a custom shader (Shader), wherein the modification rules are as follows: the closer the fragment is to the center of the trunk, the higher the color brightness; the higher the level of the fragment, the faster the brightness decay of the boundary color; the closer the fragment is to the end of the lightning special effect, the lower the overall brightness and the closer the transparency is to 0; during the power-on process, the transparency of the fragment whose height is less than the height threshold (LenthRatio = (current power-on time / total power-on time)) is 0 and is not displayed.

[0170] The lightning special effects generation method in the virtual scene provided by the embodiment of the present application can be applied to the rainy night scene of the game, and can simulate a very realistic thunderstorm effect with the sound effect of thunder and the global illumination of the lightning process. In addition, planners can also obtain lightning effects of different levels and shapes by dynamically adjusting the splitting parameters, which greatly increases the interactivity, diversity and authenticity of the rainy day scene.

[0171] In addition, the solution provided in the embodiment of the present application generates a visual plane for lightning special effects based on the camera perspective (for example, a generation plane for lightning special effects is constructed perpendicular to the player's line of sight), which reduces the number of triangular facets that need to be constructed for subsequent lightning special effects, and combined with the adjustment of factors such as the probability of lightning splitting, it can well adapt to the performance requirements of different types of terminal devices.

[0172] The following is a description of an exemplary structure of a lightning special effect generating device 465 in a virtual scene provided by an embodiment of the present application implemented as a software module. In some embodiments, Figure 2As shown, the software modules in the lightning special effects generating device 465 in the virtual scene stored in the memory 460 may include: an acquisition module 4651, a determination module 4652, a generation module 4653, a splitting module 4654, a gridding module 4655 and a drawing module 4656.

[0173] The acquisition module 4651 is used to acquire the sight line direction of the virtual object and the ground projection position of the lightning special effect to be generated; the determination module 4652 is used to determine the reference plane for drawing the lightning special effect in the virtual scene according to the sight line direction and the ground projection position; the acquisition module 4651 is also used to acquire the release start position and the release end position set for the lightning special effect in the reference plane; the generation module 4653 is used to generate a line segment passing through the release start position and the release end position; the acquisition module 4651 is also used to acquire the splitting parameters set for the lightning special effect; the splitting module 4654 is used to randomly split the line segment based on the splitting parameters to obtain a topological structure including a main trunk and multiple branches; the meshing module 4655 is used to mesh the topological structure to obtain a lightning special effect model; the drawing module 4656 is used to call a rendering program based on the lightning special effect model so that the rendering program draws the lightning special effect in the reference plane.

[0174] In some embodiments, the splitting module 4654 is also used to randomly determine multiple splitting points on the line segment based on the splitting parameters; generate a main trunk based on the release start position, the release end position, and multiple splitting points; and randomly split multiple branches at multiple splitting points according to the set splitting probability.

[0175] In some embodiments, the splitting module 4654 is also used to iteratively perform the following processing until the number of splitting points is greater than or equal to a quantity threshold: randomly determine a first splitting point on the line segment based on the splitting parameter; offset the first splitting point, and generate a first sub-line segment of the first splitting point after the release starting position and the offset processing, and a second sub-line segment after the first splitting point and the release end position after the offset processing; randomly determine a second splitting point on the first sub-line segment based on the splitting parameter, and randomly determine a third splitting point on the second sub-line segment; offset the second splitting point and the third splitting point respectively; generate a third sub-line segment of the second splitting point after the release starting position and the offset processing, a fourth sub-line segment of the second splitting point after the offset processing and the first splitting point after the offset processing, a fifth sub-line segment of the first splitting point after the offset processing and the third splitting point after the offset processing, and a sixth sub-line segment of the third splitting point after the offset processing and the release end position.

[0176] In some embodiments, the splitting module 4654 is also used to randomly determine a first offset value corresponding to a first splitting point from a set offset range; move the first splitting point in a direction perpendicular to the line segment according to the first offset value; and to randomly determine a second offset value corresponding to a second splitting point and a third offset value corresponding to a third splitting point from a set offset range; move the second splitting point in a direction perpendicular to the first sub-line segment according to the second offset value, and move the third splitting point in a direction perpendicular to the second sub-line segment according to the third offset value.

[0177] In some embodiments, the splitting module 4654 is also used to perform the following processing for each splitting point: obtain the level at which the splitting point is located on the trunk; determine the splitting probability corresponding to the splitting point based on the level and the splitting conditions of other splitting points on the trunk that are adjacent to the splitting point; when the splitting probability is greater than the probability threshold, split a corresponding branch at the splitting point.

[0178] In some embodiments, the splitting module 4654 is also used to randomly determine a splitting angle value from a set splitting angle range; randomly determine a splitting length value from a set splitting length range; and use the splitting point after the offset processing as the starting point to generate a branch extending along the splitting angle value and with a length equal to the splitting length value.

[0179] In some embodiments, the meshing module 4655 is also used to cover the topological structure with polygonal patches, and adjust the positions of common vertices of two adjacent polygonal patches corresponding to the connection of any two branches included in the topological structure to obtain a lightning special effects model.

[0180] In some embodiments, the acquisition module 4651 is also used to obtain the depth ratio information, level information, and transparency information corresponding to multiple branches respectively; the lightning special effects generating device 465 in the virtual scene also includes a normalization module 4657, which is used to normalize the depth ratio information, level information, and transparency information; the lightning special effects generating device 465 in the virtual scene also includes a storage module 4658, which is used to store the normalized depth ratio information, level information, and transparency information in the three channels of color information included in the lightning special effects model.

[0181] In some embodiments, the drawing module 4656 is also used to pass the vertex coordinates of each polygonal face included in the lightning special effects model into the vertex shader, so that the vertex shader performs primitive assembly processing on the vertex coordinates according to the programmable rendering pipeline to generate corresponding primitives; pass the primitives into the fragment shader, so that the fragment shader performs rasterization processing on the primitives to generate fragments, and update the color and transparency of the fragments according to the set shading strategy.

[0182] In some embodiments, the acquisition module 4651 is also used to obtain performance parameters of a terminal device used to display a virtual scene; the determination module 4652 is also used to determine splitting parameters that match the performance parameters from a plurality of pre-configured sets of candidate splitting parameters, wherein the complexity of the lightning effects corresponding to the splitting parameters that match the performance parameters is positively correlated with the performance parameters.

[0183] In some embodiments, the acquisition module 4651 is also used to obtain lightning data of real lightning in nature; the lightning special effects generating device 465 in the virtual scene also includes a prediction module 4659, which is used to perform predictive processing on the lightning data based on the machine learning model to obtain the fractal rules and numerical relationships of the real lightning; the determination module 4652 is also used to determine the splitting parameters of the lightning special effects based on the fractal rules and numerical relationships.

[0184] It should be noted that the description of the device in the embodiment of the present application is similar to the description of the method embodiment described above, and has similar beneficial effects as the method embodiment, so it will not be repeated. Figure 3 , Figure 5 ,or Figure 8 The present invention should be understood by referring to the description of any one of the accompanying drawings.

[0185] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions (i.e., executable instructions), which are stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method for generating lightning special effects in a virtual scene described in the embodiment of the present application.

[0186] The present application embodiment provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor will be caused to execute the method provided by the present application embodiment, for example, Figure 3 , Figure 5 ,or Figure 8 A method for generating lightning special effects in a virtual scene as shown in any of the accompanying drawings.

[0187] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.

[0188] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0189] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).

[0190] As an example, the executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.

[0191] To summarize, the embodiment of the present application randomly splits the line segments passing through the release start position and the release end position based on the splitting parameters of the lightning special effect, obtains the topological structure corresponding to the lightning special effect, grids the topological structure, and then draws the lightning special effect based on the lightning special effect model obtained after the gridding process. In this way, since the topological structure corresponding to the lightning special effect is obtained by randomly splitting the line segments based on the splitting parameters, the shapes of the lightning special effects drawn in the virtual scene are different in each lightning process, which enriches the shapes of the lightning special effects in the virtual scene and also enhances the user's immersive experience.

[0192] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A method for generating lightning special effects in a virtual scene, characterized in that: The method comprises: Acquire the sight line direction of the virtual object and the ground projection position of the lightning special effect to be generated, and determine the reference plane for drawing the lightning special effect in the virtual scene according to the sight line direction and the ground projection position; Acquire a release start position and a release end position set for the lightning special effect in the reference plane, and generate a line segment passing through the release start position and the release end position; Acquire a splitting parameter set for the lightning special effect, and perform random splitting processing on the line segment based on the splitting parameter to obtain a topological structure including a trunk and multiple branches; The topological structure is covered with polygonal patches, and the positions of common vertices of two adjacent polygonal patches corresponding to the connection of any two branches included in the topological structure are adjusted. When the branch is a newly added branch, the positions of common vertices of the preceding segments are adjusted based on the information of the two vertices and patches newly generated by the newly added branch and the segmentation direction of the newly added branch, so as to obtain a lightning special effect model. A rendering program is called based on the lightning special effect model, so that the rendering program draws the lightning special effect in the reference plane.

2. The method according to claim 1, characterized in that The line segment is randomly split based on the splitting parameter to obtain a topological structure including a trunk and multiple branches, including: Randomly determining a plurality of splitting points on the line segment based on the splitting parameter; generating the trunk based on the release start position, the release end position, and the plurality of splitting points; The multiple branches are randomly split at the multiple splitting points according to the set splitting probability.

3. The method according to claim 2, characterized in that The splitting parameters include a number threshold of splitting points; The randomly determining a plurality of splitting points on the line segment based on the splitting parameter comprises: Iterate the following process until the number of split points is greater than or equal to the number threshold: Randomly determining a first splitting point on the line segment based on the splitting parameter; Performing an offset process on the first splitting point, and generating a first sub-line segment passing through the release start position and the first splitting point after the offset process, and a second sub-line segment passing through the first splitting point after the offset process and the release end position; randomly determining a second splitting point on the first sub-segment based on the splitting parameter, and randomly determining a third splitting point on the second sub-segment; performing offset processing on the second splitting point and the third splitting point respectively; Generate a third sub-line segment of the release starting position and the second splitting point after offset processing, a fourth sub-line segment of the second splitting point after offset processing and the first splitting point after offset processing, a fifth sub-line segment of the first splitting point after offset processing and the third splitting point after offset processing, and a sixth sub-line segment of the third splitting point after offset processing and the release end position.

4. The method according to claim 3, characterized in that: The performing offset processing on the first splitting point includes: Randomly determining a first offset value corresponding to the first splitting point from a set offset range; According to the first offset value, the first splitting point is moved in a direction perpendicular to the line segment; The performing offset processing on the second splitting point and the third splitting point respectively includes: Randomly determining a second offset value corresponding to the second splitting point and a third offset value corresponding to the third splitting point from a set offset range; According to the second offset value, the second splitting point is moved in a direction perpendicular to the first sub-line segment, and according to the third offset value, the third splitting point is moved in a direction perpendicular to the second sub-line segment.

5. The method according to claim 2, characterized in that: The step of randomly splitting the plurality of branches at the plurality of splitting points according to the set splitting probability comprises: The following processing is performed for each split point: Obtaining the level at which the split point is located on the trunk; Determine a splitting probability corresponding to the splitting point based on the level and splitting conditions of other splitting points on the trunk that are adjacent to the splitting point; When the splitting probability is greater than the probability threshold, a corresponding branch is split at the splitting point.

6. The method according to claim 5, characterized in that The splitting parameters include a splitting angle range and a splitting length range; The step of splitting a corresponding branch at the splitting point comprises: Randomly determine a splitting angle value from the splitting angle range; Randomly determine a splitting length value from the splitting length range; Taking the split point after the offset processing as a starting point, a branch extending along the split angle value and having a length equal to the split length value is generated.

7. The method according to claim 6, characterized in that The method further comprises: Obtaining depth ratio information, level information, and transparency information respectively corresponding to the plurality of branches; The depth ratio information, level information, and transparency information are normalized, and the normalized depth ratio information, level information, and transparency information are stored in three channels of color information included in the lightning special effects model.

8. The method according to claim 1, characterized in that: The rendering program includes: a vertex shader and a fragment shader; The calling of a rendering program based on the lightning special effect model so that the rendering program draws the lightning special effect in the reference plane includes: The vertex coordinates of each polygonal facet included in the lightning special effect model are transmitted to the vertex shader, so that the vertex shader performs primitive assembly processing on the vertex coordinates according to the programmable rendering pipeline to generate corresponding primitives; The primitive is passed into the fragment shader, so that the fragment shader generates a fragment after rasterizing the primitive, and updates the color and transparency of the fragment according to a set shading strategy.

9. The method according to claim 1, characterized in that: The obtaining of the splitting parameters set for the lightning special effect includes: Acquiring performance parameters of a terminal device used to display the virtual scene; A splitting parameter matching the performance parameter is determined from a plurality of pre-configured groups of candidate splitting parameters, wherein the complexity of the lightning special effect corresponding to the splitting parameter matching the performance parameter is positively correlated with the performance parameter.

10. The method according to claim 1, characterized in that Before obtaining the splitting parameters set for the lightning special effect, the method further includes: Obtain lightning data of real lightning in nature; Performing prediction processing on the lightning data based on a machine learning model to obtain fractal rules and numerical relationships of the real lightning; Based on the fractal rule and the numerical relationship, the splitting parameters of the lightning special effect are determined.

11. A device for generating lightning special effects in a virtual scene, characterized in that: The device comprises: An acquisition module, used to acquire the sight line direction of the virtual object and the ground projection position of the lightning special effect to be generated; A determination module, used to determine a reference plane for drawing the lightning special effect in a virtual scene according to the sight line direction and the ground projection position; The acquisition module is further used to acquire a release start position and a release end position set for the lightning special effect in the reference plane; A generating module, used for generating a line segment passing through the release starting position and the release ending position; The acquisition module is further used to acquire the splitting parameters set for the lightning special effect; A splitting module, used for performing random splitting processing on the line segment based on the splitting parameter to obtain a topological structure including a trunk and multiple branches; A meshing module, used for covering the topological structure with polygonal patches, adjusting the positions of common vertices of two adjacent polygonal patches corresponding to the connection of any two branches included in the topological structure, and when the branch is a newly added branch, adjusting the positions of common vertices of the preceding segments based on the information of the two vertices and patches newly generated by the newly added branch and the segmentation direction of the newly added branch, so as to obtain a lightning special effect model; The drawing module is used to call a rendering program based on the lightning special effect model, so that the rendering program draws the lightning special effect in the reference plane.

12. An electronic device, characterized in that: The electronic device comprises: A memory for storing executable instructions; The processor is used to implement the method for generating lightning special effects in a virtual scene as described in any one of claims 1 to 10 when executing the executable instructions stored in the memory.

13. A computer-readable storage medium, characterized in that: Executable instructions are stored, which are used to implement the method for generating lightning special effects in a virtual scene as described in any one of claims 1 to 10 when executed by a processor.

14. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the method for generating lightning special effects in a virtual scene as described in any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • Lightning generation method and device, electronic equipment and computer readable storage medium

    CN112669423A