Crystal model rendering method and device, computer storage medium, and electronic device

By integrating the parallax offset and color of the surface texture coordinates of the crystal model, the problem that the existing technology cannot express the internal texture and scattering characteristics of the crystal is solved, and efficient and realistic crystal model rendering is achieved, which is suitable for current electronic equipment hardware. And support custom effects.

CN112785679BActive Publication Date: 2024-11-08NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110276352.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-15
Publication Date
2024-11-08
Estimated Expiration
2041-03-15

AI Technical Summary

Technical Problem

The prior art cannot effectively express the internal texture and scattering characteristics of crystals, and the ray tracing method is not friendly to the hardware of electronic equipment, and art creation is limited.

Method used

By disparity offsetting the texture coordinates of the crystal model surface, the pre-stored detailed texture map is color sampled using the offset texture coordinates, the reflection color is determined based on the environmental reflection intensity value, and the internal color of the model and the surface color are fused. Achieve rendering of the target color.

Benefits of technology

It reflects the volumetric sense and heterogeneous density differences inside the crystal, simulates the scattering effect, improves the fidelity of the model, and supports custom colors and textures, and is friendly in art production, suitable for current electronic equipment hardware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112785679B_ABST
    Figure CN112785679B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the field of model rendering technology, and provides a rendering method of a crystal model, a rendering device of a crystal model, a computer storage medium, and an electronic device, wherein the rendering method of the crystal model includes: performing parallax offset on the texture coordinates of the surface of the crystal model to be rendered to obtain offset texture coordinates; using the offset texture coordinates to perform color sampling on the pre-stored detail texture map, and determining the reflection color according to the obtained first sampled color and the input environmental reflection intensity value; fusing the input model internal color with the model surface color to obtain the target color; fusing the target color with the reflection color, and rendering the crystal model to be rendered according to the fused color. The present disclosure can reduce the amount of data calculation while presenting the inhomogeneous density difference inside the model and simulating the scattering effect, and support the simultaneous production of large quantities of crystal models.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] With the rapid development and progress of the Internet and computer computing, related game technologies are also developing rapidly. How to ensure the fit between game images and the real world has become a focus of attention for relevant developers.

[0003] The current way to achieve the ice effect is to simulate the reflection environment of the ice through the environment map, realize the diffuse reflection of the ice through the surface color of the ice, use the semi-transparent map without scattering to overlay the game background behind the ice to reflect the transparent property of the ice, use ray tracing to calculate the propagation path of the light inside the ice, and accumulate and calculate the contribution of the light at each point on the path to the pixel brightness on the final screen. However, the above method cannot reflect the texture and scattering characteristics of the inside of the ice.

[0004] In view of this, there is an urgent need in the art to develop a new method and device for rendering a crystal model.

