A method for determining and rendering shadow edges, storage medium and electronic device

By calculating the shadow intensity and angle value of the target element model in the game scene, determine the edge area of ​​the shadow, solve the difficulty and cost of the style of shadow stickers in the existing technology, and achieve efficient rendering of the edge of the dynamic shadow.

CN114288649BActive Publication Date: 2025-01-24NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111669303.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-01-24
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

When stylizing shadow maps in game scenes, it is difficult and costly. The existing technology cannot effectively support the determination and rendering of dynamic shadow edges.

Method used

By obtaining the first shadow strength value of the target element model in the game scenario, combined with the angle value between the direction of the target element model vertex method and the direction of light, calculate the second shadow strength value, and determine the shadow edge area according to its rate of change. Essence

Benefits of technology

It reduces the computational cost and difficulty of shadow edge determination and rendering, supports real-time determination and stylized rendering of dynamic shadow edges, and improves the realism and visual effects of game scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114288649B_ABST
    Figure CN114288649B_ABST
Patent Text Reader

Abstract

The present application discloses a method for determining and rendering a shadow edge, a storage medium and an electronic device, wherein the determination method comprises: obtaining a first shadow intensity value set for a target element model in a game scene; determining an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and an illumination direction of the target element model; determining a second shadow intensity value according to the angle value and the first shadow intensity value; determining a shadow edge region according to a change rate of the obtained second shadow intensity value; wherein the shadow edge region comprises a shadow edge region projected by the target element model in the illumination space, and a shadow edge region of the target element model itself in the illumination space; and effectively reducing computational cost and difficulty.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of computer graphics processing, and in particular to a method and device for determining a shadow edge, and a method and device for rendering a shadow edge. The present application also relates to a computer storage medium and an electronic device. Background Art

[0002] Games have evolved from simple game consoles in the early days to current game application software that is attached to electronic terminal devices. They have been continuously developed through computer technology, including 2D game applications and 3D game applications.

[0003] Regardless of whether it is a 2D game application or a 3D game application, a game scene usually requires a variety of game elements to form. In order to improve the realism of the game scene, adding shadows of game elements is one of the important means. Summary of the invention

[0004] The present application provides a method for determining a shadow edge to solve the technical problem of high difficulty and high cost in stylizing shadow maps in game scenes.

[0005] The present application provides a method for determining a shadow edge, comprising:

[0006] Get the first shadow intensity value set for the target element model in the game scene;

[0007] Determining an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and an illumination direction of the target element model;

[0008] Determine a second shadow intensity value according to the angle value and the first shadow intensity value;

[0009] Determine a shadow edge area according to the acquired rate of change of the second shadow intensity value; wherein the shadow edge area includes a shadow edge area projected by the target element model in the illumination space and a shadow edge area of ​​the target element model itself in the illumination space.

[0010] In some embodiments, determining the angle value of the angle between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model includes:

[0011] Obtain a first vector of the illumination direction of the target element model;

[0012] Obtain a second vector of a normal direction of a vertex of the target element model;

[0013] The angle value of the angle between the normal direction of the vertex of the target element model and the illumination direction of the target element model is determined according to the first vector and the second vector.

[0014] In some embodiments, determining the angle value of the angle between the vertex normal direction of the target element model and the illumination direction of the target element model according to the first vector and the second vector includes:

[0015] Performing a dot product operation on the first vector and the second vector to obtain a dot product result;

[0016] Determine the cosine value of the angle according to the dot product result;

[0017] The cosine value is determined as the angle value of the angle.

[0018] In some embodiments, determining the second shadow intensity value according to the angle value and the first shadow intensity value includes:

[0019] The product of the angle value and the first shadow intensity value is determined as the second shadow intensity value.

[0020] In some embodiments, determining the shadow edge area according to the acquired change rate of the second shadow intensity value includes:

[0021] determining a rate of change of the second shadow intensity value according to the second shadow intensity value and the partial derivative function;

[0022] Determine the second shadow intensity value corresponding to the selected change rate with the largest absolute value as the target shadow intensity value;

[0023] The shadow area corresponding to the target shadow intensity value is determined as the shadow edge area.

[0024] The present application also provides a device for determining a shadow edge, comprising:

[0025] An acquisition unit, used to acquire a first shadow intensity value set for a target element model in a game scene;

[0026] A first determining unit, configured to determine an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and the illumination direction of the target element model;

[0027] a second determining unit, configured to determine a second shadow intensity value according to the angle value and the first shadow intensity value;

[0028] The third determination unit is used to determine the shadow edge area according to the acquired change rate of the second shadow intensity value; wherein the shadow edge area includes the shadow edge area projected by the target element model in the illumination space and the shadow edge area of ​​the target element model itself in the illumination space.

[0029] The present application also provides a shadow edge rendering method, comprising:

[0030] Get the first shadow intensity value set for the target element model in the game scene;

[0031] Determining an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and an illumination direction of the target element model;

[0032] Determine a second shadow intensity value according to the angle value and the first shadow intensity value;

