Lighting rendering method and device, electronic equipment and storage medium
By generating target lighting data and using scene light sources to render target object models, the problem of mutual interference between light sources of character models is solved, improving rendering effects and game smoothness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING ZITIAO NETWORK TECH CO LTD
- Filing Date
- 2022-11-29
- Publication Date
- 2026-07-24
AI Technical Summary
In 3D games, the interplay of lighting between character models can lead to poor visual presentation and increase the computational burden on the rendering pipeline, affecting game smoothness.
By acquiring the initial lighting data of the target object model and combining it with the current position and lens information of the virtual camera, target lighting data is generated, avoiding the need to set a separate light source for each model and utilizing scene light sources for lighting rendering.
Independent lighting effects for character models were implemented, reducing the computational burden on the rendering pipeline and improving rendering quality and game smoothness.
Smart Images

Figure CN115761105B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of rendering technology, and more specifically, to a lighting rendering method, apparatus, electronic device, and storage medium. Background Technology
[0002] With the continuous development of computer technology, 3D games have become mainstream in the market, and people are placing higher demands on the visual effects of games while enjoying them. In related technologies, to enhance the visual effects of each character in the game, in addition to using scene lighting during the rendering process, a separate light source is set for each character's model.
[0003] However, while this method can improve the rendering effect of each character model, because each character model corresponds to a separate light, when different character models are close together, the lights between them will interfere with each other, thus affecting the overall visual presentation. Furthermore, the increased number of lights increases the computational burden on the rendering pipeline during the rendering process, thereby affecting the smoothness of the game. Summary of the Invention
[0004] This disclosure provides at least one lighting rendering method, apparatus, electronic device, and storage medium, which can improve the rendering effect of cartoon-style rendering.
[0005] This disclosure provides a lighting rendering method, including:
[0006] Obtain the initial lighting data of the model corresponding to the target object model. The initial lighting data of the model is generated by the user in advance.
[0007] The current position information of the target object model in the target scene and the current lens information of the virtual camera are obtained, and the initial lighting data of the model is processed based on the current position information and the current lens information to obtain the target lighting data of the model.
[0008] Based on the target lighting data of the model and the initial lighting data of the model, the first lighting information corresponding to the target object model is generated;
[0009] Obtain the second lighting information of the scene light source of the target scene, and perform lighting rendering on the target object model based on the first lighting information and the second lighting information.
[0010] In this embodiment, since the first lighting information corresponding to the target object model is generated from the user-preconfigured initial lighting data of the model, there is no need to set a separate light source for the target object model. This allows for individual lighting effects on the target object model, preventing interference between different models when they are close together, thus improving the model rendering effect. Furthermore, since the initial lighting data can be shared between models, some data only needs to be calculated once during the generation of the first lighting information for each model. This reduces the computational burden on the rendering pipeline, meaning that the rendering effect can be improved while maintaining the smoothness of the rendered image.
[0011] In one possible implementation, the initial lighting data of the model includes initial lighting direction data and initial lighting position data; the step of processing the initial lighting data of the model based on the current position information and the current camera information to obtain the target lighting data of the model includes:
[0012] Based on the current lens orientation information of the virtual camera, the initial illumination direction data is processed to obtain the target illumination direction data;
[0013] Based on the target illumination direction data, the current position information of the target object model, and the initial illumination position data, the target illumination position data is determined;
[0014] Based on the target illumination direction data and the target illumination position data, the model target illumination data is obtained.
[0015] In this embodiment of the disclosure, the initial lighting direction data is processed using the current lens orientation information of the virtual camera, and the initial lighting position data is adjusted using the current position information of the target object model. This ensures that the adjusted lighting direction is relative to the virtual camera and the adjusted lighting position is relative to the target object model, rather than relative to the scene. Furthermore, since each model's rendering shader only receives the initial lighting data and target lighting data corresponding to the model itself, and generates the first lighting information corresponding to the model itself without involving other models, it can be guaranteed that the lighting between different models will not affect each other when they are close to each other.
[0016] In one possible implementation, the initial illumination direction data is represented as a unit vector direction relative to the virtual camera, and the processing of the initial illumination direction data based on the current lens orientation information of the virtual camera to obtain target illumination direction data includes:
[0017] Based on the current lens orientation information of the virtual camera, determine the current orientation information of the unit vector direction in the camera space;
[0018] Based on the world space transformation matrix of the virtual camera, the current direction information of the unit vector direction in the camera space is transformed into world space to obtain the illumination direction data in the world space, and the illumination direction data in the world space is used as the target illumination direction data.
[0019] In this embodiment of the disclosure, since the initial illumination direction data is represented by a unit vector direction relative to the virtual camera, after obtaining the current lens orientation information of the virtual camera, the current direction information of the unit vector direction in the camera space can be determined. Then, through the world space transformation matrix of the virtual camera, the illumination direction data in the world space can be determined, and the target illumination direction data can be obtained. In this way, the efficiency of determining the target illumination direction data can be improved.
[0020] In one possible implementation, the initial illumination position data is represented by a preset distance relative to the virtual camera, and determining the target illumination position data based on the target illumination direction data, the current position information of the target object model, and the initial illumination position data includes:
[0021] According to the direction indicated by the target illumination direction data, the current position information of the target object model is used as the starting point and offset by the preset distance to obtain the illumination position data in the world space, and the illumination position data in the world space is used as the target illumination position data.
[0022] In this embodiment, since the initial illumination position data is represented by a preset distance relative to the virtual camera, after obtaining the target illumination direction data, the world space illumination position data can be obtained by offsetting the preset distance from the current position information of the target object model, according to the direction indicated by the target illumination direction data. This improves the efficiency of determining the target illumination position data.
[0023] In one possible implementation, the initial lighting data of the model further includes initial lighting color data and initial lighting intensity data; the step of generating first lighting information corresponding to the target object model based on the target lighting data of the model and the initial lighting data of the model includes:
[0024] Based on the current position information of the target object model and the target illumination position data, the initial illumination intensity is processed to obtain target illumination intensity data based on the surface of the target object model;
[0025] Based on the target light intensity data, the initial light color data, and the target light direction data, the first lighting information corresponding to the target object model is generated.
[0026] In this embodiment of the disclosure, the processed target light intensity data, target light direction data, and initial light color data are combined to generate the corresponding first lighting information of the target object model, thereby realizing the lighting effect of the light source corresponding to the target object model.
[0027] In one possible implementation, the step of processing the initial illumination intensity based on the current position information of the target object model and the target illumination position data to obtain target illumination intensity data based on the surface of the target object model includes:
[0028] Based on the current position information of the target object model and the target illumination position data, determine the distance between the target object model and the illumination position indicated by the target illumination position data;
[0029] Based on the distance between the target object model and the illumination position, the linear attenuation amount of the initial illumination intensity is determined;
[0030] The initial illumination intensity is processed according to the linear attenuation amount to obtain the target illumination intensity.
[0031] In this embodiment of the disclosure, by attenuating the initial light intensity, the light intensity received by the target object model can be made closer to the real lighting effect, thereby further improving the rendering effect of the model.
[0032] In one possible implementation, the step of performing lighting rendering on the target object model based on the first lighting information and the second lighting information includes:
[0033] Based on the first lighting information, the target object model is rendered using first lighting to obtain the first lighting rendering result.
[0034] Based on the second lighting information, the target object model is rendered using second lighting to obtain the second lighting rendering result.
[0035] The first lighting rendering result is fused with the second lighting rendering result to obtain the lighting rendering result of the target object model.
[0036] In this embodiment of the disclosure, the target object model is rendered separately using the first lighting information and the second lighting information, and the results of the separate renderings are merged to achieve the independent rendering effect of the model in the scene, thereby improving the overall rendering effect of multiple models in the scene.
[0037] This disclosure provides a lighting rendering apparatus, including:
[0038] The data acquisition module is used to acquire the initial lighting data of the model corresponding to the target object model. The initial lighting data of the model is generated by the user in advance.
[0039] The data processing module is used to acquire the current position information of the target object model in the target scene and the current lens information of the virtual camera, and to process the initial lighting data of the model based on the current position information and the current lens information to obtain the target lighting data of the model.
[0040] The information generation module is used to generate first lighting information corresponding to the target object model based on the target lighting data of the model and the initial lighting data of the model;
[0041] The model rendering module is used to obtain the second lighting information of the scene light source of the target scene, and to perform lighting rendering on the target object model based on the first lighting information and the second lighting information.
[0042] In one possible implementation, the initial illumination data of the model includes initial illumination direction data and initial illumination position data; the data processing module is specifically used for:
[0043] Based on the current lens orientation information of the virtual camera, the initial illumination direction data is processed to obtain the target illumination direction data;
[0044] Based on the target illumination direction data, the current position information of the target object model, and the initial illumination position data, the target illumination position data is determined;
[0045] Based on the target illumination direction data and the target illumination position data, the model target illumination data is obtained.
[0046] In one possible implementation, the initial illumination direction data is represented as a unit vector direction relative to the virtual camera, and the data processing module is specifically used for:
[0047] Based on the current lens orientation information of the virtual camera, determine the current orientation information of the unit vector direction in the camera space;
[0048] Based on the world space transformation matrix of the virtual camera, the current direction information of the unit vector direction in the camera space is transformed into world space to obtain the illumination direction data in the world space, and the illumination direction data in the world space is used as the target illumination direction data.
[0049] In one possible implementation, the initial illumination position data is represented by a preset distance relative to the virtual camera, and the data processing module is specifically used for:
[0050] According to the direction indicated by the target illumination direction data, the current position information of the target object model is used as the starting point and offset by the preset distance to obtain the illumination position data in the world space, and the illumination position data in the world space is used as the target illumination position data.
[0051] In one possible implementation, the initial lighting data of the model further includes initial lighting color data and initial lighting intensity data; the information generation module is specifically used for:
[0052] Based on the current position information of the target object model and the target illumination position data, the initial illumination intensity is processed to obtain target illumination intensity data based on the surface of the target object model;
[0053] Based on the target light intensity data, the initial light color data, and the target light direction data, the first lighting information corresponding to the target object model is generated.
[0054] In one possible implementation, the information generation module is specifically used for:
[0055] Based on the current position information of the target object model and the target illumination position data, determine the distance between the target object model and the illumination position indicated by the target illumination position data;
[0056] Based on the distance between the target object model and the illumination position, the linear attenuation amount of the initial illumination intensity is determined;
[0057] The initial illumination intensity is processed according to the linear attenuation amount to obtain the target illumination intensity.
[0058] In one possible implementation, the model rendering module is specifically used for:
[0059] Based on the first lighting information, the target object model is rendered using first lighting to obtain the first lighting rendering result.
[0060] Based on the second lighting information, the target object model is rendered using second lighting to obtain the second lighting rendering result.
[0061] The first lighting rendering result is fused with the second lighting rendering result to obtain the lighting rendering result of the target object model.
[0062] This disclosure provides an electronic device, including a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the lighting rendering method described in any of the above embodiments is executed.
[0063] This disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the lighting rendering method described in any of the above embodiments.
[0064] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0065] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.
[0066] Figure 1 A flowchart of a lighting rendering method provided in some embodiments of this disclosure is shown;
[0067] Figure 2 A flowchart illustrating a method for processing initial lighting data of a model according to some embodiments of this disclosure is shown.
[0068] Figure 3 This diagram illustrates a method for rendering a target object model based on lighting information, according to some embodiments of the present disclosure.
[0069] Figure 4 A schematic diagram of the structure of a lighting rendering apparatus provided in some embodiments of this disclosure is shown;
[0070] Figure 5 A schematic diagram of an electronic device provided in some embodiments of the present disclosure is shown. Detailed Implementation
[0071] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.
[0072] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0073] In this document, the term "and / or" merely describes a relationship, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Furthermore, the term "at least one" in this document means any combination of at least two of any one or more elements. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0074] Online games are popular due to their high realism, visual appeal, and engaging gameplay. Research has found that to meet users' demands for enhanced visual effects, rendering typically involves using scene lighting and assigning a separate light source to each character model. While this method effectively highlights the dynamic visual effects of characters within the scene, the individual lighting on each model can interfere with each other when they are close together, affecting the overall visual presentation. Furthermore, the increased number of lights increases the computational burden on the rendering pipeline, leading to higher performance costs and impacting game smoothness.
[0075] Based on the above research, this disclosure provides a lighting rendering method. First, initial lighting data of the model corresponding to the target object model is obtained, which is generated by the user in advance. Then, the current position information of the target object model in the target scene and the current lens information of the virtual camera are obtained, and the initial lighting data of the model is processed based on the current position information and the current lens information to obtain target lighting data of the model. Next, based on the target lighting data of the model and the initial lighting data of the model, first lighting information corresponding to the target object model is generated. Finally, second lighting information of the scene light source of the target scene is obtained, and the target object model is rendered based on the first lighting information and the second lighting information.
[0076] In this embodiment, since the first lighting information corresponding to the target object model is generated from the user-preconfigured initial lighting data of the model, there is no need to set a separate light source for the target object model. This allows for individual lighting effects on the target object model, preventing interference between different models when they are close together, thus improving the model rendering effect. Furthermore, since the initial lighting data can be shared between models, some data only needs to be calculated once during the generation of the first lighting information for each model. This reduces the computational burden on the rendering pipeline, meaning that the rendering effect can be improved while maintaining the smoothness of the rendered image.
[0077] To facilitate understanding of this embodiment, the executing entity of the lighting rendering method provided in this disclosure will first be described in detail. The executing entity of the lighting rendering method provided in this disclosure is an electronic device. This electronic device can be a terminal device or a server. Specifically, the terminal device can be a mobile device, a user terminal, a terminal, a handheld device, a computing device, an in-vehicle device, a wearable device, etc. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data, and artificial intelligence platforms. In other embodiments, the lighting rendering method can also be implemented by a processor calling computer-readable instructions stored in memory.
[0078] The lighting rendering method provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings. See also Figure 1 The diagram shows a flowchart of a lighting rendering method provided in an embodiment of this disclosure. The lighting rendering method includes the following steps S101 to S104:
[0079] S101, Obtain the initial lighting data of the model corresponding to the target object model, wherein the initial lighting data of the model is generated by the user in advance.
[0080] For example, the target object can be a virtual object in a virtual scene. A virtual object refers to something in a virtual scene, including but not limited to at least one of virtual characters, animals, plants, furniture, or buildings. In this embodiment of the disclosure, the target object is a controllable dynamic object in a virtual scene.
[0081] Virtual scenes, as we understand them, refer to digitized scenes created by computers using digital communication technology. These include two-dimensional and three-dimensional virtual scenes, which can use virtualization technology to realistically simulate various material forms and spatial relationships in the real world. Three-dimensional virtual scenes, in particular, can more aesthetically pleasingly display the forms of objects and provide a more intuitive representation of the virtual reality world. For example, objects in a three-dimensional virtual scene can include at least one of the following: terrain, buildings, trees, and people.
[0082] Virtual scenes can be displayed using computer 3D graphics, showcasing a 3D simulation environment on a screen. All target objects within the virtual scene can be described using 3D scene data. For example, 3D scene data can be loaded into a 3D scene to display a 3D simulation environment. This 3D scene data can include at least one of the following: model data, texture data, lighting data, terrain data, and raster data.
[0083] In this embodiment, the virtual scene is a scene used by players to control target objects to complete game logic. The virtual scene can be a simulation of the real world, a semi-simulated / semi-fictional virtual environment, or a purely fictional virtual environment. The virtual environment can be sky, land, ocean, etc., where the land includes environmental elements such as deserts and cities.
[0084] Furthermore, in this embodiment, the lighting data includes not only scene light sources but also initial lighting data for each model, which is pre-configured and generated by the user. For example, the user can configure the corresponding initial lighting data for each model in an Excel spreadsheet, and then import the data into the corresponding project when needed.
[0085] Optionally, the initial illumination data of the model includes initial illumination direction data, initial illumination position data, initial illumination color data, and initial illumination intensity data, etc.
[0086] It is understandable that before rendering the target object model, it is necessary to obtain the scene file for building the 3D model, build a virtual scene based on the scene file, and then display and process the target object model in the virtual scene.
[0087] It should be noted that, in this embodiment of the invention, when processing the three-dimensional model, a three-dimensional model design tool can be used to establish the model first, and then a three-dimensional model development tool can be used to further process the model to finally obtain the required three-dimensional model.
[0088] Furthermore, after establishing the 3D model of the target object, the 3D model can be exported for further model processing by 3D model development tools. This embodiment of the invention mainly describes the process of rendering the 3D model during gameplay after its establishment.
[0089] S102, obtain the current position information of the target object model in the target scene and the current lens information of the virtual camera, and process the initial lighting data of the model based on the current position information and the current lens information to obtain the target lighting data of the model.
[0090] The target scene can be the aforementioned virtual scene. It can be understood that since the target object is a dynamically controlled object within the virtual scene, its position within the virtual scene will change. The lighting effects received by the target object in the virtual scene will differ depending on its position; that is, when the light source in the virtual scene changes, the ambient lighting effects in the virtual scene will also change accordingly. Furthermore, as the position of the virtual object changes, the visual content displayed on the screen will also differ.
[0091] Therefore, in some embodiments, it is necessary to obtain the current position information of the target object model in the target scene and the current lens information of the virtual camera, and process the initial lighting data of the model based on the current position information and the current lens information to obtain the target lighting data of the model, so that the target lighting data matches the current state of the target object model.
[0092] For example, the initial lighting direction data and initial lighting position data in the initial lighting data of the model can be processed based on the current position information and the current lens information to obtain the model target lighting data relative to the model and the virtual camera.
[0093] In one possible implementation, see Figure 2 As shown, for step S102, when processing the initial illumination data of the model based on the current position information and the current camera information to obtain the target illumination data of the model, the following steps S1021 to S1023 may be included:
[0094] S1021, Based on the current lens orientation information of the virtual camera, the initial illumination direction data is processed to obtain the target illumination direction data.
[0095] It is understandable that, since the initial lighting direction data is in camera space, it needs to be processed to obtain world space lighting direction data for subsequent lighting rendering. In some embodiments, the initial lighting direction data can be represented as a unit vector direction relative to the virtual camera. Therefore, upon obtaining the current lens orientation information of the virtual camera, the current direction information of the unit vector direction in camera space can be determined. Then, according to the world space transformation matrix of the virtual camera, the current direction information of the unit vector direction in camera space is transformed to world space to obtain the lighting direction data in world space, and this world space lighting direction data is used as the target lighting direction data. This improves the efficiency of determining the target lighting direction data.
[0096] S1022, Determine the target illumination position data based on the target illumination direction data, the current position information of the target object model, and the initial illumination position data.
[0097] For example, the initial illumination position data is represented by a preset distance relative to the virtual camera. Therefore, after obtaining the target illumination direction data, the world space illumination position data can be obtained by offsetting the preset distance from the current position information of the target object model, according to the direction indicated by the target illumination direction data, and then using the world space illumination position data as the target illumination position data. This improves the efficiency of determining the target illumination position data. In this embodiment, the initial illumination position data is an offset value in world space.
[0098] S1023, Based on the target illumination direction data and the target illumination position data, the model target illumination data is obtained.
[0099] It is understandable that once the illumination direction data and illumination position data in world space are obtained, the illumination data of the model target can be generated.
[0100] In this embodiment of the disclosure, the initial lighting direction data is processed using the current lens orientation information of the virtual camera, and the initial lighting position data is adjusted using the current position information of the target object model. This ensures that the adjusted lighting direction is relative to the virtual camera and the adjusted lighting position is relative to the target object model, rather than relative to the scene. Furthermore, since each model's rendering shader only receives the initial lighting data and target lighting data corresponding to the model itself, and generates the first lighting information corresponding to the model itself without involving other models, it can be guaranteed that the lighting between different models will not affect each other when they are close to each other.
[0101] S103, Based on the target lighting data of the model and the initial lighting data of the model, generate the first lighting information corresponding to the target object model.
[0102] It is understood that the initial lighting data of the model includes not only initial lighting direction data and initial lighting position data, but also initial lighting color data and initial lighting intensity data. The initial lighting direction data and initial lighting position data, after the aforementioned processing, yield the target lighting direction data and the target lighting position data. Therefore, combining the target lighting direction data, the target lighting position data, the initial lighting color data, and the initial lighting intensity data yields the simulated light source corresponding to the target object model. It should be noted that this simulated light source is only for this target object model and will not affect other models.
[0103] However, since there is a distance between the simulated light source and the target object model, in order to improve the realism of the lighting, the initial light intensity needs to be processed based on the current position information of the target object model and the target light position data to obtain target light intensity data based on the surface of the target object model. Then, the target light direction data, target light position data and target light intensity data are combined to obtain the first lighting information corresponding to the target object model.
[0104] In one possible implementation, the rendering shader can determine the linear attenuation of the initial illumination intensity based on the distance from the target object model surface to the illumination position, thereby obtaining the target light intensity received by the model surface. That is, the rendering shader can first determine the distance between the target object model and the illumination position indicated by the target illumination position data based on the current position information of the target object model and the target illumination position data; then, based on the distance between the target object model and the illumination position, determine the linear attenuation of the initial illumination intensity; and finally, process the initial illumination intensity according to the linear attenuation to obtain the target illumination intensity.
[0105] S104, obtain the second lighting information of the scene light source of the target scene, and perform lighting rendering on the target object model based on the first lighting information and the second lighting information.
[0106] In computer graphics, rendering refers to the process of projecting various object models in a 3D scene into a 2D digital image according to predefined environment, materials, lighting, and rendering parameters. Lighting rendering specifically refers to the lighting calculations performed on the target object model during the rendering process, so that the pixels on the surface of the target object model have lighting effects.
[0107] In a virtual scene, a light source is a series of lighting data that realistically simulates the lighting effects of real-world light sources. Similar to real-world light sources, when a colored light source in a virtual scene is projected onto the surface of a colored object, the final rendered color depends on the reflection and absorption of the light. However, unlike real-world light sources, virtual light sources can be virtual light source nodes without shape or outline. In contrast, real-world light sources refer to objects that emit their own light and are currently emitting light, such as the sun, electric lights, and burning materials.
[0108] In some possible embodiments, the target object model can be rendered simultaneously based on the first and second lighting information to obtain a lighting rendering result. In other possible embodiments, see... Figure 3 As shown, when performing lighting rendering on the target object model based on the first lighting information and the second lighting information, the following steps S1041 to S1043 may also be included:
[0109] S1041, Perform first lighting rendering on the target object model based on the first lighting information to obtain the first lighting rendering result.
[0110] S1042, perform second lighting rendering on the target object model based on the second lighting information to obtain the second lighting rendering result.
[0111] S1043, the first lighting rendering result and the second lighting rendering result are fused to obtain the lighting rendering result of the target object model.
[0112] In this embodiment of the disclosure, the target object model is rendered separately using the first lighting information and the second lighting information, and the results of the separate renderings are merged to achieve the independent rendering effect of the model in the scene, thereby improving the overall rendering effect of multiple models in the scene.
[0113] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0114] Based on the same technical concept, this disclosure also provides a lighting rendering apparatus corresponding to the lighting rendering method. Since the principle of the apparatus in this disclosure for solving the problem is similar to the lighting rendering method described above in this disclosure, the implementation of the apparatus can refer to the implementation of the method, and the repeated parts will not be described again.
[0115] Reference Figure 4 The diagram shown is a schematic representation of a lighting rendering apparatus 400 provided in an embodiment of this disclosure. The apparatus includes:
[0116] Data acquisition module 401 is used to acquire the initial lighting data of the model corresponding to the target object model, wherein the initial lighting data of the model is generated by the user in advance;
[0117] The data processing module 402 is used to acquire the current position information of the target object model in the target scene and the current lens information of the virtual camera, and to process the initial lighting data of the model based on the current position information and the current lens information to obtain the target lighting data of the model.
[0118] The information generation module 403 is used to generate first lighting information corresponding to the target object model based on the target lighting data of the model and the initial lighting data of the model;
[0119] The model rendering module 404 is used to obtain the second lighting information of the scene light source of the target scene, and to perform lighting rendering on the target object model based on the first lighting information and the second lighting information.
[0120] In one possible implementation, the initial illumination data of the model includes initial illumination direction data and initial illumination position data; the data processing module 402 is specifically used for:
[0121] Based on the current lens orientation information of the virtual camera, the initial illumination direction data is processed to obtain the target illumination direction data;
[0122] Based on the target illumination direction data, the current position information of the target object model, and the initial illumination position data, the target illumination position data is determined;
[0123] Based on the target illumination direction data and the target illumination position data, the model target illumination data is obtained.
[0124] In one possible implementation, the initial illumination direction data is represented as a unit vector direction relative to the virtual camera, and the data processing module 402 is specifically used for:
[0125] Based on the current lens orientation information of the virtual camera, determine the current orientation information of the unit vector direction in the camera space;
[0126] Based on the world space transformation matrix of the virtual camera, the current direction information of the unit vector direction in the camera space is transformed into world space to obtain the illumination direction data in the world space, and the illumination direction data in the world space is used as the target illumination direction data.
[0127] In one possible implementation, the initial illumination position data is represented by a preset distance relative to the virtual camera, and the data processing module 402 is specifically used for:
[0128] According to the direction indicated by the target illumination direction data, the current position information of the target object model is used as the starting point and offset by the preset distance to obtain the illumination position data in the world space, and the illumination position data in the world space is used as the target illumination position data.
[0129] In one possible implementation, the initial lighting data of the model further includes initial lighting color data and initial lighting intensity data; the information generation module 403 is specifically used for:
[0130] Based on the current position information of the target object model and the target illumination position data, the initial illumination intensity is processed to obtain target illumination intensity data based on the surface of the target object model;
[0131] Based on the target light intensity data, the initial light color data, and the target light direction data, the first lighting information corresponding to the target object model is generated.
[0132] In one possible implementation, the information generation module 403 is specifically used for:
[0133] Based on the current position information of the target object model and the target illumination position data, determine the distance between the target object model and the illumination position indicated by the target illumination position data;
[0134] Based on the distance between the target object model and the illumination position, the linear attenuation amount of the initial illumination intensity is determined;
[0135] The initial illumination intensity is processed according to the linear attenuation amount to obtain the target illumination intensity.
[0136] In one possible implementation, the model rendering module 404 is specifically used for:
[0137] Based on the first lighting information, the target object model is rendered using first lighting to obtain the first lighting rendering result.
[0138] Based on the second lighting information, the target object model is rendered using second lighting to obtain the second lighting rendering result.
[0139] The first lighting rendering result is fused with the second lighting rendering result to obtain the lighting rendering result of the target object model.
[0140] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0141] Based on the same technical concept, this disclosure also provides an electronic device. (See also...) Figure 5 The diagram shown is a structural schematic of an electronic device 500 provided in an embodiment of this disclosure, including a processor 501, a memory 502, and a bus 503. The memory 502 is used to store execution instructions and includes a main memory 5021 and an external memory 5022. The main memory 5021, also called internal memory, is used to temporarily store computational data in the processor 501, as well as data exchanged with external memory 5022 such as a hard disk. The processor 501 exchanges data with the external memory 5022 through the main memory 5021.
[0142] In this embodiment, the memory 502 is specifically used to store application code that executes the solution of this application, and its execution is controlled by the processor 501. That is, when the electronic device 500 is running, the processor 501 communicates with the memory 502 through the bus 503, so that the processor 501 executes the application code stored in the memory 502, and then executes the method described in any of the foregoing embodiments.
[0143] The memory 502 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0144] Processor 501 may be an integrated circuit chip with signal processing capabilities. The aforementioned processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor.
[0145] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 500. In other embodiments of this application, the electronic device 500 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0146] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the lighting rendering method described in the above method embodiments. The storage medium can be either volatile or non-volatile computer-readable storage.
[0147] This disclosure also provides a computer program product carrying program code. The program code includes instructions that can be used to execute the steps of the lighting rendering method in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0148] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0149] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0150] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0151] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0152] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.
[0153] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.
Claims
1. A lighting rendering method, characterized in that, include: Obtain the initial lighting data of the model corresponding to the target object model. The initial lighting data of the model is generated by the user in advance. The current position information of the target object model in the target scene and the current lens information of the virtual camera are obtained, and the initial lighting data of the model is processed based on the current position information and the current lens information to obtain the target lighting data of the model. Based on the target lighting data of the model and the initial lighting data of the model, the first lighting information corresponding to the target object model is generated; Obtain the second illumination information of the scene light source of the target scene, and perform illumination rendering on the target object model based on the first illumination information and the second illumination information; The initial illumination data of the model includes initial illumination direction data and initial illumination position data; The step of processing the initial illumination data of the model based on the current position information and the current camera information to obtain the target illumination data of the model includes: Based on the current lens orientation information of the virtual camera, the initial illumination direction data is processed to obtain the target illumination direction data; Based on the target illumination direction data, the current position information of the target object model, and the initial illumination position data, the target illumination position data is determined; and Based on the target illumination direction data and the target illumination position data, the model target illumination data is obtained.
2. The method according to claim 1, characterized in that, The initial illumination direction data is represented as a unit vector direction relative to the virtual camera. The process of processing the initial illumination direction data based on the current lens orientation information of the virtual camera to obtain the target illumination direction data includes: Based on the current lens orientation information of the virtual camera, determine the current orientation information of the unit vector direction in the camera space; Based on the world space transformation matrix of the virtual camera, the current direction information of the unit vector direction in the camera space is transformed into world space to obtain the illumination direction data in the world space, and the illumination direction data in the world space is used as the target illumination direction data.
3. The method according to claim 1 or 2, characterized in that, The initial illumination position data is represented by a preset distance relative to the virtual camera. Determining the target illumination position data based on the target illumination direction data, the current position information of the target object model, and the initial illumination position data includes: According to the direction indicated by the target illumination direction data, the current position information of the target object model is used as the starting point and offset by the preset distance to obtain the illumination position data in the world space, and the illumination position data in the world space is used as the target illumination position data.
4. The method according to claim 1, characterized in that, The initial lighting data of the model also includes initial lighting color data and initial lighting intensity data; the step of generating the first lighting information corresponding to the target object model based on the target lighting data of the model and the initial lighting data of the model includes: Based on the current position information of the target object model and the target illumination position data, the initial illumination intensity is processed to obtain target illumination intensity data based on the surface of the target object model; Based on the target light intensity data, the initial light color data, and the target light direction data, the first lighting information corresponding to the target object model is generated.
5. The method according to claim 4, characterized in that, The step of processing the initial illumination intensity based on the current position information of the target object model and the target illumination position data to obtain target illumination intensity data based on the surface of the target object model includes: Based on the current position information of the target object model and the target illumination position data, determine the distance between the target object model and the illumination position indicated by the target illumination position data; Based on the distance between the target object model and the illumination position, the linear attenuation amount of the initial illumination intensity is determined; The initial illumination intensity is processed according to the linear attenuation amount to obtain the target illumination intensity.
6. The method according to claim 1, characterized in that, The step of rendering the target object model with lighting based on the first lighting information and the second lighting information includes: Based on the first lighting information, the target object model is rendered using first lighting to obtain the first lighting rendering result. Based on the second lighting information, the target object model is rendered using second lighting to obtain the second lighting rendering result. The first lighting rendering result is fused with the second lighting rendering result to obtain the lighting rendering result of the target object model.
7. A lighting rendering apparatus, characterized in that, include: The data acquisition module is used to acquire the initial lighting data of the model corresponding to the target object model. The initial lighting data of the model is generated by the user in advance. The data processing module is used to acquire the current position information of the target object model in the target scene and the current lens information of the virtual camera, and to process the initial lighting data of the model based on the current position information and the current lens information to obtain the target lighting data of the model. The information generation module is used to generate first lighting information corresponding to the target object model based on the target lighting data of the model and the initial lighting data of the model; The model rendering module is used to obtain the second lighting information of the scene light source of the target scene, and to perform lighting rendering on the target object model based on the first lighting information and the second lighting information; The initial illumination data of the model includes initial illumination direction data and initial illumination position data; The data processing module is further configured as follows: Based on the current lens orientation information of the virtual camera, the initial illumination direction data is processed to obtain the target illumination direction data; Based on the target illumination direction data, the current position information of the target object model, and the initial illumination position data, the target illumination position data is determined; and Based on the target illumination direction data and the target illumination position data, the model target illumination data is obtained.
8. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the lighting rendering method as described in any one of claims 1-6 is performed.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the lighting rendering method as described in any one of claims 1-6.