[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure. Summary of the invention

[0006] The purpose of the present disclosure is to provide a crystal model rendering method, a crystal model rendering device, a computer storage medium and an electronic device, thereby at least to a certain extent overcoming the defect in the related art that the internal texture and scattering characteristics of the crystal cannot be expressed.

[0007] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.

[0008] According to a first aspect of the present disclosure, a rendering method for a crystal model is provided, comprising: performing parallax shift on the texture coordinates of the surface of the crystal model to be rendered to obtain offset texture coordinates; performing color sampling on a pre-stored detail texture map using the offset texture coordinates, and determining a reflection color based on an obtained first sampled color and an input ambient reflection intensity value; fusing the input model internal color with the model surface color to obtain a target color; fusing the target color with the reflection color, and rendering the crystal model to be rendered based on the fused color.

[0009] In an exemplary embodiment of the present disclosure, performing parallax shift on the texture coordinates of the surface of the crystal model to be rendered to obtain offset texture coordinates includes: performing color sampling on the pre-stored detail texture map to obtain a second sampled color; converting the camera sight direction in the world space coordinate system into the camera sight direction in the tangent space coordinate system; performing parallax shift on the texture coordinates according to any color component in the second sampled color, the camera sight direction in the tangent space coordinate system, and an input depth value to obtain the offset texture coordinates.

[0010] In an exemplary embodiment of the present disclosure, the camera sight line direction in the world space coordinate system is determined in the following manner: the camera sight line direction in the world space coordinate system is determined according to the difference between the camera position coordinates and the coordinates of each pixel on the crystal model to be rendered.

[0011] In an exemplary embodiment of the present disclosure, the conversion of the camera line of sight direction in the world space coordinate system into the camera line of sight direction in the tangent space coordinate system includes: obtaining the tangent direction, binormal direction and principal normal direction of each pixel point on the crystal model to be rendered; determining the camera line of sight direction in the tangent space coordinate system according to the dot product of the tangent direction and the camera line of sight direction in the world space coordinate system, the dot product of the binormal direction and the camera line of sight direction in the world space coordinate system, and the dot product of the principal normal direction and the camera line of sight direction in the world space coordinate system.

[0012] In an exemplary embodiment of the present disclosure, the offset texture coordinates are determined based on the following formula:

[0013]

[0014] Where Distortuv represents the above offset texture coordinates, uv represents the above texture coordinates, V′ xy Represents the value of the camera's line of sight in the x and y dimensions in the above tangent space coordinate system, V′ z Represents the value of the camera line of sight in the z dimension in the above tangent space coordinate system, color represents any color component in the above first sampled color, and depth represents the depth value of the above input.

[0015] In an exemplary embodiment of the present disclosure, the fused color is determined in the following manner: a target value is determined based on the dot product of the principal normal direction and the camera line of sight direction in the world space coordinate system; the target value is used as an interpolation factor to interpolate the target color and the reflected color to obtain the fused color.

[0016] In an exemplary embodiment of the present disclosure, the step of fusing the input model internal color with the model surface color to obtain a target color includes: using any color component of the first sampling color as an interpolation factor, interpolating the input model internal color with the model surface color to obtain the target color.

[0017] In an exemplary embodiment of the present disclosure, the target color is determined based on the following formula:

[0018] result=interior_color*(1-weight)+external_color*weight

[0019] Among them, result represents the above target color, interior_color represents the internal color of the above model, external_color represents the external color of the above model, and weight represents the above interpolation factor.

[0020] According to a second aspect of the present disclosure, a rendering device for a crystal model is provided, comprising: a parallax offset module, used to perform parallax offset on the texture coordinates of the surface of the crystal model to be rendered, so as to obtain offset texture coordinates; a color sampling module, used to perform color sampling on a pre-stored detail texture map using the offset texture coordinates, and determine the reflection color according to the obtained first sampled color and the input environment reflection intensity value; a color fusion module, used to fuse the input model internal color with the model surface color to obtain a target color; and a rendering module, used to fuse the target color with the reflection color, and render the crystal model to be rendered according to the fused color.

[0021] According to a third aspect of the present disclosure, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for rendering a crystal stone model described in the first aspect is implemented.

[0022] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the crystal model rendering method described in the first aspect above by executing the executable instructions.

[0023] It can be seen from the above technical solutions that the crystal model rendering method, crystal model rendering device, computer storage medium and electronic device in the exemplary embodiments of the present disclosure have at least the following advantages and positive effects:

[0024] In the technical solutions provided by some embodiments of the present disclosure, on the one hand, the texture coordinates of the surface of the crystal model to be rendered are parallax offset to obtain offset texture coordinates, and the pre-stored detail texture map is color sampled using the offset texture coordinates, so that the internal structure positions can be staggered when the viewing angle is rotated, thereby better expressing the sense of volume inside the model.

[0025] Furthermore, the reflection color is determined according to the obtained first sampled color and the input ambient reflection intensity value, and the input model internal color and model surface color are fused to obtain the target color. It can support customizing different colors to dynamically present different display effects in real time, realize the inhomogeneous density difference inside the crystal model and simulate the scattering effect, so that the texture of the crystal model can be distinguished from stone and glass.

[0026] On the other hand, the target color is fused with the reflected color, and the crystal model to be rendered is rendered according to the fused color, which can improve the realism of the model.

[0027] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0029] Figure 1 A schematic diagram showing a flow chart of a method for rendering a crystal stone model in an exemplary embodiment of the present disclosure;

[0030] Figure 2 A schematic diagram of a process of performing parallax shift on the texture coordinates of the surface of a crystal stone model to be rendered to obtain shifted texture coordinates in an embodiment of the present disclosure is shown;

[0031] Figure 3 A schematic diagram showing a pre-stored detail texture map in an embodiment of the present disclosure;

[0032] Figure 4A-4B A schematic diagram showing the model display effects corresponding to different Mipmap levels in an exemplary embodiment of the present disclosure;

[0033] Figure 5 A schematic diagram showing a process of converting a camera sight line direction in a world space coordinate system into a camera sight line direction in a tangent space coordinate system in an embodiment of the present disclosure is shown;

[0034] Fig. 6A A schematic diagram showing a crystal model without parallax offset processing in the related art;

[0035] Figure 6B-6E A schematic diagram showing a crystal model with parallax offset processing in an embodiment of the present disclosure;