[0033] Determine a shadow edge area according to the acquired change rate of the second shadow intensity value; wherein the shadow edge area includes a shadow edge area projected by the target element model in the illumination space and a shadow edge area of ​​the target element model itself in the illumination space;

[0034] Edge rendering is performed on the shadow edge area.

[0035] In some embodiments, performing edge rendering on the shadow edge area includes:

[0036] Determine target rendering data according to the set data to be rendered in the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data;

[0037] Edge rendering is performed on the shadow edge area according to the target rendering data.

[0038] In some embodiments, determining the target rendering data according to the set data to be rendered in the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data includes:

[0039] Mixing the data to be rendered, the basic rendering data, the shadow edge coefficient and the edge intensity data;

[0040] The mixed data is determined as the target rendering data.

[0041] The present application also provides a shadow edge rendering device, comprising:

[0042] An acquisition unit, used to acquire a first shadow intensity value set for a target element model in a game scene;

[0043] A first determining unit, configured to determine an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and the illumination direction of the target element model;

[0044] a second determining unit, configured to determine a second shadow intensity value according to the angle value and the first shadow intensity value;

[0045] a third determining unit, configured to determine a shadow edge region according to the acquired change rate of the second shadow intensity value; wherein the shadow edge region includes a shadow edge region projected by the target element model in the illumination space and a shadow edge region of the target element model itself in the illumination space;

[0046] A rendering unit is used to perform edge rendering on the shadow edge area.

[0047] The present application also provides a computer storage medium for storing data generated by a network platform, and a program for processing the data generated by the network platform;

[0048] When the program is read and executed by a processor, the program executes the above-mentioned method for determining the shadow edge; or, the program executes the above-mentioned method for rendering the shadow edge.

[0049] The present application also provides an electronic device, comprising:

[0050] processor;

[0051] The memory is used to store a program for processing data generated by a network platform. When the program is read and executed by the processor, the method for determining the shadow edge as described above is executed; or the method for rendering the shadow edge as described above is executed.

[0052] Compared with the prior art, this application has the following advantages:

[0053] In an embodiment of a method for determining a shadow edge provided in the present application, the angle value of the angle between the target element model vertex normal vector and the illumination direction vector is obtained, a second shadow intensity value is obtained based on the angle value and a preset first shadow intensity value, and then the rate of change of the second shadow intensity value is determined to determine the shadow edge. Compared with the prior art, this method does not require manual determination of the shadow edge area based on a baked shadow map, effectively reducing the calculation cost and difficulty, and is not limited to the determination of the shadow edge in an offline scenario, and supports dynamic shadow edge determination.

[0054] In an embodiment of a shadow edge rendering method provided in the present application, after determining the shadow edge area by adopting the shadow edge determination method embodiment, the shadow edge area is rendered according to the set fill color, graphic or image, thereby improving the accuracy of shadow edge rendering in game scenes that require stylized shadow edges, and supporting the rendering of dynamic shadow edges, and the rendering of shadow edges can also support dynamic effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 is a flow chart of an embodiment of a method for determining a shadow edge provided by the present application;

[0056] Figure 2-1 is a schematic diagram of an angle in an embodiment of a method for determining a shadow edge provided by the present application;

[0057] Figure 2-2 is a schematic diagram of a shadow edge in an embodiment of a method for determining a shadow edge provided by the present application;

[0058] Figure 3 is a structural schematic diagram of an embodiment of a device for determining a shadow edge provided by the present application;

[0059] Figure 4 is a flow chart of an embodiment of a shadow edge rendering method provided by the present application;

[0060] Figure 5 is a schematic diagram of shadow edge rendering in an embodiment of a shadow edge rendering method provided by the present application;

[0061] Figure 6 It is a structural schematic diagram of an embodiment of a shadow edge rendering device provided by the present application;

[0062] Figure 7 It is a structural schematic diagram of an electronic device embodiment provided by the present application. DETAILED DESCRIPTION

[0063] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0064] The terms used in this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The descriptions used in this application and the appended claims, such as "a", "first", and "second", are not limitations on quantity or sequence, but are used to distinguish the same type of information from each other.

[0065] In combination with the above background technology, it can be known that the technical concept of the present application is generated from the defects in the shadow processing of game elements in the game scene. Specifically, the processing of real-time shadows of game elements in existing game scenes is usually one color, that is, black or gray, of course, it can also be other colors. For the processing of shadow edges, the shadow map generated by the lighting can be baked into a shadow map in advance in an offline state, and the edges of the shadow map can be filled with a color that is similar to a warm tone through Photoshop to achieve the processing of the shadow edges and realize the shadow stylization requirements of specific game scenes or games. However, the method of baking shadow maps has the following problems:

[0066] 1. The size of the shadow map is relatively high. Although the size of the shadow map in the current mobile game is controlled at 2048×2048, the accuracy of the shadow map is still far from the target accuracy;

[0067] 2. Since the baked shadow map needs to manually find the corresponding edge position before edge processing, the processing difficulty and cost are high;

