Three-dimensional scene rendering method, device, electronic device and storage medium

By using object color identification and position information to generate rendering textures and perform lighting calculations in three-dimensional scene rendering, the problem of excessive memory, video memory and GPU bandwidth consumption caused by a large number of light sources in the prior art is solved, and more efficient rendering processing is achieved.

CN114419234BActive Publication Date: 2025-03-14BEIJING SANKUAI ONLINE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111680490.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-03-14
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

In three-dimensional scenarios where a large number of light sources exist, the prior art multi-frame buffer output scheme results in excessive memory and video memory consumption, and the GPU bandwidth overhead is also large, especially on mobile devices.

Method used

By obtaining the object data and light source information in the three-dimensional scene to be rendered, the object color identification corresponding to the object color is determined, and the rendering texture is generated by the GPU based on the object color identification and position information. Then, the attribute information, object color identification and light source information are sent to the GPU, and the lighting calculation is performed based on the rendering texture through the GPU to obtain the three-dimensional rendering result.

Benefits of technology

This method reduces the consumption of memory and video memory, reduces the overhead of GPU bandwidth, and can be applied to devices that do not support multi-frame buffer output, significantly improving rendering processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114419234B_ABST
    Figure CN114419234B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a three-dimensional scene rendering method, device, electronic device and storage medium, the method comprising: obtaining object data and light source information in a three-dimensional scene to be rendered, the object data including attribute information of the object, the attribute information including object color and position information; determining the object color identifier corresponding to the object color; generating a rendering texture by a GPU according to the object color identifier and position information; sending the attribute information, object color identifier and light source information to the GPU; determining the texture color corresponding to the target screen position according to the rendering texture by the GPU, and determining the texture color identifier corresponding to the texture color; based on the comparison result of the object color identifier and the texture color identifier, performing illumination calculation on the object corresponding to the target screen position according to the light source information and attribute information by the GPU, obtaining a three-dimensional rendering result, and outputting the three-dimensional rendering result. The embodiment of the present application reduces the consumption of memory and video memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of image processing technology, and in particular to a three-dimensional scene rendering method, device, electronic device and storage medium. Background Art

[0002] In business scenarios such as smart cities, it is often necessary to achieve a series of cool effects, such as the lighting effects of a large number of street lamps in the city night scene; each street lamp is equivalent to a light source, and in order to achieve realistic effects, a series of mathematical calculations need to be performed on each light source; when the amount of light source data is too large (for example, more than 100), the huge amount of calculation will cause the entire scene rendering to be stuck.

[0003] In the prior art, for scenes with a large number of light sources, a delayed rendering solution is used to perform two rendering operations. The first rendering uses the multi-frame buffer output technology provided by the graphics interface to generate a position frame buffer, a normal frame buffer, and an object color frame buffer. During the second rendering, the multiple frame buffer textures generated in the first rendering are passed to the GPU, and the relevant data is read for lighting rendering calculations.

[0004] Although multi-frame buffer output can reduce the amount of calculation to a certain extent, it is not suitable for devices whose underlying graphics interface does not support multi-frame buffer output capabilities; since three frame buffers need to be generated, the consumption of memory and video memory is increased, and the overhead is too large for mobile devices; the three frame buffers are read simultaneously during the second drawing, which increases the GPU bandwidth overhead. Summary of the invention

[0005] The embodiments of the present application provide a three-dimensional scene rendering method, device, electronic device and storage medium, which help to reduce the consumption of memory and video memory and reduce GPU bandwidth.

[0006] In order to solve the above problems, in a first aspect, an embodiment of the present application provides a three-dimensional scene rendering method, comprising:

[0007] Obtaining object data and light source information in a three-dimensional scene to be rendered, wherein the object data includes attribute information of the object, and the attribute information includes object color and position information;

[0008] Determining an object color identifier corresponding to the object color;

[0009] Generate a rendering texture according to the color identification and position information of the object through the GPU;

[0010] Sending the attribute information, the object color identifier, and the light source information to the GPU;

[0011] Determining, by the GPU, a texture color corresponding to a target screen position according to the rendered texture, and determining a texture color identifier corresponding to the texture color;

[0012] Based on the comparison result of the object color identifier and the texture color identifier, the GPU performs lighting calculation on the object corresponding to the target screen position according to the light source information and the attribute information to obtain a three-dimensional rendering result, and outputs the three-dimensional rendering result.

