Model rendering method and device and electronic equipment

By adjusting the screen texture coordinate system and sampling normal maps, the problem of poor rendering effect of crystallized hair models in the existing technology is solved, and more realistic crystallized hair model rendering is achieved.

CN121010684APending Publication Date: 2025-11-25SHANGHAI NETEASE CUICAN NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510912968.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-02
Publication Date
2025-11-25

AI Technical Summary

Technical Problem

Existing technologies, when rendering crystallized hair models, only highlight the crystal effect without combining it with hair features, resulting in poor rendering results.

Method used

By acquiring the hair model, the origin of the screen texture coordinate system is offset to the center of the model to determine the target texture coordinates of each pixel. The preset normal map is sampled and the hair model is rendered based on the reflection texture, and crystallization is added.

Benefits of technology

While retaining the original hair rendering effect, the rendering effect of the crystallized hair model has been improved, enhancing the detail and realism of the crystallization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121010684A_ABST
    Figure CN121010684A_ABST
Patent Text Reader

Abstract

The invention provides a model rendering method and device and electronic equipment, and the method comprises the steps: obtaining a hair model, shifting an original point position of a screen texture coordinate system to a model center position of the hair model, and obtaining a shifted screen texture coordinate system, determining a target texture coordinate corresponding to each pixel point in the screen under the offset screen texture coordinate system; for each pixel point in the screen, sampling a preset normal map based on the target texture coordinate corresponding to the pixel point to obtain a map normal, determining a reflection texture based on the map normal, and sampling a reflection map based on the reflection texture to obtain a sampling result; and rendering the hair model based on the sampling result corresponding to each pixel point in the screen to obtain a hair model with a crystallization effect, and displaying the hair model with the crystallization effect in the screen. According to the mode, on the basis of keeping the original hair rendering effect, crystallization expression is added, and the rendering effect of the crystallized hair model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of computer graphics, and in particular, to a model rendering method and device and electronic equipment. BACKGROUND

[0002] In related technologies, when rendering a crystallized hair model, the hair model itself is made into a crystal model, and then a model map is customized. However, this method only highlights the crystal effect and does not combine the hair features, resulting in poor rendering effect of the crystallized hair model. SUMMARY

[0003] The present disclosure aims to provide a model rendering method and device and electronic equipment to add crystallization performance on the basis of preserving the original hair rendering effect and improve the rendering effect of the crystallized hair model.

[0004] In a first aspect, the present disclosure provides a model rendering method, which includes: obtaining a hair model, the hair model being stacked by a plurality of hair patches; offsetting an origin position of a screen texture coordinate system to a model center position of the hair model to obtain an offset screen texture coordinate system, and determining a target texture coordinate corresponding to each pixel point in the screen under the offset screen texture coordinate system; for each pixel point in the screen, sampling a preset normal map based on the target texture coordinate corresponding to the pixel point to obtain a map normal, determining a reflection texture based on the map normal, and sampling a reflection map based on the reflection texture to obtain a sampling result; rendering the hair model based on the sampling result corresponding to each pixel point in the screen to obtain a hair model with a crystallization effect, and displaying the hair model with the crystallization effect in the screen.

[0005] In a second aspect, the present disclosure provides a model rendering device, which includes: a model obtaining module configured to obtain a hair model, the hair model being stacked by a plurality of hair patches; a coordinate determining module configured to offset an origin position of a screen texture coordinate system to a model center position of the hair model to obtain an offset screen texture coordinate system, and determine a target texture coordinate corresponding to each pixel point in the screen under the offset screen texture coordinate system; a map sampling module configured to, for each pixel point in the screen, sample a preset normal map based on the target texture coordinate corresponding to the pixel point to obtain a map normal, determine a reflection texture based on the map normal, and sample a reflection map based on the reflection texture to obtain a sampling result; and a model rendering module configured to render the hair model based on the sampling result corresponding to each pixel point in the screen to obtain a hair model with a crystallization effect, and display the hair model with the crystallization effect in the screen.

[0006] In a third aspect, the present disclosure provides an electronic device including a processor and a memory storing machine executable instructions executable by the processor to implement the above-described model rendering method.

[0007] In a fourth aspect, the present disclosure provides a computer readable storage medium storing computer executable instructions which, when invoked and executed by a processor, cause the processor to implement the above-described model rendering method.

[0008] The present disclosure embodiments bring the following beneficial effects:

[0009] The model rendering method, device and electronic device provided by the present disclosure first obtain a hair model, which is stacked by a plurality of hair patches; then the origin position of a screen texture coordinate system is offset to the model center position of the hair model to obtain an offset screen texture coordinate system, and the target texture coordinates of each pixel point in the screen in the offset screen texture coordinate system are determined; then for each pixel point in the screen, a preset normal map is sampled based on the target texture coordinates corresponding to the pixel point to obtain a mapping normal, a reflection texture is determined based on the mapping normal, and a reflection map is sampled based on the reflection texture to obtain a sampling result; then the hair model is rendered based on the sampling result corresponding to each pixel point in the screen to obtain a hair model with crystallization effect, and the hair model with crystallization effect is displayed in the screen. This way adds crystallization performance on the basis of retaining the original hair rendering effect, improving the rendering effect of the hair model with crystallization.

[0010] Other features and advantages of the present disclosure will be described in the following description, or can be inferred from the description or determined without doubt, or can be known by implementing the above-described technologies of the present disclosure.

