Stylized rendering method and device, computer equipment and storage medium
By generating a gradient map and rendering the object model, the problem that the stylized rendering effect in the existing technology is not three-dimensional and dynamic is solved, a three-dimensional and dynamic stylized rendering effect is achieved, and the display and performance consumption are optimized.
Patent Information
- Application Number
- CN202310296937.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2024-09-20
AI Technical Summary
In the existing technology, stylized rendering effects mainly rely on simple shading techniques and static art assets, making it difficult to achieve three-dimensional and dynamic stylized visual effects.
By obtaining the object model of the object to be rendered, a gradient mask is generated and mixed with random noise to obtain a gradient map, and then the object model is rendered to generate a three-dimensional and dynamic stylized rendering result.
It achieves three-dimensional and dynamic stylized rendering effects, increases the consistency between stylized rendering results and object model texture information, optimizes the display effect, avoids translucent sorting problems, and reduces the performance consumption of rendering equipment.
Smart Images

Figure CN118674846A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a stylized rendering method, apparatus, computer equipment and storage medium. Background Art
[0002] With the development of image rendering technology, the rendering effect of image rendering has a great influence on the performance of virtual environment. The rendering effect requirements of objects in virtual scenes such as game scenes are getting higher and higher.
[0003] However, in the prior art, stylized visual effects still mainly rely on simple shading techniques and stylized art assets, and usually can only produce static stylized visual effects, with poor stereoscopic and dynamic effects. Summary of the invention
[0004] The embodiments of the present application provide a stylized rendering method, apparatus, computer equipment, and storage medium, which can generate three-dimensional and dynamic stylized rendering results.
[0005] An embodiment of the present application provides a stylized rendering method, comprising: obtaining an object model of an object to be rendered; generating a gradient mask according to texture information of the object model; mixing the gradient mask with random noise to obtain a gradient map; rendering the object model according to the gradient map to obtain a stylized rendering result of the object to be rendered.
[0006] An embodiment of the present application also provides a stylized rendering device, including: an acquisition unit, used to acquire an object model of an object to be rendered; a generation unit, used to generate a gradient mask according to texture information of the object model; a mixing unit, used to mix the gradient mask with random noise to obtain a gradient map; and a rendering unit, which renders the object model according to the gradient map to obtain a stylized rendering result of the object to be rendered.
[0007] An embodiment of the present application further provides a computer device, including a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in any stylized rendering method provided in the embodiment of the present application.
[0008] The embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for a processor to load to execute the steps in any stylized rendering method provided in the embodiment of the present application.
[0009] The embodiment of the present application can obtain an object model of an object to be rendered; generate a gradient mask based on texture information of the object model; mix the gradient mask with random noise to obtain a gradient map; render the object model according to the gradient map to obtain a stylized rendering result of the object to be rendered.
[0010] In this application, a gradient mask generated based on the texture information of the object model can be mixed with random noise to generate a gradient map, so as to quickly generate a three-dimensional, dynamic stylized rendering result through the gradient map. In addition, since the gradient map is obtained based on the texture information of the object model, the consistency between the stylized rendering result and the texture information of the object model can be increased, and the display effect of the object to be rendered can be optimized. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0012] Figure 1a is a schematic diagram of a scene of a stylized rendering method provided in an embodiment of the present application;
[0013] Figure 1b is a flowchart of a stylized rendering method provided in an embodiment of the present application;
[0014] Figure 1c It is a schematic diagram of mapping a three-dimensional model to a UV coordinate system in the prior art provided by an embodiment of the present application;
[0015] Figure 1d It is a schematic diagram of a three-dimensional model provided in an embodiment of the present application and a patch covered with UV information;
[0016] Figure 1e is a schematic diagram of a cloud model with different offset intensities provided in an embodiment of the present application;
[0017] Figure 1f It is a schematic diagram of a circular gradient mask, a gradient map and a final model effect provided in an embodiment of the present application;
[0018] Figure 1g is a gradient map with different Alpha values provided in an embodiment of the present application;
[0019] Figure 1h It is a display interface of the gradient mask parameter interface and the noise interface provided in the embodiment of the present application;
[0020] Figure 1iis a 3D noise map provided by an embodiment of the present application;
[0021] Figure 1j It is a display interface of the wind farm parameter interface provided in the embodiment of the present application;
[0022] Figure 1k is a schematic diagram of a spherical position mask provided in an embodiment of the present application;
[0023] Figure 1l It is a display interface of the mask parameter interface provided in the embodiment of the present application;
[0024] Figure 1m is a schematic diagram of a basic lighting processing result provided in an embodiment of the present application;
[0025] Figure 1n is a schematic diagram of an edge light processing result provided by an embodiment of the present application;
[0026] Figure 1o is a schematic diagram of the subsurface scattering effect of a forward light source and the subsurface scattering effect of a backlight source provided in an embodiment of the present application;
[0027] Figure 1p is a schematic diagram of a stylized rendering result provided by an embodiment of the present application;
[0028] Figure 1q It is a display interface of the lighting processing interface provided in the embodiment of the present application;
[0029] Figure 2 is a flowchart of a stylized rendering method provided by another embodiment of the present application;
[0030] Figure 3 is a schematic diagram of the structure of a stylized rendering device provided in an embodiment of the present application;
[0031] Figure 4 It is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0033] Before explaining the embodiments of the present application in detail, some terms involved in the embodiments of the present application are first explained.
[0034] Among them, the virtual scene is a virtual scene such as a game scene displayed (or provided) when the application is running on the terminal. The virtual scene can be a simulation environment of the real world, a semi-simulation and semi-fictitious virtual environment, or a purely fictitious virtual environment. The virtual scene can be any one of a two-dimensional virtual scene, a 2.5-dimensional virtual scene, or a three-dimensional virtual scene. The embodiment of the present application does not limit the dimension of the virtual scene. For example, the virtual scene may include the sky, land, ocean, etc., and the land may include environmental elements such as deserts and cities, and the user can control the virtual character to move in the virtual scene.
[0035] Among them, the virtual character refers to a character used to simulate a person or animal in the game scene. The virtual character can be a virtual person, a virtual animal, a cartoon character, etc., such as a person or an animal displayed in the game scene. The virtual character can be a virtual image in the game scene that is used to represent the user. The game scene can include multiple virtual characters, each of which has its own shape and volume in the game scene and occupies a part of the space in the game scene.
[0036] In some embodiments, the virtual character may be a user character controlled by an operation on a terminal. In some embodiments, the virtual character may be a virtual person competing in a game scene. In some embodiments, the number of virtual characters participating in the interaction in the game scene may be preset or dynamically determined according to the number of terminals participating in the interaction.
[0037] In some embodiments, the virtual characters in the game scene include virtual characters (Player Character) controlled by the user and virtual characters (Non-Player Character, NPC) controlled by the system preset and not controlled by the user.
[0038] Among them, the grid model can refer to a model composed of multiple grids, usually the grid model is a 3D model, and the 3D model can refer to a model expressed mathematically in three dimensions. The 3D model is in a space corresponding to a coordinate system composed of three mutually perpendicular vectors (X, Y, Z).
[0039] Embodiments of the present application provide a stylized rendering method, apparatus, computer device, and storage medium.
[0040] The stylized rendering device can be integrated into an electronic device, which can be a terminal, a server, etc. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, or a personal computer (PC), etc. The server can be a single server or a server cluster composed of multiple servers.
[0041] In some embodiments, the stylized rendering apparatus may also be integrated into multiple electronic devices. For example, the stylized rendering apparatus may be integrated into multiple servers, and the stylized rendering method of the present application may be implemented by multiple servers.
[0042] In some embodiments, the server may also be implemented in the form of a terminal.
[0043] For example, refer to Figure 1a A schematic diagram of a scene of a stylized rendering system is provided, and the system can implement a stylized rendering method. In the scene, a terminal, a server, and a network can be included.
[0044] The server is used to obtain an object model of an object to be rendered; generate a gradient mask according to texture information of the object model; mix the gradient mask with random noise to obtain a gradient map; render the object model according to the gradient map to obtain a stylized rendering result of the object to be rendered. The network can be used for data transmission between the server and the terminal, and the network can be a wireless network or a wired network, such as a wireless network such as a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc. The terminal can be used to display the stylized rendering result.
[0045] The following are detailed descriptions. It should be noted that the order of the following embodiments is not intended to limit the preferred order of the embodiments. It is understood that in the specific implementation of the present application, data related to users such as virtual characters is involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0046] In this embodiment, a stylized rendering method is provided, such as Figure 1b As shown, the specific process of the stylized rendering method can be as follows:
[0047] 110. Obtain an object model of the object to be rendered.
[0048] The object to be rendered refers to an object in a virtual scene that needs to be rendered. The object to be rendered may be different depending on the application scenario. For example, the object to be rendered may be an environmental object such as a building, a tree, a rock, a decoration, etc. in a virtual scene, or may be a virtual character in a virtual scene such as a virtual character controlled by a user (Player Character) or a virtual character (Non-Player Character, NPC) controlled by a system preset and not controlled by a user.
[0049] For example, in some implementations, the object to be rendered may be an object in a virtual scene whose display effect needs to be dynamically adjusted, such as clouds in a virtual scene.
[0050] The object model refers to a three-dimensional model of the object to be rendered. For example, the object model may be a three-dimensional model such as a patch model, a mesh model, or a polygonal model.
[0051] In some embodiments, the object model of the object to be rendered may be a three-dimensional model of the object to be rendered in the viewing space. For example, the vertex coordinates of the mesh model of the object to be rendered in the world coordinate system may be mapped to the vertex coordinates in the camera coordinate system to obtain the object model of the object to be rendered.
[0052] Among them, the world coordinate system is also called the real or actual world coordinate system, or the global coordinate system. It is the absolute coordinate of the objective world and a three-dimensional space coordinate system arbitrarily defined by the user; the camera coordinate system is a three-dimensional rectangular coordinate system with the focusing center of the pinhole camera model as the origin and the camera optical axis as the zc axis.
[0053] For example, when the terminal obtains a rendering instruction of an object to be rendered, the terminal may obtain an object model of the object to be rendered from a local device or a server in response to the rendering instruction.
[0054] In some implementations, the mesh model may be converted to the viewing space based on the texture coordinates to obtain an object model of the object to be rendered, so as to obtain a better model effect. Specifically, obtaining the object model of the object to be rendered includes:
[0055] Obtain the mesh model of the object to be rendered and the texture coordinates of the patches in the mesh model;
[0056] According to the texture coordinates of the patch, determine the conversion reference point of each patch;
[0057] Based on the conversion reference point, the first vertex coordinates of the mesh model are converted into the second vertex coordinates in the viewing space to obtain the object model of the object to be rendered.
[0058] Among them, texture coordinates are the mapping relationship between texture and graphics. Each vertex in the graphics is associated with a texture coordinate, indicating that the vertex needs to read the data of the texture image from that position. Texture coordinates are located in the texture space, which is the space composed of the UV (texture) coordinate system.
[0059] The perspective space, also known as the observation space, refers to a three-dimensional space based on the perspective. For example, the visual space may refer to a three-dimensional space formed by a coordinate system (i.e., a perspective coordinate system) established with the observer (camera) as the reference origin.
[0060] The conversion reference point refers to a reference point used to convert vertex coordinates. It is understandable that based on the conversion reference point, the vertex coordinates of the mesh model can be mapped to the viewing space. For example, the conversion reference point can be the center point of the patch.
[0061] The first vertex coordinates and the second vertex coordinate system may be the coordinate positions of the model vertices in the mesh model (world coordinate system) and the viewing space (observation coordinate system or camera coordinate system), respectively.
[0062] In practical applications, when the vertices (1,1,0), (1,0,0), (0,1,0), (0,0,0) of a 3D mesh model are mapped from the world coordinate system to the UV (texture) coordinate system, each quadrilateral (facet) of the 3D mesh model is mapped to the UV (texture) coordinate system, but it does not face the camera and has lost the shape of the original model. Figure 1c As shown, the three-dimensional model of the puppy shown in Figure (a) is mapped to the UV (texture) coordinate system to obtain the texture information shown in Figure (b), which loses its original shape.
[0063] However, in the embodiment of the present application, the center point of each facet is calculated by the texture coordinates (vertexTexcoord.xy) of each facet, and the coordinate position of the center point in the world coordinate system is used as the rotation center (conversion reference point) of the facet, so that the facet can be rotated to face the camera, and the object model of the object to be rendered obtained after rotating the mesh model can still maintain the shape of the original mesh model. Moreover, the center point of each facet coincides with the color output value (0, 0, 0) (when the value is less than 0, it is displayed as 0), so the embodiment of the present application uses the center point of the facet as the rotation center, which will not affect the display effect of the model.
[0064] In some implementations, in order to facilitate model construction, the model origin may be set at the center point, and thus the position of the model origin of the mesh model in the world coordinate system may be used as the rotation center.
[0065] In some implementations, in order to facilitate the calculation of the conversion reference point of the patch, such as Figure 1d As shown, the UV information of each face of the mesh model shown in Figure (a) can be tiled to cover the entire UV coordinate system with the UV information, and the vertex texture coordinates (vertexTexcoord.xy) of each face are obtained, as shown in Figure (b) which covers the entire UV information.
[0066] In some implementations, the coordinate offset value of the conversion can be determined based on the conversion reference point to quickly and accurately convert the first vertex coordinates into the second vertex coordinates. Specifically, based on the conversion reference point, the first vertex coordinates of the mesh model are converted into the second vertex coordinates in the viewing space to obtain the object model of the object to be rendered, including:
[0067] Determine the coordinate offset value between the model space and the view space;
[0068] According to the coordinate offset value, the first vertex coordinates of the mesh model are converted into the second vertex coordinates in the viewing space to obtain the object model of the object to be rendered.
[0069] The model space refers to the space where the grid model is located, for example, it can be the space formed by the world coordinate system.
[0070] Among them, the coordinate offset value refers to the change value of a point from one space to another space. For example, when a point on the perspective space (such as the perspective coordinate system) is projected to the model space (world coordinate system), the change in the coordinate value of the point can be used as the coordinate offset value. For example, when the perspective of the observer (camera) is parallel to the Z axis of the world coordinate system, the coordinate offset value is (x, y, 0); when the perspective of the observer (camera) is parallel to the x axis of the world coordinate system, the coordinate offset value is (0, y, z); when the perspective of the observer (camera) is parallel to the y axis of the world coordinate system, the coordinate offset value is (x, 0, z).
[0071] For example, the vertex texture coordinates (vertexTexcoord.xy) of each face can be obtained by processing the UV information of the model, and the vertex texture coordinates can be used for subsequent matrix operations by float4(vertexTexcoord.xy,0,0). By calling the mulmat3×4() function, matrix operations are performed on invView (the inverse matrix of the view space) and float4(vertexTexcoord.xy,0,0), and the change interpolation from the view space to the model space of the four vertices of each face with the face as the center can be obtained. The change interpolation can also be normalized to facilitate the subsequent unified intensity. The normalized value is used as the offset, and the coordinate offset value is obtained by offset * offset strength (sBillboradScale). Then the second vertex coordinate = the first vertex coordinate + coordinate offset value, so that the coordinate offset value is superimposed on the coordinates of the original model vertex. The offset strength (sBillboradScale) is a float value representing the rotation and size of a single face. The larger the value, the closer the angle of the face facing the camera is, and the face is enlarged at the same time, such as Figure 1e As shown, the offset strength is 0.02 ( Figure 1e (a), 0.18( Figure 1e (b)) and 0.31( Figure 1e In (c), the cloud model shows that as the offset strength increases, the larger the patch becomes.
[0072] 120. Generate a gradient mask according to texture information of the object model.
[0073] Among them, texture information refers to the information that characterizes the texture differences between different regions in the image.
[0074] Among them, the mask is also called Mask. The essence of the mask is to calculate 0 and 1 through the material to determine whether the model is displayed or not. 0 means display and 1 means non-display. For example, according to the depth value of the scene area, the area with a larger scene depth of the model can be masked through a mask to display the area with a smaller scene depth. For another example, at least one of the RGB color channels of the scene area can also be blocked to display part of the color. In actual use, the mask can be a 3D or 2D mask, which can be adjusted according to actual needs and is not specifically limited here.
[0075] Among them, a gradient mask refers to a mask created according to a gradient, such as from completely transparent to completely opaque.
[0076] In some implementations, a smooth gradient mask may be generated based on texture coordinate mapping and smoothing to enhance the effect of stylized rendering. Specifically, the texture information of the object model includes a first texture coordinate, and generating a gradient mask according to the texture information of the object model includes:
[0077] Based on the first mask parameter, mapping the first texture coordinate to a second texture coordinate;
[0078] Smooth the second texture coordinates to produce a gradient mask.
[0079] The first mask parameter refers to a parameter used to generate a gradient mask, such as but not limited to a mask radius, softness, etc.
[0080] For example, the RoundMask function can be used to generate a circular mask based on texture information. Figure 1fThe circular gradient mask shown in (a) in the figure. Specifically, the RoundMask function can remap the texture coordinates (uv, i.e., the first texture coordinates) of the object model to a new range such as 0-1 to -1-1 based on the first mask parameters such as radius through "OUT = distance ((uv-(floor (uv) + float (0.5, 0.5))), float2 (0, 0))" to obtain new texture coordinates (i.e., the second texture coordinates), where 0.5 represents the radius of the circle; after remapping, it can also be "OUT = (1-smoothstep ((radius-soft), (radius+soft), OUT))", where radius represents the radius and soft represents the softness, so as to use the smoothstep() function (smooth step function) to generate a smooth transition value from 0 to 1 based on the radius and softness to solidify the circle to reduce feathering, so that the gradient mask is formed by the smoothed second texture coordinates, and the smoothstep() function mixes two values to achieve a smooth transition effect.
[0081] 130. Mix the gradient mask with random noise to get a gradient map.
[0082] Among them, random noise refers to random disturbances that create surfaces based on the interaction of two colors or materials. For example, random noise can be a noise value generated by a noise function, or a noise value obtained by sampling a basic noise map. The basic noise map is a map with random brightness of each pixel generated based on random numbers. The processing operation can be at least one of the following operations: function interpolation, multi-layer scaling overlay, multi-layer absolute value overlay, multi-layer trigonometric function overlay, multi-layer rotation overlay, and multi-layer difference overlay.
[0083] For example, BlueNoise can be obtained by sampling blue noise, and the blue noise can be combined with Figure 1f The circular gradient mask shown in (a) is mixed to obtain Figure 1f (b) shows the gradient map. Specifically, the method for generating blue noise can be: two noises Noise1 and Noise2 can be generated by calling the random function sin(x) to sample the texture information, wherein the sin(x) corresponding to Noise1 is sin(uv*tilling*PI), and the sin(x) corresponding to Noise2 is sin((uv*tilling*PI)+PI), wherein tilling represents the coefficient of scaling the UV texture sampling coordinates of the model, and PI represents π; then the sum of the two noises is minimized by min(Noise1+Noise2) to obtain blue noise, and the min() function is used to return the minimum value of the given parameters.
[0084] In some implementations, the effect of pixel clipping can be adjusted by adjusting the parameter value of random noise to achieve different stylized rendering effects. For example, during the sampling process, different Alpha values can be set for random noise to adjust the transparency of the gradient map. When the Alpha value is 0.5, the resulting gradient map is as follows: Figure 1g As shown in (a), when the Alpha value is 0.1, the resulting gradient map is as follows Figure 1g As shown in (b).
[0085] In some implementations, a gradient mask parameter interface and / or noise interface may be provided to quickly obtain gradient mask parameters and noise parameters. Figure 1h As shown, a display interface including a gradient mask parameter interface corresponding to each gradient mask parameter and a noise interface corresponding to the noise parameter can be set in a graphical user interface. In this display interface, parameters such as the circular power, radius, softness corresponding to each gradient mask parameter interface can be input / adjusted, as well as the coefficient (scaling coefficient) of the scaling model UV texture sampling coordinates corresponding to the noise interface can be input / adjusted, so as to quickly realize different gradient masks and random noises.
[0086] 140. Render the object model according to the gradient map to obtain a stylized rendering result of the object to be rendered.
[0087] For example, rendering can be to perform pixel cropping on the pixels drawn to the screen based on the gradient map to obtain a stylized rendering result of the object to be rendered. In practical applications, the gradient map can be applied to the alpha value of the shader, and the shader performs pixel cropping to obtain the following: Figure 1f After rendering the object model based on the gradient map, the model can have the following effect: Figure 1f The plush effect shown in (d) in the figure. By rendering the object model with a gradient map, a stylized rendering result of the object to be rendered that is three-dimensional, dynamic, and has softened boundaries can be obtained. Since the gradient map is obtained by generating a gradient mask from the texture information of the object model, the consistency between the stylized rendering result and the texture information of the object model can be increased, thereby optimizing the display effect of the object to be rendered. In addition, compared with the existing method for producing stylized visual effects, the embodiment of the present application renders the three-dimensional model (object model) through a map, and can use opaque materials to achieve a translucent effect, avoid translucent sorting problems, and reduce the performance consumption of the rendering device; when applied to three-dimensional models that need to be traversed, such as clouds, the rendered model can also be made traversable, thereby enhancing the display effect of the model.
[0088] In some embodiments, after rendering the object model based on the gradient map, further detail enhancement processing may be performed to enhance the display effect of the model. Specifically, the object model is rendered according to the gradient map to obtain a stylized rendering result of the object to be rendered, including:
[0089] Rendering the object model according to the gradient map to obtain a rendered model;
[0090] The rendered model is subjected to detail enhancement processing to obtain a stylized rendering result of the object to be rendered.
[0091] It should be noted that, in practical applications, the rendered model can be enhanced in detail in different ways, and the detail enhancement method may include but is not limited to at least one of adding wind field effects, interactive effects, and lighting rendering. It is also possible to combine two or more methods of adding wind field effects, adding interactive effects, and lighting processing and apply them to the detail enhancement process of the rendered model. For example, after adding a wind field effect to the rendered model, the model with the added wind field effect can be used as the rendered model to add an interactive effect, and then the model with the added interactive effect can be used as the rendered model to perform lighting processing on it.
[0092] In some embodiments, detail enhancement processing may include adding a wind field effect, and a wind field effect may be added to the model through a wind field map to enhance the dynamic effect of the model. Specifically, detail enhancement processing is performed on the rendered model to obtain a stylized rendering result of the object to be rendered, including:
[0093] Get wind field map;
[0094] According to the wind field map, the vertex positions of the rendered model are moved along the vertex normal direction of the rendered model to obtain a stylized rendering result of the object to be rendered.
[0095] The wind map refers to a map used to represent the wind field changes in the virtual scene. For example, a 2D or 3D noise map can be generated as a wind map by a Noise method. The Noise method may include but is not limited to Perlin Noise, Value Noise, Simplex Noise, Worley Noise, etc.
[0096] The normal direction may be represented by a normal vector, and the normal vector is used to represent the normal direction of the model vertex in a spatial coordinate system, and the spatial coordinate system may be a world coordinate system.
[0097] For example, you can call the Perlin Noise generator, which in turn calls the SimplexNoise function to generate the following: Figure 1i The 3D noise map shown in the figure is used as a virtual mask, and the VertexCustomSimple (vertex custom format) function is called to calculate the offset result along the vertex normal of the model through the virtual mask. The VertexCustomSimple function calculates the offset value through "noise map × vertex normal of the rendered model × vertex offset (vertexoffset), wherein the vertex offset can be used to adjust the offset value along the vertex normal of the model to use the input noise map as a mask, which is multiplied by the vertex normal of the rendered model and the vertex offset to obtain the offset value of the vertex offset along the normal direction of the rendered model, thereby adding a wind field effect to the model.
[0098] In some embodiments, a wind map can be generated based on a speed offset and a noise level. The speed offset can be used to adjust the effect speed offset value of the wind map; the noise level can be used to adjust the noise intensity of the generated noise map (wind map). For example, SimplexNosie (simple noise generator) can be called to process the calculation result of "(vertex coordinates in model space × noise level) + time × speed offset" to generate a noise value (NoiseVlue), which constitutes a 3D noise map (wind map), wherein time can refer to the time in the virtual scene. Taking the virtual scene as a game scene as an example, the time is the game time.
[0099] In some implementations, a wind farm parameter interface may be provided to quickly obtain wind farm parameters. Figure 1j As shown, a display interface including wind field parameter interfaces corresponding to various wind field parameters can be set in a graphical user interface. In this display interface, parameters such as speed offset, vertex offset, and noise level corresponding to each wind field parameter interface can be input / adjusted to quickly achieve different wind field effects.
[0100] In some embodiments, the detail enhancement process may include increasing the interactive effect. Based on the position of the virtual character in the virtual scene, the model of the object to be rendered may be adjusted to increase the interactive effect between the object to be rendered and the specified virtual character in the virtual scene, so as to enhance the dynamic effect of the model. Specifically, performing detail enhancement process on the rendered model to obtain a stylized rendering result of the object to be rendered includes:
[0101] Get the location information of the specified virtual character;
[0102] Generate a position mask according to the position information;
[0103] Perform mixed calculation on the position mask and the vertex normal of the rendered model to obtain the vertex displacement parameters;
[0104] According to the vertex displacement parameters, the vertex positions of the rendered model are adjusted to obtain a stylized rendering result of the object to be rendered.
[0105] Among them, the designated virtual character refers to a virtual character specified in a virtual scene, such as a virtual character that can be controlled by the current user in the game scene, such as a virtual character, a virtual summoned pet, etc., or a system preset control and non-user-controlled virtual character determined according to actual needs or application scenarios, such as a monster, etc.
[0106] It should be noted that the designated virtual character and the object to be rendered are different individuals in the virtual scene. For example, the designated virtual character and the object to be rendered may be different virtual characters in the virtual scene.
[0107] The position information refers to the position in the virtual scene. For example, the position information of a specified virtual character may include its coordinate position in the world coordinate system, camera coordinate system, image coordinate system or pixel coordinate system of the virtual scene. The position mask refers to a mask based on the position information. For example, the position mask may be a spherical, rectangular or other shaped mask generated based on the position of the specified virtual character.
[0108] For example, the coordinate position of a specified virtual character in a virtual scene (world coordinate system) can be obtained, and a virtual scene such as Figure 1k The spherical position mask shown in FIG. 1 is obtained by calculating the vertex displacement parameter by “vertex displacement parameter = spherical mask × vertex normal direction of the rendered model × offset strength”. The vertex position of the rendered model can be adjusted along the vertex normal direction of the rendered model according to the vertex displacement parameter to obtain the following: Figure 1k The vertices on the model are offset based on the specified virtual character, thereby enhancing the dynamic interaction effect between the object to be rendered and the specified virtual character in the virtual scene.
[0109] In some embodiments, adjusting the vertex position of the rendered model = vertex normal direction of the rendered model × (1-spherical mask) × offset strength, wherein the offset strength may refer to the offset of the vertex offset generated by the interaction between the specified virtual character and the model, which is used for interactive control strength.
[0110] In some embodiments, a position mask centered on the position information may be generated to improve the accuracy of the offset generated by the interaction between the specified virtual character and the rendered model. Specifically, generating the position mask based on the position information includes:
[0111] A position mask is generated based on the second mask parameter and centered on the position information.
[0112] Among them, the second mask parameter refers to a parameter used to generate a position mask, such as may include but not limited to a mask radius, a mask edge hardness, etc.
[0113] For example, the Spheremask function can generate a spherical mask (position) with the position of the specified virtual character as the center. The Spheremask function has four input parameters: the position to be checked (A), the position of the center of the circle (B), the radius (Radius), and the hardness (Hardness). Specifically, the coordinate position of any point of the virtual scene in the world coordinate system can be used as input A, and the coordinate position of the specified virtual character in the world coordinate system can be used as input B. By "float length=dot(AB,AB); length=sqrt(length)", the difference between AB is first dot-multiplied (dot), and then the square root (sqr) is taken to obtain the distance parameter (length) between A and B, where the dot() function refers to matrix multiplication (dot multiplication), and the sqrt() function refers to calculating the arithmetic square root; by "float Range=1 / max(9.99999975e-06,Radius)", the range value Range of the mask is calculated based on the radius Radius; by "fioat S=1-Hardness;S= / max(9.99999975e-06); S=1 / S”, the hardness parameter S is calculated by Hardness, where the max() function refers to the maximum element of a vector or matrix, or the maximum value of several specified values; by “Out=length*Range;Out=1-Out;Out=Out*S;Out=saturate(Out)”, where the saturate() function is used to convert the value into a value within [0,1], that is, length, Range and S are calculated by “saturate((1-(length*Range))*S)” to obtain the output value of each point A, so that the output values of all points A constitute a spherical position mask.
[0114] In some implementations, a mask parameter interface may be provided to quickly obtain the mask parameters of the position mask. Figure 1lAs shown, a display interface of a mask parameter interface corresponding to each mask parameter of a position mask can be set in a graphical user interface, and parameters such as a mask radius, mask edge hardness, and offset strength corresponding to each mask parameter interface can be input / adjusted in the display interface to quickly adjust the dynamic effect of the interaction between the object to be rendered and the specified virtual character in the virtual scene. Specifically, the mask radius can be used to adjust the size of the generated position mask, and the mask edge hardness can be used to control the smooth transition of the edge of the position mask. The appearance of the generated position mask can be adjusted by the mask radius and the mask edge hardness.
[0115] In some embodiments, the detail enhancement process may include illumination processing, and the illumination processing may be performed based on illumination parameters. Specifically, performing detail enhancement processing on the rendered model to obtain a stylized rendering result of the object to be rendered includes:
[0116] Get lighting parameters;
[0117] According to the lighting parameters, the rendered model is subjected to lighting processing to obtain a stylized rendering result of the object to be rendered, wherein the lighting processing includes at least one of basic lighting processing, subsurface scattering processing and edge light processing.
[0118] The lighting parameters may refer to parameters used to adjust the lighting effect, and may include at least one of basic lighting parameters, sub-surface lighting parameters, and edge light parameters.
[0119] For example, taking the object to be rendered as clouds, the lighting parameters may include: cBaseColor (base color of the object to be rendered (clouds)), sInteriorColor (internal light transmittance color of the object to be rendered (clouds)), sInteriorColor_power (internal light transmittance smoothing coefficient), sFrontSubsurfaceDistortion (forward lighting scattering coefficient of the object to be rendered (clouds)), sBackSubsurfaceDistortion (backlight scattering coefficient of the object to be rendered (clouds)), sFrontSssIntensity (forward scattering intensity), cAmbientColorSclae (ambient lighting influence coefficient), cSunlightScale (sunlight intensity influence coefficient), cRim_power (edge light smoothing), sRimRange (edge light range remapping), sUpColor (ambient light sky light color), sSideColor (ambient light ground light color), sRimIntensity (edge light intensity), and sDarkEnvIntensity (backlight edge light intensity). For example, in edge lighting processing, sSideColor is used to control the dark color, and sUpColor is used to control the bright color; in subsurface scattering processing, sInteriorColor is used to control the color effect of the transparent part of the object to be rendered (clouds); in basic lighting processing, since the basic lighting color itself is affected by the ambient color and the color of sunlight, cBaseColor is added on this basis to control the inherent color of the object to be rendered (clouds).
[0120] In some embodiments, basic lighting processing includes:
[0121] Superimpose the sunlight parameters and ambient light parameters to obtain the basic lighting processing results.
[0122] For example, sunlight parameters include sunlight color and sunlight intensity (controlled by sunlight intensity influence coefficient), ambient light parameters include ambient light color and ambient light influence coefficient. Customized light maps can be obtained by sampling or semi-Lambert lighting model can be used as initial basic lighting results. The sunlight lighting effect is calculated by "initial basic lighting result × sunlight parameters × sunlight intensity", and the ambient light lighting effect is calculated by "ambient light color × ambient light influence coefficient". The basic lighting effect is obtained by sunlight lighting effect + ambient light effect, and the rendered model is rendered by the basic lighting effect to obtain the following: Figure 1m The basic lighting results for the rendered model are shown.
[0123] In some embodiments, the basic illumination processing further includes light transmission processing, superimposing sunlight parameters and ambient light parameters to obtain a basic illumination processing result, including:
[0124] Superimpose sunlight parameters and ambient light parameters to obtain basic lighting effects;
[0125] Determine the light transmission effect based on the basic lighting effect and the internal light transmission color.
[0126] For example, the color of the rendered model, the preset internal light-transmitting color, and the blending coefficient can be multiplied to get the backlighting color. The blending coefficient can be customized to be 0.5. The lerp() function is called to interpolate the backlighting color, the internal light-transmitting color, and the basic lighting effect to get the color of the backlighting and light-transmitting areas of the model and the color of the illuminated and non-light-transmitting areas.
[0127] In some embodiments, edge light processing includes:
[0128] Generate a rim light mask of the rendered model using the Finniel method;
[0129] The edge light mask is smoothed to obtain the edge light processing result.
[0130] For example, you can call the fresnel() function to generate an edge light mask, and then call the smoothstep() function to smooth the edge light mask to control the mask range, and get the following: Figure 1n The result of edge light processing is shown.
[0131] In some embodiments, the subsurface scattering effect can be calculated for the forward and back directions of the model respectively, and then the subsurface scattering processing result of the model can be obtained by superimposing them, so as to determine the subsurface scattering effect based on the overall effect of the model and improve the accuracy of the subsurface scattering processing. Specifically, the subsurface scattering parameters include the forward illumination scattering coefficient and the back illumination scattering coefficient, and the subsurface scattering processing includes:
[0132] According to the normal direction of the rendered model and the forward illumination scattering coefficient, the forward illumination direction parameter is obtained;
[0133] According to the normal direction of the rendered model and the backlight scattering coefficient, the backlight direction parameter is obtained;
[0134] According to the forward lighting direction parameters and the backlighting direction parameters, the subsurface scattering effect of the forward light source and the subsurface scattering effect of the backlight source are determined respectively;
[0135] Superimpose the subsurface scattering effect of the forward light source and the subsurface scattering effect of the backlight source to obtain the total scattering effect;
[0136] The subsurface scattering processing result of the rendered model is determined by the total scattering effect.
[0137] The scattering coefficient is a parameter that describes the strength of the scattering effect, and the scattering coefficient may include a forward scattering coefficient (forward illumination scattering coefficient) and a backward scattering coefficient (backward illumination scattering coefficient).
[0138] For example, the forward illumination direction parameter can be obtained by multiplying the normal direction of the rendered model by the forward illumination scattering coefficient and then subtracting the value of the light source direction. The back illumination direction parameter can be obtained by multiplying the normal direction of the rendered model by the back illumination scattering coefficient and then subtracting the value of the light source direction. Then, the forward illumination direction parameter (frontLitDir) can be obtained by performing dot multiplication, absolute value calculation, maximum value calculation, power calculation and normalization processing with "float frontSSS=saturate(pow(max(abs(saturate(dot(viewDir,-frontLitDir))),0),2))" as shown below. Figure 1o The subsurface scattering effect (frontSSS) of the forward light source shown in (b) and the backlight direction parameter (frontLitDir) obtained by "float backSSS=saturate(pow(max(abs(saturate(dot(viewDir,-backLitDir))),0),2))" after dot multiplication, absolute value, maximum value, power calculation and normalization are as follows Figure 1o The subsurface scattering effect (backSSS) of the backlight source shown in (a), where viewDir refers to the direction (visual direction) from which the observer looks at the object, the dot() function refers to matrix multiplication (dot product), the abs() function is used to find the absolute value of an integer, the max() function is used to find the maximum element of a vector or matrix, or the maximum value of several specified values, the pow(x, y) function is used to calculate the y power (power) of x, and the saturate() function is used to convert the value into a value within [0,1] (i.e., standard processing). The subsurface scattering effect (frontSSS) of the forward light source can be multiplied by the forward scattering intensity (FrontSssIntensity) and then added to the subsurface scattering effect (backSSS) of the backlight source. Finally, the saturate() function is used to convert the result of the addition into a value within [0,1], that is, to obtain the total scattering effect, thereby obtaining the subsurface scattering processing result of the rendered model.
[0139] In some implementations, determining a subsurface scattering processing result of a rendered model based on a total scattering effect includes:
[0140] Interpolate the basic lighting effects, sunlight parameters and total scattering effects to obtain the target color value;
[0141] The subsurface scattering result of the rendered model is determined by the target color value and the total scattering effect.
[0142] For example, the lerp() function can be called for interpolation processing, such as "lerp(sInteriorColor,Lcolor,saturate(pow(sssValue,sInteriorColor_power))).rgb", where sInteriorColor represents the basic lighting effect, Lcolor represents the sunlight parameter, sssValue represents the total scattering effect, sInteriorColor_power represents the internal light transmission smoothing coefficient, the pow(x,y) function is used to calculate the y power of x, and the saturate() function is used to convert the value into a value within [0,1] (i.e., standard processing). That is, after the total scattering effect and the internal light transmission smoothing coefficient are power-calculated and standardized, the processing result is interpolated with the basic lighting effect and the sunlight parameter to obtain the target color value, the target color value is multiplied by the total scattering effect to obtain the subsurface scattering effect of the rendered model, and the rendered model is rendered by the subsurface scattering effect to obtain the subsurface scattering processing result of the rendered model.
[0143] In some embodiments, the subsurface scattering processing result, the basic lighting processing result, and the edge light processing result can be superimposed, and the rendered model can be rendered to obtain a stylized rendering result of the object to be rendered. For example, the subsurface scattering processing result can be superimposed with the light transmission processing result by addition, and the saturate() function can be called to normalize the superimposed result, and then the processed result can be superimposed with the edge light processing result by addition, and the rendered model can be rendered to obtain a stylized rendering result of the object to be rendered. When superimposing the processed result with the edge light processing result, the grayscale color (darkenvcolor) can also be superimposed with it to obtain the following: Figure 1p The stylized rendering result shown.
[0144] In some implementations, the lighting parameters can be quickly acquired through the lighting processing interface to improve the lighting processing effect.
[0145] For example, Figure 1qAs shown, a display interface corresponding to the lighting processing interface can be set in the graphical user interface, and the lighting parameters corresponding to each lighting processing interface can be input / adjusted in the display interface, and lighting processing can be performed based on the lighting parameters. For example, the ambient lighting influence coefficient and the sunlight intensity influence coefficient are usually set to 1 by default, and can be adjusted according to the stylization to achieve different stylized rendering effects.
[0146] The stylized rendering solution provided by the embodiment of the present application can be applied in various rendering scenarios. For example, taking model rendering as an example, an object model of the object to be rendered is obtained; a gradient mask is generated according to the texture information of the object model; the gradient mask is mixed with random noise to obtain a gradient map; the object model is rendered according to the gradient map to obtain a stylized rendering result of the object to be rendered.
[0147] As can be seen from the above, the embodiment of the present application can generate a gradient mask based on the texture information of the object model, and mix it with random noise to generate a gradient map, so as to quickly generate a three-dimensional, dynamic, and model-boundary softened stylized rendering result through the gradient map. In addition, since the gradient map is obtained based on the texture information of the object model, the consistency between the stylized rendering result and the texture information of the object model can be increased, and the display effect of the object to be rendered can be optimized.
[0148] The method described in the above embodiment will be further described in detail below.
[0149] In this embodiment, the method of the embodiment of the present application is described in detail by taking the object to be rendered as a cloud in a game scene as an example.
[0150] like Figure 2 As shown, the specific process of a stylized rendering method is as follows:
[0151] 210. Get the mesh model of the cloud.
[0152] For example, you can build a mesh model of a cloud composed of multiple quadrilateral patches.
[0153] 220. Convert the mesh model into a cloud object model.
[0154] For example, the mesh model of the cloud and the texture coordinates of the faces in the mesh model can be obtained; the transformation reference point of each face can be determined according to the texture coordinates of the face; based on the transformation reference point, the first vertex coordinate of the mesh model is transformed into the second vertex coordinate in the viewing space to obtain the object model of the cloud.
[0155] Specifically, a customized cloud modeling mesh can be created to ensure Figure 1d The mesh models shown in (a) are all composed of quadrilaterals, such as Figure 1dIn (b), the model UV is processed to fill the entire UV coordinate with the UV information of each face of the mesh model. The main purpose is to store the UV information on the vertex when the material vertex stage is processed later, calculate the center point of the quadrilateral, and facilitate mapping the texture sampling UV.
[0156] The vertices of the model can be processed through the vertex shading stage in the material. The center point of each facet is calculated through the UV information stored in the facet, and then the vertex information is converted from the world space coordinates to the view space coordinates through matrix operations. Finally, the information is transmitted back to the model vertex position information, so that every single facet in the model will face the camera to obtain the object model.
[0157] 230. Generate a gradient mask according to texture information of the object model.
[0158] For example, you can use a noise map combined with Alpha to create a mask (gradient mask), such as generating a circular gradient mask as shown in Figure (a) based on UV.
[0159] 240. Mix the gradient mask with random noise to get a gradient map.
[0160] For example, you can combine a circular gradient mask with Noise to get Figure 1f (b) The circular gradient map shown.
[0161] 250. Render the object model according to the gradient map to obtain a rendered model of the cloud.
[0162] For example, you can clip pixels and apply it to the Alpha value to get the following Figure 1f The effect shown in (c) above makes the opaque material form a translucent gradient effect, and finally combines the model to make the model look like Figure 1f The plush effect shown in (d) in the figure. Compared with translucent materials, achieving similar effects through opaque materials can avoid translucent sorting problems and performance consumption issues.
[0163] 260. According to the wind field map, the vertex positions of the rendered model are moved along the vertex normal direction of the rendered model to obtain a first model.
[0164] For example, a wind field map may be obtained; according to the wind field map, the vertex positions of the rendered model are moved along the vertex normal direction of the rendered model to obtain a stylized rendering result of clouds.
[0165] Specifically, a simple wind field effect can be added after the camera-oriented processing. The wind field sampling here can be 2D, as well as Figure 1i3DNoise graph shown. This type of image can be highly customized, and RT (real-time rendering) images can also be collected for richer interactive effects.
[0166] 270. According to the vertex displacement parameters, adjust the vertex positions of the first model to obtain the second model.
[0167] For example, the position information of a specified virtual character is obtained; a position mask is generated based on the position information; a mixed calculation is performed on the position mask and the vertex normals of the rendered model to obtain vertex displacement parameters; and the vertex positions of the rendered model are adjusted based on the vertex displacement parameters to obtain a stylized rendering result of the clouds.
[0168] Specifically, the character position information can be accessed to obtain a spherical range centered on the character, and its range information can be added. The range information is finally used as a mask to combine with the cloud vertex normals, and multiplied by sPlayerPushIntensity to control the vertex offset intensity to achieve the expansion effect. The performance processing here is mainly combined with the stylized performance requirements of the project.
[0169] 280. Perform lighting processing on the second model to obtain a stylized rendering result of the clouds.
[0170] For example, obtain lighting parameters; perform lighting processing on the rendered model according to the lighting parameters to obtain a stylized rendering result of the clouds.
[0171] Specifically, the basic lighting color diffCol (such as Figure 1m The basic lighting processing results of the rendered model shown), subsurface scattering effect sssCol, edge bright part rimCol (such as Figure 1n Edge light processing results shown in the figure), edge light dark part DarkEnvColor (such as Figure 1n The second model is illuminated by the edge light processing result shown in the figure. The subsurface scattering effect is mainly affected by the back projection light source and does not completely follow the physics.
[0172] In order to meet the needs of stylization, Figure 1q The display interface shown in the figure adds an external color interface for more precise control. The dark and bright parts of the edge light are controlled by sSideColor and sUpColor, respectively. Subsurface scattering also adds sInteriorColor to control the color effect of the transparent part of the cloud. The basic lighting color itself is affected by the ambient color and the color of the sunlight. On this basis, cBaseColor is added to control the inherent color of the cloud. This link serves the overall needs of the project for stylized lighting.
[0173] As can be seen from the above, the embodiment of the present application can achieve a stylized rendering effect of fluffy clouds. At the same time, it also solves the problem of the cloud model's rigid and impenetrable boundaries; it uses opaque materials instead of translucent materials to achieve the Alpha gradient effect, reduces a series of problems caused by translucency, and also takes into account performance consumption issues. Therefore, the embodiment of the present application can quickly customize the realization of cloud dynamic effects. In addition to the basic wind field effects, it also adds multiple interfaces, greatly expanding the scope of stylized dynamic performance of clouds, and can more conveniently produce dynamically changing clouds.
[0174] In order to better implement the above method, the embodiment of the present application also provides a stylized rendering device, which can be integrated in an electronic device, and the electronic device can be a terminal, a server, etc. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.
[0175] For example, in this embodiment, the method of the embodiment of the present application will be described in detail by taking the stylized rendering device being specifically integrated in the server as an example.
[0176] For example, Figure 3 As shown, the stylized rendering apparatus may include an acquisition unit 310, a generation unit 320, a mixing unit 330, and a rendering unit 340, as follows:
[0177] (I) Acquisition Unit 310
[0178] Can be used to obtain the object model of the object to be rendered.
[0179] In some implementations, the acquisition unit 310 may be specifically configured to:
[0180] Obtain the mesh model of the object to be rendered and the texture coordinates of the patches in the mesh model;
[0181] According to the texture coordinates of the patch, determine the conversion reference point of each patch;
[0182] Based on the conversion reference point, the first vertex coordinates of the mesh model are converted into the second vertex coordinates in the viewing space to obtain the object model of the object to be rendered.
[0183] In some implementations, based on the conversion reference point, converting the first vertex coordinates of the mesh model into the second vertex coordinates in the viewing space to obtain the object model of the object to be rendered includes:
[0184] Determine the coordinate offset value between the model space and the view space;
[0185] According to the coordinate offset value, the first vertex coordinates of the mesh model are converted into the second vertex coordinates in the viewing space to obtain the object model of the object to be rendered.
[0186] (II) Generation Unit 320
[0187] It can be used to generate a gradient mask based on the texture information of the object model.
[0188] In some implementations, the texture information of the object model includes the first texture coordinates, and the generating unit 320 may be specifically configured to:
[0189] Based on the first mask parameter, mapping the first texture coordinate to a second texture coordinate;
[0190] Smooth the second texture coordinates to produce a gradient mask.
[0191] (III) Mixing unit 330
[0192] Can be used to blend a gradient mask with random noise to create a gradient map.
[0193] (IV) Rendering unit 340
[0194] It can be used to render the object model according to the gradient map to obtain the stylized rendering result of the object to be rendered.
[0195] In some implementations, the rendering unit 340 may be specifically configured to:
[0196] Rendering the object model according to the gradient map to obtain a rendered model;
[0197] The rendered model is subjected to detail enhancement processing to obtain a stylized rendering result of the object to be rendered.
[0198] In some implementations, performing detail enhancement processing on the rendered model to obtain a stylized rendering result of the object to be rendered includes:
[0199] Get wind field map;
[0200] According to the wind field map, the vertex positions of the rendered model are moved along the vertex normal direction of the rendered model to obtain a stylized rendering result of the object to be rendered.
[0201] In some implementations, performing detail enhancement processing on the rendered model to obtain a stylized rendering result of the object to be rendered includes:
[0202] Get the location information of the specified virtual character;
[0203] Generate a position mask according to the position information;
[0204] Perform mixed calculation on the position mask and the vertex normal of the rendered model to obtain vertex displacement parameters;
[0205] According to the vertex displacement parameters, the vertex positions of the rendered model are adjusted to obtain a stylized rendering result of the object to be rendered.
[0206] In some implementations, generating a virtual mask according to the position information includes:
[0207] A position mask is generated based on the second mask parameter and centered on the position information.
[0208] In some implementations, performing detail enhancement processing on the rendered model to obtain a stylized rendering result of the object to be rendered includes:
[0209] Get lighting parameters;
[0210] According to the lighting parameters, the rendered model is subjected to lighting processing to obtain a stylized rendering result of the object to be rendered, wherein the lighting processing includes at least one of basic lighting processing, subsurface scattering processing and edge light processing.
[0211] In some embodiments, subsurface scattering processing includes:
[0212] According to the normal direction of the rendered model and the forward illumination scattering coefficient, the forward illumination direction parameter is obtained;
[0213] According to the normal direction of the rendered model and the backlight scattering coefficient, the backlight direction parameter is obtained;
[0214] According to the forward lighting direction parameters and the backlighting direction parameters, the subsurface scattering effect of the forward light source and the subsurface scattering effect of the backlight source are determined respectively;
[0215] Superimpose the subsurface scattering effect of the forward light source and the subsurface scattering effect of the backlight source to obtain the total scattering effect;
[0216] The subsurface scattering processing result of the rendered model is determined by the total scattering effect.
[0217] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0218] Therefore, the embodiment of the present application can generate a gradient mask based on the texture information of the object model, and mix it with random noise to generate a gradient map, so as to quickly generate a three-dimensional, dynamic stylized rendering result through the gradient map. In addition, since the gradient map is obtained based on the texture information of the object model, the consistency between the stylized rendering result and the texture information of the object model can be increased, and the display effect of the object to be rendered can be optimized.
[0219] Correspondingly, an embodiment of the present application also provides a computer device, which may be a terminal or a server, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer, a personal digital assistant (PDA), or other terminal devices.
[0220] like Figure 4 As shown, Figure 4 The schematic diagram of the structure of the computer device provided in the embodiment of the present application is that the computer device 400 includes a processor 410 having one or more processing cores, a memory 420 having one or more computer-readable storage media, and a computer program stored in the memory 420 and executable on the processor. The processor 410 is electrically connected to the memory 420. It can be understood by those skilled in the art that the computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0221] The processor 410 is the control center of the computer device 400. It uses various interfaces and lines to connect various parts of the entire computer device 400, executes various functions of the computer device 400 and processes data by running or loading software programs and / or modules stored in the memory 420, and calling data stored in the memory 420, thereby monitoring the computer device 400 as a whole.
[0222] In the embodiment of the present application, the processor 410 in the computer device 400 will load instructions corresponding to the processes of one or more application programs into the memory 420 according to the following steps, and the processor 410 will run the application programs stored in the memory 420 to implement various functions:
[0223] Obtain an object model of an object to be rendered; generate a gradient mask according to texture information of the object model; mix the gradient mask with random noise to obtain a gradient map; render the object model according to the gradient map to obtain a stylized rendering result of the object to be rendered.
[0224] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0225] Optional, such as Figure 4 As shown, the computer device 400 further includes: a touch screen 430, a radio frequency circuit 440, an audio circuit 450, an input unit 460, and a power supply 470. The processor 410 is electrically connected to the touch screen 430, the radio frequency circuit 440, the audio circuit 450, the input unit 460, and the power supply 470, respectively. Those skilled in the art will appreciate that Figure 4 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0226] The touch display screen 430 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 430 may include a display panel and a touch panel. Among them, the display panel may be used to display information input by the user or information provided to the user and various graphical user interfaces of the computer device, which may be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel may be used to collect the user's touch operation on or near it (such as the user using any suitable object or accessory such as a finger, stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 410, and can receive the command sent by the processor 410 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 410 to determine the type of touch event, and then the processor 410 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 430 to realize the input and output functions. However, in some embodiments, the touch panel and the display panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 430 can also be used as a part of the input unit 460 to realize the input function.
[0227] In the embodiment of the present application, the processor 410 executes the game application to generate a graphical user interface on the touch screen 430. The virtual scene on the graphical user interface includes at least one skill control area, and the skill control area includes at least one skill control. The touch screen 430 is used to present the graphical user interface and receive operation instructions generated by the user acting on the graphical user interface.
[0228] The radio frequency circuit 440 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other computer devices through wireless communication, and to send and receive signals between the network device or other computer devices.
[0229] The audio circuit 450 can be used to provide an audio interface between the user and the computer device through a speaker and a microphone. The audio circuit 450 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 450 and converted into audio data, and then the audio data is output to the processor 410 for processing, and then sent to another computer device through the radio frequency circuit 440, or the audio data is output to the memory 420 for further processing. The audio circuit 450 may also include an earphone jack to provide communication between an external headset and the computer device.
[0230] The input unit 460 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0231] The power supply 470 is used to supply power to various components of the computer device 400. Optionally, the power supply 470 can be logically connected to the processor 410 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 470 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0232] although Figure 4 Not shown, the computer device 400 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0233] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0234] As can be seen from the above, the computer device provided in this embodiment can generate a gradient mask based on the texture information of the object model, and mix it with random noise to generate a gradient map, so as to quickly generate a three-dimensional, dynamic stylized rendering result through the gradient map. In addition, since the gradient map is obtained based on the texture information of the object model, the consistency between the stylized rendering result and the texture information of the object model can be increased, and the display effect of the object to be rendered can be optimized.
[0235] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0236] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of computer programs are stored, and the computer program can be loaded by a processor to execute the steps in any stylized rendering method provided in the embodiment of the present application. For example, the computer program can execute the following steps:
[0237] Obtain an object model of an object to be rendered; generate a gradient mask according to texture information of the object model; mix the gradient mask with random noise to obtain a gradient map; render the object model according to the gradient map to obtain a stylized rendering result of the object to be rendered.
[0238] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0239] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0240] Since the computer program stored in the storage medium can execute the steps in any stylized rendering method provided in the embodiments of the present application, the beneficial effects that can be achieved by any stylized rendering method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0241] The above is a detailed introduction to a stylized rendering method, device, computer equipment and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technicians in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A stylized rendering method, characterized in that: include: Get the object model of the object to be rendered; generating a gradient mask according to texture information of the object model; Mixing the gradient mask with random noise to obtain a gradient map; The object model is rendered according to the gradient map to obtain a stylized rendering result of the object to be rendered.
2. The stylized rendering method according to claim 1, characterized in that: The step of obtaining the object model of the object to be rendered includes: Acquire a mesh model of the object to be rendered and texture coordinates of patches in the mesh model; Determining a conversion reference point of each of the face patches according to the texture coordinates of the face patches; Based on the conversion reference point, the first vertex coordinates of the mesh model are converted into second vertex coordinates in the viewing space to obtain the object model of the object to be rendered.
3. The stylized rendering method according to claim 2, characterized in that: The step of converting the first vertex coordinates of the mesh model into the second vertex coordinates in the viewing space based on the conversion reference point to obtain the object model of the object to be rendered includes: Determining a coordinate offset value between the model space and the view space; According to the coordinate offset value, the first vertex coordinates of the mesh model are converted into second vertex coordinates in the viewing space to obtain the object model of the object to be rendered.
4. The stylized rendering method according to claim 1, wherein: The texture information of the object model includes a first texture coordinate, and generating a gradient mask according to the texture information of the object model includes: Based on a first mask parameter, mapping the first texture coordinate to a second texture coordinate; Smooth the second texture coordinates to produce a gradient mask.
5. The stylized rendering method according to claim 1, wherein: Rendering the object model according to the gradient map to obtain a stylized rendering result of the object to be rendered includes: Rendering the object model according to the gradient map to obtain a rendered model; Perform detail enhancement processing on the rendered model to obtain a stylized rendering result of the object to be rendered.
6. The stylized rendering method according to claim 5, characterized in that: Performing detail enhancement processing on the rendered model to obtain a stylized rendering result of the object to be rendered includes: Get wind field map; According to the wind field map, the vertex positions of the rendered model are moved along the vertex normal direction of the rendered model to obtain a stylized rendering result of the object to be rendered.
7. The stylized rendering method according to claim 5, characterized in that: The performing detail enhancement processing on the rendered model to obtain a stylized rendering result of the object to be rendered includes: Get the location information of the specified virtual character; Generate a position mask according to the position information; Performing mixed calculation on the position mask and the vertex normals of the rendered model to obtain vertex displacement parameters; According to the vertex displacement parameters, the vertex positions of the rendered model are adjusted to obtain a stylized rendering result of the object to be rendered.
8. The stylized rendering method according to claim 7, characterized in that: Generating a virtual mask according to the position information includes: A position mask is generated based on the second mask parameter and with the position information as the center.
9. The stylized rendering method according to claim 5, characterized in that: The performing detail enhancement processing on the rendered model to obtain a stylized rendering result of the object to be rendered includes: Get lighting parameters; According to the illumination parameters, illumination processing is performed on the rendered model to obtain a stylized rendering result of the object to be rendered, wherein the illumination processing includes at least one of basic illumination processing, subsurface scattering processing and edge light processing.
10. The stylized rendering method according to claim 9, characterized in that: The subsurface scattering processing comprises: Obtaining a forward illumination direction parameter according to the normal direction of the rendered model and the forward illumination scattering coefficient; Obtaining a backlighting direction parameter according to the normal direction of the rendered model and a backlighting scattering coefficient; Determining the subsurface scattering effect of the forward light source and the subsurface scattering effect of the backlight source respectively according to the forward light direction parameter and the backlight direction parameter; Superimposing the subsurface scattering effect of the forward light source and the subsurface scattering effect of the backlight source to obtain a total scattering effect; The subsurface scattering processing result of the rendered model is determined according to the total scattering effect.
11. A stylized rendering device, characterized in that: include: An acquisition unit, used for acquiring an object model of an object to be rendered; A generating unit, configured to generate a gradient mask according to texture information of the object model; A mixing unit, used for mixing the gradient mask with random noise to obtain a gradient map; A rendering unit is used to render the object model according to the gradient map to obtain a stylized rendering result of the object to be rendered.
12. A computer device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the stylized rendering method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the stylized rendering method according to any one of claims 1 to 10.
Citation Information
Cited By
Stylized effect rendering method and apparatus, electronic device, and storage medium
WO2026214636A1