[0036] Fig. 7A A schematic diagram showing a crystal model without color mixing in the related art;

[0037] Figure 7B A schematic diagram showing a crystal stone model after the internal color of the model and the surface color of the model are merged in the present disclosure;

[0038] Figure 8 A schematic diagram showing a process of determining the fused color in an embodiment of the present disclosure;

[0039] Fig. 9A A schematic diagram showing a stylized ice cube generated based on the method in an embodiment of the present disclosure;

[0040] Fig. 9B A schematic diagram showing a realistic ice cube generated based on the method in an embodiment of the present disclosure;

[0041] Fig. 9C A schematic diagram showing a high-transmittance small ice cube generated based on the method in an embodiment of the present disclosure;

[0042] Fig.9D A schematic diagram showing amber generated based on the method in an embodiment of the present disclosure;

[0043] Fig.10 A schematic diagram showing the structure of a rendering device for a crystal stone model in an exemplary embodiment of the present disclosure;

[0044] Fig.11 A schematic structural diagram of an electronic device in an exemplary embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0045] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.

[0046] The terms "a", "an", "the" and "said" are used in this specification to indicate the presence of one or more elements / components / etc.; the terms "including" and "having" are used to express an open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first" and "second" etc. are used only as labels and are not intended to limit the quantity of their objects.

[0047] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings represent the same or similar parts, and their repeated descriptions will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities.

[0048] Currently, the common methods of implementing real-time ice effects are: simulating the reflective environment of smooth ice through environment maps; expressing the diffuse reflection of the ice surface through the surface color of the ice model; superimposing the game background behind the ice with non-scattering translucency to express the transparent properties of the ice; using ray tracing to calculate the path of light propagation in the ice, and accumulating the lighting contribution of each sampling point on the path along the way.

[0049] However, the above solution has the following drawbacks:

[0050] First, the above method can express the surface color and surface characteristics of the ice cube model, but the internal texture of the ice cube cannot express the scattering effect inside the ice cube because the model itself only has a surface and no internal volume.

[0051] Second, using ray tracing to determine the contribution of light can be relatively accurate, but it requires a lot of sampling calculations, which is not friendly to electronic equipment hardware;

[0052] Third, the method of using ray tracing to determine the contribution of light, such as to achieve the change of inhomogeneous media, requires the definition of volume-based density data, which is not shared with the model data based on triangles. In addition, the parameters need to be relatively objective, which imposes more restrictions on artistic creation.

[0053] In the embodiments of the present disclosure, a method for rendering a crystal model is first provided, which at least to some extent overcomes the defect in the related art that the internal texture and scattering characteristics of the crystal cannot be expressed.

[0054] Figure 1 A schematic flow chart of a method for rendering a crystal model in an exemplary embodiment of the present disclosure is shown. The execution subject of the method for rendering a crystal model may be a server that renders the crystal model.

[0055] refer to Figure 1 According to an embodiment of the present disclosure, a method for rendering a crystal model includes the following steps:

[0056] Step S110, performing parallax offset on the texture coordinates of the surface of the crystal stone model to be rendered to obtain offset texture coordinates;

[0057] Step S120, performing color sampling on the pre-stored detail texture map using the offset texture coordinates, and determining the reflection color according to the obtained first sampled color and the input environment reflection intensity value;

[0058] Step S130, fusing the input model internal color with the model surface color to obtain a target color;

[0059] Step S140, merging the target color and the reflected color, and rendering the crystal model to be rendered according to the fused color.

[0060] exist Figure 1 In the technical solution provided by the illustrated embodiment, on the one hand, the texture coordinates of the surface of the crystal model to be rendered are subjected to parallax offset to obtain offset texture coordinates, and the pre-stored detail texture map is sampled for color using the offset texture coordinates, so that the effect of the internal structure positions being interlaced can be reflected when the viewing angle is rotated, and the volume sense inside the model is better expressed. Furthermore, the reflection color is determined based on the obtained first sampled color and the input environmental reflection intensity value, and the input model internal color and model surface color are fused to obtain the target color. Different colors can be customized to dynamically present different display effects in real time, and the inhomogeneous density difference inside the crystal model and the simulated scattering effect are realized, so that the texture of the crystal model is distinguished from stone and glass. On the other hand, the target color is fused with the reflection color, and the crystal model to be rendered is rendered according to the fused color, which can improve the realism of the model.

[0061] The following Figure 1 The specific implementation process of each step is described in detail:

[0062] It should be noted that the crystal model in the present disclosure may include ice, ore, crystal, gem, diamond, amber, etc., which can be set according to actual conditions and fall within the protection scope of the present disclosure.

[0063] In step S110, the texture coordinates of the surface of the crystal model to be rendered are subjected to parallax offset to obtain offset texture coordinates.

[0064] In this step, the crystal model to be rendered can be constructed based on a variety of image data of the crystal, and the construction method can be flexibly selected according to the actual application scenario, all of which fall within the protection scope of the present disclosure.

[0065] For example, the texture coordinates of the surface of the crystal model to be rendered can be expressed as (u, v), and then, can refer to Figure 2 , Figure 2 The schematic diagram of the process of performing parallax offset on the texture coordinates of the surface of the crystal model to be rendered to obtain offset texture coordinates in the embodiment of the present disclosure includes steps S201 to S203. Figure 2 Step S110 is explained.

[0066] In step S201, color sampling is performed on a pre-stored detail texture map to obtain a second sampled color.

[0067] In this step, the first Mipmap level (for example, 3.72, which can be set according to actual conditions) can be input into the sampler to perform color sampling on the pre-stored detail texture map to obtain a second sampled color. Exemplarily, after the color sampling, the obtained color value can be normalized, for example, the value of each channel is divided by 255 to obtain the above-mentioned second sampled color. Exemplarily, the obtained second sampled color can be (0.3, 0.3, 0.3).

[0068] The pre-stored detail texture map can be produced by the art production personnel for the above-mentioned crystal model to be rendered, and can reflect the grayscale image of the inherent color inside the crystal (that is, the values ​​of the three channels of RGB are equal, R=G=B), for example: a four-square continuous noise map, for example, can be referred to Figure 3 , Figure 3 A schematic diagram of the above-mentioned pre-stored detail texture map is shown, in which the light-colored part represents the area closer to the model surface, and the dark-colored part represents the area farther from the model surface.

[0069] By setting different Mipmap levels, you can blur the texture to present a more homogeneous texture inside the model. Figure 4A-4B , Figure 4A-4B A schematic diagram showing the model display effect corresponding to different Mipmap levels in an exemplary embodiment of the present disclosure is shown. Specifically, Figure 4B The Mipmap level set in Figure 4A The Mipmap level set in , thus, Figure 4B It can present a more homogenous texture.

[0070] In step S202, the camera sight line direction in the world space coordinate system is converted into the camera sight line direction in the tangent space coordinate system.

[0071] In this step, the camera line of sight direction in the world space coordinate system can be obtained first. Specifically, the camera line of sight direction in the world space coordinate system can be determined according to the difference between the camera position coordinates and the coordinates of each pixel on the crystal model to be rendered. Exemplarily, taking the camera position coordinates as O(a1, b1, c1) and the pixel coordinates as A(a2, b2, c2) as an example, the camera line of sight direction V in the above world space coordinate system can be expressed as (a1-a2, b1-b2, c1-c2).

[0072] Furthermore, we can refer to Figure 5 , Figure 5 A schematic diagram of a process for converting the camera sight line direction in the world space coordinate system into the camera sight line direction in the tangent space coordinate system in the embodiment of the present disclosure is shown, including steps S501 and S502. Figure 5 Step S202 is explained.

[0073] In step S501, the tangent direction, the binormal direction and the principal normal direction of each pixel point on the crystal model to be rendered are obtained.

[0074] In this step, the tangent direction Tangent (for example: x1, y1, z1), the binormal direction Binormal (for example: x2, y2, z2) and the main normal direction Normal (for example: x3, y3, z3) of each pixel point on the crystal model to be rendered can be obtained.

[0075] In step S502, the camera line of sight direction in the tangent space coordinate system is determined according to the dot product of the tangent direction and the camera line of sight direction in the world space coordinate system, the dot product of the binormal direction and the camera line of sight direction in the world space coordinate system, and the dot product of the principal normal direction and the camera line of sight direction in the world space coordinate system.

[0076] In this step, taking the camera line of sight direction V(a3, b3, c3) in the world space coordinate system as an example for explanation, the dot product of the tangent direction and the camera line of sight direction in the world space coordinate system is: a3*x1+b3*y1+c3*z1, the dot product of the binormal direction and the camera line of sight direction in the world space coordinate system can be: a3*x2+b3*y2+c3*z2, the dot product of the principal normal direction and the camera line of sight direction in the world space coordinate system can be: a3*x3+b3*y3+c3*z3, thus, the camera line of sight direction V' in the tangent space coordinate system can be expressed as: (a4, b4, c4).

