Respiration light effect rendering method and device, electronic equipment and storage medium
By normal outscaling and halo contour generation of vertices of local shapes of the model, combined with interpolation processing technology, it is possible to add respiratory light effects to local shapes of the model under low performance overhead, solving the local custom light effects requirements in the existing technology The problem has high flexibility and good light effect performance.
Patent Information
- Application Number
- CN202411509632.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-02-18
AI Technical Summary
The prior art is difficult to meet the needs of locally customizing various luminous luminous effects under low performance overhead and high flexibility, especially when locally adding respiratory luminous effects to the model.
By moving the vertices of local shapes in the preset model outward along their normal direction, a halo profile that fits the local shape is generated, and several layers of halos are created based on the halo profile, interpolation is performed to simulate the multi-layer blur effect , and finally render the respiratory light effect in response to the control command.
It realizes that while adapting to the local shapes of different models, it increases the respiratory light effect for the local shape of the model in the picture under low performance overhead, and has high flexibility and good light effect performance.
Smart Images

Figure CN119478170A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of game rendering technology, and in particular to a breathing light effect rendering method, a breathing light effect rendering device, a corresponding electronic device, and a corresponding computer-readable storage medium. Background Art
[0002] Current games have a demand for rich screen lighting effects, such as adding lighting effects with different colors, brightness, and flickering frequencies to different parts of the screen. The aforementioned lighting effects with different colors, brightness, and flickering frequencies can be called breathing lighting effects.
[0003] In the art process of adding breathing light effects to parts of the model, texture objects can be created separately for the parts of the model where breathing light effects are to be added, and multiple blurs are performed to simulate light scattering and glare effects. Alternatively, special effects facing the camera can be added to the parts of the model where breathing light effects are to be added. However, the aforementioned solutions cannot meet the needs of local customized light effects. Summary of the invention
[0004] In view of the above problems, embodiments of the present invention are proposed to provide a method for rendering a breathing light effect, a device for rendering a breathing light effect, a corresponding electronic device, and a corresponding computer-readable storage medium that overcome the above problems or at least partially solve the above problems.
[0005] An embodiment of the present invention discloses a method for rendering a breathing light effect, the method comprising:
[0006] Acquire vertices of a local shape in a preset model, and move the vertices outward along the normal direction of the vertices;
[0007] Generating a halo contour fitting the local shape according to the sight direction of the moved vertex toward the camera position;
[0008] Creating a plurality of halo layers based on the halo contour, and performing interpolation processing on the plurality of halo layers to obtain a plurality of halo effects that fit the local shape;
[0009] In response to the control instruction for the halo effect, a breathing light effect is rendered.
[0010] The embodiment of the present invention further discloses a rendering device for a breathing light effect, the device comprising:
[0011] A vertex moving module, used to obtain the vertices of the local shape in the preset model, and move the vertices outward along the normal direction of the vertices;
[0012] A halo contour generating module, used for generating a halo contour fitting the local shape according to the sight direction of the moved vertex toward the camera position;
[0013] A halo effect generation module, used for creating several layers of halo based on the halo outline, and performing interpolation processing on the several layers of halo to obtain several layers of halo effects fitting the local shape;
[0014] The breathing light effect rendering module is used to respond to the control instruction of the halo effect and render the breathing light effect.
[0015] An embodiment of the present invention further discloses an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, any one of the methods for rendering the breathing light effect is implemented.
[0016] The embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, any one of the rendering methods for the breathing light effect is implemented.
[0017] The embodiments of the present invention include the following advantages:
[0018] In an embodiment of the present invention, a halo contour that fits the local shape in a preset model is generated by moving the vertices of the local shape in the normal direction outward, and according to the line of sight direction of the moved vertices toward the camera position, a halo contour that fits the local shape is generated, and then several layers of halo are created based on the halo contour, and the created several layers of halo are interpolated to obtain several layers of halo effects that fit the local shape, and then a breathing light effect is rendered by responding to the control instructions of the aforementioned halo effect that fits the local shape. A halo contour that fits the local shape of the model is formed by utilizing the normal expansion combined with the line of sight direction of the vertices of the local shape toward the camera position, and then several layers of halo created based on the halo contour are interpolated to simulate the light effect achieved by several layers of blur when fitting the local shape of the model, and then a breathing light effect is rendered by controlling the aforementioned several layers of light effect, ensuring that the rendered breathing light effect can adapt to different local shapes of the model, with low performance overhead and high flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flowchart of the steps of an embodiment of a rendering method of a breathing light effect of the present invention;
[0020] Figure 2 is a flowchart of another embodiment of a rendering method for breathing light effect of the present invention;
[0021] FIG. 3A to FIG. 3Cis a rendering schematic diagram of the breathing light effect provided by an embodiment of the present invention;
[0022] Figure 4 It is a structural block diagram of an embodiment of a rendering device for breathing light effect of the present invention. DETAILED DESCRIPTION
[0023] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0024] To facilitate those skilled in the art to understand the present invention, the following explains the terms or nouns involved in the following embodiments of the present invention:
[0025] NeoX2: A self-developed cross-platform 3D game engine.
[0026] RenderTexture: RT for short, is a special texture object that allows real-time graphics rendering on it. Usually, the image data rendered to RenderTexture is not directly displayed on the screen, but can be used for subsequent processing, synthesis or other purposes. RenderTexture is usually used to implement various graphics rendering technologies such as special effects, post-processing, lens effects, shadow rendering, etc.
[0027] Bloom: In computer graphics and game development, the Bloom effect is a visual effect used to enhance game graphics or graphics rendering. The Bloom effect simulates light scattering and glare effects, making bright areas in the scene produce floodlight or radiation effects, thereby enhancing the performance of light and making the entire scene look more colorful and vivid.
[0028] Billboard: It is a special effects technology used to render 2D sprites or special effects objects in the game scene so that they always face the camera position, thus producing a realistic effect. This technology is often used to render trees, grass, fire, particle effects, etc. in games.
[0029] Pass: refers to a link or stage in the rendering pipeline. During the rendering process, the rendering task is usually divided into multiple Passes, each of which is responsible for performing specific rendering operations, such as geometry processing, lighting calculation, shadow rendering, post-processing, etc.
[0030] Vertex shader: is a program executed for each vertex in the graphics. Its main function is to transform, project, and perform other operations on the vertex according to the input vertex information (such as vertex position, normal, color, texture coordinates, etc.), and finally pass the transformed vertex position to the next stage (usually primitive assembly or geometry shader). In the vertex shader, developers can implement various operations such as transformation, deformation, lighting calculation, and perform some vertex-level calculations and processing.
[0031] Fragment shader: is a program executed for each pixel (or fragment) in the graphics. Its main function is to calculate the final color value of each pixel, usually including operations such as color, normal, texture sampling, lighting calculation, etc. Fragment shaders can be used to achieve various visual effects, such as lighting models, texture mapping, shadow calculation, transparency effects, post-processing, etc.
[0032] Fresnel Effect: Fresnel Effect is a term that describes the reflection behavior of light at the interface of different media. Specifically, Fresnel Effect refers to the phenomenon that when light enters from one medium into another, its reflectivity and transmittance change with the change of the incident angle.
[0033] Fresnel algorithm: Fresnel algorithm, usually refers to the calculation method of Fresnel reflection.
[0034] The breathing light effect can meet the needs of adding different colors, brightness, and flashing frequencies to different parts of the picture.
[0035] In the art process of adding breathing light effects to the local part of the model, as an example, a texture object RenderTexture can be established separately for the local part of the model where the breathing light effect is to be added, and multiple blurs are performed in the established RenderTexture to simulate the post-processing effect of Bloom. For example, in the local Bloom post-processing solution, assuming that three colors need to be customized to diffuse different light effects, at this time, at least one new texture object needs to be created, and at most three new texture objects need to be created, and algorithms such as luminous area extraction and circular blur need to be performed on different texture object RTs. Especially in the case of processing a local part with a small pixel area, the performance overhead is large and the cost performance is low; as another example, the billboard camera-facing special effect can be added to the local part of the model where the breathing light effect is to be added, but the special effects added locally based on the aforementioned solution are easy to intersect with the entire model, and cannot adaptively generate light effects along the outer contour of the model. For example, in the solution of adding billboard special effects, assuming that it is necessary to extend the halo along the outer contour of different model objects, multiple mask maps are required or uniformly replaced by circles, and the potential angle is easy to intersect with the model when changing, and the flexibility is low, which leads to poor generated effects.
[0036] In summary, the current art solutions cannot meet the needs of local customization of various luminous effects with low performance overhead and high flexibility.
[0037] The embodiment of the present invention forms a halo outline that fits the local shape of the model by utilizing normal expansion in combination with the line of sight of the vertices of the local shape toward the camera position, and then interpolates several layers of halo created based on the halo outline, so that it can simulate the lighting effect achieved by several layers of blur while fitting the local shape of the model, and then renders a breathing light effect by controlling the aforementioned several layers of lighting effects, which can add a breathing light effect to the local shape of the model in the picture while adapting to different local shapes of the model and with low performance overhead. Furthermore, by adding a rendering link to combine the normal expansion with the Fresnel algorithm, several layers of halo can be quickly interpolated and fused, which can reduce the number of RT rendering times, and fit various model shapes on the basis of reducing the number of RT rendering times, to achieve a customizable breathing halo effect.
[0038] Reference Figure 1 , shows a flowchart of a method for rendering a breathing light effect according to an embodiment of the present invention, which may specifically include the following steps:
[0039] Step 101, obtaining vertices of a local shape in a preset model, and moving the vertices outward along the normal direction of the vertices;
[0040] The breathing light effect can meet the needs of adding different colors, brightness, and flashing frequencies to different parts of the screen. The preset model can refer to any game model rendered in the game screen, and the local shape can be any local shape of any game model, such as a specific face or area; the local shape can be presented in any shape, such as a square, circle, etc., and the embodiment of the present invention is not limited to this.
[0041] In an embodiment of the present invention, the local shape may be a part of a model where a breathing light effect needs to be added, and the vertices of the local shape in the acquired preset model may refer to the model vertices of the part of the model where the breathing light effect is to be added. For the realization of the breathing light effect, the light effect may be generated first, and optionally, in order to ensure that the subsequently generated light effect can fit the local shape, the light effect may be rendered and generated based on the vertices of the local shape of the model.
[0042] In some embodiments of the present invention, the lighting effect usually has a halo effect. In this case, the vertex can be moved outward along the normal direction of the vertex to subsequently generate a halo outline; wherein, since the halo outline is generated based on the vertex after being moved outward along the normal direction of the vertex, the subsequently generated halo outline can always be guaranteed to fit the local shape.
[0043] Step 102, generating a halo contour that fits the local shape according to the line of sight of the moved vertex toward the camera position;
[0044] In some embodiments of the present invention, for each moved vertex, its sight direction toward the camera position can be calculated. The sight direction can be calculated by the vector difference between the vertex position and the camera position, so as to generate a halo outline that fits the local shape according to the sight direction.
[0045] Optionally, the generation of the halo contour can be achieved by using a Fresnel algorithm to perform Fresnel calculation. Specifically, the Fresnel calculation can be performed according to the line of sight direction of the moved vertex toward the camera position and the normal direction of the world space to generate a halo contour that fits the local shape. The embodiment of the present invention does not limit the specific Fresnel calculation process of the halo contour.
[0046] Step 103, creating several layers of halos based on the halo contour, and performing interpolation processing on the several layers of halos to obtain several layers of halo effects that fit the local shape;
[0047] In order to make the generated light effect richer and three-dimensional, the visual effect can be enhanced based on several layers of halos by superimposing halos on different levels; in order to simulate the real halo effect, several layers of halo effects can be formed by creating several layers of halo; in order to make the generated light effect transition more smoothly and naturally, interpolation processing can be performed between each layer of halo in the several layers to smooth the edges of the halo and avoid abrupt boundaries; and, in order to simulate the breathing effect of halo and make the light effect more vivid and dynamic, in the breathing light effect, the dynamic effect can be enhanced based on several layers of halo.
[0048] In some embodiments of the present invention, several layers of halos can be created based on the halo contour, and the several layers of halos can be interpolated so that they can simulate the lighting effects achieved by several layers of blur while fitting the local shape of the model, so that the halo effect produced can meet the above-mentioned effects of enhancing visual effects, simulating real halos, smooth transitions, enhancing dynamic effects, and improving visual hierarchy. That is, the superposition and interpolation of several layers of halos can ensure that the generated lighting effects are richer, more realistic, more dynamic and more attractive.
[0049] It should be noted that the specific method of creating the multiple layers of halos and the specific process of generating the halos effect are not limited in the embodiments of the present invention.
[0050] Step 104, responding to the control instruction for the halo effect, rendering to obtain a breathing light effect.
[0051] After generating several layers of halo effects that fit the local shape, in order to achieve the breathing effect of light effect, the breathing light effect can be rendered by controlling the aforementioned several layers of halo effects. This can add breathing light effect to the local shape of the model in the picture while adapting to the local shapes of different models and with low performance overhead.
[0052] Optionally, the breathing light effect can meet the needs of adding different colors, brightness, and flashing frequencies to different parts of the picture. In order to achieve the aforementioned breathing light effect, the control instruction can usually carry relevant control parameters for the luminous frequency, luminous intensity, luminous color, etc., so as to perform breathing control on the aforementioned several layers of halo effects.
[0053] In practical applications, control parameters for each layer of halo effect can be used to independently control the luminous frequency, luminous intensity, luminous color, etc. of each layer of halo effect to meet the dynamic effect and visual layering of the generated light effect as much as possible.
[0054] In an embodiment of the present invention, a halo contour that fits the local shape in a preset model is generated by moving the vertices of the local shape in the normal direction outward, and according to the line of sight direction of the moved vertices toward the camera position, a halo contour that fits the local shape is generated, and then several layers of halo are created based on the halo contour, and the created several layers of halo are interpolated to obtain several layers of halo effects that fit the local shape, and then a breathing light effect is rendered by responding to the control instructions of the aforementioned halo effect that fits the local shape. A halo contour that fits the local shape of the model is formed by utilizing the normal expansion combined with the line of sight direction of the vertices of the local shape toward the camera position, and then several layers of halo created based on the halo contour are interpolated to simulate the light effect achieved by several layers of blur when fitting the local shape of the model, and then a breathing light effect is rendered by controlling the aforementioned several layers of light effect, ensuring that the rendered breathing light effect can adapt to different local shapes of the model, with low performance overhead and high flexibility.
[0055] Reference Figure 2 , shows a flowchart of another embodiment of a rendering method for breathing light effect of the present invention, which may specifically include the following steps:
[0056] Step 201, moving the vertices of the local shape in the preset model outward along the normal direction of the vertex;
[0057] In an embodiment of the present invention, the local shape may be a part of a model where there is a need to increase the breathing light effect. The vertex extraction of the local shape may be performed by extracting all vertices of the local shape from the model after determining the local shape where the breathing light effect needs to be increased.
[0058] For the realization of breathing light effect, the light effect may be generated first. Optionally, in order to ensure that the subsequently generated light effect can fit the local shape, the light effect may be rendered and generated based on the vertices of the local shape of the model.
[0059] In some embodiments of the present invention, the lighting effect usually has a halo effect. In this case, the vertex can be moved outward along the normal direction of the vertex to subsequently generate a halo outline; wherein, since the halo outline is generated based on the vertex after being moved outward along the normal direction of the vertex, the subsequently generated halo outline can always be guaranteed to fit the local shape.
[0060] In practical applications, vertex extraction and movement of local shapes can be implemented in vertex shaders. As for the determination of relevant model vertices that need to add breathing light effects locally, as an example, it can be achieved by assigning different materials to the models that need to add breathing light effects locally for identification; as another example, it can be achieved by adding a new map for identification, in which the white area in the map can be set as the relevant part that needs to add breathing light effects, and the black area can be set as the relevant part that does not need to add breathing light effects.
[0061] Optionally, the extracted vertices are moved outward a certain distance along their normal directions. First, in the vertex shader, for each vertex, its normal direction can be calculated. The normal direction is usually perpendicular to the direction of the face where the vertex is located. Then each vertex can be moved a certain distance along its normal direction. The distance can be adjusted as needed to control the thickness of the halo.
[0062] In the specific implementation, the process of normal expansion of vertices in the model space (i.e. moving vertices outward along the normal direction) can be implemented in code as follows:
[0063] Fragment frag=(Fragment)θ;
[0064] frag.position_local=float4(input.position+normalize(input.normal)*_outkidt h,1.0f)
[0065] Among them, Fragment can be a custom structure for storing input data of the fragment shader; input.position can be the vertex position passed from the vertex shader to the fragment shader, which is located in the model space and refers to the position of the vertex in the model's own coordinate system; input.normal can be the normal passed from the vertex shader to the fragment shader, which is also located in the model space and is usually a direction vector perpendicular to the face where the vertex is located. The above two need to be in the same model space to realize the above normal expansion calculation; normalize (input.normal) is mainly used to normalize the normal vector so that its length is 1 to ensure that the movement distance along the normal direction is uniform. Uniform; _outkidth can refer to a constant, which is used to represent the distance moved outward along the normal direction. This value can be used to determine the thickness of the halo; "input.position+normalize(input.normal)*_outkidth" means moving the vertex position outward along the normalized normal direction by a distance of _outkidth, and then the calculated three-dimensional vertex position can be converted into a four-dimensional vector based on float4 operations, in which the fourth component (w component) is set to 1.0f, indicating that this is a position vector to store the calculated vertex position in the position_local member of the Fragment structure.
[0066] Through the above method, the normal expansion of the vertex can be realized in the model space, which is convenient for the subsequent generation of the halo effect.
[0067] Step 202, performing Fresnel calculation according to the line of sight direction of the moved vertex toward the camera position and the normal direction of the world space, to generate a halo contour that fits the local shape;
[0068] In the embodiment of the present invention, a halo contour that fits the local shape of the model can be formed by utilizing normal expansion in combination with the line of sight of the vertices of the local shape toward the camera position.
[0069] In some embodiments of the present invention, for each moved vertex, its sight direction toward the camera position can be calculated. The sight direction can be calculated by the vector difference between the vertex position and the camera position, so as to generate a halo outline that fits the local shape according to the sight direction.
[0070] Optionally, the generation of the halo outline can be achieved by using a Fresnel algorithm to perform Fresnel calculations, which can be specifically performed by performing Fresnel calculations according to the line of sight of the moved vertex toward the camera position and the normal direction of the world space to generate a halo outline that fits the local shape.
[0071] Specifically, when using the Fresnel algorithm to calculate the halo effect, since the Fresnel effect describes the reflection and transmission behavior of light at the interfaces of different media, changes in reflectivity and transmittance can be used to control the intensity and color of the halo, and the reflectivity and transmittance of light change with the incident angle, that is, it depends on the incident angle, and the incident angle usually refers to the angle between the light and the normal.
[0072] In Fresnel calculations, the dot product of the view direction and the normal direction can be used to calculate the angle of incidence.
[0073] In some embodiments of the present invention, the world space normal direction can be obtained, and a dot product calculation can be performed based on the line of sight of the moved vertex toward the camera position and the world space normal direction to obtain a dot product value. Based on the calculated dot product value, the behavior of light reflection on the surface of the local shape is simulated to obtain a halo contour that fits the local shape.
[0074] Among them, the world space normal direction refers to the direction of the normal vector in the global coordinate system, which is perpendicular to the surface of the object. The world space normal direction in the embodiment of the present invention may refer to the direction perpendicular to the surface of the local shape of the model; the line of sight direction is specifically the world space direction of the line of sight, which may refer to the direction from a certain point on the surface of the object, such as a moved vertex to the observer (i.e., the camera position), which can be mainly used to calculate the light reflected from the surface of the object to the observer.
[0075] The dot product is the inner product between two vectors, i.e. The modulus of two vectors multiplied by the cosine of the angle between the two vectors results in a scalar value. The dot product value can be used to calculate the angle between the two vectors. In a specific implementation, the dot product value can be obtained by obtaining the vector in the direction of the line of sight and the normal vector in the direction of the world space normal, and performing a dot product calculation using the vector in the direction of the line of sight and the normal vector. Exemplarily, the dot product (dot) of the world space direction of the line of sight and the world space normal direction can be relied on in the fragment shader to obtain a Fresnel effect from the middle to the edge where the model and the line of sight meet. The code implementation can be as follows:
[0076] floatrim=saturate(dot(normalize(CameraVec),normalize(input.normal_world)));
[0077] Among them, rim can be a calculated dot product value, that is, the value of the Fresnel effect obtained by dot product of the world space direction dependent on the line of sight and the world space normal direction, the dot product is realized by the dot product of the vector from the vertex to the camera (i.e., CameraVec) and the normal vector (i.e., normal_world), and the calculated dot product value can simulate the halo contour of the object surface, which is the halo contour that fits the local shape in the embodiment of the present invention. At this time, the larger the dot product value, the smaller the incident angle, the higher the intensity of the reflected light, and the more obvious the halo contour intensity; the smaller the dot product value, the larger the incident angle, the lower the intensity of the reflected light, and the less obvious the halo contour. Specifically, the calculated dot product value can be used to calculate the reflectivity and transmittance generated by the light on the local shape surface as the incident angle changes, so as to obtain the Fresnel effect of the reflection amount change caused by the change of the line of sight.
[0078] Optionally, by responding to the adjustment instruction of the exponential function of the dot product value, the reflection amount transformation value generated on the surface of the local shape based on the change of the line of sight direction can be obtained, and then the halo intensity of the halo contour can be controlled based on the reflection amount transformation value, so as to achieve the following: Figure 3A The transition effect from the middle to the edge where the model meets the line of sight is shown, resulting in a basic glow effect that fits the local shape of the model.
[0079] It should be noted that the rendering implementation of the above-mentioned Fresnel effect can be calculated in a fragment shader.
[0080] Step 203, creating several layers of halos based on the halo outline;
[0081] In some embodiments of the present invention, several layers of halos can be created based on the halo outline to achieve enhanced visual effects, simulated real halos, smooth transitions, enhanced dynamic effects, improved visual layering, and the like.
[0082] The creation of several layers of halos can be expressed as parameter control of the dot product value, so as to generate several layers of halos according to the halo contour.
[0083] Optionally, the preset control parameters may include at least one or more of the following, such as a first parameter for controlling the luminous range of the halo, and a second parameter for controlling the feathering degree of the luminous edge of the halo. At this time, the first parameter and the second parameter can be used to perform smooth interpolation processing on the dot product value to obtain several layers of halo with different widths and feathering degrees along the halo contour.
[0084] In practical applications, the basic rim value calculated in step 203 can be derived into three layers of halos with different widths and feathering degrees through parameters such as _RimWidth and _RimFeather. That is, for each layer of rim, the luminous range can be controlled by the first parameter, assuming _RimWidth, and the feathering degree of the luminous edge can be controlled by the second parameter, assuming _RimFeather.
[0085] Step 204, interpolating the multiple layers of halos to obtain multiple layers of halos that fit the local shape;
[0086] In some embodiments of the present invention, after creating several layers of halo, the several layers of halo can be interpolated so that they can simulate the lighting effects achieved by several layers of blur while fitting the local shape of the model, so that the halo effect produced can meet the above-mentioned effects of enhancing visual effects, simulating real halo, smooth transition, enhancing dynamic effects, and improving visual hierarchy. That is, the superposition and interpolation of several layers of halo can ensure that the generated lighting effects are richer, more realistic, more dynamic and more attractive.
[0087] Specifically, several layers of halos can be interpolated and fused quickly to reduce the number of RT rendering times. Optionally, several layers of halos can be obtained by obtaining dot product values of several layers of halos and then performing linear interpolation and mixing processing on the dot product values of several layers of halos to obtain halo effects that fit the local shape.
[0088] Exemplarily, the process of generating several layers of halo effects may be implemented in the following code:
[0089] floatriml=smoothstep(1-_RimMidth,1,rim);
[0090] riml=smoothstep(θ,_RimFeather,rim);
[0091] float rim2=smoothstep(1-_RinMiath2,1,rim);
[0092] rim2=smoothstep(0,_RimFeather2,rim);
[0093] float rim3=smoothstep(1-_Rinhidth3,1,rim);
[0094] rim3=smoothstep(0,_RimFeather3,rim);
[0095] rim=lerp(rim3,lerp(riml,rim2,8.5),0.5);
[0096] Among them, smoothstep is an interpolation function commonly used in computer graphics and other fields. It is used to smoothly transition data. Its main purpose is to ensure smooth interpolation within a given range, such as smoothstep(edge0,edge1,x), where edge0 and edge1 are assumed to be the minimum and maximum boundary values, respectively, and x is the input value to be interpolated. When performing linear interpolation mixing, normalization can be performed first to normalize the input value x to the range of [0,1]. Specifically, it can be expressed as float t=(x-edge0) / (edge1-edge0), and the calculated t value is the normalized input value; then clipping can be performed to limit t to the range of [0,1] to ensure that the output value does not exceed this range, which can be specifically expressed as t=clamp(t,0.0,1.0); then a cubic interpolation polynomial can be applied, that is, t*t*(3.0-2.0*t), and finally a smooth transition effect from 0 to 1 between edge0 and edge1 is formed.
[0097] It should be noted that for each layer of rim, the luminous range can be controlled by the parameter _RimWidth of the first smoothstep in the above code, and the feathering degree of the luminous edge can be controlled by the parameter _RimFeather of the second smoothsetp in the above code. Taking rim1 as an example, the code calculation to be executed is as follows:
[0098] float rim1=smoothstep(1-_Rimwidth,1,rim);
[0099] rim1=smoothstep(0,_RimFeather,rim);
[0100] At this time, the input values of the corresponding parameters above can be substituted into the following formula for calculation:
[0101] smoothstep(edge0,edge1,x)
[0102] {
[0103] float t=(x-edge0) / (edge1-edge0);
[0104] t = clamp(t, 0.0, 1.0);
[0105] Return(t*t*(3.0-2.0*t))
[0106] }
[0107] The basic luminous effect is superimposed by controlling the transition of different levels through the smoothstep function, thereby ensuring that each layer of rim can form a smooth transition effect from 0 to 1 between edge0 and edge1, thereby obtaining several layers of halo effects that fit the local shape.
[0108] Step 205, controlling the light emission frequency of the halo effect, and rendering to obtain a breathing light effect.
[0109] After generating several layers of halo effects that fit the local shape, in order to achieve the breathing effect of light effect, the breathing light effect can be rendered by controlling the aforementioned several layers of halo effects. This can add breathing light effect to the local shape of the model in the picture while adapting to the local shapes of different models and with low performance overhead.
[0110] Optionally, the breathing light effect can meet the needs of adding different colors, brightness, and flashing frequencies to different parts of the picture. In order to achieve the aforementioned breathing light effect, the control instruction can usually carry relevant control parameters for the luminous frequency, luminous intensity, luminous color, etc., so as to perform breathing control on the aforementioned several layers of halo effects.
[0111] In practical applications, control parameters for each layer of halo effect can be used to independently control the luminous frequency, luminous intensity, luminous color, etc. of each layer of halo effect to meet the dynamic effect and visual layering of the generated light effect as much as possible.
[0112] In some embodiments of the present invention, when it is determined that the breathing light effect is enabled, in response to a control instruction, the halo effect is rendered based on the multiplication of the luminous frequency and the luminous intensity of the halo effect to obtain the breathing light effect.
[0113] For example, the implementation code may be as follows:
[0114] floatspeed=(_BlinkSpeed>0)? (saturate(sin(_BlinkSpeed*FrameTime))):1;
[0115] float rimintensity=_RimIntensity*speed;
[0116] Among them, it can be judged whether the breathing light effect is enabled. In one case, when the _BlinkSpeed parameter is greater than 0, it means that the breathing light effect is currently enabled. At this time, the sin function can be combined with the control frequency _BlinkSpeed, and multiplied by the overall intensity of the halo to obtain the halo flickering effect; in another case, when the _BlinkSpeed parameter is equal to 0, it means that the breathing light effect is not currently enabled. At this time, the luminous brightness continues to be 1, and no flickering effect will be generated. That is, based on the process of multiplying the luminous frequency with the luminous intensity of the halo effect, the breathing flickering function can be added to the halo effect generated in step 204.
[0117] For example, Figure 3B The effect shown is without the blooming halo. The breathing light effect rendering method provided by the embodiment of the present invention can achieve the blooming halo effect. Specifically, the front rendering effect of the blooming halo can be as follows Figure 3C As shown in ①, the side rendering effect of the bloom halo can be as follows Figure 3C As shown in ②, in the resulting rendering effect, the halo fits the shape of the model and there is no abnormal effect when interlaced with the model, which can simulate Bloom well with low consumption.
[0118] In a preferred embodiment of the present invention, the process of fitting the model shape to produce a basic luminous effect, superimposing the basic luminous effect by controlling the transition of different levels through the smoothstep function to obtain a halo effect, and adding a breathing flashing function to the halo effect can be achieved by adding a rendering link.
[0119] Specifically, the newly added Pass code declaration for breathing light effect rendering is written in rampscene_atlas_lbs_bright.nfx. The specific shader code can include all the codes in the above steps, and the implemented code can be written in the rampscene_atlas_lbs_bright_p1.hlsl file. This file is the shader file of NeoX. Its code implementation can be as follows:
[0120]
[0121] Among them, Pass p1 can be a rendering link newly created in an embodiment of the present invention; EnableZWritable = false, which means turning off depth writing to prevent the bloom effect of the semi-transparent newly added Pass rendering from performing depth judgment, and avoiding the elimination of the model effect rendered by the original Pass, that is, setting the halo effect not to participate in the depth sorting judgment to ensure that the rendering of the model itself will not be blocked; EnableAlphaBlend = true, which means turning on semi-transparent blending to perform semi-transparent fusion of the breathing halo with the model basic effect rendering performed by the original Pass; BlendFactor specifies the blending method as the rgb result rendered by Pass1 + the result rendered by Pass2 * semi-transparent value; Vertexshader indicates that the vertex shader is located in the .hlsl file and is named vs_main_outlinebloom; PixeShader indicates that the fragment shader is located in the .hlsl file and is called ps_main_outlinebloom.
[0122] Optionally, if rendering one frame requires multiple Passes to complete the effect of the last frame, the newly created rendering link, namely Pass p1, can be mixed with the Pass rendered by the original normal model, so that the newly added Pass can be flexibly added to different materials to achieve the breathing light effect that different models want to achieve. The specific mixing of the rendering links is not limited in the embodiments of the present invention.
[0123] In an embodiment of the present invention, a halo outline that fits the local shape of the model is formed by utilizing normal expansion in combination with the line of sight of the vertices of the local shape toward the camera position, and then several layers of halo created based on the halo outline are interpolated, so that it can simulate the lighting effect achieved by several layers of blur while fitting the local shape of the model, and then by controlling the aforementioned several layers of lighting effects, a breathing light effect is rendered, which can add a breathing light effect to the local shape of the model in the picture while being adaptive to different local shapes of the model and with low performance overhead. Furthermore, by adding a rendering link to combine the solution of normal expansion plus Fresnel algorithm, several layers of halo are interpolated and fused quickly, which can reduce the number of RT rendering times, and fit various model shapes on the basis of reducing the number of RT rendering times, to achieve a customizable breathing halo effect.
[0124] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0125] Reference Figure 4 , shows a structural block diagram of an embodiment of a rendering device for breathing light effect of the present invention, which may specifically include the following modules:
[0126] A vertex moving module 401 is used to obtain vertices of a local shape in a preset model, and move the vertices outward along the normal direction of the vertices;
[0127] A halo contour generating module 402 is used to generate a halo contour that fits the local shape according to the sight direction of the moved vertex toward the camera position;
[0128] A halo effect generating module 403 is used to create several layers of halo based on the halo outline, and perform interpolation processing on the several layers of halo to obtain several layers of halo effects that fit the local shape;
[0129] The breathing light effect rendering module 404 is used to respond to the control instruction of the halo effect and render the breathing light effect.
[0130] In some embodiments of the present invention, the halo outline generation module 402 may include the following submodules:
[0131] The halo outline generation submodule is used to obtain the world space normal direction; perform dot product calculation based on the line of sight direction of the moved vertex toward the camera position and the world space normal direction to obtain a dot product value; the dot product value is used to simulate the behavior of light reflecting on the surface of the local shape to obtain a halo outline that fits the local shape.
[0132] In some embodiments of the present invention, the halo contour generation submodule may include the following units:
[0133] The dot product calculation unit is used to obtain the vector in the sight line direction and the normal vector in the normal direction of the world space; perform dot product calculation using the vector in the sight line direction and the normal vector to obtain a dot product value.
[0134] In some embodiments of the present invention, the halo outline generation module 402 may further include the following submodules:
[0135] The halo intensity adjustment submodule is used to respond to the adjustment instruction of the exponential function of the dot product value, obtain the reflection amount transformation value generated on the surface of the local shape based on the change of the line of sight direction; and control the halo intensity of the halo contour based on the reflection amount transformation value.
[0136] In some embodiments of the present invention, the halo effect generation module 403 may include the following submodules:
[0137] The halo effect generation submodule is used to perform parameter control on the dot product value to generate several layers of halo according to the halo contour; and perform interpolation processing on the several layers of halo to obtain several layers of halo effects that fit the local shape.
[0138] In some embodiments of the present invention, the halo effect generation submodule may include the following units:
[0139] A halo creation unit is used to use preset control parameters to perform smooth interpolation processing on the dot product value to obtain several layers of halo with different widths and feathering degrees along the halo contour; wherein the preset control parameters include at least one or more of the following: a first parameter and a second parameter, the first parameter is used to control the luminous range of the halo, and the second parameter is used to control the feathering degree of the luminous edge of the halo.
[0140] In some embodiments of the present invention, the halo effect generation submodule may include the following units:
[0141] The halo effect generating unit is used to obtain the dot product values of the plurality of halo layers; perform linear interpolation and mixing processing on the dot product values of the plurality of halo layers to obtain a plurality of halo effects that fit the local shape.
[0142] In some embodiments of the present invention, the control instruction carries the light emitting frequency, and the breathing light effect rendering module 404 may include the following submodules:
[0143] The breathing light effect rendering submodule is used to respond to the control instruction when it is determined that the breathing light effect is enabled, and render the halo effect based on the multiplication of the luminous frequency and the luminous intensity of the halo effect to obtain the breathing light effect.
[0144] In an embodiment of the present invention, a rendering device for a breathing light effect provided by an embodiment of the present invention generates a halo outline that fits the local shape by moving the vertices of a local shape in a preset model outward along the direction of the normal, and according to the line of sight of the moved vertices toward the camera position, a halo outline is generated that fits the local shape, and then several layers of halo are created based on the halo outline, and the created several layers of halo are interpolated to obtain several layers of halo effects that fit the local shape, and then the breathing light effect is rendered by responding to the control instructions of the aforementioned halo effect that fits the local shape. A halo outline that fits the local shape of the model is formed by utilizing the normal expansion combined with the line of sight of the vertices of the local shape toward the camera position, and then the several layers of halo created based on the halo outline are interpolated to simulate the light effect effect achieved by several layers of blur when fitting the local shape of the model, and then the breathing light effect is rendered by controlling the aforementioned several layers of light effect, ensuring that the rendered breathing light effect can adapt to different local shapes of the model, and has low performance overhead and high flexibility.
[0145] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0146] An embodiment of the present invention further provides an electronic device, including:
[0147] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, each process of the rendering method embodiment of the above-mentioned breathing light effect is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0148] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned breathing light effect rendering method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0149] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0150] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0151] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0152] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0153] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0154] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0155] Finally, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0156] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0157] A method for rendering a breathing light effect, a device for rendering a breathing light effect, a corresponding electronic device and a corresponding computer-readable storage medium provided by the present invention are introduced in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for rendering a breathing light effect, characterized in that: The method comprises: Acquire vertices of a local shape in a preset model, and move the vertices outward along the normal direction of the vertices; Generating a halo contour fitting the local shape according to the sight direction of the moved vertex toward the camera position; Creating a plurality of halo layers based on the halo contour, and performing interpolation processing on the plurality of halo layers to obtain a plurality of halo effects that fit the local shape; In response to the control instruction for the halo effect, a breathing light effect is rendered.
2. The method according to claim 1, characterized in that The step of generating a halo contour fitting the local shape according to the sight direction of the moved vertex toward the camera position includes: Get the world space normal direction; A dot product value is obtained by performing a dot product calculation based on the sight line direction of the moved vertex toward the camera position and the normal direction of the world space; the dot product value is used to simulate the behavior of light reflecting on the surface of the local shape to obtain a halo contour that fits the local shape.
3. The method according to claim 2, characterized in that The step of performing a dot product calculation based on the sight line direction of the moved vertex toward the camera position and the normal direction of the world space to obtain a dot product value includes: Obtaining the vector of the sight direction and the normal vector of the world space normal direction; A dot product calculation is performed using the vector of the sight direction and the normal vector to obtain a dot product value.
4. The method according to claim 2 or 3, characterized in that: The method further comprises: In response to an instruction to adjust the exponential function of the dot product value, obtaining a reflection amount transformation value generated on the surface of the local shape based on a change in the sight line direction; The halo intensity of the halo profile is controlled based on the reflection amount conversion value.
5. The method according to claim 2, characterized in that: The step of creating a plurality of halo layers based on the halo contour and performing interpolation processing on the plurality of halo layers to obtain a plurality of halo effects that fit the local shape includes: Performing parameter control on the dot product value to generate a plurality of halo layers according to the halo profile; Interpolation processing is performed on the plurality of layers of halos to obtain a plurality of layers of halos that fit the local shape.
6. The method according to claim 5, characterized in that The step of performing parameter control on the dot product value and generating a plurality of halo layers according to the halo profile includes: The dot product value is smoothly interpolated by using preset control parameters to obtain a plurality of halo layers with different widths and feathering degrees along the halo contour; The preset control parameters include at least one or more of the following: a first parameter and a second parameter, wherein the first parameter is used to control the luminous range of the halo, and the second parameter is used to control the feathering degree of the luminous edge of the halo.
7. The method according to claim 1 or 5, characterized in that: The interpolation process is performed on the plurality of halo layers to obtain a plurality of halo effects that fit the local shape, including: Obtaining dot product values of the plurality of layers of halos; Linear interpolation and mixing processing is performed on the dot product values of the plurality of layers of halos to obtain a plurality of layers of halos that fit the local shape.
8. The method according to claim 1, characterized in that The control instruction carries a light emitting frequency; the response to the control instruction for the halo effect, rendering to obtain a breathing light effect, includes: In the case where it is determined that the breathing light effect is enabled, in response to the control instruction, the halo effect is rendered based on the multiplication of the light emitting frequency and the light emitting intensity of the halo effect to obtain the breathing light effect.
9. A rendering device for breathing light effect, characterized in that: The device comprises: A vertex moving module, used to obtain the vertices of the local shape in the preset model, and move the vertices outward along the normal direction of the vertices; A halo contour generating module, used for generating a halo contour fitting the local shape according to the sight direction of the moved vertex toward the camera position; A halo effect generation module, used for creating several layers of halo based on the halo outline, and performing interpolation processing on the several layers of halo to obtain several layers of halo effects fitting the local shape; The breathing light effect rendering module is used to respond to the control instruction of the halo effect and render the breathing light effect.
10. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the method for rendering the breathing light effect as claimed in any one of claims 1 to 8 is implemented.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for rendering the breathing light effect as claimed in any one of claims 1 to 8 is implemented.