[0011] In order to make the above-mentioned purposes, features and advantages of the present disclosure more obvious and easy to understand, the following preferred embodiments are specifically described in detail below, and the accompanying drawings are described as follows. BRIEF DESCRIPTION OF DRAWINGS

[0012] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present disclosure, and those skilled in the art can obtain other drawings according to these drawings without creative labor.

[0013] Figure 1 A flowchart of a model rendering method provided by the present disclosure embodiments;

[0014] Figure 2 An effect diagram of rendering a preset normal map based on different UVs for a hair model is provided for an embodiment of the present disclosure;

[0015] Figure 3 An effect diagram of a hair model after moving is provided for an embodiment of the present disclosure;

[0016] Figure 4 An effect diagram of a hair model after moving after rendering is provided for an embodiment of the present disclosure;

[0017] Figure 5 A schematic diagram of a hair model after rotating is provided for an embodiment of the present disclosure;

[0018] Figure 6 A rendering effect diagram of a hair model after rotating is provided for an embodiment of the present disclosure;

[0019] Figure 7 A structural schematic diagram of a model rendering device is provided for an embodiment of the present disclosure;

[0020] Figure 8 A structural schematic diagram of an electronic device is provided for an embodiment of the present disclosure. DETAILED DESCRIPTION

[0021] In order to make the objectives, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments of the present disclosure. The components of the embodiments of the present disclosure described and shown in the drawings herein can be arranged and designed in various different configurations.

[0022] Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the claimed present disclosure, but only represents selected embodiments of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative labor are within the scope of protection of the present disclosure.

[0023] In the related art, when rendering a crystallized hair model, the hair model itself is made into a crystal model, and then a model map is customized. However, this method only highlights the crystal effect and does not combine the hair features, and there is no difference from rendering a general crystal model, resulting in poor rendering effect of the crystallized hair model.

[0024] Based on the above problems, the embodiments of the present disclosure provide a model rendering method, device and electronic device, which can be applied to the scene of generating a hair model with a crystallization effect.

[0025] To facilitate the understanding of the embodiments of the present disclosure, first, a model rendering method disclosed by the embodiments of the present disclosure is introduced in detail, as shown in the following. Figure 1 The method comprises the following specific steps:

[0026] Step S102, a hair model is acquired, the hair model is stacked by a plurality of hair patches.

[0027] In the specific implementation, the hair model can be various styles of hair models, which can be determined according to user demand or research and development demand. The hair model is different from other three-dimensional models, which is stacked by many hair patches, so that when the crystallization effect of the hair model is rendered, the crystallization of the hair model needs to be regular and not messy, and each hair patch can be connected completely.

[0028] Step S104, the origin position of the screen texture coordinate system is offset to the model center position of the hair model, the offset screen texture coordinate system is obtained, and the target texture coordinate corresponding to each pixel point in the screen under the offset screen texture coordinate system is determined.

[0029] In the specific implementation, the screen can be an electronic screen on an electronic device, or a separate display screen; wherein the electronic device can be a mobile phone, a computer or a server, etc. The screen is used to display the hair model, and the screen texture coordinate can be a two-dimensional coordinate system established with the screen center as the origin, or a two-dimensional coordinate system established with a specified position in the screen as the origin, which is used to determine the screen texture coordinate of each pixel point in the screen. After the origin position of the screen texture coordinate system is offset to the model center position of the hair model, the screen texture coordinate system also offsets with the origin position, so that the screen texture coordinate of each pixel point in the screen also offsets with the screen texture coordinate system, so as to determine the target texture coordinate corresponding to each pixel point based on the offset screen texture coordinate corresponding to each pixel point. For example, the offset screen texture coordinate corresponding to each pixel point can be determined as the target texture coordinate corresponding to the pixel point, or the offset screen texture coordinate corresponding to each pixel point can be normalized, and the normalized screen texture coordinate is determined as the target texture coordinate corresponding to the pixel point.

[0030] In a specific embodiment, the target texture coordinate can also be referred to as screen UV, which refers to the texture coordinate obtained after the screen texture coordinate is normalized. Wherein, screen UV = screen space position / screen resolution; U refers to the horizontal axis of the screen texture coordinate system, from 0(screen left edge) to 1(screen right edge); V refers to the vertical axis of the screen texture coordinate system, from 0(screen top) to 1(screen bottom).

[0031] In step S106, for each pixel point in the screen, a preset normal map is sampled based on the target texture coordinate corresponding to the pixel point to obtain a mapping normal, and a reflection texture is determined based on the mapping normal, and a reflection map is sampled based on the reflection texture to obtain a sampling result.

[0032] In a specific implementation, the preset normal map can be a normal map determined according to research and development requirements or user requirements. The preset normal map refers to a normal map simulating the normal of a crystal corner. Specifically, the preset normal map can be a normal at each point on the model surface of the hair model. The direction of the normal is marked by an RGB color channel. For visual effects, if a light source is applied at a specific position, a model surface with a relatively low level of detail can generate an accurate light direction and reflection effect with a high level of detail. In addition, the preset normal map is a special texture that can be applied to a 3D surface and is an extension of a concave-convex texture. It enables each pixel of a plane to have a height value and contains a large amount of surface information, and can create a variety of special stereoscopic visual effects on the shape of an object model.