[0077] Next reference Figure 2 In step S203, the texture coordinates are parallax-shifted according to any color component in the second sampled color, the camera sight direction in the tangent space coordinate system, and the input depth value to obtain shifted texture coordinates.

[0078] In this step, the above texture coordinates can be offset based on the following formula 1 to obtain offset texture coordinates:

[0079]

[0080] Wherein, the above Distortuv represents the texture coordinates after displacement; uv represents the texture coordinates of the surface of the crystal model to be rendered, for example: (0.5, 0.5); V′ xy Represents the value of the camera's line of sight in the xy dimension in the above tangent space coordinate system, V′ z represents the value of the camera's line of sight in the z dimension in the tangent space coordinate system. For example, V' is (0.0, 0.8, 0.6). Then V' xy is (0.0, 0.8), V′ z is 0.6; color represents any color component in the above second sampled color, that is, 0.3, and depth represents the input depth value, for example: 2.

[0081] Thus, illustratively, the calculated offset texture coordinates may be:

[0082] For example, please refer to Fig. 6A , Fig. 6A A schematic diagram showing a crystal model without parallax offset processing in the related art, wherein Fig. 6A It can be seen that when the viewing angle is rotated, the transformation effect of the internal structure cannot be reflected, and only a display effect as shown in the figure can be presented. Figure 6B-6E , Figure 6B-6EA schematic diagram of a crystal model with parallax offset processing is shown. The present disclosure offsets the texture coordinates, and when the viewing angle is subsequently rotated, there will be a visual effect of the internal structure positions being intertwined, that is, different viewing angles will present different display effects.

[0083] Next reference Figure 1 In step S120, the pre-stored detail texture map is color sampled using the offset texture coordinates, and the reflection color is determined according to the obtained first sampled color and the input environment reflection intensity value.

[0084] In this step, after obtaining the above-mentioned offset texture coordinates, the above-mentioned offset texture coordinates and the second Mipmap level (for example, 0, which can be set according to actual conditions) can be input into the sampler to perform color sampling on the above-mentioned pre-stored detail texture map to obtain a first sampled color. Specifically, the relevant explanation of the above-mentioned step S201 can be referred to. After color sampling, the obtained color value is normalized, for example, the value of each channel is divided by 255 to obtain the first sampled color. Exemplarily, the obtained first sampled color can be (0.1, 0.1, 0.1).

[0085] After obtaining the first sampled color, the first sampled color can be multiplied by the inputted ambient reflection intensity value to determine the reflection color. For example, when the inputted ambient reflection intensity value is 0.2, the obtained reflection color is (0.1, 0.1, 0.1)*0.2=(0.02, 0.02, 0.02).

[0086] It should be noted that, given that the above-mentioned pre-stored detail texture map is a distorted map of uneven texture, and the surface of the crystal is also an uneven random texture, the above-mentioned detail texture map can be reused to process it to obtain the texture map of the crystal model to be rendered. Therefore, there is no need to make an additional detail texture map. Only one picture needs to be saved to implement the relevant processing steps, saving memory usage.

[0087] The detail texture map pre-stored in this step can also be Figure 3 The newly produced maps that are different from the detail texture maps can be set according to the actual situation and belong to the protection scope of this disclosure.

[0088] In step S130, the input model internal color and model surface color are merged to obtain a target color.

[0089] In this step, any color component of the first sampled color may be used as an interpolation factor, and a lerp function may be used to interpolate the input model internal color and the model surface color to obtain a target color.

[0090] Exemplarily, the target color may be determined based on the following formula:

[0091] result=interior_color*(1-weight)+external_color*weight formula 2 Among them, result represents the above target color, interior_color represents the internal color of the above model, external_color represents the external color of the above model, and weight represents the above interpolation factor.

[0092] Referring to the explanation of step S120, if any color component of the first sampled color is 0.1, the interpolation factor is 0.1. Thus, when the input model interior color is (80, 200, 200) and the input model surface color is (70, 100, 100), the target color can be expressed as: (80, 200, 200)*(1-0.1)+(77, 100, 100)*0.1=(79.7, 190, 190). Furthermore, the obtained data can be normalized to obtain the target color (0.31, 0.75, 0.75).

[0093] For example, Fig. 7A A schematic diagram showing a crystal model without color mixing in the related art, Figure 7B A schematic diagram of a crystal stone model after the internal color of the model and the surface color of the model are merged in the present disclosure.

[0094] In step S140, the target color and the reflected color are merged, and the crystal model to be rendered is rendered according to the merged colors.