[0068] 3. Since the baked shadow map generates a fixed map for the game elements, it cannot reflect different attenuation according to the light direction in the game scene, that is, it cannot support the dynamic effect of the shadow.

[0069] Therefore, in view of the above problems, the present application provides a method for determining a shadow edge and a method for rendering a shadow edge, which are described below respectively.

[0070] like Figure 1 As shown, Figure 1 : is a flow chart of an embodiment of a method for determining a shadow edge provided by the present application, and the embodiment of the method for determining the shadow edge includes:

[0071] Step S101: Obtain a first shadow intensity value set for a target element model in a game scene.

[0072] The purpose of step S101 is to obtain a first shadow intensity value. In this embodiment, the first shadow intensity value can be preset, and of course can also be set when needed. The target element model can be a target element in a game scene. Specifically, the target element can be a game element pre-set in a model space, that is, the target element can be regarded as a target model. Usually in a game scene, each model (target element model) has its own independent coordinate space. When the model is moved, rotated, and scaled relative to the world center of the game level (game scene), the target element model has a change in the world space. In a game level or game scene, the target element model has a shadow due to the illumination of a light camera.

[0073] The specific implementation process of step S101 can be to obtain the first shadow intensity in a shader, wherein the shader graphics image processing language is used to write a calculation method for graphics rendering, and a calculation method can be customized to achieve the lighting effect. Generally, it includes a vertex shader and a fragment shader, wherein the vertex shader calculates the position of the game model (target element model) in the camera space in the world space and maps it to the screen, and the fragment shader is the process of coloring each pixel in the game model after the vertex shader.

[0074] When obtaining the first shadow intensity value set by the game engine through the shader, in this embodiment, mainLight (main light source) can be used to obtain shadowAttenuation (shadow information), where shadowAttenuation is responsible for using ShadowCoord to sample the corresponding texture to obtain shadow information (the first shadow intensity in this embodiment), that is, float shadowIntensity = MainLight.shadowAttenuation.

[0075] Step S102: determining the angle value of the angle between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model.

[0076] like Figure 2-1 As shown, the purpose of step S102 is to obtain the angle value between the normal direction of the vertex of the target element model and the illumination direction.

[0077] Usually, the vertex normal is the sum of the normals of several faces that share the vertex of the target element model, and then normalized, that is, divided by the number of faces, to obtain the average normal, that is, the vertex normal direction of the target element model in this embodiment, for example: nv = (ns1 + ns2) / 2, where ns1 and ns2 can be face normals, and the faces of the target element model are two faces s1 and s2. Of course, the determination of the vertex normal direction is not limited to the above method, and any method that can obtain or calculate the vertex normal direction of the target element model is acceptable.

[0078] The illumination direction of the target element model may be understood as the direction in which the light source in the illumination space illuminates the target element model in the game scene or game level, and different illumination directions may be generated.

[0079] The specific implementation process of step S102 may include:

[0080] Step S102-1: Obtain a first vector of the illumination direction of the target element model, for example, I. The first vector can be obtained through parameters in the target element model.

[0081] Step S102-2: Obtain a second vector in the normal direction of the vertex of the target element model, for example, N. The second vector can also be obtained through parameters in the target element model.

[0082] Step S102-3: Determine the angle value of the angle between the normal direction of the vertex of the target element model and the illumination direction of the target element model according to the first vector and the second vector; specifically, perform a dot product operation on the first vector I and the second vector N, i.e. float ndotl=dot(N, I) to obtain a dot product result; determine the cosine value of the angle according to the dot product result; and determine the cosine value as the angle value of the angle. Because the result of dot (dot product) can be a scalar, which is equal to the product of the vector size and the cosine value of the angle, the calculation formula is as follows:

[0083]

[0084] In this embodiment, because vectors I and N are unit vectors, that is, the results of the first two terms of the formula are 1, the dot (dot product) result is the cosine value of the angle between the two vectors, that is: float ndot1 = dot (N, I). When the angle between the two vectors is closer to 0 degrees, the cosine value is closer to 1, and when the angle between the two vectors is closer to 180 degrees, the cosine value is closer to -1. The cosine value can be used to simulate the relationship between the illumination direction and the target element model. The closer the cosine value is to 1, the smaller the angle is, the higher the similarity between the first vector and the second vector is, the stronger the illumination intensity on the surface of the target element model is, and vice versa. In other words, the angle of the space vector can be measured by cosine similarity, so that the difference in direction can be reflected.

[0085] Step S103: determining a second shadow intensity value according to the angle value and the first shadow intensity value.

[0086] The specific implementation process of step S103 may include:

[0087] Step S103 - 1 : multiplying the angle value by the first shadow intensity value to determine the second shadow intensity value.