[0033] For each pixel point in the screen, the preset normal map is sampled based on the target texture coordinate corresponding to the pixel point to obtain a mapping normal. The mapping normal is used to indicate the normal direction corresponding to each pixel point. Then, the reflection texture is determined based on the mapping normal and a reflection function. The reflection texture is used to simulate the reflection performance of a crystal. Then, the reflection map is sampled based on the reflection texture to generate a mirror surface and a color deviation effect, that is, to simulate the prismatic color of the crystal. The reflection map can be a map containing any color.

[0034] In a specific implementation, the advantage of sampling the preset normal map based on the target texture coordinate (equivalent to screen UV) corresponding to each pixel point in the screen in the offset screen texture coordinate system is that the preset normal map can be displayed completely regardless of the model itself UV. Figure 2 FIG. 1 shows an effect diagram of rendering a hair model by sampling a preset normal map based on different UVs according to an embodiment of the present disclosure, Figure 2 The left image in FIG. 1 is a model rendering effect diagram obtained by sampling a normal map using model itself UV, and the right image is a model rendering effect diagram obtained by sampling a normal map using screen UV. The normal map sampled using model UV is not as complete as the normal map sampled using screen UV in displaying the preset normal map. Because the hair model is special in that the hair patches are stacked layer by layer, the model UV of the hair model is not coherent, and only a normal map with customized UV can be used, but a four-square continuous map (equivalent to the preset normal map) with non-customized UV cannot be used.

[0035] In addition, the rendering effect obtained by sampling a normal map using model itself UV is completely segmented from the model and does not follow the movement of the model, as shown in FIG. 2.Figure 3 The image shown is an illustration of the effect of moving a hair model according to an embodiment of this disclosure. Figure 3 When the hair model is in different positions, the texture pattern does not move with the movement of the hair model, which is not the desired effect.

[0036] Specifically, the screen UV and model UV mentioned above are two completely different texture coordinate systems. Model UV is defined in the model's local coordinate system and is an inherent property of the model. It maps textures onto the model's surface, and the UV changes as the model's vertex positions change. Screen UV is defined in the screen normalized coordinate system (equivalent to the screen texture coordinate system mentioned above), which is completely dependent on the screen resolution and is independent of the model. Instead, it maps textures onto screen regions.

[0037] Step S108: Render the hair model based on the sampling results corresponding to each pixel in the screen to obtain a crystallized hair model, and display the crystallized hair model on the screen.

[0038] In practice, the hair model is rendered based on the sampling results corresponding to each pixel on the screen. The reflection and prismatic color representation of crystals simulated based on the sampling results can be mixed into the original hair effect.

[0039] The model rendering method provided in this disclosure adds crystallization representation while retaining the original hair rendering effect, thereby improving the rendering effect of the crystallized hair model.

[0040] The following examples describe how to determine the target texture coordinates corresponding to each pixel.

[0041] Specifically, the process of shifting the origin of the screen texture coordinate system to the center of the hair model to obtain the shifted screen texture coordinate system can include: aligning the origin of the screen texture coordinate system with the center of the hair model on the screen pixels to obtain the shifted screen texture coordinate system.

[0042] In practice, the aforementioned model center position can be any location on the hair model that the user selects near the model center. This model center position is a coordinate point of the hair model in model space. For example, if the coordinates of the model center point LocalPos are (0, 0, 160), the value obtained after transforming it from local space to world space is centerPointPos (equivalent to the aforementioned model center point). If the hair model has no rotation transformation, the coordinates of point centerPointPos are the coordinates obtained by adding the world position of the model's central axis to the coordinates (0, 0, 160).

[0043] When the origin of the screen texture coordinate system is aligned with the center of the hair model on the screen pixels, the position of the screen UV origin on the screen coincides with the center of the hair model on the screen. At this time, the screen UV can move with the movement of the hair model.

[0044] Based on the above description, the specific process of determining the target texture coordinates corresponding to each pixel in the screen under the offset screen texture coordinate system may include: determining the coordinate offset based on the position coordinates of the center position of the hair model, the current view size, and the scene texel size; and subtracting the coordinate offset from the screen texture coordinates corresponding to each pixel in the screen to obtain the target texture coordinates corresponding to the pixel.

[0045] In practical implementation, the view size mentioned above is used to indicate the screen size; that is, the larger the screen size, the larger the view. The scene texels mentioned above are used to indicate the texture size of the background area on the screen, excluding the texture occupied by the hair model. Among them, a texel (texture element) represents the smallest unit of a two-dimensional texture mapped to a three-dimensional surface. A texel is the basic unit of the texture image space and can be regarded as the "pixel" that makes up the texture.

[0046] In an optional embodiment, the specific process of determining the coordinate offset based on the position coordinates of the hair model's center position, the current view size, and the scene texel size may include: determining the first position coordinates of the hair model's center position in the model coordinate system; transforming the first position coordinates to world space to obtain the second position coordinates of the model's center position in world space; transforming the second position coordinates to clipping space to obtain the third position coordinates; and determining the coordinate offset based on the third position coordinates, the current view size, and the scene texel size.

[0047] For example, using the Transform Position node, the input parameter LocalPos (equivalent to the first position coordinates mentioned above) is transformed from model space (equivalent to the model coordinate system mentioned above) to world space, resulting in the world position centerPointPos of the model's center point (equivalent to the second position coordinates mentioned above). Here, the parameter LocalPos is a position in model space; generally, LocalPos is the approximate position corresponding to the texture using screen UVs. CenterPointPos is then transformed from world space to clip space, resulting in centerPointClipPos. Then, based on the following code, the target texture coordinates corresponding to each pixel on the screen can be obtained:

[0048] float2 centerScreenUV=screenUV-float2(centerPointClipPos.x / centerPointClipPos.w*0.5+0.5,centerPointClipPos.y / centerPointClipPos.w*(-0.5)+0.5)*viewSize*sceneTexelSize;

[0049] Where centerScreenUV represents the target texture coordinates corresponding to the pixel, screenUV represents the screen texture coordinates corresponding to the pixel, centerPointClipPos.x represents the coordinate value of the model center position in the X-axis direction in clip space, and centerPointClipPos.w represents the w component of the model center position in clip space. This w component is a scalar used to determine the range of clip space. In clip space, whether a point is within the view frustum is determined by the relationship between its coordinates and the w component, satisfying the following conditions. Only the following conditions can be preserved: -w<=x<=w, -w<=y<=w, and -w<=z<=w (in OpenGL, while in DirectX the z range is 0<=z<=w). If it is perspective projection, the projection matrix will generate a non-uniform clipping space, where the w component will be set to the z value (i.e., depth value) in the view space. During perspective division (from clipping space to NDC space), it is necessary to divide by the w component to achieve the effect of objects appearing larger when closer and smaller when farther away. viewSize represents the current view size (in pixels), and sceneTexelSize represents the scene texel size.

[0050] In an optional embodiment, after determining the target texture coordinates of each pixel on the screen in the offset screen texture coordinate system, the target texture coordinates of each pixel on the screen are corrected according to the virtual camera position, the center position of the hair model, and a preset scaling factor to obtain the final target texture coordinates. The preset scaling factor is a parameter related to the field of view of the virtual camera and the current view size. The virtual camera is used to capture images of the hair model and display the captured images on the screen. This method is mainly used to correct the tiling value of the target texture coordinates corresponding to each pixel, so that the texture coordinates corresponding to each pixel can be scaled according to the field of view size and the view size. The tiling value of the target texture coordinates is also the UV tiling value, which refers to the parameter used to tile the image texture onto the surface of the 3D model during UV mapping.

[0051] In practice, the specific parameters included in the aforementioned preset scaling factor can be determined according to the R&D requirements. For example, the preset scaling factor may include the view size of a certain channel, or it may include the inverse projection matrix related to the field of view of the virtual camera.

[0052] In practical applications, the target texture coordinates can be calculated and corrected using the following code to obtain the final target texture coordinates:

[0053] float2 offsetScreenUV=length(camPos-centerPointPos)*centerScreenUV*View.ClipToView[0][0] / viewSize.r;

[0054] Where offsetScreenUV represents the final target texture coordinates corresponding to a certain pixel, the length() function is used to calculate the length of the vector, which is the distance between the virtual camera position and the center point of the model; camPos represents the virtual camera position; centerScreenUV represents the target texture coordinates corresponding to a certain pixel; ClipToView[0][0] represents the first element of the inverse projection matrix, which corresponds to the scaling factor from the clip space X-axis to the view space X-axis, and is related to FOV (i.e., field of view). FOV x The horizontal field of view angle is defined as the scaling factor of the X-coordinate in view space, used to convert the X-component of NDC space back to the X-coordinate in view space.

[0055] After completing the above calculations, the preset normal map is sampled using the final target texture coordinates corresponding to each pixel on the screen, resulting in the following: Figure 4 The image shown is a rendered image of a hair model after it has been moved. The textures are consistent across the hair model in different positions, meaning the textures follow the movement of the hair model.

[0056] The following examples describe how texture offsets are calculated based on model rotation.

[0057] It is incorrect to assume that the texture positions on the sampled hair model remain unchanged when the hair model is rotated, such as... Figure 5 The diagram shown is a schematic representation of a hair model rotation according to an embodiment of this disclosure. Figure 5 The texture in the image does not rotate with the hair model. In fact, the ideal rendering effect is that the texture position follows the rotation of the hair model. That is, when the model rotates to the right, the texture shifts to the right.

[0058] Based on the above description, after determining the target texture coordinates of each pixel in the screen in the offset screen texture coordinate system, it is necessary to determine the rotation offset of the pixels in the screen when the hair model rotates; and adjust the target texture coordinates of the pixels in the screen based on the rotation offset to obtain the adjusted target texture coordinates.

[0059] In practice, the aforementioned rotation offset is determined based on the orientation of the hair model and the orientation of the virtual camera; that is, the rotation offset is calculated based on the orientation of the virtual camera looking at the hair model.

[0060] In an optional embodiment, the specific process of determining the rotation offset of the pixels on the screen when the hair model is rotated may include: determining the angle between the orientation of the hair model and the orientation of the virtual camera; and determining the rotation offset of the pixels on the screen based on the angle.

[0061] In practical implementation, the model orientation vector can be determined based on the orientation of the hair model, and the camera orientation vector can be determined based on the orientation of the virtual camera. Then, the vector product of the model orientation vector and the camera orientation vector can be calculated. Based on this vector product, the angle between the orientation of the hair model and the orientation of the virtual camera can be obtained. Then, the rotation offset of the pixel in the screen can be determined according to the size of the angle.

[0062] The specific process of determining the rotation offset of a pixel on the screen based on the included angle can include: in response to the included angle being equal to a preset angle, determining that the rotation offset of a pixel on the screen is zero; in response to the angle being less than a preset angle, determining that the rotation offset of a pixel on the screen is positively correlated with the angle; and in response to the angle being greater than a preset angle, determining that the rotation offset of a pixel on the screen is negatively correlated with the angle.