[0095] In this step, after obtaining the target color and the reflected color, the target color and the reflected color can be merged. For details, please refer to Figure 8 , Figure 8 The schematic diagram of the process of determining the fused color in the embodiment of the present disclosure includes steps S801 and S802. Figure 8 Explanation of step S140:

[0096] In step S801 , a target value is determined according to the dot product of the principal normal direction and the camera sight line direction in the world space coordinate system.

[0097] In this step, the relevant explanation of the above step S302 can be referred to, and the dot product of the principal normal direction and the camera sight direction in the world space coordinate system is: a3*x3+b3*y3+c3*z3, and the value is 0.6 as an example for explanation. For example, the square of the dot product can be determined as the target value, and the target value can be 0.36. It should be noted that the target value can also be the cube of the dot product, the fifth power, etc., which can be set according to the actual situation and belongs to the protection scope of the present disclosure.

[0098] In step S802, the target value is used as an interpolation factor to interpolate the target color and the reflected color to obtain a fused color.

[0099] In this step, after determining the above target value, the above target value can be used as an interpolation factor to interpolate the above target color and the above reflected color to obtain the fused color. Referring to the relevant explanations of the above steps, when the target color is (0.31, 0.75, 0.75) and the reflected color is (0.02, 0.02, 0.02), the fused color can be obtained as follows: (0.31, 0.75, 0.75) * (1-0.36) + (0.02, 0.02, 0.02) * 0.36 = (0.21, 0.49, 0.49). Furthermore, the color components of the numerical value can be multiplied by 255 to obtain the above fused color (53.55, 124.95, 124.95).

[0100] Furthermore, the crystal model to be rendered may be rendered according to the fused color, so that the crystal model to be rendered presents a color corresponding to the fused color.

[0101] It should be noted that the relevant input parameters in this application can also be adjusted to generate different types of ice cube, amber and other models. Figure 9A-9D :

[0102] When the input model internal color is (80,216,234), the input model surface color is (77,110,110), the depth value is 0.32, the ambient reflection intensity value is 1, and the Mipmap levels of the first and second samples are both 0, then the following can be generated: Fig. 9A Stylized ice cube model shown.

[0103] When the input model internal color is (126,140,151), the input model surface color is (63,79,77), the depth value is 0.32, the reflection intensity coefficient is 0.3, and the Mipmap levels of the first and second samples are both 0, then the following can be generated: Fig. 9B Realistic ice model shown.

[0104] When the input model internal color is (124,196,199), the input model surface color is (222,255,254), the depth value is 0.3, the reflection intensity coefficient is 1, and the Mipmap levels of the first and second samples are both 0, then the following can be generated: Fig. 9C A model of a small, highly transmissive ice cube is shown.

[0105] When the input model internal color is (246,233,53), the input model surface color is (219,117,67), the depth value is 0.31, the reflection intensity coefficient is 0.2, and the Mipmap levels of the first and second samples are both 3.72, then the following can be generated: Fig.9D Amber model shown.

[0106] Based on the above technical solution, on the one hand, the present disclosure consumes very little engine memory, and the additional overhead caused is basically negligible. It can be used on current mainstream mobile phone platforms and can also support the simultaneous generation of large quantities of crystal models. Furthermore, the present disclosure is friendly to art production, supports the customization of different colors and textures, and can dynamically see the effects of different degrees of homogenization in real time without the need for additional volume data. On the other hand, the present disclosure can achieve heterogeneous density differences within the medium and simulate scattering effects, so that the texture of ice cubes is distinguished from stone and glass.

[0107] The present disclosure also provides a crystal model rendering device, Fig.10 A schematic diagram showing the structure of a rendering device for a crystal model in an exemplary embodiment of the present disclosure is shown; Fig.10 As shown, the rendering device 1000 of the crystal model may include a parallax offset module 1001, a color sampling module 1002, a color fusion module 1003 and a rendering module 1004. Among them:

[0108] The parallax offset module 1001 is used to perform parallax offset on the texture coordinates of the surface of the crystal model to be rendered to obtain offset texture coordinates.

[0109] In an exemplary embodiment of the present disclosure, a parallax offset module is used to perform color sampling on a pre-stored detail texture map to obtain a second sampled color; convert the camera sight direction in the world space coordinate system into the camera sight direction in the tangent space coordinate system; and perform parallax offset on the texture coordinates according to any color component in the second sampled color, the camera sight direction in the tangent space coordinate system, and an input depth value to obtain offset texture coordinates.

[0110] In an exemplary embodiment of the present disclosure, the parallax offset module is used to determine the camera sight direction in the world space coordinate system according to the difference between the camera position coordinates and the coordinates of each pixel on the crystal model to be rendered.