[0088] It can be understood that in this embodiment, the shadow intensity is the intensity of the projection generated by the game element model in the game scene in the lighting space, and the shadow intensity of the dark area of ​​the game element model itself in the lighting space. The attenuation of the shadow intensity can be at the edge of the projection shadow and the edge of the shadow of the dark area. The intensity of the shadow area outside the shadow edge area will not change under the set intensity value. The angle value is the value of the angle between the normal direction of the vertex of the target element model's own structure and the lighting direction. When the first shadow intensity value is a set fixed value, the structure of the target element model is relatively steep or uneven, then the shadow contour of the target element model generated in the lighting direction and the dark area will have a shadow intensity attenuation. Multiplying the angle value with the first shadow intensity value can obtain the edge of the dark area (i.e., the place where the light is not completely illuminated) of the existing target element model due to unevenness and lighting and the edge of the projection area generated by the projection.

[0089] In this embodiment, the expression of the angle value can be: ShadowIntensity=shadowIntensity×ndot1; wherein ShadowIntensity is the shadow intensity, shadowIntensity is the first shadow intensity value, and ndot1 is the angle value.

[0090] Step S104: determining a shadow edge area according to the acquired change rate of the second shadow intensity value.

[0091] like Figure 2-2 As shown, the specific implementation process of step S104 may include:

[0092] Step S104-1: determining a change rate of the second shadow intensity value according to the second shadow intensity value and the partial derivative function;

[0093] Step S104-2: determining the second shadow intensity value corresponding to the selected change rate with the largest absolute value as the target shadow intensity value;

[0094] Step S104 - 3 : determining the shadow area corresponding to the target shadow intensity value as the shadow edge area.

[0095] The implementation process of step S104-1 in this embodiment may be to substitute the second shadow intensity value into the partial derivative function for calculation, and calculate the rate of change of the second shadow intensity. The partial derivative function is divided into HLSL: ddx and ddy, GLSL: dFdx and dFdy. In this embodiment, ddx and ddy are used to calculate the rate of change of the second shadow intensity. The ddx and ddy are local difference derivative functions, which calculate the rate of change of any instruction in the fragment shader relative to the screen space coordinates. The ddx and ddy functions are mainly used in the fragment shader in the shader. When the mobile GPU performs pixel rendering, it is not executed one by one, but usually executed in parallel in 2×2 blocks. ddx represents the value of the pixel block on the right minus the value of the pixel block on the left, and ddy represents the value of the pixel block below minus the value of the pixel block above. The x and y represent the screen coordinates, so the ddx and ddy functions can obtain the rate of change between the two pixels through the pixel difference between the two blocks. The calculation formula is as follows:

[0096] Float radiance=abs(ddx(shadowIntensity))+abs(ddy(shadowIntenisty));

[0097] Among them, Float radiance is the rate of change of shadow intensity; abs(ddx(shadowIntensity)) is the absolute value of the pixel value of the second shadow intensity on the x-axis; abs(ddy(shadowIntenisty)) is the absolute value of the pixel value of the second shadow intensity on the y-axis; shadowIntenisty is the second shadow intensity value.

[0098] The shadows produced by projection will have numerical attenuation at the edge of the shadow or at the large-angle position (edge ​​of the dark area) of the dark area of ​​the game element model itself. The attenuation value of the shadow intensity can be calculated by ddx / ddy. The larger the attenuation value, the closer it is to the edge of the shadow or the edge of the dark area.

[0099] The above is an embodiment of a method for determining a shadow edge provided by the present application, which obtains the angle value of the angle between the target element model vertex normal vector and the illumination direction vector, obtains the second shadow intensity value based on the angle value and the preset first shadow intensity value, and then determines the rate of change of the second shadow intensity value to determine the shadow edge. Compared with the prior art, it does not require manual determination of the edge area of ​​the shadow based on the baked shadow map, effectively reducing the calculation cost and difficulty, and is not limited to the determination of the shadow edge in offline scenarios, and supports dynamic shadow edge determination.

[0100] The above is a specific description of an embodiment of a device for determining a shadow edge provided by the present application. Corresponding to an embodiment of a method for determining a shadow edge provided above, the present application also discloses an embodiment of a device for determining a shadow edge. Figure 3 Since the device embodiment 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. The device embodiment described below is only illustrative.

[0101] like Figure 3 As shown, Figure 3 : is a schematic diagram of a structure of an embodiment of a device for determining a shadow edge provided by the present application, and the device embodiment includes:

[0102] The acquisition unit 301 is used to acquire a first shadow intensity value set for a target element model in the game scene; the specific content of the acquisition unit 301 can refer to the above step S101, which will not be repeated here.

[0103] The first determining unit 302 is used to determine the angle value of the angle between the vertex normal direction of the target element model and the illumination direction of the target element model according to the vertex normal direction of the target element model and the illumination direction of the target element model.

[0104] The first determination unit 302 may include: a first acquisition subunit, a second acquisition subunit and a determination subunit. The first acquisition subunit is used to acquire a first vector of the illumination direction of the target element model; the second acquisition subunit is used to acquire a second vector of the vertex normal direction of the target element model; the determination subunit is used to determine the angle value of the angle between the vertex normal direction of the target element model and the illumination direction of the target element model according to the first vector acquired in the first acquisition subunit and the second vector acquired by the second acquisition subunit. In this embodiment, the determination subunit may include: an acquisition subunit, used to perform a dot product operation on the first vector and the second vector to obtain a dot product result; a cosine value determination subunit, used to determine the cosine value of the angle according to the dot product result; and an angle value determination subunit, used to determine the cosine value as the angle value of the angle. The specific implementation process of the first determination unit 302 can refer to the content of the above step S102.