[0063] In practical implementation, the aforementioned preset angle can be determined according to R&D needs. For example, the preset angle can be 0 degrees or 90 degrees. In a specific embodiment, when the virtual camera is perpendicular to the model's orientation, there is no offset; when the virtual camera is located to the left of the hair model, the magnitude of the rotation offset is positively correlated with the angle between the two vectors; when the virtual camera is located to the right of the hair model, the magnitude of the rotation offset is negatively correlated with the angle between the two vectors.

[0064] In an optional embodiment, the preset angle can be set to 0 degrees. When the vector product of the model orientation vector and the camera orientation vector (equivalent to the aforementioned included angle) is equal to 0, the rotation offset is 0. When the vector product of the model orientation vector and the camera orientation vector is greater than 0, the inner product of the model orientation vector and the camera orientation vector is determined. Then, the inner product is calculated by performing an inverse cosine calculation, multiplied by 180 degrees, and divided by pi to obtain the target offset, which is also the rotation offset. When the vector product of the model orientation vector and the camera orientation vector is less than 0, the result of subtracting the target offset from 360 degrees is taken as the rotation offset.

[0065] like Figure 6 The image shown is a rendering of a hair model after rotation according to an embodiment of this disclosure. When the hair model rotates, the texture also shifts, making the texture appear to follow the model's rotation.

[0066] The following examples are used to describe the model rendering method.

[0067] Specifically, the process of determining the reflection texture based on the texture normal and sampling the reflection map based on the reflection texture to obtain the sampling result may include: determining the reflection vector based on the texture normal and the reflection function; determining the reflection texture based on the reflection vector, the orientation and position of the virtual camera; and sampling the reflection map based on the reflection texture to obtain the sampling result.

[0068] In practical implementation, the reflection vector can be obtained from the texture normal and the built-in reflection function. Then, the inner product of the virtual camera's orientation vector and the virtual camera's position can be calculated. After the inner product is processed by inverse cosine and multiplied by 180 and then divided by pi, the intermediate vector can be obtained. Then, the reflection texture can be obtained based on the intermediate vector and the reflection vector. Based on the reflection texture, the reflection map can be sampled to generate the prismatic color effect of the crystal.

[0069] In one optional embodiment, the process of sampling a reflection map based on a reflection texture includes: first, defining a reflection map and a sampler, wherein the sampler defines how to perform texture sampling on the reflection map; then defining texture coordinates texCoord; and finally sampling the texture to obtain the sampling result color, color = Sample(texture, sampler, texCoord); wherein the sampler is used to sample the texture at a given coordinate.

[0070] Furthermore, the specific process of rendering the hair model based on the sampling results corresponding to each pixel in the screen to obtain a crystallized hair model may include: obtaining a crystallized rendering effect corresponding to the hair model based on the sampling results corresponding to each pixel in the screen; rendering the hair model based on preset hair rendering parameters to obtain a first rendering result; and combining the first rendering result with the crystallized rendering effect corresponding to the hair model to obtain a crystallized hair model.

[0071] In practical implementation, Fresnel rendering can be used to combine the initial rendering result and the crystallization rendering effect. For example, the following code can be used:

[0072] float fresnel=dot(camVector,vertexNormal);

[0073] float mask=smoothstep(fresnel,fresnel+smooth,offset);

[0074] float3 color=lerp(color01,color02,mask);

[0075] Where dot represents inner product calculation, smoothstep is the smoothing step function, lerp is the interpolation function; camVector is the viewing direction, i.e., the direction from the pixel world position to the camera world position; vertexNormal is the model vertex normal; color01 and color02 are the original rendering appearance of the hair (equivalent to the first rendering effect mentioned above) and the crystallization effect; smooth and offset are input parameters that can be modified, and their meaning is to distinguish the range of the two rendering effects.

[0076] In the above method, the normal UV is calculated based on the screen UV, so that the UV changes as the model rotates and shifts, just like on the surface of the hair model. Then, the reflection UV is calculated from the normal to simulate the reflection of crystals. The reflection map is sampled from the reflection UV to simulate the prismatic color of crystals. Finally, the above crystallization effect is blended into the original hair effect.

[0077] Corresponding to the above method embodiments, this disclosure provides a model rendering apparatus, such as... Figure 7 As shown, the device includes:

[0078] The model acquisition module 60 is used to acquire the hair model, which is composed of multiple stacked hair facets.

[0079] The coordinate determination module 61 is used to offset the origin of the screen texture coordinate system to the center of the hair model, obtain the offset screen texture coordinate system, and determine the target texture coordinates of each pixel in the screen under the offset screen texture coordinate system.

[0080] The texture sampling module 62 is used to sample a preset normal map for each pixel on the screen based on the target texture coordinates corresponding to the pixel, obtain the texture normal, determine the reflection texture based on the texture normal, and sample the reflection map based on the reflection texture to obtain the sampling result.

[0081] The model rendering module 63 is used to render the hair model based on the sampling results corresponding to each pixel on the screen, to obtain a crystallized hair model, and to display the crystallized hair model on the screen.

[0082] The aforementioned model rendering device, while retaining the original hair rendering effect, incorporates crystallization, thereby improving the rendering effect of the crystallized hair model.

[0083] Furthermore, the coordinate determination module 61 is used to: align the origin of the screen texture coordinate system with the center position of the hair model on the screen pixels to obtain the offset screen texture coordinate system.