[0111] In an exemplary embodiment of the present disclosure, a parallax offset module is used to obtain the tangent direction, binormal direction and principal normal direction of each pixel point on the crystal model to be rendered; the camera line of sight direction in the tangent space coordinate system is determined according to the scalar product of the tangent direction and the camera line of sight direction in the world space coordinate system, the scalar product of the binormal direction and the camera line of sight direction in the world space coordinate system, and the scalar product of the principal normal direction and the camera line of sight direction in the world space coordinate system.

[0112] In an exemplary embodiment of the present disclosure, the offset texture coordinates are determined based on the following formula:

[0113]

[0114] Where Distortuv represents the above offset texture coordinates, uv represents the above texture coordinates, V′ xy Represents the value of the camera's line of sight in the x and y dimensions in the above tangent space coordinate system, V′ z Represents the value of the camera line of sight in the z dimension in the above tangent space coordinate system, color represents any color component in the above first sampled color, and depth represents the depth value of the above input.

[0115] The color sampling module 1002 is used to perform color sampling on the pre-stored detail texture map using the offset texture coordinates, and determine the reflection color according to the obtained first sampled color and the input environment reflection intensity value.

[0116] In an exemplary embodiment of the present disclosure, the color sampling module is used to determine the reflection color according to the product of the first sampled color and the input environment reflection intensity value.

[0117] The color fusion module 1003 is used to fuse the input model internal color with the model surface color to obtain the target color.

[0118] In an exemplary embodiment of the present disclosure, the color fusion module is used to use any color component of the first sampled color as an interpolation factor to interpolate the input model internal color and the model surface color to obtain a target color.

[0119] In an exemplary embodiment of the present disclosure, the target color is determined based on the following formula:

[0120] result=interior_color*(1-weight)+external_color*weight

[0121] Among them, result represents the above target color, interior_color represents the internal color of the above model, external_color represents the external color of the above model, and weight represents the above interpolation factor.

[0122] The rendering module 1004 is used to fuse the target color with the reflected color, and render the crystal model to be rendered according to the fused color.

[0123] In an exemplary embodiment of the present disclosure, a rendering module is used to determine a target value based on the dot product of the main normal direction and the camera line of sight direction in the world space coordinate system; using the target value as an interpolation factor, the target color and the reflected color are interpolated to obtain a fused color.

[0124] The specific details of each module in the above-mentioned crystal model rendering device have been described in detail in the corresponding crystal model rendering method, so they will not be repeated here.

[0125] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0126] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0127] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0128] The present application also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device.

[0129] The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0130] Computer-readable storage media can send, propagate or transmit programs for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0131] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiments.

[0132] In addition, an electronic device capable of implementing the above method is also provided in an embodiment of the present disclosure.

[0133] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".

[0134] Refer to the following Fig.11 1100 according to this embodiment of the present disclosure is described. Fig.11 The electronic device 1100 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0135] like Fig.11As shown, the electronic device 1100 is in the form of a general computing device. The components of the electronic device 1100 may include, but are not limited to: the at least one processing unit 1110, the at least one storage unit 1120, a bus 1130 connecting different system components (including the storage unit 1120 and the processing unit 1110), and a display unit 1140.

[0136] The storage unit stores a program code, which can be executed by the processing unit 1110, so that the processing unit 1110 performs the steps described in the "Exemplary Method" section of the present specification according to various exemplary embodiments of the present disclosure. For example, the processing unit 1110 can perform the following steps: Figure 1 As shown in: Step S110, parallax shift is performed on the texture coordinates of the surface of the crystal model to be rendered to obtain offset texture coordinates; Step S120, color sampling is performed on the pre-stored detail texture map using the offset texture coordinates, and the reflection color is determined according to the obtained first sampled color and the input environment reflection intensity value; Step S130, the input model internal color and model surface color are merged to obtain a target color; Step S140, the target color is merged with the reflection color, and the crystal model to be rendered is rendered according to the merged color.

[0137] The storage unit 1120 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 11201 and / or a cache storage unit 11202 , and may further include a read-only storage unit (ROM) 11203 .

[0138] The storage unit 1120 may also include a program / utility 11204 having a set (at least one) of program modules 11205, such program modules 11205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0139] Bus 1130 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0140] The electronic device 1100 may also communicate with one or more external devices 1200 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1100, and / or communicate with any device that enables the electronic device 1100 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1150. Furthermore, the electronic device 1100 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 1160. As shown, the network adapter 1160 communicates with other modules of the electronic device 1100 via a bus 1130. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1100, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0141] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0142] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0143] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.