[0013] In a second aspect, an embodiment of the present application provides a three-dimensional scene rendering device, including:

[0014] A scene data acquisition module, used to acquire object data and light source information in a three-dimensional scene to be rendered, wherein the object data includes attribute information of the object, and the attribute information includes object color and position information;

[0015] An object color identification determination module, used to determine the object color identification corresponding to the object color;

[0016] A rendering texture generation module, used to generate a rendering texture according to the color identification and position information of the object through a GPU;

[0017] A data sending module, used for sending the attribute information, the object color identification and the light source information to the GPU;

[0018] A texture color identifier determination module, used to determine the texture color corresponding to the target screen position according to the rendered texture through the GPU, and determine the texture color identifier corresponding to the texture color;

[0019] A rendering module is used to perform lighting calculation on the object corresponding to the target screen position according to the light source information and the attribute information through the GPU based on the comparison result of the object color identifier and the texture color identifier, obtain a three-dimensional rendering result, and output the three-dimensional rendering result.

[0020] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the three-dimensional scene rendering method described in the embodiment of the present application when executing the computer program.

[0021] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the three-dimensional scene rendering method disclosed in the embodiment of the present application.

[0022] The three-dimensional scene rendering method, device, electronic device and storage medium provided by the embodiments of the present application obtain object data and light source information in the three-dimensional scene to be rendered, determine the object color identifier corresponding to the object color, generate a rendering texture according to the object color identifier and position information through the GPU to achieve the first drawing, and then send the attribute information, object color identifier and light source information to the GPU, determine the texture color corresponding to the target screen position according to the rendering texture through the GPU, and determine the texture color identifier corresponding to the texture color, based on the comparison result of the object color identifier and the texture color identifier, perform lighting calculation on the object corresponding to the target screen position according to the light source information and the attribute information through the GPU to obtain the three-dimensional rendering result, and output the three-dimensional rendering result, thereby achieving the second drawing. Since the GPU only needs to generate the rendering texture according to the object color identifier and the position information, that is, when drawing for the first time, three frame buffers are not needed, thereby reducing the consumption of memory and video memory, and when drawing for the second time, one rendering texture can be read for drawing, thereby reducing the GPU bandwidth consumption, and can be applied to devices that do not support multi-frame buffer output. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only 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.

[0024] Figure 1 is a flow chart of a three-dimensional scene rendering method according to the first embodiment of the present application;

[0025] Figure 2 This is a diagram of the overall technical architecture of the method for implementing three-dimensional scene rendering in an embodiment of the present application;

[0026] Figure 3 This is a schematic diagram of the structure of a three-dimensional scene rendering device according to the second embodiment of the present application;

[0027] Figure 4 It is a structural diagram of an electronic device according to the third embodiment of the present application. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are 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.

[0029] Embodiment 1

[0030] This embodiment provides a 3D scene rendering method, which is applicable to scenes with a large number of light sources. The 3D scene rendering method is completed by drawing twice. Figure 1 As shown, the method includes: steps 110 to 160.

[0031] Step 110, obtaining object data and light source information in the three-dimensional scene to be rendered, wherein the object data includes attribute information of the object, and the attribute information includes object color and position information.

[0032] The object data and light source information in the 3D scene to be rendered input by the user can be obtained through the user interface. The light source information includes the position, color and intensity information of each light source. The position information can include the horizontal coordinate, vertical coordinate and depth data of the object. The object data can also include geometric information of the object.

[0033] Step 120: Determine the object color identifier corresponding to the object color.

[0034] Based on the object color of the object, an object color identifier is assigned to the object. The object color identifier corresponding to the object color can be determined based on the corresponding relationship between the color and the color identifier, or can also be determined based on a coding method.

[0035] Step 130: Generate a rendering texture using a GPU according to the color identifier and position information of the object.

[0036] The correspondence between the object color identification and position information is sent to the GPU (Graphics Processing Unit), and the GPU can generate a rendering texture based on the object color identification and position information, thereby achieving the first drawing. The rendering texture is a three-dimensional texture, which is a texture image with multiple layers of depth composed of layers of two-dimensional texture image matrices.

[0037] In one embodiment of the present application, generating a rendering texture according to the object color identifier and position information by the GPU includes: performing a depth test on the position information by the GPU and decoding the object color identifier into the color value; generating the rendering texture according to the depth test result and the color value by the GPU.