[0105] The second determination unit 303 is used to determine a second shadow intensity value according to the angle value and the first shadow intensity value. In this embodiment, the second determination unit 303 can be specifically used to determine the second shadow intensity value by multiplying the angle value by the first shadow intensity value. The specific implementation process can refer to the content of the above step S103.

[0106] The third determination unit 304 is used to determine the shadow edge area according to the acquired change rate of the second shadow intensity value; in this embodiment, the third determination unit 304 may include: a first determination subunit, a second determination subunit and a third determination subunit; the first determination subunit can be used to determine the change rate of the second shadow intensity value according to the second shadow intensity value and the partial derivative function; the second determination subunit can be used to correspond the selected change rate with the largest absolute value to the second shadow intensity value, and determine it as the target shadow intensity value; the third determination subunit can be used to determine the shadow area corresponding to the target shadow intensity value as the shadow edge area.

[0107] The above is a description of an embodiment of a device for determining a shadow edge provided in the present application. For the specific contents of the embodiment of the determination device, please refer to the above-mentioned determination method embodiment, and no repetitive description will be given here.

[0108] Based on the above content, the present application also provides a method for rendering shadow edges, such as Figure 4 and Figure 5 As stated, Figure 4 is a flow chart of an embodiment of a shadow edge rendering method provided by the present application; Figure 5 : is a schematic diagram of shadow edge rendering in an embodiment of a shadow edge rendering method provided by the present application; in this embodiment, the rendering method may include:

[0109] Step S401: Obtain a first shadow intensity value set for a target element model in a game scene;

[0110] Step S402: determining the angle value of the angle between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model;

[0111] Step S403: determining a second shadow intensity value according to the angle value and the first shadow intensity value;

[0112] Step S404: determining a shadow edge area according to the acquired change rate of the second shadow intensity value;

[0113] Step S405: performing edge rendering on the shadow edge area.

[0114] The shadow edge rendering method described in this embodiment differs from the above-mentioned shadow edge determination method embodiment in step S405, that is, the shadow edge rendering method embodiment is based on the description of how to render the shadow edge after the shadow edge is determined in the shadow edge determination method embodiment. Therefore, the contents of steps S401 to S404 can refer to the above-mentioned steps S101 to S104 embodiments, which will not be repeated here.

[0115] The specific implementation process of step S405 may include:

[0116] Step S405 - 1 : determining target rendering data according to the set data to be rendered in the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data.

[0117] Step S405 - 2 : performing edge rendering on the shadow edge area according to the target rendering data.

[0118] The specific implementation process of step S405-1 may include:

[0119] Step S405-11: Mix the data to be rendered (GradientColor) according to the determined shadow edge area and the basic rendering data (baseColor); for example: finalColor=lerp(baseColor, GradientColor, radiance×GradientAttenInstensity); wherein finalColor is the target rendering color (target rendering data), baseColor is the basic color (basic rendering data), radiance is a custom variable for storing the editing function; GradientAttenInstensity is the shadow edge (shadow edge coefficient) determined by the rate of change.

[0120] The specific mixing can be: assuming that the basic color of the target element model is baseColor, add two parameters GradientColor and GradientAttenInstensity to adjust the shadow edge color, and mix GradientColor according to the final shadow edge (GradientAttenInstensity shadow edge coefficient), the custom variable (radiance) and the basic color (baseColor).

[0121] Step S405 - 12: Determine the mixed data as the target rendering data.

[0122] The shadow edge area is rendered according to the target rendering data.

[0123] The above is a description of an embodiment of a shadow edge rendering method provided by the present application. This embodiment can fill the shadow edge with any required color, graphic or image by determining the shadow edge in real time, so that the target element object in the game scene has a shadow area with a real-time dynamic stylized shadow edge under the lighting space. The rendering of any one or more combinations of the filled target colors, images or graphics no longer relies on the shadow map to manually search for shadow edges, thereby ensuring the accuracy of edge rendering.

[0124] The above is a description of an embodiment of a method for rendering a shadow edge provided by the present application. Corresponding to the embodiment of a method for rendering a shadow edge provided above, the present application also discloses an embodiment of a device for rendering a shadow edge. Figure 6 Since the device embodiment 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. The device embodiment described below is only illustrative.

[0125] like Figure 6 As shown, Figure 6 : is a schematic diagram of a structure of an embodiment of a rendering device for a shadow edge provided by the present application, and the rendering device embodiment includes:

[0126] The acquisition unit 601 is used to acquire a first shadow intensity value set for a target element model in the game scene. In this embodiment, the specific content of the acquisition unit 301 can refer to the above-mentioned step S101 and step S401, which will not be repeated here.