[0084] Furthermore, the coordinate determination module 61 is also used to: determine the coordinate offset based on the position coordinates of the center position of the hair model, the current view size, and the scene texel size; and for each pixel in the screen, subtract the coordinate offset from the screen texture coordinates corresponding to the pixel to obtain the target texture coordinates corresponding to the pixel.

[0085] Furthermore, the coordinate determination module 61 described above is also used to: determine the first position coordinates of the hair model's center position in the model coordinate system, transform the first position coordinates to world space to obtain the second position coordinates of the model's center position in world space; transform the second position coordinates to clipping space to obtain the third position coordinates; and determine the coordinate offset based on the third position coordinates, the current view size, and the scene texel size.

[0086] Furthermore, the aforementioned device also includes a coordinate correction module, used to: after determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system, correct the target texture coordinates for each pixel in the screen according to the virtual camera position, the center position of the hair model, and a preset scaling factor, to obtain the final target texture coordinates; wherein, the preset scaling factor is a parameter related to the field of view of the virtual camera and the current view size, and the virtual camera is used to: capture the hair model and display the captured image on the screen.

[0087] Furthermore, the above-mentioned device also includes a rotation offset module, used to: after determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system, determine the rotation offset of the pixels in the screen when the hair model rotates; adjust the target texture coordinates corresponding to the pixels in the screen based on the rotation offset to obtain the adjusted target texture coordinates.

[0088] Furthermore, the aforementioned rotation offset module is also used to: determine the angle between the orientation of the hair model and the orientation of the virtual camera; and determine the rotation offset corresponding to the pixel on the screen based on the angle.

[0089] Furthermore, the aforementioned rotation offset module is also used to: determine that the rotation offset of a pixel on the screen is zero in response to the included angle being equal to a preset angle; determine that the rotation offset of a pixel on the screen is positively correlated with the angle in response to the angle being less than a preset angle; and determine that the rotation offset of a pixel on the screen is negatively correlated with the angle in response to the angle being greater than a preset angle.

[0090] Furthermore, the texture sampling module 62 described above is used to: determine the reflection vector based on the texture normal and the reflection function; determine the reflection texture based on the reflection vector, the orientation and position of the virtual camera; and sample the reflection texture to obtain the sampling result.

[0091] Furthermore, the aforementioned model rendering module 63 is used to: obtain the crystallized rendering effect corresponding to the hair model based on the sampling results corresponding to each pixel in the screen; render the hair model based on preset hair rendering parameters to obtain a first rendering result; and combine the first rendering result with the crystallized rendering effect corresponding to the hair model to obtain a crystallized hair model.

[0092] The model rendering apparatus provided in this disclosure has the same implementation principle and technical effects as the aforementioned method embodiments. For the sake of brevity, any parts not mentioned in the apparatus embodiments can be referred to the corresponding content in the aforementioned method embodiments.

[0093] This disclosure also provides an electronic device, such as... Figure 8 As shown, the electronic device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, which executes the machine-executable instructions to implement the above-described model rendering method.

[0094] Specifically, the above model rendering method includes: acquiring a hair model, which is composed of multiple stacked hair patches; offsetting the origin of the screen texture coordinate system to the center of the hair model to obtain the offset screen texture coordinate system, and determining the target texture coordinates corresponding to each pixel in the screen under the offset screen texture coordinate system; for each pixel in the screen, sampling a preset normal map based on the target texture coordinates corresponding to the pixel to obtain the map normal, and determining the reflection texture based on the map normal, and sampling the reflection map based on the reflection texture to obtain the sampling result; rendering the hair model based on the sampling result corresponding to each pixel in the screen to obtain a crystallized hair model, and displaying the crystallized hair model on the screen.

[0095] The above model rendering method, while retaining the original hair rendering effect, adds crystallization representation, thereby improving the rendering effect of the crystallized hair model.

[0096] In an optional embodiment, the step of shifting the origin of the screen texture coordinate system to the center of the hair model to obtain the shifted screen texture coordinate system includes: aligning the origin of the screen texture coordinate system with the center of the hair model on the screen pixels to obtain the shifted screen texture coordinate system.

[0097] In an optional embodiment, the step of determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system includes: determining the coordinate offset based on the position coordinates of the center position of the hair model, the current view size, and the scene texel size; and subtracting the coordinate offset from the screen texture coordinates corresponding to each pixel in the screen to obtain the target texture coordinates corresponding to the pixel.

[0098] In an optional embodiment, the step of determining the coordinate offset based on the position coordinates of the hair model's center position, the current view size, and the scene texel size includes: determining the first position coordinates of the hair model's center position in the model coordinate system; transforming the first position coordinates to world space to obtain the second position coordinates of the model's center position in world space; transforming the second position coordinates to clipping space to obtain the third position coordinates; and determining the coordinate offset based on the third position coordinates, the current view size, and the scene texel size.

[0099] In an optional embodiment, after determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system, the method further includes: for each pixel in the screen, correcting the target texture coordinates according to the virtual camera position, the center position of the hair model, and a preset scaling factor to obtain the final target texture coordinates; wherein, the preset scaling factor is a parameter related to the field of view of the virtual camera and the current view size, and the virtual camera is used to: capture the hair model and display the captured image on the screen.

[0100] In an optional embodiment, after determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system, the method further includes: determining the rotation offset corresponding to the pixel in the screen when the hair model rotates; adjusting the target texture coordinates corresponding to the pixel in the screen based on the rotation offset to obtain the adjusted target texture coordinates.