[0038] The GPU performs a depth test on the depth data in the position information to determine whether the object is located behind other objects. If the object is located behind other objects, the object is covered. If the object is located in front of other objects or is not mutually blocked by other objects, the object color identifier is decoded into the color value of the RGB channel. According to the depth test result, when the object is not blocked by other objects, the color value of the object can be generated in the rendering texture. When part or all of the object is blocked by other objects, the color value of the blocked part of the object does not need to be included in the rendering texture. By generating a rendering texture based on the depth test result, the accuracy of the generated rendering texture can be improved, thereby improving the rendering effect.

[0039] Step 140: Send the attribute information, the object color identifier, and the light source information to the GPU.

[0040] During the second drawing, the rendering texture is bound to the GPU so that the GPU can process the rendering texture. The object's attribute information, object color identification, and light source information are sent to the GPU so that the GPU can render the three-dimensional scene based on the rendering texture, attribute information, object color identification, and light source information.

[0041] Step 150: Determine, by the GPU, a texture color corresponding to a target screen position based on the rendered texture, and determine a texture color identifier corresponding to the texture color.

[0042] The GPU reads the rendered texture, determines the texture color corresponding to the target screen position, and determines the texture color identifier corresponding to the texture color. The texture color identifier corresponding to the texture color can be determined based on the correspondence between the color and the color identifier, or the texture color identifier corresponding to the texture color can be determined based on the encoding method. Among them, the texture color is the color value of the RGB channel, which is the same as the color value obtained by decoding the object color identifier. The target screen position can be the position of a target pixel.

[0043] In one embodiment of the present application, determining the texture color corresponding to the target screen position according to the rendered texture by the GPU includes: reading the texture color corresponding to the target screen position in the rendered texture by the GPU using a fragment shader.

[0044] The fragment shader is used to color pixels.

[0045] The GPU uses a fragment shader to read the texture color corresponding to the target screen position in the rendering texture, and can accurately obtain the texture color of the target screen position.

[0046] Step 160, based on the comparison result of the object color identifier and the texture color identifier, the GPU performs lighting calculation on the object corresponding to the target screen position according to the light source information and the attribute information to obtain a three-dimensional rendering result, and outputs the three-dimensional rendering result.

[0047] The GPU compares whether the object color identifier and the texture color identifier are the same, and based on the comparison result, performs lighting calculations on the object corresponding to the target screen position according to the light source information and the object's attribute information, determines the final displayed color of the target screen position, obtains the three-dimensional rendering result, and outputs the three-dimensional rendering result to be displayed on the screen, realizing the second drawing.

[0048] The object data also includes geometric information of the object, and the attribute information also includes a normal vector.

[0049] In one embodiment of the present application, based on the comparison result of the object color identifier and the texture color identifier, the GPU performs illumination calculation on the object corresponding to the target screen position according to the light source information and the attribute information to obtain a three-dimensional rendering result, including:

[0050] If the object color identifier and the texture color identifier are the same, the GPU performs illumination calculation on the geometric information and texture color of the object corresponding to the target screen position according to the light source information and the attribute information to obtain a three-dimensional rendering result;

[0051] If the object color identifier and the texture color identifier are different, a preset color is assigned to the target screen position by the GPU to obtain a three-dimensional rendering result.

[0052] If the object color identifier and the texture color identifier are the same, it indicates that the object is visible at the target screen position, that is, the object is not blocked at the target screen position. At this time, it is necessary to perform illumination calculation on the object at the target screen position, that is, based on the light source information and the position information, perform illumination calculation on the geometric information and texture color of the object corresponding to the target screen position, determine the color value finally output at the target screen position, and obtain the three-dimensional rendering result of the target screen position. If the object color identifier and the texture color identifier are different, it indicates that the object is not visible at the target screen position, that is, the object is blocked at the target screen position, and there is no need to perform illumination calculation on the target screen position. At this time, a preset color can be assigned to the target screen position, for example, the preset color can be (0,0,0,0), and the three-dimensional rendering result of the target screen position is obtained. After the three-dimensional rendering result is calculated for each target screen position (that is, each pixel), the three-dimensional rendering result of the entire screen is obtained.

[0053] By performing illumination calculation on the target screen position when the object color identifier and the texture color identifier are the same, and not performing illumination calculation on the target screen position when the object color identifier and the texture color identifier are different, the processing speed can be improved and unnecessary calculation can be avoided.