Claims

1. A method for rendering a crystal model, characterized in that: include: Perform parallax offset on the texture coordinates of the surface of the crystal model to be rendered to obtain offset texture coordinates; The process of performing parallax shift on the texture coordinates of the surface of the crystal stone model to be rendered to obtain the offset texture coordinates includes: performing color sampling on a pre-stored detail texture map to obtain a second sampled color; converting a camera sight line direction in a world space coordinate system into a camera sight line direction in a tangent space coordinate system; performing parallax shift on the texture coordinates according to any color component in the second sampled color, the camera sight line direction in the tangent space coordinate system, and an input depth value to obtain the offset texture coordinates; Performing color sampling on the pre-stored detail texture map using the offset texture coordinates, and determining a reflection color according to a first sampled color obtained and an input environment reflection intensity value; The input model internal color is merged with the model surface color to obtain the target color; The target color and the reflected color are merged, and the crystal model to be rendered is rendered according to the merged colors.

2. The method according to claim 1, characterized in that The camera's sight direction in the world space coordinate system is determined by: The camera sight direction in the world space coordinate system is determined according to the difference between the camera position coordinates and the coordinates of each pixel on the crystal model to be rendered.

3. The method according to claim 2, characterized in that The converting the camera sight line direction in the world space coordinate system into the camera sight line direction in the tangent space coordinate system comprises: Obtaining the tangent direction, the binormal direction and the principal normal direction of each pixel point on the crystal model to be rendered; The camera line of sight direction in the tangent space coordinate system is determined according to the dot product of the tangent direction and the camera line of sight direction in the world space coordinate system, the dot product of the binormal direction and the camera line of sight direction in the world space coordinate system, and the dot product of the principal normal direction and the camera line of sight direction in the world space coordinate system.

4. The method according to claim 3, characterized in that The performing parallax offset on the texture coordinates according to any color component in the first sampled color, the camera sight direction in the tangent space coordinate system, and the input depth value to obtain the offset texture coordinates includes: The offset texture coordinates are determined based on the following formula: Where Distortuv represents the above offset texture coordinates, uv represents the above texture coordinates, V' xy Represents the value of the camera's line of sight in the x and y dimensions in the above tangent space coordinate system, V' z Represents the value of the camera line of sight in the z dimension in the above tangent space coordinate system, color represents any color component in the above first sampled color, and depth represents the depth value of the above input.

5. The method according to claim 3, characterized in that: The fused color is determined by: Determining a target value according to the dot product of the principal normal direction and the camera sight line direction in the world space coordinate system; The target value is used as an interpolation factor to interpolate the target color and the reflected color to obtain the fused color.

6. The method according to any one of claims 1 to 4, characterized in that: The step of fusing the input model internal color with the model surface color to obtain a target color includes: Any color component of the first sampled color is used as an interpolation factor to interpolate the input model internal color and the model surface color to obtain the target color.

7. The method according to claim 6, characterized in that The step of using any color component of the first sampled color as an interpolation factor to interpolate the input model internal color and the model surface color to obtain the target color includes: The target color is determined based on the following formula: result=interior_color*(1-weight)+external_color*weight Among them, result represents the above target color, interior_color represents the internal color of the above model, external_color represents the external color of the above model, and weight represents the above interpolation factor.

8. A crystal model rendering device, characterized in that: include: A parallax offset module, used for performing parallax offset on the texture coordinates of the surface of the crystal model to be rendered, to obtain offset texture coordinates; The process of performing parallax shift on the texture coordinates of the surface of the crystal stone model to be rendered to obtain the offset texture coordinates includes: performing color sampling on a pre-stored detail texture map to obtain a second sampled color; converting a camera sight line direction in a world space coordinate system into a camera sight line direction in a tangent space coordinate system; performing parallax shift on the texture coordinates according to any color component in the second sampled color, the camera sight line direction in the tangent space coordinate system, and an input depth value to obtain the offset texture coordinates; A color sampling module, configured to perform color sampling on the pre-stored detail texture map using the offset texture coordinates, and determine a reflection color according to a first sampled color obtained and an input environment reflection intensity value; The color fusion module is used to fuse the input model internal color with the model surface color to obtain the target color; A rendering module is used to fuse the target color with the reflected color, and render the crystal model to be rendered according to the fused color.

9. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for rendering a crystal model according to any one of claims 1 to 7 is implemented.

10. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the method for rendering a crystal model according to any one of claims 1 to 7 by executing the executable instructions.