[0101] In an optional embodiment, the step of determining the rotation offset of the pixels on the screen when the hair model rotates includes: determining the angle between the orientation of the hair model and the orientation of the virtual camera; and determining the rotation offset of the pixels on the screen based on the angle.

[0102] In an optional embodiment, the step of determining the rotation offset of a pixel in the screen based on the included angle includes: determining that the rotation offset of a pixel in the screen is zero in response to the included angle being equal to a preset angle; determining that the rotation offset of a pixel in the screen is positively correlated with the angle in response to the angle being less than the preset angle; and determining that the rotation offset of a pixel in the screen is negatively correlated with the angle in response to the angle being greater than the preset angle.

[0103] In an optional embodiment, the steps of determining the reflection texture based on the texture normal and sampling the reflection map based on the reflection texture to obtain the sampling result include: determining the reflection vector based on the texture normal and the reflection function; determining the reflection texture according to the reflection vector, the orientation and position of the virtual camera; and sampling the reflection map based on the reflection texture to obtain the sampling result.

[0104] In an optional embodiment, the step of rendering the hair model based on the sampling results corresponding to each pixel in the screen to obtain a crystallized hair model includes: obtaining a crystallized rendering effect corresponding to the hair model based on the sampling results corresponding to each pixel in the screen; rendering the hair model based on preset hair rendering parameters to obtain a first rendering result; and combining the first rendering result with the crystallized rendering effect corresponding to the hair model to obtain a crystallized hair model.

[0105] Furthermore, Figure 8The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 101, the communication interface 103 and the memory 100 connected via the bus 102.

[0106] The memory 100 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 8 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0107] Processor 101 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 101 or by instructions in software form. The processor 101 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 100, and processor 101 reads information from memory 100 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0108] This disclosure also provides a computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the above-described model rendering method.

[0109] Specifically, the above model rendering method includes: acquiring a hair model, which is composed of multiple stacked hair patches; offsetting the origin of the screen texture coordinate system to the center of the hair model to obtain the offset screen texture coordinate system, and determining the target texture coordinates corresponding to each pixel in the screen under the offset screen texture coordinate system; for each pixel in the screen, sampling a preset normal map based on the target texture coordinates corresponding to the pixel to obtain the map normal, and determining the reflection texture based on the map normal, and sampling the reflection map based on the reflection texture to obtain the sampling result; rendering the hair model based on the sampling result corresponding to each pixel in the screen to obtain a crystallized hair model, and displaying the crystallized hair model on the screen.

[0110] The above model rendering method, while retaining the original hair rendering effect, adds crystallization representation, thereby improving the rendering effect of the crystallized hair model.

[0111] In an optional embodiment, the step of shifting the origin of the screen texture coordinate system to the center of the hair model to obtain the shifted screen texture coordinate system includes: aligning the origin of the screen texture coordinate system with the center of the hair model on the screen pixels.

[0112] In an optional embodiment, the step of determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system includes: determining the coordinate offset based on the position coordinates of the center position of the hair model, the current view size, and the scene texel size; and subtracting the coordinate offset from the screen texture coordinates corresponding to each pixel in the screen to obtain the target texture coordinates corresponding to the pixel.

[0113] In an optional embodiment, the step of determining the coordinate offset based on the position coordinates of the hair model's center position, the current view size, and the scene texel size includes: determining the first position coordinates of the hair model's center position in the model coordinate system; transforming the first position coordinates to world space to obtain the second position coordinates of the model's center position in world space; transforming the second position coordinates to clipping space to obtain the third position coordinates; and determining the coordinate offset based on the third position coordinates, the current view size, and the scene texel size.

[0114] In an optional embodiment, after determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system, the method further includes: for each pixel in the screen, correcting the target texture coordinates according to the virtual camera position, the center position of the hair model, and a preset scaling factor to obtain the final target texture coordinates; wherein, the preset scaling factor is a parameter related to the field of view of the virtual camera and the current view size, and the virtual camera is used to: capture the hair model and display the captured image on the screen.

[0115] In an optional embodiment, after determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system, the method further includes: determining the rotation offset corresponding to the pixel in the screen when the hair model rotates; adjusting the target texture coordinates corresponding to the pixel in the screen based on the rotation offset to obtain the adjusted target texture coordinates.

[0116] In an optional embodiment, the step of determining the rotation offset of the pixels on the screen when the hair model rotates includes: determining the angle between the orientation of the hair model and the orientation of the virtual camera; and determining the rotation offset of the pixels on the screen based on the angle.

[0117] In an optional embodiment, the step of determining the rotation offset of a pixel in the screen based on the included angle includes: determining that the rotation offset of a pixel in the screen is zero in response to the included angle being equal to a preset angle; determining that the rotation offset of a pixel in the screen is positively correlated with the angle in response to the angle being less than the preset angle; and determining that the rotation offset of a pixel in the screen is negatively correlated with the angle in response to the angle being greater than the preset angle.

[0118] In an optional embodiment, the steps of determining the reflection texture based on the texture normal and sampling the reflection map based on the reflection texture to obtain the sampling result include: determining the reflection vector based on the texture normal and the reflection function; determining the reflection texture according to the reflection vector, the orientation and position of the virtual camera; and sampling the reflection map based on the reflection texture to obtain the sampling result.