[0054] The three-dimensional scene rendering method provided by the embodiment of the present application obtains the object data and light source information in the three-dimensional scene to be rendered, determines the object color identifier corresponding to the object color, generates a rendering texture according to the object color identifier and position information through the GPU, and realizes the first drawing. Then, the attribute information, the object color identifier and the light source information are sent to the GPU, and the GPU determines the texture color corresponding to the target screen position according to the rendering texture, and determines the texture color identifier corresponding to the texture color. Based on the comparison result of the object color identifier and the texture color identifier, the GPU performs illumination calculation on the object corresponding to the target screen position according to the light source information and the attribute information to obtain the three-dimensional rendering result, and outputs the three-dimensional rendering result, thereby realizing the second drawing. Since the GPU only needs to generate the rendering texture according to the object color identifier and the position information, that is, when drawing for the first time, three frame buffers are not needed, thereby reducing the consumption of memory and video memory, and when drawing for the second time, one rendering texture can be read for drawing, thereby reducing the GPU bandwidth consumption. Compared with the solution using three frame buffers, about 75% of the memory and video memory can be saved, and about 75% of the bandwidth overhead of the GPU reading data can be reduced, and it can be applied to devices that do not support multi-frame buffer output.

[0055] Based on the above technical solution, before generating a rendering texture through the GPU according to the object color identification and position information, it also includes: creating a frame buffer; sending the object color identification and position information to the GPU, and the GPU caches the object color identification and position information in the frame buffer.

[0056] Create a frame buffer to allocate a certain amount of video memory in the GPU to process the data, and send the correspondence between the object color identification and the position information to the GPU. The GPU caches the correspondence between the object color identification and the position information in the frame buffer, thereby realizing the use of a frame buffer to cache the object color identification and position information, and only needs to transmit the object color identification and position information to the GPU, thereby reducing the video memory consumption of the GPU and reducing memory consumption.

[0057] On the basis of the above technical solution, the determining the object color identification corresponding to the object color includes: encoding the object color to obtain the object color identification;

[0058] The determining of the texture color identifier corresponding to the texture color includes: encoding the texture color to obtain the texture color identifier.

[0059] When determining the object color identification, the object color of the RGB channel is encoded based on the preset encoding rule to obtain the object color identification. When determining the texture color identification, the texture color of the RGB channel is encoded based on the same preset encoding rule to obtain the texture color identification.

[0060] By determining the object color identification and texture color identification in a coding-based manner, there is no need to pre-store the corresponding relationship between color and color identification, and it can be directly encoded to save storage space. Moreover, since there are many color values, the color identification can also be quickly determined through coding, thereby improving the processing speed.

[0061] Figure 2 is an overall technical architecture diagram of a method for implementing a three-dimensional scene rendering in an embodiment of the present application. Figure 2 As shown, the technical architecture mainly includes: data layer, engine layer, strategy layer, logic layer and interface layer. The data layer is processed by the data processing module, the engine layer is processed by the rendering engine module, the strategy layer is processed by the rendering strategy module, the logic layer is processed by the logic scheduling module, and the interface layer is processed by the user interface module. Among them, the data processing module is used to process the data input by the user, and different algorithms are used to process the user data according to different statistical results. The rendering engine module is used to render the three-dimensional scene, such as executing the above steps of generating rendering textures and the steps of realizing three-dimensional rendering by illumination calculation. It is mainly based on the WebGL solution. The rendering engine encapsulates the WebGL underlying interface, shields the differences between multiple versions of WebGL, and unifies the use of the upper layer. It can use the most efficient underlying interface based on the comprehensive performance and availability of factors such as the specific version supported by the browser, communicate with the browser, and avoid the complicated adaptation and debugging work of the upper layer. The rendering strategy module is used to implement different rendering strategies based on the display effect and the amount of user data, comprehensive performance availability, and the interface encapsulated by the rendering engine to obtain efficient performance. The logic scheduling module is used to combine and encapsulate the internal rendering engine module and data processing module, and provide a friendly interface for users to use. The user interface module is used to provide an interface to obtain data input by the user, such as obtaining object data and light source information in the three-dimensional scene to be rendered.

[0062] Through practice, when there are 2600 light sources in the three-dimensional scene to be rendered, the three-dimensional scene rendering method in the embodiment of the present application is used for rendering, and the FPS (Frames Per Second) can still be maintained at around 25-35, thereby reducing the consumption of memory and video memory, improving the rendering processing efficiency, and achieving the effect of making the rendering of three-dimensional scenes under multiple light sources smoother.