[0127] The first determination unit 602 is used to determine the angle value of the angle between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model; in this embodiment, the first determination unit 602 may include: a first acquisition subunit, a second acquisition subunit and a determination subunit. The first acquisition subunit is used to acquire the first vector of the illumination direction of the target element model; the second acquisition subunit is used to acquire the second vector of the vertex normal direction of the target element model; the determination subunit is used to determine the angle value of the angle between the target element model and the illumination direction according to the first vector acquired in the first acquisition subunit and the second vector acquired by the second acquisition subunit. In this embodiment, the determination subunit can be specifically used to calculate the cosine value of the angle according to the first vector and the second vector by using the dot product method. The specific implementation process of the first determination unit 302 can refer to the content of the above-mentioned step S102 and the content of step S402.

[0128] The second determining unit 603 is used to determine a second shadow intensity value according to the angle value and the first shadow intensity value. In this embodiment, the second determining unit 603 can be specifically used to determine the second shadow intensity value by multiplying the angle value by the first shadow intensity value. The specific implementation process can refer to the content of the above step S103 and the content of step S403.

[0129] The third determining unit 604 is used to determine the shadow edge area according to the obtained change rate of the second shadow intensity value; in this embodiment, the third determining unit 604 may include: a first determining subunit and a second determining subunit, the first determining subunit may be used to determine the change rate of the second shadow intensity value according to the second shadow intensity value and the partial derivative function; the second determining subunit may be used to determine the shadow area corresponding to the absolute value of the maximum change amplitude in the change rate as the shadow edge area. For specific content, please refer to the content of the above-mentioned step S104 and step S404, which will not be repeated here.

[0130] The rendering unit 605 is used to perform edge rendering on the shadow edge area. In this embodiment, the rendering unit 605 may include: a target data determination subunit and a rendering subunit. The target data determination subunit is used to determine the target rendering data according to the set data to be rendered of the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data. The rendering subunit is used to perform edge rendering on the shadow edge area according to the target rendering data. In this embodiment, the target data determination subunit may include: a mixing subunit and a determining subunit. The mixing subunit is used to mix the data to be rendered according to the determined shadow edge area and the basic rendering data. The determining subunit is used to determine the mixed data as the target rendering data. The shadow edge area is rendered according to the target rendering data, and a game scene with a rendering effect on the shadow edge area is output.

[0131] For the specific implementation process of the rendering unit 605, reference may be made to the content of the above step S405, which is only briefly described here.

[0132] Based on the above content, the present application also provides a computer storage medium for storing data generated by a network platform, and a program for processing the data generated by the network platform;

[0133] When the program is read and executed by the processor, the following steps are performed:

[0134] Get the first shadow intensity value set for the target element model in the game scene;

[0135] Determining an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and an illumination direction of the target element model;

[0136] Determine a second shadow intensity value according to the angle value and the first shadow intensity value;

[0137] A shadow edge area is determined according to the acquired change rate of the second shadow intensity value.

[0138] In some embodiments, determining the angle value of the angle between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model includes:

[0139] Obtain a first vector of the illumination direction of the target element model;

[0140] Obtain a second vector of a normal direction of a vertex of the target element model;

[0141] An angle value of an angle between the target element model and the illumination direction is determined according to the first vector and the second vector.

[0142] In some embodiments, determining the angle value of the angle between the vertex normal direction of the target element model and the illumination direction of the target element model according to the first vector and the second vector includes:

[0143] The cosine value of the angle is calculated according to the first vector and the second vector by adopting a dot product method.

[0144] In some embodiments, determining the second shadow intensity value according to the angle value and the first shadow intensity value includes:

[0145] The product of the angle value and the first shadow intensity value is determined as the second shadow intensity value.

[0146] In some embodiments, determining the shadow edge area according to the acquired change rate of the second shadow intensity value includes:

[0147] determining a rate of change of the second shadow intensity value according to the second shadow intensity value and the partial derivative function;

[0148] The shadow area corresponding to the absolute value of the maximum change amplitude in the change rate is determined as the shadow edge area.

[0149] Alternatively, when the program is read and executed by the processor, the following steps are performed:

[0150] Get the first shadow intensity value set for the target element model in the game scene;

[0151] Determining an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and an illumination direction of the target element model;

[0152] Determine a second shadow intensity value according to the angle value and the first shadow intensity value;

[0153] Determining a shadow edge area according to the acquired rate of change of the second shadow intensity value;

[0154] Edge rendering is performed on the shadow edge area.

[0155] In some embodiments, determining the angle value of the angle between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model includes:

[0156] Obtain a first vector in the normal direction of a vertex of the target element model;

[0157] Obtain a second vector of the illumination direction of the target element model;

[0158] Determine an angle between the target element model and the illumination direction according to the first vector and the second vector;

[0159] The cosine value of the angle is determined as the angle value.

[0160] In some embodiments, determining the angle between the vertex normal direction of the target element model and the illumination direction of the target element model according to the first vector and the second vector includes:

[0161] The cosine value of the angle is calculated according to the first vector and the second vector by adopting a dot product method.

[0162] In some embodiments, determining the second shadow intensity value according to the angle value and the first shadow intensity value includes:

[0163] The product of the angle value and the first shadow intensity value is determined as the second shadow intensity value.

[0164] In some embodiments, determining the shadow edge area according to the acquired change rate of the second shadow intensity value includes:

[0165] determining a rate of change of the second shadow intensity value according to the second shadow intensity value and the partial derivative function;

[0166] The shadow area corresponding to the absolute value of the maximum change amplitude in the change rate is determined as the shadow edge area.

[0167] In some embodiments, performing edge rendering on the shadow edge area includes:

[0168] Determine target rendering data according to the set data to be rendered in the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data;

[0169] Edge rendering is performed on the shadow edge area according to the target rendering data.

[0170] In some embodiments, determining the target rendering data according to the set data to be rendered in the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data includes:

[0171] Mixing the data to be rendered, the basic rendering data, the shadow edge coefficient and the edge intensity data;

[0172] The mixed data is determined as the target rendering data.

[0173] The present application also provides an electronic device, such as Figure 7 As shown, the electronic device embodiment may include:

[0174] Processor 701;

[0175] The memory 702 is used to store a program for processing data generated by the network platform. When the program is read and executed by the processor 701, the following steps are performed:

[0176] Get the first shadow intensity value set for the target element model in the game scene;

[0177] Determining an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and an illumination direction of the target element model;

[0178] Determine a second shadow intensity value according to the angle value and the first shadow intensity value;

[0179] A shadow edge area is determined according to the acquired change rate of the second shadow intensity value.

[0180] In some embodiments, determining the angle value of the angle between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model includes:

[0181] Obtain a first vector of the illumination direction of the target element model;

[0182] Obtain a second vector of a normal direction of a vertex of the target element model;

[0183] An angle value of an angle between the target element model and the illumination direction is determined according to the first vector and the second vector.

[0184] In some embodiments, determining the angle value of the angle between the vertex normal direction of the target element model and the illumination direction of the target element model according to the first vector and the second vector includes:

[0185] The cosine value of the angle is calculated according to the first vector and the second vector by adopting a dot product method.

[0186] In some embodiments, determining the second shadow intensity value according to the angle value and the first shadow intensity value includes:

[0187] The product of the angle value and the first shadow intensity value is determined as the second shadow intensity value.

[0188] In some embodiments, determining the shadow edge area according to the acquired change rate of the second shadow intensity value includes:

[0189] determining a rate of change of the second shadow intensity value according to the second shadow intensity value and the partial derivative function;

[0190] The shadow area corresponding to the absolute value of the maximum change amplitude in the change rate is determined as the shadow edge area.

[0191] Alternatively, when the program is read and executed by the processor 701, the following steps are performed:

[0192] Get the first shadow intensity value set for the target element model in the game scene;

[0193] Determining an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and an illumination direction of the target element model;

[0194] Determine a second shadow intensity value according to the angle value and the first shadow intensity value;

[0195] Determining a shadow edge area according to the acquired rate of change of the second shadow intensity value;

[0196] Edge rendering is performed on the shadow edge area.

[0197] In some embodiments, determining the angle value of the angle between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model includes:

[0198] Obtain a first vector in the normal direction of a vertex of the target element model;

[0199] Obtain a second vector of the illumination direction of the target element model;

[0200] Determine an angle between the target element model and the illumination direction according to the first vector and the second vector;

[0201] The cosine value of the angle is determined as the angle value.

[0202] In some embodiments, determining the angle between the vertex normal direction of the target element model and the illumination direction of the target element model according to the first vector and the second vector includes:

[0203] The cosine value of the angle is calculated according to the first vector and the second vector by adopting a dot product method.

[0204] In some embodiments, determining the second shadow intensity value according to the angle value and the first shadow intensity value includes:

[0205] The product of the angle value and the first shadow intensity value is determined as the second shadow intensity value.

[0206] In some embodiments, determining the shadow edge area according to the acquired change rate of the second shadow intensity value includes:

[0207] determining a rate of change of the second shadow intensity value according to the second shadow intensity value and the partial derivative function;

[0208] The shadow area corresponding to the absolute value of the maximum change amplitude in the change rate is determined as the shadow edge area.

[0209] In some embodiments, performing edge rendering on the shadow edge area includes:

[0210] Determine target rendering data according to the set data to be rendered in the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data;

[0211] Edge rendering is performed on the shadow edge area according to the target rendering data.

[0212] In some embodiments, determining the target rendering data according to the set data to be rendered in the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data includes:

[0213] Mixing the data to be rendered, the basic rendering data, the shadow edge coefficient and the edge intensity data;

[0214] The mixed data is determined as the target rendering data.

[0215] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0216] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0217] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.

[0218] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application can 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 code.

[0219] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.

Claims