[0119] In an optional embodiment, the step of rendering the hair model based on the sampling results corresponding to each pixel in the screen to obtain a crystallized hair model includes: obtaining a crystallized rendering effect corresponding to the hair model based on the sampling results corresponding to each pixel in the screen; rendering the hair model based on preset hair rendering parameters to obtain a first rendering result; and combining the first rendering result with the crystallized rendering effect corresponding to the hair model to obtain a crystallized hair model.

[0120] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal device, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0121] In the description of this disclosure, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this disclosure and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this disclosure. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0122] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.

Claims

1. A model rendering method, characterized in that, The method includes: Obtain a hair model, which is composed of multiple stacked hair panels; The origin of the screen texture coordinate system is offset to the center of the hair model to obtain the offset screen texture coordinate system, and the target texture coordinates of each pixel in the screen are determined in the offset screen texture coordinate system. For each pixel in the screen, a preset normal map is sampled based on the target texture coordinates corresponding to the pixel to obtain the map normal, and a reflection texture is determined based on the map normal, and a reflection map is sampled based on the reflection texture to obtain the sampling result; The hair model is rendered based on the sampling results corresponding to each pixel in the screen to obtain a crystallized hair model, and the crystallized hair model is displayed on the screen.

2. The method according to claim 1, characterized in that, The step of offsetting the origin of the screen texture coordinate system to the center of the hair model to obtain the offset screen texture coordinate system includes: Align the origin of the screen texture coordinate system with the center of the hair model on the screen pixels to obtain the offset screen texture coordinate system.

3. The method according to claim 1, characterized in that, The step of determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system includes: The coordinate offset is determined based on the position coordinates of the center position of the hair model, the current view size, and the scene texel size; For each pixel in the screen, the target texture coordinates corresponding to the pixel are obtained by subtracting the coordinate offset from the screen texture coordinates corresponding to the pixel.

4. The method according to claim 3, characterized in that, The step of determining the coordinate offset based on the position coordinates of the center position of the hair model, the current view size, and the scene texel size includes: Determine the first position coordinates of the center position of the hair model in the model coordinate system, and transform the first position coordinates to world space to obtain the second position coordinates of the center position of the model in the world space; Transform the second position coordinates to clip space to obtain the third position coordinates; The coordinate offset is determined based on the third position coordinates, the current view size, and the scene texel size.

5. The method according to claim 1, characterized in that, After the step of determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system, the method further includes: For each pixel on the screen, the target texture coordinates are corrected based on the virtual camera position, the center position of the hair model, and a preset scaling factor to obtain the final target texture coordinates. The preset scaling factor is a parameter related to the field of view of the virtual camera and the current view size. The virtual camera is used to capture images of the hair model and display the captured images on the screen.

6. The method according to claim 1 or 5, characterized in that, After the step of determining the target texture coordinates corresponding to each pixel in the screen in the offset screen texture coordinate system, the method further includes: When the hair model is rotated, determine the rotation offset of the pixels on the screen; The target texture coordinates corresponding to the pixels in the screen are adjusted based on the rotation offset to obtain the adjusted target texture coordinates.

7. The method according to claim 6, characterized in that, The step of determining the rotation offset of the pixels on the screen when the hair model is rotated includes: Determine the angle between the orientation of the hair model and the orientation of the virtual camera; The rotation offset of the pixel in the screen is determined based on the included angle.

8. The method according to claim 7, characterized in that, The step of determining the rotation offset of the pixel in the screen based on the included angle includes: In response to the included angle being equal to a preset angle, the rotation offset of the pixel in the screen is determined to be zero. In response to the angle being less than the preset angle, it is determined that the rotation offset of the pixel in the screen is positively correlated with the angle. In response to the angle being greater than the preset angle, it is determined that the rotation offset of the pixel in the screen is negatively correlated with the angle.

9. The method according to claim 1, characterized in that, The steps of determining the reflection texture based on the texture normal and sampling the reflection map based on the reflection texture to obtain the sampling result include: Based on the texture normal and reflection function, determine the reflection vector; The reflection texture is determined based on the reflection vector, the orientation and position of the virtual camera; The sampling result is obtained by sampling the reflection map based on the reflection texture.

10. The method according to claim 1, characterized in that, The step of rendering the hair model based on the sampling results corresponding to each pixel in the screen to obtain a crystallized hair model includes: Based on the sampling results corresponding to each pixel in the screen, the crystallization rendering effect corresponding to the hair model is obtained; The hair model is rendered based on preset hair rendering parameters to obtain a first rendering result; The first rendering result is combined with the crystallization rendering effect corresponding to the hair model to obtain a hair model with a crystallization effect.

11. A model rendering apparatus, characterized in that, The device includes: The model acquisition module is used to acquire a hair model, which is composed of multiple stacked hair patches. The coordinate determination module is used to offset the origin of the screen texture coordinate system to the center of the hair model to obtain the offset screen texture coordinate system, and determine the target texture coordinates of each pixel in the screen under the offset screen texture coordinate system. The texture sampling module is used to sample a preset normal map for each pixel in the screen based on the target texture coordinates corresponding to the pixel, obtain the texture normal, determine the reflection texture based on the texture normal, and sample the reflection map based on the reflection texture to obtain the sampling result; The model rendering module is used to render the hair model based on the sampling results corresponding to each pixel in the screen, to obtain a crystallized hair model, and to display the crystallized hair model on the screen.

12. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the model 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 computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the model rendering method according to any one of claims 1 to 10.