Three-dimensional image rendering method and system
Through a new three-dimensional image rendering method, the scene information and texture coordinates of the three-dimensional image are obtained, the scene lighting and pixel colors are calculated, and the target image is generated, solving the performance and ease of use of traditional WebGL technology in three-dimensional image rendering, achieving efficient rendering and good user experience.
Patent Information
- Application Number
- CN202411746196.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-25
AI Technical Summary
Traditional WebGL technology has performance and ease of use limitations in three-dimensional image rendering, which is difficult to meet the needs of modern web applications for efficient rendering and good user experience.
A three-dimensional image rendering method is proposed. By acquiring scene information and texture coordinates of the three-dimensional image, the first feature information and second feature information of the image are determined, the scene lighting and pixel color are calculated based on these information, and the target image is finally generated. This method combines vertex shader and fragment shader to render and display with framebuffer objects.
By improving the rendering efficiency of three-dimensional images, the real three-dimensional visual effect on the web is realized, and the user's immersive experience is enhanced. It is suitable for various application scenarios such as online games, virtual reality and visualization.
Smart Images

Figure CN119693530A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a three-dimensional image rendering method and system. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the application that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
[0003] With the development of network (abbreviated as: Web) technology, Web applications have an increasing demand for graphics processing, especially in three-dimensional (full name: Three Dimensions; abbreviated as: 3D) image rendering. Although the traditional WebGL (full name: WebGraphics Library; Chinese: 3D Drawing Protocol) technology can realize 3D image rendering in Web browsers, it has limitations in performance and ease of use.
[0004] In view of this, there is an urgent need to propose a three-dimensional image rendering method and system that can solve the above technical problems. Summary of the invention
[0005] Multiple aspects of the present application provide a three-dimensional image rendering method and system to improve image rendering efficiency and enhance user experience.
[0006] In one aspect of the present application, a three-dimensional image rendering method is provided, the method being applied to a web image processor, the method comprising:
[0007] Acquire scene information and texture coordinate information of a to-be-rendered three-dimensional image, and determine first feature information and second feature information of the to-be-rendered three-dimensional image;
[0008] Determining scene illumination of the image to be rendered based on first feature information of the three-dimensional image to be rendered;
[0009] Determining a pixel color of the image to be rendered based on the scene illumination and second characteristic information of the three-dimensional image to be rendered;
[0010] The three-dimensional image to be rendered is rendered based on the pixel color to generate a target image.
[0011] Furthermore, scene information and texture coordinate information of a three-dimensional image to be rendered are obtained, and first feature information and second feature information of the three-dimensional image to be rendered are determined, including: in response to a three-dimensional image rendering request, scene information and texture coordinate information of the three-dimensional image to be rendered are obtained, the scene information including vertex position information, light source color, light source position information, viewpoint position information and fragment position information; based on the scene information, the first feature information is determined; based on the texture coordinate information, the second feature information is determined.
[0012] Furthermore, based on the scene information, the first feature information is determined, including: based on the vertex position information and the normalization rule, determining the normal direction of the vertex position; based on the light source position information and the fragment position information, determining the illumination direction vector; based on the viewpoint position information and the fragment position information, determining the sight direction vector; based on the illumination direction vector and the normal direction, determining the reflection direction vector; the first feature information includes the normal direction, the illumination direction vector, the sight direction vector and the reflection direction vector.
[0013] Furthermore, based on the first characteristic information of the three-dimensional image to be rendered, the scene lighting of the image to be rendered is determined, including: determining the ambient lighting based on the preset ambient lighting intensity and the light source color; determining the diffuse lighting based on the lighting direction vector, the normal direction and the light source color; determining the specular reflection lighting based on the sight direction vector, the reflection direction vector, the light source color and the preset specular reflection intensity; determining the scene lighting of the image to be rendered based on the ambient lighting, diffuse reflection lighting and specular reflection lighting.
[0014] Furthermore, based on the pixel color, rendering the three-dimensional image to be rendered to generate a target image includes: generating a frame buffer object based on the three-dimensional image to be rendered; rendering the pixel color to the frame buffer object; and displaying the frame buffer object to a display device to generate a target image.
[0015] Furthermore, the frame buffer object includes a color buffer and a depth buffer.
[0016] Furthermore, displaying the frame buffer object to a display interface to generate a target image includes: creating a data feature memory and a texture feature memory; caching the data features and texture features of the frame buffer object to the data feature memory and the texture feature memory, respectively; transmitting the data features cached in the data feature memory and the texture features cached in the texture feature memory to an image processor of the display device, and displaying the frame buffer object to the display device to generate a target image.
[0017] Furthermore, when the data features and texture features of the frame buffer object are cached in the data feature memory and the texture feature memory respectively, the method also includes: compressing and optimizing the data features and texture features of the frame buffer object according to preset compression optimization rules; and caching the compressed and optimized data features and the compressed and optimized texture features in the data feature memory and the texture feature memory respectively according to the data structure of the hash table.
[0018] In another aspect of the present application, a three-dimensional image rendering system is provided, the system comprising:
[0019] A vertex shader is used to obtain scene information and texture coordinate information of a three-dimensional image to be rendered, and determine first feature information and second feature information of the three-dimensional image to be rendered;
[0020] a fragment shader, configured to determine scene illumination of the image to be rendered based on first characteristic information of the three-dimensional image to be rendered, and further configured to determine pixel color of the image to be rendered based on the scene illumination and second characteristic information of the three-dimensional image to be rendered;
[0021] An image rendering unit is used to render the to-be-rendered three-dimensional image based on the pixel color to generate a target image.
[0022] The present application proposes a 3D image rendering method and system applied to a Web image processor, the 3D image rendering method comprising acquiring scene information and texture coordinate information of a 3D image to be rendered, determining first feature information and second feature information of the 3D image to be rendered; determining scene illumination of the image to be rendered based on the first feature information of the 3D image to be rendered; determining pixel color of the image to be rendered based on the scene illumination and the second feature information of the 3D image to be rendered; rendering the 3D image to be rendered based on the pixel color to generate a target image; based on the high-performance image rendering capability of the Web graphics processor, the image rendering method as described above is used to achieve a real 3D visual effect on the Web end, thereby enhancing the user's immersive experience, and can be applied to various application scenarios such as online games, virtual reality and visualization;
[0023] Furthermore, the present application proposes a variety of lighting calculation rules such as ambient lighting, diffuse lighting and specular lighting, striving to achieve a realistic lighting effect; and proposes a method for determining scene lighting based on the above-mentioned lighting calculation rules in combination with actual application scenarios, so as to improve the rendering effect of three-dimensional images and provide users with a good visual experience;
[0024] Furthermore, the present application proposes creating a frame buffer object, rendering pixel colors to the frame buffer object and then displaying a target image generation rule to generate a target image, and storing and transmitting data features and texture features separately, thereby reducing resource usage while effectively improving the transmission rate of data features and texture features, thereby achieving high responsiveness of three-dimensional image rendering. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present application, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0026] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0027] Figure 1 A schematic diagram of a flow chart of a three-dimensional image rendering method provided in one embodiment of the present application;
[0028] Figure 2 A schematic diagram of the structure of a three-dimensional image rendering system provided in one embodiment of the present application;
[0029] Figure 3 A schematic diagram of the structure of an electronic device suitable for implementing the method in the embodiment of the present application;
[0030] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0032] In a typical configuration of the present application, the terminal and the equipment of the service network each include one or more processors (CPU), input / output interface, network interface and memory.
[0033] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0034] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer program instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0035] Figure 1 A three-dimensional image rendering method provided by an embodiment of the present application is shown, and the method is applied to a web image processor, and the method includes:
[0036] Step S101, obtaining scene information and texture coordinate information of a to-be-rendered three-dimensional image, and determining first feature information and second feature information of the to-be-rendered three-dimensional image;
[0037] Step S102: determining scene illumination of the image to be rendered based on first feature information of the three-dimensional image to be rendered;
[0038] Step S103, determining the pixel color of the image to be rendered based on the scene illumination and the second characteristic information of the three-dimensional image to be rendered;
[0039] Step S104: Render the to-be-rendered three-dimensional image based on the pixel color to generate a target image.
[0040] In actual scenarios, the execution subject of the method can be a user device, or a device formed by integrating a user device and a network device through a network, or an application running on the above device. The user device includes but is not limited to various terminal devices such as computers, mobile phones, tablet computers, smart watches, and bracelets. The network device includes but is not limited to network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets, which can be used to implement some processing functions when setting an alarm. Here, the cloud is composed of a large number of hosts or network servers based on cloud computing, where cloud computing is a type of distributed computing, a virtual computer composed of a group of loosely coupled computer sets.
[0041] Embodiment 1
[0042] The present application provides a processing flow of a 3D image rendering method, which is applied to a Web image processor and applied to an application scenario of online games and / or architectural visualization. The method includes at least the following processing steps:
[0043] Acquire scene information and texture coordinate information of a to-be-rendered three-dimensional image, and determine first feature information and second feature information of the to-be-rendered three-dimensional image;
[0044] Determining scene illumination of the image to be rendered based on first feature information of the three-dimensional image to be rendered;
[0045] Determine dynamic shadows of the image to be rendered based on shadow mapping or shadow volume algorithms;
[0046] Determining a pixel color of the image to be rendered based on the scene illumination and second characteristic information of the three-dimensional image to be rendered;
[0047] The to-be-rendered three-dimensional image is rendered based on the pixel color and the dynamic shadow to generate a target image.
[0048] In one embodiment, determining the scene lighting of the image to be rendered based on the first feature information of the three-dimensional image to be rendered includes: determining the scene lighting of the image to be rendered using a Phong lighting model or a Blinn-Phong lighting model based on the first feature information of the three-dimensional image to be rendered.
[0049] In one embodiment, scene information and texture coordinate information of a three-dimensional image to be rendered are obtained, and first feature information and second feature information of the three-dimensional image to be rendered are determined, including: in response to a three-dimensional image rendering request, scene information and texture coordinate information of the three-dimensional image to be rendered are obtained, the scene information including vertex position information, light source color, light source position information, viewpoint position information and fragment position information; based on the scene information, the first feature information is determined; based on the texture coordinate information, the second feature information is determined.
[0050] In one embodiment, based on the scene information, the first feature information is determined, including: based on the vertex position information and the normalization rule, determining the normal direction of the vertex position; based on the light source position information and the fragment position information, determining the illumination direction vector; based on the viewpoint position information and the fragment position information, determining the sight direction vector; based on the illumination direction vector and the normal direction, determining the reflection direction vector; the first feature information includes the normal direction, the illumination direction vector, the sight direction vector and the reflection direction vector.
[0051] Specifically, based on the following code segment, the normal direction of the vertex position is determined:
[0052] normal=normalize(fragNormal); where normal represents the normal direction, which can also be called the normalized initial normal direction, and fragNormal represents the initial normal direction. The initial normal direction is normalized to ensure that the length of the normal vector corresponding to the normal direction is 1, so as to correctly calculate the ambient lighting and diffuse lighting.
[0053] In one implementation, based on the light source position information and the fragment position information, the illumination direction vector (i.e., the direction vector between the light source position and the fragment position) is determined by the following code segment:
[0054] lightDir=normalize(light.lightPosition-fragPosition);
[0055] Among them, light.lightPosition represents the light source position information, and fragPosition represents the fragment position information.
[0056] In one implementation, based on the viewpoint position information and the fragment position information, the sight direction vector (i.e., the direction vector between the viewpoint position and the fragment position) is determined by the following code segment:
[0057] viewDir=normalize(light.viewPosition-fragPosition);
[0058] Among them, light.viewPosition represents the viewpoint position information, and fragPosition represents the fragment position information.
[0059] In one implementation, based on the illumination direction vector and the normal direction, the reflection direction vector (i.e., the emission direction vector of the illumination direction on the normal) is determined by the following code segment:
[0060] reflectDir=reflect(-lightDir,normal);
[0061] Among them, lightDir represents the lighting direction vector, and normal represents the normal direction.
[0062] In one embodiment, based on the first feature information of the three-dimensional image to be rendered, the scene lighting of the image to be rendered is determined, including: determining the ambient lighting based on the preset ambient lighting intensity and the light source color; determining the diffuse lighting based on the lighting direction vector, the normal direction and the light source color; determining the specular reflection lighting based on the sight direction vector, the reflection direction vector, the light source color and the preset specular reflection intensity; determining the scene lighting of the image to be rendered based on the ambient lighting, diffuse reflection lighting and specular reflection lighting.
[0063] In one embodiment, determining the ambient lighting based on a preset ambient lighting intensity and a light source color includes: determining the ambient lighting based on a product of a preset ambient lighting intensity and a light source color.
[0064] In one embodiment, the diffuse reflection lighting is determined based on the illumination direction vector, the normal direction and the light source color, including: determining the diffuse reflection lighting based on the angle between the illumination direction vector and the normal direction and the light source color.
[0065] Specifically, based on the following code segment, diffuse lighting is determined based on the lighting direction vector, normal direction and light source color: diffuse = max(dot(normal,lightDir),0.0)*lightColor; wherein diffuse represents diffuse lighting, normal represents the normal direction, lightDir represents the lighting direction vector, and lightColor represents the light source color.
[0066] In one embodiment, determining the specular reflection illumination based on the sight direction vector, the reflection direction vector, the light source color and the preset specular reflection intensity includes: determining the specular reflection illumination based on the angle between the sight direction vector and the reflection direction vector, the light source color and the preset specular reflection intensity.
[0067] Specifically, the specular lighting is determined by the code snippet:
[0068] specular=specularStrength*pow(max(dot(viewDir,reflectDir),0.0),shininess)*lightColor;wherein, specularStrength represents the preset specular reflection strength, viewDir represents the sight direction vector, reflectDir represents the reflection direction vector, and lightColor represents the light source color.
[0069] In one embodiment, after generating the target image, the method further includes: transmitting the target image to an image processor of a display device to display the target image on a display interface of the display device.
[0070] It should be understood that due to the actual requirements of high-performance rendering, complex lighting and shadow effects, and strong interactivity in the application scenario of online games, it is necessary to focus on the lighting and shadow effects of three-dimensional images during the rendering process of three-dimensional images; similarly, due to the actual requirements of the application scenario of architectural visualization for rendering quality, material and lighting realism, and interactivity, it is necessary to focus on the lighting and shadow effects of three-dimensional images during the rendering process of three-dimensional images.
[0071] Furthermore, in the process of processing the lighting effect of the three-dimensional image, it is necessary to strengthen the processing of the ambient lighting, diffuse lighting and specular lighting of the three-dimensional image.
[0072] Embodiment 2
[0073] The present application embodiment provides a processing flow of a three-dimensional image rendering method, which is applied to a Web image processor and applied to an application scenario of virtual reality (VR). The three-dimensional image rendering method proposed in the present embodiment at least includes the following processing flow:
[0074] Acquire scene information and texture coordinate information of a to-be-rendered three-dimensional image, and determine first feature information and second feature information of the to-be-rendered three-dimensional image;
[0075] Determining scene illumination of the image to be rendered based on first feature information of the three-dimensional image to be rendered;
[0076] Determine dynamic shadows of the image to be rendered based on shadow mapping or shadow volume algorithms;
[0077] Determining a pixel color of the image to be rendered based on the scene illumination and second characteristic information of the three-dimensional image to be rendered;
[0078] The to-be-rendered three-dimensional image is rendered based on the pixel color and the dynamic shadow to generate a target image.
[0079] In one embodiment, determining the scene lighting of the image to be rendered based on the first feature information of the three-dimensional image to be rendered includes: determining the scene lighting of the image to be rendered using a Phong lighting model or a Blinn-Phong lighting model based on the first feature information of the three-dimensional image to be rendered.
[0080] In one embodiment, scene information and texture coordinate information of a three-dimensional image to be rendered are obtained, and first feature information and second feature information of the three-dimensional image to be rendered are determined, including: in response to a three-dimensional image rendering request, scene information and texture coordinate information of the three-dimensional image to be rendered are obtained, the scene information including vertex position information, light source color, light source position information, viewpoint position information and fragment position information; based on the scene information, the first feature information is determined; based on the texture coordinate information, the second feature information is determined.
[0081] In one embodiment, based on the first feature information of the three-dimensional image to be rendered, determining the scene lighting of the image to be rendered includes: determining the ambient lighting based on a preset ambient lighting intensity and the light source color; and determining the ambient lighting as the scene lighting of the image to be rendered.
[0082] In one embodiment, determining the ambient lighting based on a preset ambient lighting intensity and a light source color includes: determining the ambient lighting based on a product of a preset ambient lighting intensity and a light source color;
[0083] Specifically, the ambient lighting is determined by the following code segment:
[0084] ambient=ambientStrength*lightColor;
[0085] Among them, ambient represents ambient lighting, ambientStrength represents the preset ambient lighting intensity, and lightColor represents the light source color.
[0086] In one embodiment, after generating the target image, the method further includes: transmitting the target image to an image processor of a display device to display the target image on a display interface of the display device.
[0087] In one embodiment, rendering the three-dimensional image to be rendered based on the pixel color to generate a target image includes: generating a frame buffer object based on the three-dimensional image to be rendered; rendering the pixel color to the frame buffer object; and displaying the frame buffer object to a display device to generate a target image.
[0088] In one embodiment, the frame buffer object includes a color buffer and a depth buffer.
[0089] In one embodiment, displaying the frame buffer object to a display interface to generate a target image includes: creating a data feature memory and a texture feature memory; caching data features and texture features of the frame buffer object to the data feature memory and the texture feature memory, respectively; transmitting the data features cached in the data feature memory and the texture features cached in the texture feature memory to an image processor of the display device, and displaying the frame buffer object to the display device to generate a target image.
[0090] Specifically, the data feature memory includes but is not limited to Buffer; the texture feature memory includes but is not limited to Texture.
[0091] In one embodiment, creating a data feature memory and a texture feature memory includes: creating and managing a Buffer through a WebGPU API, and creating and managing a Texture through a WebGPU API.
[0092] In one of the embodiments, in order to reduce repeated resource loading, reduce resource transmission and reduce resource memory usage, when caching the data features and texture features of the frame buffer object to the data feature memory and the texture feature memory respectively, the method also includes: compressing and optimizing the data features and texture features of the frame buffer object according to preset compression optimization rules; and caching the compressed and optimized data features and the compressed and optimized texture features to the data feature memory and the texture feature memory respectively according to the data structure of the hash table.
[0093] Specifically, by compressing and optimizing the data features and texture features of the frame buffer object, the memory usage is effectively reduced; the compressed and optimized data features and texture features are stored separately according to the data structure of the hash table, and the resource access and data transmission efficiency are improved by using an efficient data storage structure.
[0094] Furthermore, by creating a frame buffer object to store data features and texture features separately and cache commonly used resources, the resource usage of repeated loading and transmission can be effectively reduced, thereby effectively improving the rendering efficiency and rendering effect of three-dimensional images.
[0095] It should be understood that due to the actual requirements of high frame rate, low latency and strong realism in the application scenario of virtual reality, it is necessary to focus on the lighting effect, shadow effect and transmission efficiency of the three-dimensional image when rendering the three-dimensional image.
[0096] Embodiment 3
[0097] The present application embodiment provides a processing flow of a three-dimensional image rendering method, which is applied to a Web image processor and applied to the application scenario of data visualization. The three-dimensional image rendering method proposed in this embodiment at least includes the following processing flow:
[0098] Acquire scene information and texture coordinate information of a to-be-rendered three-dimensional image, and determine first feature information and second feature information of the to-be-rendered three-dimensional image;
[0099] Determining scene illumination of the image to be rendered based on first feature information of the three-dimensional image to be rendered;
[0100] Determining a pixel color of the image to be rendered based on the scene illumination and second characteristic information of the three-dimensional image to be rendered;
[0101] The three-dimensional image to be rendered is rendered based on the pixel color to generate a target image.
[0102] In one embodiment, determining the scene lighting of the image to be rendered based on the first feature information of the three-dimensional image to be rendered includes: determining the scene lighting of the image to be rendered using a Phong lighting model or a Blinn-Phong lighting model based on the first feature information of the three-dimensional image to be rendered.
[0103] In one embodiment, scene information and texture coordinate information of a three-dimensional image to be rendered are obtained, and first feature information and second feature information of the three-dimensional image to be rendered are determined, including: in response to a three-dimensional image rendering request, scene information and texture coordinate information of the three-dimensional image to be rendered are obtained, the scene information including vertex position information, light source color, light source position information, viewpoint position information and fragment position information; based on the scene information, the first feature information is determined; based on the texture coordinate information, the second feature information is determined.
[0104] In one embodiment, based on the first feature information of the three-dimensional image to be rendered, determining the scene lighting of the image to be rendered includes: determining the ambient lighting based on a preset ambient lighting intensity and the light source color; and determining the ambient lighting as the scene lighting of the image to be rendered.
[0105] In one embodiment, determining the ambient lighting based on a preset ambient lighting intensity and a light source color includes: determining the ambient lighting based on a product of a preset ambient lighting intensity and a light source color;
[0106] Specifically, the ambient lighting is determined by the following code segment:
[0107] ambient=ambientStrength*lightColor;
[0108] Among them, ambient represents ambient lighting, ambientStrength represents the preset ambient lighting intensity, and lightColor represents the light source color.
[0109] In one embodiment, after generating the target image, the method further includes: transmitting the target image to an image processor of a display device to display the target image on a display interface of the display device.
[0110] It should be understood that the display device mentioned in this embodiment can be a human-computer interaction device, which supports user and data interaction, that is, the user can obtain data information with the help of the camera, and the user can control the position and direction of the camera through mouse and keyboard operations to achieve interaction with the 3D scene to realize data visualization.
[0111] In one embodiment, rendering the three-dimensional image to be rendered based on the pixel color to generate a target image includes: generating a frame buffer object based on the three-dimensional image to be rendered; rendering the pixel color to the frame buffer object; and displaying the frame buffer object to a display device to generate a target image.
[0112] In one embodiment, the frame buffer object includes a color buffer and a depth buffer.
[0113] In one embodiment, displaying the frame buffer object to a display interface to generate a target image includes: creating a data feature memory and a texture feature memory; caching data features and texture features of the frame buffer object to the data feature memory and the texture feature memory, respectively; transmitting the data features cached in the data feature memory and the texture features cached in the texture feature memory to an image processor of the display device, and displaying the frame buffer object to the display device to generate a target image.
[0114] In one embodiment, when the data features and texture features of the frame buffer object are cached in the data feature memory and the texture feature memory respectively, the method further includes: compressing and optimizing the data features and texture features of the frame buffer object according to preset compression optimization rules; and caching the compressed and optimized data features and the compressed and optimized texture features in the data feature memory and the texture feature memory respectively according to the data structure of the hash table.
[0115] It should be understood that due to the actual needs of human-computer interaction and data-driven in the application scenario of data visualization, it is necessary to focus on the transmission efficiency of the lighting effects of three-dimensional images when rendering them.
[0116] Embodiment 4
[0117] Figure 2 A schematic diagram of the structure of a three-dimensional image rendering system provided in an embodiment of the present application is shown, and the system at least includes:
[0118] A vertex shader is used to obtain scene information and texture coordinate information of a three-dimensional image to be rendered, and determine first feature information and second feature information of the three-dimensional image to be rendered;
[0119] a fragment shader, configured to determine scene illumination of the image to be rendered based on first characteristic information of the three-dimensional image to be rendered, and further configured to determine pixel color of the image to be rendered based on the scene illumination and second characteristic information of the three-dimensional image to be rendered;
[0120] An image rendering unit is used to render the to-be-rendered three-dimensional image based on the pixel color to generate a target image.
[0121] In one of the implementations, the vertex shader is mainly responsible for processing the vertex data of the three-dimensional image for converting it to the coordinate system of the screen space; generally speaking, the processing logic of the vertex shader includes: receiving input data such as vertex position, normal, texture coordinates, etc.; applying the model matrix, view matrix and projection matrix to convert the vertex position from the model space to the screen space; calculating the normal direction of the vertex for lighting calculation; passing the transformed vertex position and other data to the fragment shader.
[0122] In one of the implementations, the fragment shader is mainly responsible for calculating the pixel color of each pixel of the three-dimensional image; generally speaking, the processing logic of the fragment shader includes: receiving normals, texture coordinates and other data passed by the vertex shader; calculating lighting effects, including ambient light, diffuse reflection and specular reflection; combining texture data to calculate the final pixel color; and outputting the calculated color value.
[0123] In one of the embodiments, the image rendering unit can be understood as a frame buffer object including a color buffer and a depth buffer; generally speaking, the processing logic of the image rendering unit includes: creating and configuring a frame buffer object, including a color buffer and a depth buffer; outputting the rendering result to the frame buffer object; after the rendering is completed, displaying the content of the frame buffer object on the screen.
[0124] Embodiment 5
[0125] Based on the same inventive concept, an electronic device is also provided in an embodiment of the present application, and the method corresponding to the electronic device may be the method for three-dimensional image rendering in the aforementioned embodiment, and its principle of solving the problem is similar to that of the method. The electronic device provided in an embodiment of the present application includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the methods and / or technical solutions of the aforementioned multiple embodiments of the present application.
[0126] The electronic device may be a user device, or a device formed by integrating a user device and a network device through a network, or may be an application running on the above device. The user device includes but is not limited to various terminal devices such as computers, mobile phones, tablet computers, smart watches, and bracelets. The network device includes but is not limited to network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets, which can be used to implement some processing functions when setting an alarm. Here, the cloud is composed of a large number of hosts or network servers based on cloud computing, where cloud computing is a type of distributed computing, a virtual computer composed of a group of loosely coupled computer sets.
[0127] Figure 3 The structure of an electronic device suitable for implementing the method and / or technical solution in the embodiment of the present application is shown, and the device 500 includes a central processing unit (CPU, Central Processing Unit) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM, Read Only Memory) 502 or the program loaded from the storage part 508 to the random access memory (RAM, Random Access Memory) 503. In RAM503, various programs and data required for system operation are also stored. CPU 501, ROM 502 and RAM 503 are connected to each other through a bus 504. An input / output (I / O, Input / Output) interface 505 is also connected to the bus 504.
[0128] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, a touch screen, a microphone, an infrared sensor, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), an LED display, an OLED display, etc., and a speaker, etc.; a storage section 508 including one or more computer-readable media such as a hard disk, an optical disk, a magnetic disk, a semiconductor memory, etc.; and a communication section 509 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet.
[0129] In particular, the methods and / or embodiments in the embodiments of the present application may be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. When the computer program is executed by the central processing unit (CPU) 501, the above functions defined in the method of the present application are executed.
[0130] Embodiment 6
[0131] Another embodiment of the present application further provides a computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions can be executed by a processor to implement the methods and / or technical solutions of any one or more embodiments of the present application described above.
[0132] Specifically, the present embodiment can adopt any combination of one or more computer-readable media. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0133] Computer readable signal media may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer readable program code. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than a computer readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device.
[0134] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0135] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0136] The flow chart or block diagram in the accompanying drawings shows the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated system for hardware that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0137] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0138] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or page components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0139] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0140] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0141] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0142] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
[0143] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in a device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
Claims
1. A three-dimensional image rendering method, characterized in that: The method is applied to a Web image processor, and the method comprises: Acquire scene information and texture coordinate information of a to-be-rendered three-dimensional image, and determine first feature information and second feature information of the to-be-rendered three-dimensional image; Determining scene illumination of the image to be rendered based on first feature information of the three-dimensional image to be rendered; Determining a pixel color of the image to be rendered based on the scene illumination and second characteristic information of the three-dimensional image to be rendered; The three-dimensional image to be rendered is rendered based on the pixel color to generate a target image.
2. The three-dimensional image rendering method according to claim 1, characterized in that: Acquiring scene information and texture coordinate information of a to-be-rendered three-dimensional image, and determining first feature information and second feature information of the to-be-rendered three-dimensional image, including: In response to a three-dimensional image rendering request, acquiring scene information and texture coordinate information of the three-dimensional image to be rendered, the scene information including vertex position information, light source color, light source position information, viewpoint position information, and fragment position information; Based on the scene information, determining the first feature information; Based on the texture coordinate information, the second feature information is determined.
3. The three-dimensional image rendering method according to claim 2, characterized in that: Determining the first feature information based on the scene information includes: Determine the normal direction of the vertex position based on the vertex position information and the normalization rule; Determine a lighting direction vector based on the light source position information and the fragment position information; Determine a sight line direction vector based on the viewpoint position information and the fragment position information; Determine a reflection direction vector based on the illumination direction vector and the normal direction; The first feature information includes the normal direction, the illumination direction vector, the sight direction vector and the reflection direction vector.
4. The three-dimensional image rendering method according to claim 3, characterized in that: Determining scene illumination of the image to be rendered based on first feature information of the three-dimensional image to be rendered includes: Determining ambient lighting based on a preset ambient lighting intensity and the light source color; Determining diffuse lighting based on the lighting direction vector, the normal direction and the light source color; Determining specular reflection illumination based on the sight direction vector, the reflection direction vector, the light source color, and a preset specular reflection intensity; The scene lighting of the image to be rendered is determined based on the ambient lighting, or the scene lighting of the image to be rendered is determined based on the ambient lighting, the diffuse lighting and the specular lighting.
5. The three-dimensional image rendering method according to claim 4, characterized in that: Rendering the to-be-rendered three-dimensional image based on the pixel color to generate a target image includes: Generate a frame buffer object based on the three-dimensional image to be rendered; Rendering the pixel color to the framebuffer object; Display the frame buffer object to a display device to generate a target image.
6. The three-dimensional image rendering method according to claim 5, characterized in that: Rendering the to-be-rendered three-dimensional image based on the pixel color to generate a target image includes: Determining a dynamic shadow of the image to be rendered based on a preset shadow map or a preset shadow volume calculation algorithm; The three-dimensional image to be rendered is rendered based on the dynamic shadow and the pixel color to generate a target image.
7. The three-dimensional image rendering method according to claim 5 or 6, characterized in that: The frame buffer object includes a color buffer and a depth buffer.
8. The three-dimensional image rendering method according to claim 7, characterized in that: Displaying the frame buffer object to a display interface to generate a target image includes: Creating a data feature memory, and a texture feature memory; caching the data features and texture features of the frame buffer object in the data feature memory and the texture feature memory respectively; The data features cached in the data feature memory and the texture features cached in the texture feature memory are transmitted to the image processor of the display device, and the frame buffer object is displayed to the display device to generate a target image.
9. The three-dimensional image rendering method according to claim 8, characterized in that: When caching the data features and the texture features of the frame buffer object in the data feature memory and the texture feature memory respectively, the method further comprises: According to preset compression optimization rules, compress and optimize the data features and texture features of the frame buffer object; According to the data structure of the hash table, the compressed and optimized data features and the compressed and optimized texture features are cached in the data feature memory and the texture feature memory respectively.
10. A three-dimensional image rendering system, characterized in that: The system comprises: A vertex shader is used to obtain scene information and texture coordinate information of a three-dimensional image to be rendered, and determine first feature information and second feature information of the three-dimensional image to be rendered; a fragment shader, configured to determine scene illumination of the image to be rendered based on first characteristic information of the three-dimensional image to be rendered, and further configured to determine pixel color of the image to be rendered based on the scene illumination and second characteristic information of the three-dimensional image to be rendered; An image rendering unit is used to render the to-be-rendered three-dimensional image based on the pixel color to generate a target image.
11. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.
12. A computer readable medium having computer program instructions stored thereon, wherein the computer program instructions can be executed by a processor to implement the method according to any one of claims 1 to 9.
13. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.