1. A method for determining a shadow edge, characterized in that: include: Get the first shadow intensity value set for the target element model in the game scene; Determining an angle value between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model; Determine a second shadow intensity value according to a product of the angle value and the first shadow intensity value; According to the second shadow intensity value and the partial derivative function, the change rate of the second shadow intensity value is determined; the second shadow intensity value corresponding to the selected change rate with the largest absolute value is determined as the target shadow intensity value; the shadow area corresponding to the target shadow intensity value is determined as the shadow edge area; wherein the shadow edge area includes the shadow edge area projected by the target element model in the illumination space, and the shadow edge area of ​​the target element model itself in the illumination space.

2. The method for determining the shadow edge according to claim 1, characterized in that: The step of determining the angle value between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model includes: Obtain a first vector of the illumination direction of the target element model; Obtain a second vector of a normal direction of a vertex of the target element model; The angle value of the angle between the normal direction of the vertex of the target element model and the illumination direction of the target element model is determined according to the first vector and the second vector.

3. The method for determining the shadow edge according to claim 2, characterized in that: The step of determining the angle value between the normal direction of the vertex of the target element model and the illumination direction of the target element model according to the first vector and the second vector includes: Performing a dot product operation on the first vector and the second vector to obtain a dot product result; Determine the cosine value of the angle according to the dot product result; The cosine value is determined as the angle value of the angle.

4. A device for determining a shadow edge, characterized in that: include: An acquisition unit, used to acquire a first shadow intensity value set for a target element model in a game scene; A first determining unit, configured to determine an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and the illumination direction of the target element model; A second determining unit, configured to determine a second shadow intensity value according to a product of the angle value and the first shadow intensity value; The third determination unit is used to determine the change rate of the second shadow intensity value according to the second shadow intensity value and the partial derivative function; determine the second shadow intensity value corresponding to the selected change rate with the largest absolute value as the target shadow intensity value; determine the shadow area corresponding to the target shadow intensity value as the shadow edge area; wherein the shadow edge area includes the shadow edge area projected by the target element model in the illumination space, and the shadow edge area of ​​the target element model itself in the illumination space.

5. A method for rendering a shadow edge, characterized in that: include: Get the first shadow intensity value set for the target element model in the game scene; Determining an angle value between the target element model and the illumination direction according to the vertex normal direction of the target element model and the illumination direction of the target element model; Determine a second shadow intensity value according to a product of the angle value and the first shadow intensity value; Determine the change rate of the second shadow intensity value according to the second shadow intensity value and the partial derivative function; determine the second shadow intensity value corresponding to the selected change rate with the largest absolute value as the target shadow intensity value; determine the shadow area corresponding to the target shadow intensity value as the shadow edge area; wherein the shadow edge area includes the shadow edge area projected by the target element model in the illumination space, and the shadow edge area of ​​the target element model itself in the illumination space; Edge rendering is performed on the shadow edge area.

6. The method for rendering shadow edges according to claim 5, characterized in that: The performing edge rendering on the shadow edge area includes: Determine target rendering data according to the set data to be rendered in the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data; Edge rendering is performed on the shadow edge area according to the target rendering data.

7. The method for rendering shadow edges according to claim 6, characterized in that: The step of determining target rendering data according to the set data to be rendered in the shadow edge area, the basic rendering data of the target element model, the shadow edge coefficient and the edge strength data comprises: Mixing the data to be rendered, the basic rendering data, the shadow edge coefficient and the edge intensity data; The mixed data is determined as the target rendering data.

8. A shadow edge rendering device, characterized in that: include: An acquisition unit, used to acquire a first shadow intensity value set for a target element model in a game scene; A first determining unit, configured to determine an angle value of an angle between the target element model and the illumination direction according to a vertex normal direction of the target element model and the illumination direction of the target element model; A second determining unit, configured to determine a second shadow intensity value according to a product of the angle value and the first shadow intensity value; A third determining unit is used to determine the change rate of the second shadow intensity value according to the second shadow intensity value and the partial derivative function; determine the second shadow intensity value corresponding to the selected change rate with the largest absolute value as the target shadow intensity value; determine the shadow area corresponding to the target shadow intensity value as the shadow edge area; wherein the shadow edge area includes the shadow edge area projected by the target element model in the illumination space, and the shadow edge area of ​​the target element model itself in the illumination space; A rendering unit is used to perform edge rendering on the shadow edge area.

9. A computer storage medium for storing data generated by a network platform and a program for processing the data generated by the network platform; When the program is read and executed by a processor, the program executes the method for determining a shadow edge as described in any one of claims 1 to 3 above; or, executes the method for rendering a shadow edge as described in any one of claims 5 to 7 above.

10. An electronic device, comprising: processor; A memory for storing a program for processing data generated by a network platform, wherein when the program is read and executed by the processor, the program executes a method for determining a shadow edge as described in any one of claims 1 to 3 above; or, executes a method for rendering a shadow edge as described in any one of claims 5 to 7 above.

Citation Information

Patent Citations

  • Image rendering method and related device

    CN111292405A

  • Information processing method and device in game, electronic equipment and storage medium

    CN111408131A