Three-dimensional object rendering method and device and computer program product
Through different frequency texture mapping and parallax calculation, combined with refraction and reflection sampling, the problem of high computational consumption when rendering translucent three-dimensional objects is solved, and realistic optical performance and efficient rendering effects are achieved.
Patent Information
- Application Number
- CN202410725893.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-09-06
AI Technical Summary
The existing technology consumes a lot of calculations when rendering translucent three-dimensional objects, and it is difficult to effectively present its true optical performance, especially when trace elements are mixed in pure transparent materials or cracks and sections appear.
Using texture maps and parallax calculations of different frequencies, by obtaining the first texture map and the second texture map, texture sampling is performed to simulate the refraction phenomenon, and combined with reflection texture sampling, the rendered image value is calculated to reduce computing consumption.
It achieves the presentation of real refraction and reflection effects of translucent objects at low computational cost, and is suitable for different types of translucent objects such as diamonds and spar, improving the authenticity and efficiency of rendering.
Smart Images

Figure CN118608666A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer graphics, and in particular to a method, device and computer program product for rendering a three-dimensional object. Background Art
[0002] In the application field of computer graphics, it is often necessary to render semi-transparent three-dimensional objects (or objects, three-dimensional bodies). When trace elements, impurities, cracks, and cross-sections are mixed into a transparent object made of pure, transparent materials, the visual transparency will decrease and appear semi-transparent. Exemplary semi-transparent objects can be diamonds, crystals, ice cubes, etc. Semi-transparent objects will show rich refraction and reflection visual effects under the action of light.
[0003] Some embodiments of the present specification are intended to provide an efficient rendering method for a semi-transparent three-dimensional object, which can present a more realistic optical appearance of the semi-transparent object with lower computational cost. Summary of the invention
[0004] One or more embodiments of the present specification provide a method for rendering a three-dimensional object, including: obtaining a first texture map and a second texture map; the image frequency of the second texture map is different from the image frequency of the first texture map; performing parallax calculation on the texture coordinates of the three-dimensional model of the object to be rendered to obtain the parallax texture coordinates of the three-dimensional model; performing texture sampling on the first texture map and the second texture map based on the parallax texture coordinates of the three-dimensional model to obtain a first sampling result and a second sampling result; obtaining a refraction texture sampling result of the object to be rendered based on the first sampling result and the second sampling result; obtaining a reflection texture sampling result of the object to be rendered; and obtaining a rendering image value of the object to be rendered based on the refraction texture sampling result and the reflection texture sampling result.
[0005] According to the method described in some embodiments of the present specification, within a map area of the same size, the high-frequency component of the second texture map is greater than the high-frequency component of the first texture map.
[0006] According to the method described in some embodiments of the present specification, the first texture map and the second texture map have the same base color.
[0007] According to the method described in some embodiments of the present specification, the first texture map and the second texture map include one or more of the following texture units: triangle, polygon, circle, crack.
[0008] According to the method described in some embodiments of the present specification, performing disparity calculation on the texture coordinates of the three-dimensional model of the object to be rendered to obtain the disparity texture coordinates of the three-dimensional model includes: performing disparity calculation on the texture coordinates of the three-dimensional model of the object to be rendered based on height information to obtain the disparity texture coordinates of the three-dimensional model; wherein the height information includes a negative value.
[0009] According to the method described in some embodiments of the present specification, obtaining the refraction texture sampling result of the object to be rendered based on the first sampling result and the second sampling result includes: performing Lerp calculation on the first sampling result and the second sampling result to obtain the refraction texture sampling result.
[0010] According to the method described in some embodiments of this specification, the three-dimensional model includes a plurality of vertices; the texture coordinates of the three-dimensional model include texture coordinates corresponding to each vertex.
[0011] According to the method described in some embodiments of the present specification, obtaining the reflection texture sampling result of the object to be rendered includes: obtaining a three-dimensional environment map; calculating the reflection vector corresponding to each vertex based on the spatial normal vector of each vertex of the three-dimensional model and the shooting direction vector of a preset virtual camera relative to each vertex; sampling the three-dimensional environment map based on the reflection vector corresponding to each vertex of the three-dimensional model to obtain the reflection texture sampling result.
[0012] According to the method described in some embodiments of the present specification, obtaining a rendered image value of the object to be rendered based on the refraction texture sampling result and the reflection texture sampling result includes: calculating a weighted sum of the refraction texture sampling result and the reflection texture sampling result.
[0013] According to the method described in some embodiments of the present specification, the weight corresponding to the reflection texture sampling result is less than the weight corresponding to the refraction texture sampling result.
[0014] According to the method described in some embodiments of the present specification, the rendering image value of the object to be rendered is obtained based on the refraction texture sampling result and the reflection texture sampling result, and also includes: calculating the dot product of the spatial normal vector of each vertex of the three-dimensional model and the shooting direction vector of the preset virtual camera relative to each vertex; based on the dot product results corresponding to each vertex of the three-dimensional model and the weighted sum, the rendering image value of the object to be rendered is obtained.
[0015] One or more embodiments of the present specification also provide a rendering device for a three-dimensional object, including: a map acquisition module, used to acquire a first texture map and a second texture map; in a map area of the same size, the high-frequency component of the second texture map is greater than the high-frequency component of the first texture map; a disparity calculation module, used to perform disparity calculation on the texture coordinates of the three-dimensional model of the object to be rendered, and obtain the disparity texture coordinates of the three-dimensional model; a sampling module, used to perform texture sampling on the first texture map and the second texture map respectively based on the disparity texture coordinates of the three-dimensional model, and obtain a first sampling result and a second sampling result; a refraction texture acquisition module, used to obtain a refraction texture sampling result of the object to be rendered based on the first sampling result and the second sampling result; a reflection texture acquisition module, used to obtain a reflection texture sampling result of the object to be rendered; a rendering value acquisition module, used to obtain a rendering image value of the object to be rendered based on the refraction texture sampling result and the reflection texture sampling result.
[0016] One or more embodiments of the present specification further provide a computer program product, including computer instructions, which can implement the methods described in some embodiments of the present specification when at least part of the computer instructions are executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] This specification will be further explained by way of exemplary embodiments, which will be described in detail by way of the accompanying drawings. The same numbers in the drawings represent the same structures or steps.
[0018] Figure 1 It is a schematic diagram of a computer graphics rendering scene according to some embodiments of the present specification.
[0019] Figure 2 is an exemplary flow chart of a method for rendering a three-dimensional object according to some embodiments of the present specification.
[0020] Figure 3 It is a schematic diagram of a first texture map according to some embodiments of this specification.
[0021] Figure 4 It is a schematic diagram of a second texture map according to some embodiments of this specification.
[0022] Figure 5 This is an exemplary flow chart of obtaining a rendering image value of an object to be rendered based on a refraction texture sampling result and a reflection texture sampling result as shown in some embodiments of this specification.
[0023] Figure 6 It is a schematic diagram of the Fresnel reflection calculation effect shown in some embodiments of this specification.
[0024] Figure 7 It is a schematic diagram of a diamond effect obtained according to the rendering method shown in some embodiments of this specification.
[0025] Figure 8 is an exemplary block diagram of a rendering system for a three-dimensional object according to some embodiments of the present specification. DETAILED DESCRIPTION
[0026] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the embodiments will be described in detail below with reference to the accompanying drawings. Obviously, the contents described below are some examples or embodiments of this specification. For ordinary technicians in this field, without paying creative work, the technical solutions or means disclosed in this specification can also be applied to other scenarios based on these technical contents.
[0027] It should be understood that the "system", "device", "unit" and / or "module" used in this specification is a method for distinguishing different components, elements, parts, portions or assemblies at different levels. However, if other words can achieve the same purpose, the words can be replaced by other expressions.
[0028] Unless otherwise specified, technical terms used in this specification to describe components, elements, etc. do not refer to the singular, but may also include the plural. Generally speaking, terms such as "include", "comprise", etc. only indicate that the steps, elements, or components that have been clearly identified are included, and these steps, elements, and components do not constitute an exclusive list, such as the method or device described may also include other steps or components.
[0029] Flowcharts are used in this specification to illustrate the operation steps performed by the device or system of the relevant embodiments, but unless otherwise specified, the order used to describe these steps should not be understood as a limitation on the order in which the steps are performed. A person of ordinary skill in the art can adjust the order in which these steps are performed based on the knowledge and information conveyed by the embodiments of this specification, and the adjustment includes but is not limited to swapping the order, merging multiple steps, and splitting a certain step.
[0030] Computer graphics technology is widely used in movie stunts, virtual reality, animation and video games. In some embodiments of this specification, the shapes in three-dimensional computer graphics are referred to as objects or three-dimensional objects. The shape or outline of an object is often characterized by a three-dimensional model. Therefore, in some embodiments, the three-dimensional model of an object can also be used to refer to the object. The three-dimensional model can include multiple points or faces, each of which can include spatial parameters of its position or posture in three-dimensional space. The three-dimensional model can also be referred to as a three-dimensional body. The surface appearance of an object can be described by a material. In some embodiments, the material can include attribute information such as color, metallicity, and glossiness.
[0031] Rendering is a very important technical content in computer graphics technology, which includes the process of drawing objects based on three-dimensional models and surface materials for visual display on display devices. In the application field of computer graphics, it is often necessary to render translucent three-dimensional objects (or objects, three-dimensional bodies). When trace elements, impurities, cracks, and cross-sections are mixed into a transparent object made of pure, transparent materials, the visual transparency will decrease and appear translucent. Exemplary translucent objects can be diamonds, crystals, ice cubes, etc. Translucent objects will show rich refraction and reflection visual effects under the action of light.
[0032] In some embodiments, multiple passes can be used to render semi-transparent objects. Multiple passes are also called multi-layer rendering and drawing, and one pass corresponds to a specific rendering task. Taking the rendering of semi-transparent objects as an example, a dual-pass rendering mechanism can be adopted. Specifically, the first pass can be set to complete the rendering of the front of the object (the area on the object's three-dimensional model that is closer to the virtual camera, or the area with a smaller depth), and then the back of the object (the area on the object's three-dimensional model that is farther from the virtual camera, or the area with a larger depth) is rendered based on the rendering result of the first pass. Multi-pass rendering involves layered calculations based on the depth information of different points on the three-dimensional model, and there are sorting problems between multiple passes, which has a high computational cost.
[0033] To this end, some embodiments of the present specification propose a more efficient method for rendering semi-transparent three-dimensional objects, which simulates the internal refraction phenomenon of semi-transparent three-dimensional objects through texture mapping of different frequencies and parallax calculations, and presents a more realistic optical performance of semi-transparent objects with lower computing costs.
[0034] Figure 1 Schematic diagram of computer graphics rendering scene shown in some embodiments of this specification. Figure 1 As shown, scenario 100 may include a processing device 110 , a network 120 , a storage medium 130 , and a user terminal 140 .
[0035] In some embodiments, the processing device 110 may include one or more processors or processing engines (e.g., a single-chip processing engine or a multi-chip processing engine). The processor or processing engine may execute computer instructions to implement the rendering method of the three-dimensional object shown in one or more embodiments of this specification. As an example only, the processor or processing engine may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), an application-specific instruction processor (ASIP), a graphics processing unit (GPU), a physical processing unit (PPU), a digital signal processor (DSP), a field programmable gate array (FPGA), a programmable logic circuit (PLD), a controller, a microcontroller unit, a reduced instruction set computer (RISC), a microprocessor, etc., or any combination thereof.
[0036] The network 120 may include any suitable network that can facilitate information and / or data exchange between components in the scene 100. In some embodiments, one or more components in the scene 100 (e.g., the processing device 110, the storage medium 130, etc.) may exchange information and / or data through the network 120. For example, the processing device 110 obtains data in the storage medium 130 through the network 120. For another example, the user terminal 140 may receive an animation scene rendered by the processing device 110 through the network 120 and display it on a display screen. In some embodiments, the network 120 may be any one or more of a wired network or a wireless network. For example, the network 120 may include a cable network, an optical fiber network, a telecommunications network, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a public switched telephone network (PSTN), a Bluetooth network, a ZigBee network (ZigBee), a near field communication (NFC), an in-device bus, an in-device line, a cable connection, etc., or any combination thereof. The network connection between the various parts may be in one of the above-mentioned ways, or in multiple ways. In some embodiments, the network may be of various topologies such as point-to-point, shared, centralized, etc., or a combination of multiple topologies.
[0037] The storage medium 130 may be used to store data and / or instructions related to the scene 100. In some embodiments, the storage medium 130 may store data and / or information obtained from the processing device 110, the terminal 140, etc. As an example, the storage medium 130 may store data such as a three-dimensional model of one or more objects and surface materials. In some embodiments, the storage medium 130 may include one or more storage components, each of which may be an independent device or part of another device. In some embodiments, the storage medium 130 may be set in the processing device 110. In some embodiments, the storage medium 130 may include a random access memory (RAM), a read-only memory (ROM), a large capacity memory, a removable memory, a volatile read-write memory, etc., or any combination thereof. Exemplarily, the large capacity storage may include a magnetic disk, an optical disk, a solid-state disk, etc. In some embodiments, the storage medium 130 may be implemented on a cloud platform.
[0038] The user can use the terminal 140 to obtain the rendering result of the processing device 110 through the network 120. In some embodiments, the terminal 140 can be a mobile device, a tablet computer, a laptop computer, a desktop computer, or any combination thereof, and other devices with input and / or output functions. In some embodiments, the terminal 140 can also transmit relevant information and data through the network 120 and other components in the application scenario 100 (for example, the storage medium 130).
[0039] It is worth noting that the scene 100 is provided for illustration purposes only and is not intended to limit the scope of the rendering scenes provided by some embodiments of this specification. For example, in some application scenarios, the rendering methods shown in some embodiments of this specification can also be implemented directly on the user terminal.
[0040] Figure 2 is an exemplary flow chart of a method for rendering a three-dimensional object according to some embodiments of this specification. In some embodiments, Figure 2 The process 200 shown may be performed by a processing device (such as Figure 1 Specifically, the process 200 may be implemented by a three-dimensional object rendering system 800 deployed on the processing device. Figure 2 As shown, process 200 may include the following steps.
[0041] Step 210 , obtaining a first texture map and a second texture map. In some embodiments, step 210 may be implemented by the texture acquisition module 810 .
[0042] The first texture map and the second texture map are used to simulate the refraction effect of a translucent object. In some embodiments, the first texture map and the second texture map can be produced by an artist according to the refraction visual effect of a translucent object. In other embodiments, the shape, color, distribution density and other information of the texture unit can be pre-specified, and the first texture map and the second texture map can be automatically generated by a computer program. In some other embodiments, the map acquisition module 810 can directly obtain the first texture map and the second texture map by accessing a data source or storage medium such as a material database.
[0043] In some embodiments, the first texture map may be composed of one or more texture units. The texture unit may refer to a basic graphic unit that constitutes a texture effect. For example, the texture unit may be a basic geometric figure, such as a triangle, a polygon, a circle, etc., or the texture unit may be a crack, etc. In some embodiments, the first texture map may be a grayscale image, or it may be a color image. Specifically, the first texture map may correspond to a basic color, or simply referred to as a base color, such as sapphire blue, sapphire green, pink, blue, etc. By adjusting the contrast or saturation based on the base color, a variety of color variations under the base color can be obtained. Each texture unit of the first texture map may have one of the following colors: a base color or a color based on a base color variation.
[0044] Figure 3 It is a schematic diagram of a first texture map according to some embodiments of this specification. Figure 3 The texture unit of the first texture map shown is a triangle, which is obtained by arranging triangles of different sizes and directions. Different triangles have different color values or grayscales. For example, different triangles can have different grayscale values, or different triangles have a specified base color and different color variations under the base color. Taking diamond rendering as an example, the base color of the first texture map can be sapphire blue.
[0045] The second texture map may have the same or similar texture units and / or base colors as the first texture map. In some embodiments, the second texture map may also have the same or similar texture unit arrangement as the first texture map. The image frequency of the second texture map is different from the image frequency of the first texture map. In some embodiments, the second texture map has a higher frequency than the first texture map, or has more high-frequency components. For a map or image, frequency refers to spatial frequency, or image frequency. Intuitively, image frequency represents an indicator of the degree of change of image values (such as color values, brightness values, depth values, etc.) in the image. From a mathematical point of view, image frequency can be obtained by calculating the gradient of the image in space (such as a two-dimensional plane). For a map or image, its frequency component is not single, and generally includes low-frequency information (or low-frequency components), medium-frequency information (or medium-frequency components) and high-frequency information (or high-frequency components). In an image, a low-frequency component refers to an area where the image value does not change or the change intensity is small, and a high-frequency component refers to an area where the image value changes with a large intensity. In practical applications, a low-frequency threshold and a high-frequency threshold can be set according to actual conditions to distinguish between low-frequency areas and high-frequency areas in the image. Considering that the texture map can be a four-sided continuous two-dimensional image, in some embodiments of the present specification, the second texture map has a higher frequency relative to the first texture map, which can be understood as the second texture map having more high-frequency components than the first texture map in the same size of the map area. Among them, the size can be length, width, diameter, major axis, minor axis, etc. As an example, a circular area with a diameter of 2 cm is circled in the first texture map and the second texture map, respectively, which may be referred to as the first map area and the second map area. In the second map area, the area where the image value change intensity is greater than the set high-frequency threshold is more than the area where the image value change intensity is greater than the set high-frequency threshold in the first map area. In some other embodiments, the map can also be a two-dimensional image of a limited area. As an example, the map can be a two-dimensional image with a length and width of 1 respectively. Based on the lower left corner of the map, the origin is established, the direction of the long side of the map is the U coordinate axis, and the direction of the wide side is the V coordinate axis, and the map coordinate system can be established. At this time, a circular area with a diameter of 0.2 can be circled at the same coordinate position in the first texture map and the second texture map, such as the coordinate (0.5, 0.5), as the first texture map area and the second texture map area for high frequency component comparison. From the overall appearance of the map, the texture units in the second texture map can be smaller and denser than the texture units in the first texture map, and the color contrast of the texture units can also be stronger.
[0046] Figure 41 is a schematic diagram of a second texture map according to some embodiments of the present specification. Similar to the first texture map, the texture unit of the second texture map is a triangle, which is obtained by arranging triangles of different sizes and directions. Different triangles have different color values or grayscales. Taking diamond rendering as an example, the base color of the first texture map can also be sapphire blue. Figure 3 By comparison, it can be seen intuitively that the texture unit size of the second texture map is smaller and the density is higher, and the color contrast between different texture units is also stronger.
[0047] In some embodiments of this specification, a texture map formed by a specific arrangement of texture units simulates the refraction effect of a semi-transparent object, simplifies the steps of obtaining the refraction effect map, and further reduces the calculation loss. By fusion sampling of texture maps of different frequencies, rich refraction light effects of semi-transparent objects can be presented.
[0048] Step 220 , performing parallax calculation on the texture coordinates of the three-dimensional model of the object to be rendered, to obtain the parallax texture coordinates of the three-dimensional model. In some embodiments, step 220 may be implemented by the parallax calculation module 820 .
[0049] In some embodiments of the present specification, the rendered three-dimensional object may be referred to as an object to be rendered. Parallax calculation is also called bump offset. Parallax calculation can offset the texture coordinates of the three-dimensional model based on the height information to obtain the corresponding parallax texture coordinates. After sampling the texture map based on the offset texture coordinates (i.e., parallax texture coordinates), the material on the surface of the three-dimensional model can present a three-dimensional stereoscopic effect with different bumps. Among them, the height information can specifically be a height map or a preset height value. The height map can reflect the distance from different points on the three-dimensional model to the virtual camera. The virtual camera is a virtual camera set in the three-dimensional space of the computer. In the process of computer three-dimensional graphics rendering, if the three-dimensional model and the material determine the content of the picture, then the virtual camera determines the composition of the picture. The rendered picture can also be figuratively understood as a picture taken by a virtual camera in the three-dimensional space of the computer. Therefore, when performing parallax calculation on the three-dimensional model, the distance (i.e., height or depth) information from the three-dimensional model to the virtual camera can be introduced to make the rendering result more in line with the laws of nature and more realistic. In some embodiments, the height information can also be a preset constant.
[0050] As mentioned above, the three-dimensional model can be composed of multiple faces and vertices, and each vertex has spatial parameters for describing its position or posture in space. In order to achieve rendering, the vertices of the three-dimensional model can further include parameters such as texture coordinates and space normal vectors. Texture coordinates are also called UV coordinates, which characterize the position information of the vertices of the three-dimensional model in the corresponding texture map. For the description of the coordinate system of the texture map or map, please refer to the description in step 210, which will not be repeated here. Based on the UV coordinates, the texture map can be properly "wrapped" on the surface of the three-dimensional model, and the rendered object looks more vivid and realistic. When performing parallax calculation, the UV value of the vertex on the three-dimensional model can be used as the basic texture coordinates that need to be modified or offset for the parallax calculation. After parallax calculation, the parallax texture coordinates of each vertex on the three-dimensional model can be obtained.
[0051] Taking diamond as an example, the UV value of each vertex on the diamond 3D model is used as the basic texture coordinate, and the height information is set to a negative value. The parallax texture coordinates of the diamond 3D model can be obtained through parallax calculation. Setting the height information to a negative value can more realistically simulate the refraction phenomenon inside the diamond.
[0052] Step 230 , based on the parallax texture coordinates of the three-dimensional model, texture sampling is performed on the first texture map and the second texture map to obtain a first sampling result and a second sampling result. In some embodiments, step 230 may be implemented by the sampling module 830 .
[0053] After the parallax calculation, the first texture map and the second texture map can be sampled respectively based on the parallax texture coordinates of the three-dimensional model. Specifically, each vertex of the three-dimensional model can be sampled respectively. As an example, an image value is obtained from the corresponding coordinate position in the first texture map based on the parallax texture coordinate Uva' of the vertex A of the three-dimensional model, which can be specifically the first map color value. In this way, the first sampling result of each vertex on the three-dimensional model in the first texture map can be obtained. It is not difficult to understand that the first sampling result may include the first map color value corresponding to each vertex of the three-dimensional model.
[0054] The second texture map may be texture sampled based on the parallax texture coordinates of the three-dimensional model in a similar sampling manner to the first texture map to obtain a second sampling result.
[0055] Step 240 , based on the first sampling result and the second sampling result, obtain the refraction texture sampling result of the object to be rendered. In some embodiments, step 240 may be implemented by the refraction texture acquisition module 840 .
[0056] In some embodiments, the first sampling result and the second sampling result may be weighted and summed, and the result may be used as the sampling result of the refraction texture of the object to be rendered. Exemplarily, the weights corresponding to the first sampling result and the second sampling result may be 0.5 and 0.5, respectively, or 0.2 and 0.8, respectively. In some embodiments, Lerp calculation may be performed on the first sampling result and the second sampling result to obtain the sampling result of the refraction texture of the object to be rendered. Lerp (LinearInterpolation), also known as an interpolation function, is used to perform linear interpolation between two values and return a value between the two values. When the weight parameter of the Lerp calculation can be a variable or a constant, when the weight parameter is a constant (such as 0.5), the Lerp calculation can be equivalent to the weighted sum calculation of the aforementioned example.
[0057] Step 250 , obtaining the reflection texture sampling result of the object to be rendered. In some embodiments, step 250 may be implemented by the reflection texture acquisition module 850 .
[0058] The reflection texture sampling result simulates the reflection effect of the surrounding environment on the surface of the semi-transparent three-dimensional object. In some embodiments, the reflection texture map of the object to be rendered can be directly obtained. The reflection texture map can be a two-dimensional image, and its texture reflects the pattern or texture of the surrounding environment reflected on the surface of the three-dimensional object. Specifically, the reflection texture acquisition module 850 can directly obtain the reflection texture map from a data source such as a material database or a storage medium. Further, the reflection texture map can be sampled based on the texture coordinates of the three-dimensional model to obtain the reflection texture sampling result. As an example, based on the texture coordinate Uva of the vertex A of the three-dimensional model (the original texture coordinate without parallax calculation), the image value is obtained from the corresponding coordinate position in the reflection texture map, which can be a reflection map color value. In this way, the reflection texture sampling results of each vertex on the three-dimensional model in the reflection texture map can be obtained. It is not difficult to understand that the reflection texture sampling result may include the reflection map color value corresponding to each vertex of the three-dimensional model.
[0059] In some other embodiments, an environment map may be obtained, wherein the environment map may be three-dimensional. Further, the three-dimensional environment map is sampled based on the spatial normal vector of each vertex of the three-dimensional model and the shooting direction vector of the preset virtual camera relative to each vertex to obtain a reflection texture sampling result. Specifically, the reflection vector corresponding to each vertex may be calculated based on the spatial normal vector of each vertex of the three-dimensional model and the shooting direction vector of the preset virtual camera relative to each vertex; the three-dimensional environment map is sampled based on the reflection vector corresponding to each vertex of the three-dimensional model to obtain a reflection texture sampling result.
[0060] The environment described here can be the space where the translucent object is located, such as the room in the virtual three-dimensional animation, the alchemy room and other places. Take the room as an example. At a certain position in the room, light from any direction can shine on this position, and recording all the light shining on this position is the environment map. In some embodiments, the environment map can be a cube, and the outer surfaces of its six faces record the pattern or texture information of the ambient light irradiated or projected onto the cube from all directions. The spatial normal vector of the vertex represents the normal direction of the corresponding vertex on the three-dimensional model, which can be a unit three-dimensional vector, that is, the modulus value of the spatial normal vector is 1. Sampling the environment map can be intuitively understood as placing the three-dimensional object in the aforementioned cube, and determining the sampled image value of each vertex in the environment map based on the spatial normal vector of each vertex on the object three-dimensional model and the preset virtual camera relative to each vertex The shooting direction vector. Among them, the virtual camera can be located at any specified position in the virtual space, and its shooting direction vector is also called the view vector, which can be obtained based on the position coordinates of the virtual camera in the virtual space and the position coordinates of the vertex on the three-dimensional model in the virtual space. As an example, the difference between the three-dimensional coordinate vector of the virtual camera and the three-dimensional coordinate vector of the vertex can be used as the shooting direction vector of the virtual camera. In some embodiments, the reflection vector can be calculated based on the spatial normal vector of vertex A of the three-dimensional model and the shooting direction vector of the virtual camera relative to vertex A, and then the image value is obtained from the corresponding three-dimensional coordinate position in the environment map based on the reflection vector, which can be the color value of the environment map. In this way, the reflection texture sampling results of each vertex on the three-dimensional model in the environment map can be obtained. It is not difficult to understand that the reflection texture sampling results can include the color values of the environment map corresponding to each vertex of the three-dimensional model.
[0061] Step 260 , based on the refraction texture sampling result and the reflection texture sampling result, obtain the rendering image value of the object to be rendered. In some embodiments, step 260 may be implemented by the rendering value acquisition module 860 .
[0062] In some embodiments, the weighted sum of the refraction texture sampling result and the reflection texture sampling result of the three-dimensional model (i.e., the result obtained by weighted summation) can be calculated and used as the rendered image value of the three-dimensional model. Among them, the weight corresponding to the reflection texture sampling result and the weight corresponding to the refraction texture sampling result can be adjusted according to actual conditions. Exemplarily, the weights of the two can be 0.6 and 0.4, or 0.2 and 0.8, or 0.1 and 0.9, etc. Taking diamond as an example, the weight corresponding to the reflection texture sampling result can be set to be smaller than the weight corresponding to the refraction texture sampling result, thereby reducing the reflection intensity of the diamond surface to below the refraction intensity, and more fully presenting the rich refraction effect of the diamond.
[0063] The Fresnel Effect refers to the fact that when light reaches the interface of a material, part of the light is reflected and part of it is refracted. That is, when the line of sight (corresponding to the shooting direction of the virtual camera in 3D graphics rendering) is perpendicular to the surface of the object, the reflection is weaker, and when the line of sight is not perpendicular to the surface, the smaller the angle, the more obvious the reflection. All objects have Fresnel reflection, but the intensity varies. Therefore, adding Fresnel reflection calculation during the rendering process can simulate this optical phenomenon in the real world more realistically. Figure 5 is an exemplary flow chart of obtaining a rendered image value of an object to be rendered based on a refraction texture sampling result and a reflection texture sampling result according to some embodiments of this specification. In some embodiments, Figure 5 The process shown can be implemented by the rendering value acquisition module 860. Figure 5 As shown, process 500 includes the following steps.
[0064] Step 510: Calculate the weighted sum of the refraction texture sampling result and the reflection texture sampling result.
[0065] The detailed description of step 510 can be found in the previous text. Specifically, for each vertex of the three-dimensional model, the weighted sum of the refraction texture sampling result and the reflection texture sampling result can be calculated.
[0066] Step 520 , calculating the dot product of the space normal vector of each vertex of the three-dimensional model and the shooting direction vector of the preset virtual camera relative to each vertex.
[0067] In some embodiments, the position coordinates of the virtual camera in the virtual space can be obtained through an interface function or instruction provided by a rendering engine or a rendering service program. Based on the position coordinates of the virtual camera in the virtual space and the position coordinates of each vertex on the three-dimensional model in the virtual space, the shooting direction vector of the virtual camera relative to each vertex can be obtained. The dot product of vectors reflects the degree of the same direction of two vectors. For a three-dimensional model, the dot product result of the spatial normal vector of each vertex and the shooting direction vector of the preset virtual camera relative to each vertex corresponds to the Fresnel reflection phenomenon of the translucent object "seen" or photographed by the virtual camera under the action of ambient light. Figure 6 It is a schematic diagram of the Fresnel reflection calculation effect shown in some embodiments of this specification. Figure 6 Taking diamond as an example, area 601 and edge 602 in the figure are areas with stronger reflection from the perspective of the virtual camera, and the remaining areas have weaker reflection.
[0068] Step 530 : Obtain a rendered image value of the object to be rendered based on the dot product results and the weighted sum corresponding to each vertex of the three-dimensional model.
[0069] In some embodiments, the dot product results corresponding to each vertex of the three-dimensional model and the aforementioned weighted sum may be multiplied, and the obtained calculation result may reflect the rendered image value of the object to be rendered. Specifically, the aforementioned calculation result may be normalized to the numerical range of the object rendered image value to obtain the rendered image value of the object to be rendered. The aforementioned numerical range may be [0, 255], or [0, 1023], etc.
[0070] Rendering is performed based on the rendered image value of the object, and the aforementioned object can be presented on the screen. Figure 7 This is a schematic diagram of a diamond effect obtained by the rendering method shown in some embodiments of this specification. It can be seen that the rendering method provided by the embodiments of this specification can present the optical properties of a semi-transparent object more realistically. The method provided by the embodiments of this specification does not require multi-pass rendering based on the depth information of points on the three-dimensional model, which effectively reduces the computational cost.
[0071] Figure 8 FIG. 1 is an exemplary block diagram of a rendering system for a three-dimensional object according to some embodiments of the present specification. Figure 8 As shown, the three-dimensional object rendering system 800 may include the following modules.
[0072] The map acquisition module 810 is used to acquire a first texture map and a second texture map; in a map area of the same size, the high-frequency component of the second texture map is greater than the high-frequency component of the first texture map.
[0073] The parallax calculation module 820 is used to perform parallax calculation on the texture coordinates of the three-dimensional model of the object to be rendered, so as to obtain the parallax texture coordinates of the three-dimensional model.
[0074] The sampling module 830 is used to perform texture sampling on the first texture map and the second texture map respectively based on the parallax texture coordinates of the three-dimensional model to obtain a first sampling result and a second sampling result.
[0075] The refraction texture acquisition module 840 is used to obtain the refraction texture sampling result of the object to be rendered based on the first sampling result and the second sampling result.
[0076] The reflection texture acquisition module 850 is used to obtain the reflection texture sampling result of the object to be rendered.
[0077] The rendering value acquisition module 860 obtains a rendering image value of the object to be rendered based on the refraction texture sampling result and the reflection texture sampling result.
[0078] For more information about each module, see Figure 2 as well as Figure 5 The relevant description of will not be repeated here. It should be understood that Figure 8 The system and its modules shown can be implemented in various ways. For example, in some embodiments, the system and its modules can be implemented by hardware, software, or a combination of software and hardware. Among them, the hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. Those skilled in the art will understand that the above methods and systems can be implemented using computer executable instructions and / or control codes contained in a processor, such as a disk, CD or DVD-ROM, etc., and such codes are provided in a carrier medium or a memory of a programmable device. The system and its modules of this specification can not only be implemented by hardware circuits such as ultra-large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, etc., or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., but can also be implemented by software executed by various types of processors, and can also be implemented by a combination of the above hardware circuits and software (e.g., firmware).
[0079] It should be noted that the above description of the system and its modules is only for convenience of description and does not limit this specification to the scope of the embodiments. It is understandable that for those skilled in the art, after understanding the principle of the system, it is possible to arbitrarily combine the modules without deviating from this principle to form a subsystem connected to other modules. Or some modules may be split to obtain more modules or multiple units under the module. Such variations are all within the scope of the disclosure of this specification.
[0080] Some embodiments of the present specification also provide a computer program product, including computer instructions. When at least part of the computer instructions are executed by a processor, the present specification can be implemented. Figure 2 or Figure 5 In some embodiments, the computer program product may only involve computer instructions, which may be carried by a storage medium, a processing device, or a terminal device. In other embodiments, the computer program product may also be a storage medium, a processing device, or a terminal device containing the aforementioned computer instructions. Exemplary descriptions of storage media, terminal devices, processing devices, and processors can be found elsewhere in this specification and will not be repeated here.
[0081] The beneficial effects that may be brought about by the embodiments of this specification include but are not limited to: (1) By simulating the internal refraction phenomenon of translucent three-dimensional objects through texture mapping of different frequencies and parallax calculation, it is possible to present a more realistic refraction performance of translucent objects. (2) The introduction of Fresnel reflection calculation can more realistically simulate the reflection effect of translucent objects under a set viewing angle. (3) It can be applied to different types of translucent objects such as diamonds, crystals, ice cubes, etc. (4) The calculation loss of the calculation process is low. It should be noted that different embodiments may produce different beneficial effects. In different embodiments, the beneficial effects that may be produced may be any one or a combination of the above, or any other possible beneficial effects.
[0082] The basic concepts have been described above. Obviously, for those skilled in the art, the above detailed disclosure is only for example and does not constitute a limitation of this specification. Although not explicitly stated here, those skilled in the art may make various modifications, improvements and corrections to this specification. Such modifications, improvements and corrections are taught in this specification, so such modifications, improvements and corrections still belong to the spirit and scope of the exemplary embodiments of this specification.
Claims
1. A method for rendering a three-dimensional object, characterized in that: include: Obtain a first texture map and a second texture map; The image frequency of the second texture map is different from the image frequency of the first texture map; Performing parallax calculation on texture coordinates of a three-dimensional model of an object to be rendered to obtain parallax texture coordinates of the three-dimensional model; Based on the parallax texture coordinates of the three-dimensional model, texture sampling is performed on the first texture map and the second texture map respectively to obtain a first sampling result and a second sampling result; Based on the first sampling result and the second sampling result, obtaining a refraction texture sampling result of the object to be rendered; Obtaining a reflection texture sampling result of the object to be rendered; Based on the refraction texture sampling result and the reflection texture sampling result, a rendering image value of the object to be rendered is obtained.
2. The method according to claim 1, characterized in that In a map area of the same size, the high-frequency component of the second texture map is greater than the high-frequency component of the first texture map.
3. The method according to claim 1, characterized in that The first texture map and the second texture map have the same base color.
4. The method according to claim 1, characterized in that: The first texture map and the second texture map include one or more of the following texture units: triangle, polygon, circle, crack.
5. The method according to claim 1, characterized in that The performing parallax calculation on the texture coordinates of the three-dimensional model of the object to be rendered to obtain the parallax texture coordinates of the three-dimensional model includes: The texture coordinates of the three-dimensional model of the object to be rendered are subjected to parallax calculation based on the height information to obtain the parallax texture coordinates of the three-dimensional model; wherein the height information includes a negative value.
6. The method according to claim 1, characterized in that The obtaining, based on the first sampling result and the second sampling result, a refraction texture sampling result of the object to be rendered includes: The first sampling result and the second sampling result are subjected to Lerp calculation to obtain the refraction texture sampling result.
7. The method according to claim 1, characterized in that The three-dimensional model includes a plurality of vertices; the texture coordinates of the three-dimensional model include texture coordinates corresponding to each vertex.
8. The method according to claim 7, characterized in that The obtaining of the reflection texture sampling result of the object to be rendered includes: Get the 3D environment map; Calculating a reflection vector corresponding to each vertex based on a spatial normal vector of each vertex of the three-dimensional model and a shooting direction vector of a preset virtual camera relative to each vertex; The three-dimensional environment map is sampled based on the reflection vectors corresponding to each vertex of the three-dimensional model to obtain the reflection texture sampling result.
9. The method according to claim 1 or 7, characterized in that: The obtaining, based on the refraction texture sampling result and the reflection texture sampling result, a rendering image value of the object to be rendered comprises: A weighted sum of the refraction texture sampling result and the reflection texture sampling result is calculated.
10. The method according to claim 9, characterized in that The weight corresponding to the reflection texture sampling result is less than the weight corresponding to the refraction texture sampling result.
11. The method according to claim 9, characterized in that The step of obtaining a rendering image value of the object to be rendered based on the refraction texture sampling result and the reflection texture sampling result further includes: Calculating the dot product of the space normal vector of each vertex of the three-dimensional model and the shooting direction vector of the preset virtual camera relative to each vertex; Based on the dot product results and the weighted sum corresponding to each vertex of the three-dimensional model, a rendering image value of the object to be rendered is obtained.
12. A three-dimensional object rendering device, characterized in that: include: A texture acquisition module, used to acquire a first texture map and a second texture map; In a map area of the same size, the high-frequency component of the second texture map is greater than the high-frequency component of the first texture map; A disparity calculation module, used for performing disparity calculation on the texture coordinates of the three-dimensional model of the object to be rendered, to obtain the disparity texture coordinates of the three-dimensional model; A sampling module, configured to perform texture sampling on the first texture map and the second texture map respectively based on the parallax texture coordinates of the three-dimensional model to obtain a first sampling result and a second sampling result; A refraction texture acquisition module, used for obtaining a refraction texture sampling result of the object to be rendered based on the first sampling result and the second sampling result; A reflection texture acquisition module, used to obtain the reflection texture sampling result of the object to be rendered; The rendering value acquisition module obtains the rendering image value of the object to be rendered based on the refraction texture sampling result and the reflection texture sampling result.
13. A computer program product, comprising computer instructions, which, when at least part of the computer instructions are executed by a processor, can implement the method according to any one of claims 1 to 11.