[0063] Embodiment 2

[0064] This embodiment provides a three-dimensional scene rendering device, such as Figure 3 As shown, the three-dimensional scene rendering device 300 includes:

[0065] The scene data acquisition module 310 is used to acquire object data and light source information in the three-dimensional scene to be rendered, wherein the object data includes attribute information of the object, and the attribute information includes object color and position information;

[0066] An object color identification determination module 320 is used to determine an object color identification corresponding to the color of the object;

[0067] A rendering texture generation module 330, configured to generate a rendering texture according to the color identification and position information of the object through a GPU;

[0068] A data sending module 340, configured to send the attribute information, the object color identifier and the light source information to the GPU;

[0069] A texture color identifier determination module 350, configured to determine, through the GPU, a texture color corresponding to a target screen position according to the rendered texture, and determine a texture color identifier corresponding to the texture color;

[0070] The rendering module 360 ​​is used to perform lighting calculation on the object corresponding to the target screen position according to the light source information and the attribute information through the GPU based on the comparison result of the object color identifier and the texture color identifier, obtain a three-dimensional rendering result, and output the three-dimensional rendering result.

[0071] Optionally, the device further comprises:

[0072] A frame buffer creation module, used to create a frame buffer;

[0073] The color position sending module is used to send the object color identification and position information to the GPU, and the GPU caches the object color identification and position information in the frame buffer.

[0074] Optionally, the rendering texture generation module includes:

[0075] A depth test unit, configured to perform a depth test on the position information through the GPU, and decode the object color identifier into the color value;

[0076] A rendering texture generating unit is used to generate the rendering texture according to the depth test result and the color value through the GPU.

[0077] Optionally, the object data also includes geometric information of the object, and the attribute information also includes a normal vector.

[0078] Optionally, the rendering module is specifically used for:

[0079] If the object color identifier and the texture color identifier are the same, the GPU performs illumination calculation on the geometric information and texture color of the object corresponding to the target screen position according to the light source information and the attribute information to obtain a three-dimensional rendering result;

[0080] If the object color identifier and the texture color identifier are different, a preset color is assigned to the target screen position by the GPU to obtain a three-dimensional rendering result.

[0081] Optionally, the texture color identification determination module includes:

[0082] A texture color acquisition unit is used to read the texture color corresponding to the target screen position in the rendering texture using a fragment shader through the GPU.

[0083] Optionally, the object color identification determination module is specifically used to:

[0084] Encoding the color of the object to obtain a color identifier of the object;

[0085] The texture color identification determination module comprises:

[0086] The texture color identification determination unit is used to encode the texture color to obtain a texture color identification.

[0087] The three-dimensional scene rendering device provided in the embodiment of the present application is used to implement the various steps of the three-dimensional scene rendering method described in the first embodiment of the present application. The specific implementation methods of each module of the device refer to the corresponding steps and will not be repeated here.

[0088] The three-dimensional scene rendering device provided by the embodiment of the present application obtains the object data and light source information in the three-dimensional scene to be rendered, determines the object color identifier corresponding to the object color, generates a rendering texture according to the object color identifier and position information through the GPU to achieve the first drawing, and then sends the attribute information, the object color identifier and the light source information to the GPU, determines the texture color corresponding to the target screen position according to the rendering texture through the GPU, and determines the texture color identifier corresponding to the texture color, and based on the comparison result of the object color identifier and the texture color identifier, performs illumination calculation on the object corresponding to the target screen position according to the light source information and the attribute information through the GPU to obtain the three-dimensional rendering result, and outputs the three-dimensional rendering result, thereby achieving the second drawing. Since the GPU only needs to generate the rendering texture according to the object color identifier and the position information, that is, when drawing for the first time, three frame buffers are not needed, thereby reducing the consumption of memory and video memory, and when drawing for the second time, one rendering texture can be read for drawing, thereby reducing the GPU bandwidth consumption. Compared with the solution of using three frame buffers, about 75% of memory and video memory can be saved, and about 75% of the bandwidth overhead of GPU reading data can be reduced, and it can be applied to devices that do not support multi-frame buffer output.

[0089] Embodiment 3

[0090] The present application also provides an electronic device, such as Figure 4 As shown, the electronic device 400 may include one or more processors 410 and one or more memories 420 connected to the processor 410. The electronic device 400 may also include an input interface 430 and an output interface 440 for communicating with another device or system. The program code executed by the processor 410 may be stored in the memory 420.

[0091] The processor 410 in the electronic device 400 calls the program code stored in the memory 420 to execute the three-dimensional scene rendering method in the above embodiment.

[0092] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the three-dimensional scene rendering method as described in the first embodiment of the present application are implemented.

[0093] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0094] The above is a detailed introduction to a three-dimensional scene rendering method, device, electronic device and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.

[0095] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

Claims

1. A three-dimensional scene rendering method, characterized in that: include: Obtaining object data and light source information in a three-dimensional scene to be rendered, wherein the object data includes attribute information of the object, and the attribute information includes object color and position information; Determining an object color identifier corresponding to the object color; Generate a rendering texture according to the color identification and position information of the object through the GPU; Sending the attribute information, the object color identifier, and the light source information to the GPU; Determining, by the GPU, a texture color corresponding to a target screen position according to the rendered texture, and determining a texture color identifier corresponding to the texture color; Based on the comparison result of the object color identifier and the texture color identifier, the GPU performs illumination calculation on the object corresponding to the target screen position according to the light source information and the attribute information to obtain a three-dimensional rendering result, and outputs the three-dimensional rendering result; Wherein, based on the comparison result of the object color identifier and the texture color identifier, the GPU performs illumination calculation on the object corresponding to the target screen position according to the light source information and the attribute information to obtain a three-dimensional rendering result, including: If the object color identifier and the texture color identifier are the same, the GPU performs illumination calculation on the geometric information and texture color of the object corresponding to the target screen position according to the light source information and the attribute information to obtain a three-dimensional rendering result; If the object color identifier and the texture color identifier are different, a preset color is assigned to the target screen position by the GPU to obtain a three-dimensional rendering result.

2. The method according to claim 1, characterized in that Before generating a rendering texture according to the color identifier and position information of the object through the GPU, the method further includes: Create a framebuffer; The object color identification and position information are sent to the GPU, and the GPU caches the object color identification and position information in the frame buffer.

3. The method according to claim 1, characterized in that The step of generating a rendering texture according to the color identifier and position information of the object by using a GPU includes: Performing a depth test on the position information by the GPU, and decoding the object color identifier into a color value; The rendering texture is generated by the GPU according to the depth test result and the color value.

4. The method according to claim 1, characterized in that The object data also includes geometric information of the object, and the attribute information also includes a normal vector.

5. The method according to claim 1, characterized in that Determining, by the GPU, a texture color corresponding to a target screen position according to the rendered texture, comprising: The GPU uses a fragment shader to read a texture color corresponding to the target screen position in the rendering texture.

6. The method according to claim 1, characterized in that The determining the object color identifier corresponding to the object color includes: Encoding the color of the object to obtain a color identifier of the object; The step of determining a texture color identifier corresponding to the texture color includes: The texture color is encoded to obtain a texture color identifier.

7. A three-dimensional scene rendering device, characterized in that: include: A scene data acquisition module, used to acquire object data and light source information in a three-dimensional scene to be rendered, wherein the object data includes attribute information of the object, and the attribute information includes object color and position information; An object color identification determination module, used to determine the object color identification corresponding to the object color; A rendering texture generation module, used to generate a rendering texture according to the color identification and position information of the object through a GPU; A data sending module, used for sending the attribute information, the object color identification and the light source information to the GPU; A texture color identifier determination module, used to determine the texture color corresponding to the target screen position according to the rendered texture through the GPU, and determine the texture color identifier corresponding to the texture color; A rendering module, configured to perform illumination calculation on the object corresponding to the target screen position according to the light source information and the attribute information through the GPU based on the comparison result of the object color identifier and the texture color identifier, obtain a three-dimensional rendering result, and output the three-dimensional rendering result; Wherein, the rendering module is specifically used for: If the object color identifier and the texture color identifier are the same, the GPU performs illumination calculation on the geometric information and texture color of the object corresponding to the target screen position according to the light source information and the attribute information to obtain a three-dimensional rendering result; If the object color identifier and the texture color identifier are different, a preset color is assigned to the target screen position by the GPU to obtain a three-dimensional rendering result.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the three-dimensional scene rendering method described in any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the three-dimensional scene rendering method described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Object rendering method and device, storage medium and electronic device

    CN108564646A

  • Image rendering method and device, computer equipment and storage medium

    CN112381918A