Model rendering method and apparatus, computer-readable storage medium, and electronic device

By defining the bounding area of ​​the virtual model and calculating the light attenuation data for lighting rendering, the problem of low lighting rendering efficiency is solved, achieving efficient hardware performance adaptation and multi-light source support, thus improving the realism and smoothness of the virtual scene.

CN116543094BActive Publication Date: 2026-11-27NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310507003.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-04
Publication Date
2026-11-27
Estimated Expiration
2043-05-04

AI Technical Summary

Technical Problem

Current lighting rendering technology has low processing efficiency, high hardware performance requirements, and is difficult to adapt to mobile devices and multi-light source application scenarios.

Method used

The model bounding area is determined by the model bounding box based on the target virtual model. Lighting attenuation data is calculated using lighting vector data, and lighting rendering is performed on the target virtual model, restricting the lighting rendering to be carried out within the model bounding area.

Benefits of technology

It improves model rendering efficiency, reduces hardware performance requirements, adapts to mobile devices and supports multi-light source application scenarios, and enhances game smoothness and the visual realism of lighting rendering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116543094B_ABST
    Figure CN116543094B_ABST
Patent Text Reader

Abstract

The present disclosure provides a model rendering method and device, a computer readable storage medium and an electronic device, and relates to the technical field of computers. The method comprises: determining a model bounding area matched with a target virtual model based on a model bounding box of the target virtual model, the model bounding area being an area wrapping the target virtual model; determining light attenuation data corresponding to a plurality of orientations on the surface of the model bounding area based on light vector data of a preset light source in a current light direction; and performing light rendering on the target virtual model based on the light attenuation data. The present disclosure limits the light rendering to the model bounding area by determining the model bounding area, which can reduce unnecessary computing overhead to a certain extent and improve the processing efficiency of model rendering, has a lower requirement for the performance of hardware, and can be better applied to multi-light source application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a model rendering method, a model rendering apparatus, a computer-readable storage medium, and an electronic device. Background Technology

[0002] To enhance the realism and atmosphere of virtual scenes, one or more virtual light sources are typically configured in the virtual scene, and the virtual scene is then rendered with lighting based on the configured virtual light sources.

[0003] In related technologies, lighting rendering is usually based on basic lighting models, such as the Phong Lighting Model or the Blinn-Phong Lighting Model. When performing lighting rendering, the light intensity and color of each pixel need to be quickly calculated on the GPU (graphics processing unit) through the shader program. The lighting rendering processing efficiency is low and the hardware performance requirements are high.

[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] This disclosure provides a model rendering method, a model rendering apparatus, a computer-readable storage medium, and an electronic device, thereby overcoming, to at least a certain extent, the problems of low efficiency in lighting rendering and high hardware performance requirements in related technologies.

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

[0007] According to a first aspect of this disclosure, a model rendering method is provided, the method comprising: determining a model bounding region matching the target virtual model based on a model bounding box of the target virtual model, the model bounding region being the area enclosing the target virtual model; determining illumination attenuation data corresponding to multiple orientations on the surface of the model bounding region based on illumination vector data of a preset light source under the current illumination direction; and performing illumination rendering on the target virtual model based on the illumination attenuation data.

[0008] According to a second aspect of this disclosure, a model rendering apparatus is provided, the apparatus comprising: a bounding region determination module, configured to determine a model bounding region matching the target virtual model based on a model bounding box of the target virtual model, the model bounding region being the area enclosing the target virtual model; an attenuation determination module, configured to determine illumination attenuation data corresponding to multiple orientations on the surface of the model bounding region based on illumination vector data of a preset light source under the current illumination direction; and an illumination rendering module, configured to perform illumination rendering on the target virtual model based on the illumination attenuation data.

[0009] According to a third aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements any of the above-described model rendering methods.

[0010] According to a fourth aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform any of the above-described model rendering methods by executing the executable instructions.

[0011] The technical solution disclosed herein has the following beneficial effects:

[0012] In the above model rendering process, based on the bounding box of the target virtual model, a bounding region matching the target virtual model is determined. The bounding region is the area that encloses the target virtual model. Based on the lighting vector data of the preset light source under the current lighting direction, lighting attenuation data corresponding to multiple directions on the surface of the bounding region is determined. Based on the lighting attenuation data, lighting rendering is performed on the target virtual model. By determining the bounding region of the target virtual model, lighting rendering is restricted to the bounding region, reducing unnecessary computational overhead and lowering computational complexity. This not only improves the processing efficiency of model rendering to a certain extent and ensures the smoothness of the game, but also reduces the requirements for hardware performance, making it well-suited for mobile devices and multi-light source application scenarios.

[0013] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0014] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0015] Figure 1This diagram illustrates a model rendering method according to an exemplary embodiment.

[0016] Figure 2A An example diagram of the model bounding box corresponding to a target virtual model in this exemplary embodiment is shown;

[0017] Figure 2B This illustration shows an example diagram of a spherical enclosing region corresponding to a target virtual model in this exemplary embodiment.

[0018] Figure 2C This illustration shows a rendering example of a single-light source model in this exemplary embodiment;

[0019] Figure 2D This illustration shows a rendering example of a multi-light source model in this exemplary embodiment;

[0020] Figure 3 This diagram illustrates a flowchart of a real-time update of lighting effects in this exemplary embodiment.

[0021] Figure 4 This diagram illustrates a flowchart of adjusting the lighting details of a target virtual model in this exemplary embodiment.

[0022] Figure 5 An example diagram illustrating a color channel detail effect in this exemplary embodiment is shown;

[0023] Figure 6 This illustrates a flowchart of a lighting rendering process for a model using a model bounding region in this exemplary embodiment.

[0024] Figure 7 This diagram illustrates a structural block diagram of a model rendering apparatus according to this exemplary embodiment;

[0025] Figure 8 An electronic device for implementing the above-described model rendering method is shown in this exemplary embodiment. Detailed Implementation

[0026] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the example embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more of the specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.

[0027] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0028] In this article, "first," "second," etc., are labels for specific objects, rather than limiting the number or order of objects.

[0029] In related technologies, lighting rendering requires the shader program to quickly calculate the light intensity and color of each pixel on the GPU using a basic lighting model to achieve gradient lighting effects. This process involves a large amount of computation and rendering, resulting in low lighting rendering efficiency, high hardware performance requirements, and poor adaptability to mobile devices and multi-light source applications.

[0030] In view of one or more of the above-mentioned problems, the exemplary embodiments of this disclosure provide a model rendering method, a model rendering apparatus, a computer-readable storage medium and an electronic device, which can be deployed on smart processing devices such as mobile phones, tablets, computers, and servers, and can simultaneously perform lighting rendering on multiple light sources.

[0031] like Figure 1 The diagram illustrates a model rendering method, which may include the following steps S110 to S130:

[0032] Step S110: Based on the model bounding box of the target virtual model, determine the model bounding region that matches the target virtual model. The model bounding region is the area that encloses the target virtual model.

[0033] Step S120: Based on the illumination vector data of the preset light source under the current illumination direction, determine the illumination attenuation data corresponding to multiple orientations on the surface of the model-enclosed area;

[0034] Step S130: Perform lighting rendering on the target virtual model based on the light attenuation data.

[0035] In the above model rendering process, by determining the model bounding area of ​​the target virtual model, the lighting rendering is restricted to the model bounding area, which reduces unnecessary computational overhead and computational complexity. This not only improves the processing efficiency of model rendering to a certain extent and ensures the smoothness of the game, but also reduces the requirements for hardware performance. It can be well adapted to mobile devices and is suitable for multi-light source application scenarios.

[0036] The following is about Figure 1 Each step in the process will be explained in detail.

[0037] In step S110, based on the model bounding box of the target virtual model, a model bounding region that matches the target virtual model is determined. The model bounding region is the area that encloses the target virtual model.

[0038] The target virtual model refers to the virtual model to be rendered using lighting, and this target virtual model can be a three-dimensional virtual model. Taking a virtual scene as an example, the target virtual model can be any type of virtual model located in the virtual scene, such as virtual models of people, animals, buildings, etc.

[0039] In one optional implementation, before determining the model bounding area matching the target virtual model based on the model bounding box of the target virtual model, the target virtual model can be determined by the following steps: obtaining the virtual model to be displayed in the scene display interface; determining the scene type to which the virtual model to be displayed belongs based on the relative position information of the virtual model to be displayed in the scene display interface; determining whether the virtual model to be displayed meets the preset conditions based on the scene type to which the virtual model to be displayed belongs; if the preset conditions are met, then the virtual model to be displayed is taken as the target virtual model.

[0040] The virtual model to be displayed can be a 3D virtual model located in a virtual scene. For example, the scene type can include three types: foreground, midground, and background. Specifically, if the virtual model to be displayed is positioned in the foreground relative to the scene display interface, the scene type is determined to be foreground; if it is positioned in the background, it is determined to be background; and if it is positioned in the middle, it is determined to be midground. The preset conditions can include any of the following: the scene type is foreground; or the scene type is either foreground or midground. It should be noted that the scene type classification here is only an example. In actual applications, other classifications can be made according to actual needs, such as dividing the scene type into foreground and background.

[0041] In the above steps, determining the target virtual model based on the scene type can reduce the number of model objects that need to be rendered to a certain extent, without having to perform lighting rendering on all model objects in the scene, which can further reduce the performance requirements of the hardware.

[0042] Here, the model bounding box refers to the smallest square bounding volume that can contain the target virtual model. The model bounding volume can be represented by a center point and its lengths along three axes. Specifically, the center point of the target virtual model can be used as the center point of the model bounding box, and the length, width, and height of the target virtual model can be used as the lengths along the three axes of the model bounding box, thus obtaining a model bounding box that matches the target virtual model. For example, as shown... Figure 2A As shown, an example diagram of a model bounding box 202 corresponding to a target virtual model 201 is provided.

[0043] The model bounding area refers to the area that encloses the target virtual model. Optionally, the model bounding area can be a closed region contained within the model bounding box, with a smooth surface and no sharp edges. It should be noted that the size of the model bounding area is determined by the length, width, and height of the target virtual model; the larger the target virtual model, the larger its model bounding area; the smaller the target virtual model, the smaller its model bounding area. Because the surface of the model bounding area is smoother than the surface of the target virtual model, it is easier to process. Using the model bounding area to assist in lighting rendering of the target virtual model can improve the processing efficiency of model rendering to a certain extent.

[0044] The bounding box of the model is used as a reference to determine the bounding region of the model. Since the bounding box of the model is usually simpler in structure than the target virtual model, it can simplify the process of determining the bounding region of the model to a certain extent, thereby improving processing efficiency.

[0045] In an optional implementation, step S110 determines the model bounding area that matches the target virtual model based on the model bounding box of the target virtual model. Specifically, this can be achieved through the following steps: determining the model bounding area of ​​the target virtual model based on the axis vector of the model bounding box in three-dimensional space.

[0046] Here, the axis vector refers to the vector parallel to the coordinate axis.

[0047] Optionally, if a spatial coordinate system is constructed with the center point of the model bounding box as the origin, the axis vector of the model bounding box in three-dimensional space can be a vector parallel to the coordinate axes, starting from the origin and ending at the boundary of the model bounding box. Optionally, when determining the model bounding region of the target virtual model based on the axis vector of the model bounding box in three-dimensional space, the axis vector of the model bounding box in three-dimensional space can be used as a key vector set to limit the range of the model bounding region, and then the model bounding region can be fitted to obtain the model bounding region.

[0048] Optionally, if the world space coordinate system is used as the reference coordinate system, the axis vector of the model bounding box in three-dimensional space can be a vector parallel to the coordinate axes, starting from the origin and ending at the plane containing the surface of the model bounding box. Optionally, when determining the model bounding region of the target virtual model based on the axis vector of the model bounding box in three-dimensional space, three auxiliary vectors parallel to the coordinate axes can first be determined based on the three-dimensional coordinate values ​​corresponding to the center point of the model bounding box. For example, if the three-dimensional coordinate values ​​corresponding to the center point of the model bounding box are (a, b, c), three auxiliary vectors parallel to the coordinate axes can be determined: ai+0j+0k, 0i+bj+0k, and 0i+0j+ck, where i, j, and k represent three basis vectors parallel to the coordinate axes, respectively. Then, the auxiliary vectors with the same direction as the axis vectors can be subtracted from each axis vector of the model bounding box in three-dimensional space to obtain a set of key vectors that define the range of the model bounding region, so that the model bounding region can be fitted based on these key vector sets.

[0049] Optionally, the model's bounding box axis vectors in world space can also be obtained by configuring the following code:

[0050] GetPrimitiveData(Parameters.PrimitiveId).LocalObjectBoundsMax.xyz.

[0051] It should be noted that the above code is designed based on the C++ programming language. In practical applications, other programming languages ​​can also be used, and no specific restrictions are made here.

[0052] Optionally, the model bounding area can be a spherical bounding area with the center of the model's bounding box as its center. Since the surface of a spherical bounding area is relatively smoother, using it to assist in lighting rendering results in a smoother and more natural transition of lighting effects, and avoids some unnecessary computational overhead. Furthermore, the model bounding area can also be an ellipsoidal bounding area, a square bounding area, a regular polygon bounding area, etc. Figure 2B As shown, an example diagram of an ellipsoidal enclosing region 203 corresponding to a target virtual model 201 is provided.

[0053] After determining the model bounding region that matches the target virtual model, step S120 can be continued.

[0054] In step S120, based on the illumination vector data of the preset light source under the current illumination direction, the illumination attenuation data corresponding to multiple orientations on the surface of the model-enclosed area are determined.

[0055] The spatial vector data corresponding to multiple orientations on the surface of the model enclosure can be the vector data corresponding to the spatial vectors formed from the center of the model enclosure to each point on the surface of the model enclosure. The preset light source can be a simulated light source pre-configured in the virtual scene, such as virtual stage lights or virtual streetlights. The lighting vector data can be the lighting vector parameters of the preset light source under the current lighting direction, and the direction from the location of the preset light source to the current location of the target virtual model can be used as the current lighting direction.

[0056] Specifically, illumination attenuation data corresponding to multiple orientations on the surface of the model-enclosed area can be obtained by mapping the spatial vector data corresponding to multiple orientations on the surface of the model-enclosed area with the illumination vector data of the preset light source under the current illumination direction.

[0057] In an optional implementation, the determination of illumination attenuation data corresponding to multiple orientations on the surface of the model enclosure region in step S120 based on the illumination vector data of the preset light source under the current illumination direction can be achieved through the following steps: performing a dot product operation on the spatial vector data corresponding to multiple orientations on the surface of the model enclosure region and the illumination vector data of the preset light source under the current illumination direction to obtain the dot product operation result corresponding to multiple orientations on the surface of the model enclosure region; performing illumination attenuation mapping on the dot product operation result corresponding to multiple orientations on the surface of the model enclosure region to obtain the illumination attenuation data corresponding to multiple orientations on the surface of the model enclosure region.

[0058] Specifically, the spatial vector data corresponding to multiple orientations on the surface of the model's enclosed region are multiplied by the illumination vector data of a preset light source under the current illumination direction. After obtaining the dot product result, illumination attenuation mapping can be applied to the dot product result corresponding to multiple orientations on the surface of the model's enclosed region based on a pre-defined mapping relationship. Optionally, the mapping relationship here can be a positive correlation between the dot product result and the illumination attenuation data, that is, the larger the dot product result, the stronger the illumination attenuation, and the smaller the dot product result, the weaker the illumination attenuation. In practical applications, the mapping relationship can be configured based on the specific mapping effect, and no specific limitation is made here.

[0059] In the above steps, by using light attenuation mapping, different attenuation intensities can be made for different orientations of the model's enclosed area. This results in less light attenuation on the illuminated side and more light attenuation on the shaded side, thereby achieving a gradual change in lighting and further enhancing the visual realism of the lighting rendering.

[0060] In an optional implementation, the step S120, which determines the illumination attenuation data corresponding to multiple orientations on the surface of the model enclosure area based on the illumination vector data of the preset light source under the current illumination direction, can also be achieved through the following steps: determining the illumination attenuation data corresponding to preset orientations on the surface of the model enclosure area based on the illumination vector data of the preset light source under the current illumination direction; and determining the illumination attenuation data corresponding to non-preset orientations between adjacent preset orientations by interpolation based on the illumination attenuation data corresponding to adjacent preset orientations.

[0061] The preset orientation refers to different orientations relative to the center of the model's enclosing region. Several preset orientations can be pre-set according to the model's appearance characteristics, such as up, down, front, back, left, and right. It should be noted that the specific directions and number of preset orientations listed here are merely illustrative examples. In actual applications, these can be set according to requirements, and no specific limitations are made here. Optionally, the spatial vector data corresponding to the preset orientation on the surface of the model's enclosing region can be multiplied by the illumination vector data of the preset light source under the current illumination direction to obtain the dot product result corresponding to the preset orientation on the surface of the model's enclosing region.

[0062] Among them, two preset directions that have no other preset directions between their smallest included angles can be considered as adjacent preset directions. Taking the preset directions as up, down, front, back, left, and right as an example, the front, left, and up directions are adjacent preset directions; the front, up, and right directions are adjacent preset directions; the front, right, and down directions are adjacent preset directions; the front, down, and left directions are adjacent preset directions; the back, left, and up directions are adjacent preset directions; the back, up, and right directions are adjacent preset directions; the back, right, and down directions are adjacent preset directions; and the back, down, and left directions are adjacent preset directions.

[0063] Here, non-preset orientation refers to orientations other than preset orientations on the surface of the model's bounding area. Optionally, non-preset orientations can be orientations on the surface of the model's bounding area that lie between adjacent preset orientations.

[0064] Specifically, after determining the illumination attenuation data corresponding to the preset orientation on the surface of the model-enclosed area, illumination attenuation data interpolation can be performed directly between adjacent preset orientations to obtain the illumination attenuation data corresponding to non-preset orientations located between adjacent preset orientations. This allows for the determination of illumination attenuation data corresponding to multiple orientations on the surface of the model-enclosed area, further improving processing efficiency.

[0065] After determining the light attenuation data, step S130 can be continued.

[0066] In step S130, the target virtual model is rendered with lighting based on the light attenuation data.

[0067] By using illumination attenuation data for illumination mapping, it is possible to achieve lower illumination attenuation and higher brightness on the illuminated side, and higher attenuation and lower brightness on the shaded side. For example, such as... Figure 2C As shown, a single-light source model rendering example is provided.

[0068] Specifically, during lighting rendering, the lighting of the target virtual model can be rendered based on the lighting attenuation data parameters and other pre-configured parameters of the preset light source, such as lighting intensity and lighting color.

[0069] In practical applications, it can also be achieved through repetition. Figure 1 The steps in this process involve overlaying lighting effects from multiple light sources onto the target virtual model. For example, such as... Figure 2D As shown, a rendering example of a multi-light source model is provided.

[0070] In one alternative implementation, the following can also be performed: Figure 3 The steps shown enable real-time updates of the lighting effects:

[0071] Step S310: Adjust the lighting parameters of the preset light source;

[0072] Step S320: Update the illumination attenuation data based on the illumination parameters adjusted by the preset light source;

[0073] Step S330: Update the lighting effect of the target virtual model based on the updated illumination attenuation data.

[0074] The lighting parameters of the preset light source may include lighting direction parameters. For example, the lighting direction of the preset light source can be adjusted.

[0075] After adjusting the illumination parameters of a preset light source, the illumination attenuation data can be updated based on the adjusted illumination parameters. Taking adjusting the illumination direction of the preset light source as an example, specifically, the spatial vector data corresponding to multiple orientations on the surface of the model's enclosed region can be multiplied with the illumination vector data corresponding to the preset light source under the adjusted illumination direction. This yields new dot product results for multiple orientations on the surface of the model's enclosed region. These new dot product results are then mapped to illumination attenuation to obtain new illumination attenuation data for multiple orientations on the surface of the model's enclosed region, thus updating the illumination attenuation data.

[0076] Specifically, after updating the illumination attenuation data, the target virtual model can be rendered with illumination based on the updated illumination attenuation data to obtain a new illumination effect for the target virtual model. This enables real-time updates of the illumination effect of the target virtual model and improves the diversity of the illumination effect of the target virtual model to a certain extent.

[0077] In addition, the lighting parameters of the preset light source may also include configuration parameters such as light intensity and light color. For example, parameters such as the lighting direction, light intensity, light color, and light source position of the preset light source can be adjusted to adaptively change the lighting effect of the target virtual model.

[0078] In one alternative implementation, after rendering the target virtual model based on illumination attenuation data, the following can also be performed: Figure 4 The steps shown are for adjusting the lighting details of the target virtual model:

[0079] Step S410: Obtain the grayscale data of the vertex normals of the target virtual model in each color channel;

[0080] Step S420: Based on the grayscale data of the vertex normals of the target virtual model in each color channel, the color of the target virtual model is adjusted to obtain the lighting detail adjustment effect of the target virtual model.

[0081] The color channels can include three color channels: red, green, and blue. Grayscale data can be used to represent the brightness of the corresponding color channel. The combination of grayscale data from these three color channels can represent a color.

[0082] Figure 4 In the steps shown, indirect lighting is simulated by using the grayscale data of the vertex normals of the target virtual model in each color channel. This allows for detailed adjustments to the lighting effects of the model, making the lighting rendering of the target virtual model more realistic and natural.

[0083] In an optional implementation, step S420, which involves adjusting the color of the target virtual model based on the grayscale data of the vertex normals in each color channel to obtain the lighting detail adjustment effect of the target virtual model, can be achieved through the following steps: determining the color data to be superimposed based on preset channel weight parameters and the grayscale data of the vertex normals in each color channel of the target virtual model; and performing color superposition on the target virtual model based on the color data to be superimposed to obtain the lighting detail adjustment effect of the target virtual model.

[0084] The color data to be superimposed refers to the color data composed of grayscale data in each color channel under the influence of preset channel weight parameters. It can be superimposed on the target virtual model to perform indirect light simulation.

[0085] The preset channel weights can be used to control the degree of detail adjustment for different color channels, which can improve the controllability of lighting details to a certain extent. In practical applications, the weights can be configured according to the specific rendering effect; no specific limitations are made here.

[0086] For example, such as Figure 5 As shown, an example image of a color channel detail effect is provided. The parameters Nr, Ng, and Nb represent the preset channel weights for the red, green, and blue color channels, respectively. Models 501, 502, and 503 represent exemplary detail effect models for the red, green, and blue color channels, respectively.

[0087] In one optional implementation, the above-mentioned color overlay on the target virtual model based on the color data to be overlaid to obtain the lighting detail adjustment effect of the target virtual model can be achieved through the following steps: determining transition color data based on the color data to be overlaid; adjusting the color of the target virtual model based on the transition color data to obtain the intermediate adjustment effect of the target virtual model; and adjusting the color of the target virtual model based on the intermediate adjustment effect based on the color data to be overlaid to obtain the final adjustment effect of the target virtual model.

[0088] The transition color data refers to the transition color data used by the target virtual model in superimposing the color data to be overlaid. For example, the transition color data can be determined using a linear interpolation algorithm.

[0089] The intermediate adjustment effect of the target virtual model refers to the lighting rendering effect obtained after the target virtual character is overlaid with the color corresponding to the transition color data.

[0090] In the above steps, the target virtual model is first adjusted based on the transition color data, and then adjusted again based on the color data to be superimposed, so that there is a transition phase in the adjustment of model details, so that the performance effect is more natural and smooth.

[0091] Optionally, if the target virtual model is a foreground object, the target model can be lit and rendered using a model bounding area that matches the target virtual model, and the lighting details of the target virtual model can be adjusted using the grayscale data of the vertex normals of the target virtual model in each color channel; if the target virtual model is a midground or background object, the target model can be lit and rendered using a model bounding area that matches the target virtual model, without adjusting the lighting details, in order to further reduce unnecessary computational overhead and improve the efficiency of model rendering.

[0092] Optionally, in multi-light source scenarios, if the target virtual model is a foreground, a first number of light source effects can be superimposed on the target virtual model; if the target virtual model is a midground, a second number of light source effects can be superimposed on the target virtual model; if the target virtual model is a background, a third number of light source effects can be superimposed on the target virtual model, wherein the first number is greater than the second number, and the second number is greater than the third number, in order to further reduce unnecessary computational overhead and improve model rendering efficiency.

[0093] like Figure 6 As shown, a flowchart for lighting rendering a model using the model's bounding region is provided, which may include the following steps:

[0094] Step S601: Based on the axis vector of the model bounding box of the target virtual model in three-dimensional space, determine the model bounding region of the target virtual model. The model bounding region includes a spherical bounding region with the center of the model bounding box as the center of the sphere.

[0095] Step S602: Perform a dot product operation on the spatial vector data corresponding to the preset orientation of the model bounding area surface and the illumination vector data of the preset light source under the current illumination direction to obtain the dot product operation result corresponding to the preset orientation of the model bounding area surface.

[0096] Step S603: Perform illumination attenuation mapping on the dot product operation result corresponding to the preset orientation of the model enclosing area surface to obtain illumination attenuation data corresponding to the preset orientation of the model enclosing area surface. Based on the illumination attenuation data corresponding to adjacent preset orientations, determine the illumination attenuation data corresponding to non-preset orientations between adjacent preset orientations by interpolation.

[0097] Step S604: Based on the light attenuation data, perform lighting rendering on the target virtual model;

[0098] Step S605: Obtain the grayscale data of the vertex normals of the target virtual model in each color channel;

[0099] Step S606: Based on the preset channel weight parameters and the grayscale data of the vertex normals of the target virtual model in each color channel, determine the color data to be superimposed.

[0100] Step S607: Determine the transition color data based on the color data to be superimposed;

[0101] Step S608: Based on the transition color data, adjust the color of the target virtual model to obtain the intermediate adjustment effect of the target virtual model;

[0102] Step S609: Based on the color data to be superimposed, adjust the color of the target virtual model on the basis of the intermediate adjustment effect to obtain the final adjustment effect of the target virtual model.

[0103] Figure 7 A model rendering apparatus 700 according to an exemplary embodiment of this disclosure is shown. For example... Figure 7 As shown, the model rendering device 700 may include:

[0104] The bounding area determination module 710 is used to determine the bounding area that matches the target virtual model based on the model bounding box of the target virtual model. The model bounding area is the region that encloses the target virtual model.

[0105] The attenuation determination module 720 is used to determine the light attenuation data corresponding to multiple orientations on the surface of the model-enclosed area based on the light vector data of the preset light source under the current light direction.

[0106] The lighting rendering module 730 is used to perform lighting rendering on the target virtual model based on lighting attenuation data.

[0107] In an alternative implementation, based on the aforementioned scheme, the bounding area determination module 710 can be configured to: determine the bounding area of ​​the target virtual model based on the axis vector of the model bounding box in three-dimensional space.

[0108] In one alternative implementation, based on the aforementioned scheme, the model enclosing region includes a spherical enclosing region with the center of the model enclosing box as its center.

[0109] In an optional implementation, based on the aforementioned scheme, the attenuation determination module 720 may include: a click calculation module, used to perform a dot product operation on the spatial vector data corresponding to multiple orientations on the surface of the model enclosure area and the illumination vector data of the preset light source under the current illumination direction, to obtain the dot product operation result corresponding to multiple orientations on the surface of the model enclosure area; and an attenuation mapping module, used to perform illumination attenuation mapping on the dot product operation result corresponding to multiple orientations on the surface of the model enclosure area, to obtain illumination attenuation data corresponding to multiple orientations on the surface of the model enclosure area.

[0110] In an optional implementation, based on the aforementioned scheme, the attenuation determination module 720 may include: a preset orientation attenuation determination module, used to determine the illumination attenuation data corresponding to the preset orientation on the surface of the model enclosure area based on the illumination vector data of the preset light source under the current illumination direction; and an attenuation data interpolation module, used to determine the illumination attenuation data corresponding to the non-preset orientation between adjacent preset orientations by interpolation based on the illumination attenuation data corresponding to adjacent preset orientations.

[0111] In an optional implementation, based on the aforementioned scheme, the model rendering device 700 may further include: a parameter adjustment module for adjusting the illumination parameters of a preset light source; an attenuation update module for updating illumination attenuation data based on the adjusted illumination parameters of the preset light source; and an illumination effect update module for updating the illumination effect of the target virtual model based on the updated illumination attenuation data.

[0112] In an optional implementation, based on the aforementioned scheme, after rendering the target virtual model based on the light attenuation data, the model rendering device 700 further includes: a grayscale data acquisition module, used to acquire the grayscale data of the vertex normals of the target virtual model in each color channel; and a detail adjustment module, used to adjust the color of the target virtual model based on the grayscale data of the vertex normals of the target virtual model in each color channel, to obtain the lighting detail adjustment effect of the target virtual model.

[0113] In an optional implementation, based on the aforementioned scheme, the detail adjustment module may include: a color data determination module, used to determine the color data to be superimposed based on preset channel weight parameters and the grayscale data of the vertex normals of the target virtual model in each color channel; and a color superposition module, used to perform color superposition on the target virtual model based on the color data to be superimposed, to obtain the lighting detail adjustment effect of the target virtual model.

[0114] In an optional implementation, based on the aforementioned scheme, the color overlay module can be configured to: determine transition color data based on the color data to be overlaid; adjust the color of the target virtual model based on the transition color data to obtain an intermediate adjustment effect of the target virtual model; and adjust the color of the target virtual model based on the intermediate adjustment effect based on the color data to be overlaid to obtain the final adjustment effect of the target virtual model.

[0115] The specific details of each module in the above-mentioned model rendering device 700 have been described in detail in the method section of the implementation. For any undisclosed details, please refer to the implementation content of the method section, and therefore will not be repeated here.

[0116] Exemplary embodiments of this disclosure also provide a computer-readable storage medium storing a program product capable of implementing the model rendering method described above. In some possible embodiments, various aspects of this disclosure may also be implemented as a program product including program code that, when run on an electronic device, causes the electronic device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure.

[0117] The program product may be a portable compact disc read-only memory (CD-ROM) and include program code, and may run on an electronic device, such as a personal computer. However, the program product disclosed herein is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0118] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0119] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0120] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF (Radio Frequency), etc., or any suitable combination thereof.

[0121] Program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing devices can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0122] Exemplary embodiments of this disclosure also provide an electronic device capable of implementing the above-described model rendering method. Referring below... Figure 8 To describe an electronic device 800 according to such an exemplary embodiment of the present disclosure. Figure 8 The electronic device 800 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0123] like Figure 8 As shown, the electronic device 800 can be represented as a general-purpose computing device. The components of the electronic device 800 may include, but are not limited to: at least one processing unit 810, at least one storage unit 820, a bus 830 connecting different system components (including storage unit 820 and processing unit 810), and a display unit 840.

[0124] The storage unit 820 stores program code, which can be executed by the processing unit 810, causing the processing unit 810 to perform the steps described in the "Exemplary Methods" section above according to various exemplary embodiments of this disclosure.

[0125] Specifically, a program product stored on a computer-readable storage medium enables an electronic device to perform the following steps:

[0126] Based on the model bounding box of the target virtual model, determine the model bounding region that matches the target virtual model. The model bounding region is the area that encloses the target virtual model.

[0127] Based on the illumination vector data of the preset light source under the current illumination direction, determine the illumination attenuation data corresponding to multiple directions on the surface of the model-enclosed area;

[0128] Lighting rendering is performed on the target virtual model based on light attenuation data.

[0129] In an optional implementation, based on the aforementioned scheme, the model bounding box of the target virtual model is used to determine the model bounding region that matches the target virtual model. Specifically, this can be achieved through the following steps: determining the model bounding region of the target virtual model based on the axis vector of the model bounding box in three-dimensional space.

[0130] In one alternative implementation, based on the aforementioned scheme, the model enclosing region includes a spherical enclosing region with the center of the model enclosing box as its center.

[0131] In an optional implementation, based on the aforementioned scheme, the determination of illumination attenuation data corresponding to multiple orientations on the surface of the model-enclosed area based on the illumination vector data of the preset light source under the current illumination direction can be achieved through the following steps: performing a dot product operation on the spatial vector data corresponding to multiple orientations on the surface of the model-enclosed area and the illumination vector data of the preset light source under the current illumination direction to obtain the dot product operation result corresponding to multiple orientations on the surface of the model-enclosed area; performing illumination attenuation mapping on the dot product operation result corresponding to multiple orientations on the surface of the model-enclosed area to obtain the illumination attenuation data corresponding to multiple orientations on the surface of the model-enclosed area.

[0132] In an optional implementation, based on the aforementioned scheme, the determination of illumination attenuation data corresponding to multiple orientations on the surface of the model enclosure area based on the illumination vector data of the preset light source under the current illumination direction can be achieved through the following steps: determining illumination attenuation data corresponding to preset orientations on the surface of the model enclosure area based on the illumination vector data of the preset light source under the current illumination direction; determining illumination attenuation data corresponding to non-preset orientations between adjacent preset orientations by interpolation based on the illumination attenuation data corresponding to adjacent preset orientations.

[0133] In an optional implementation, based on the aforementioned scheme, the following steps may also be performed: adjusting the illumination parameters of a preset light source; updating the illumination attenuation data based on the adjusted illumination parameters of the preset light source; and updating the illumination effect of the target virtual model based on the updated illumination attenuation data.

[0134] In an optional implementation, based on the aforementioned scheme, after rendering the target virtual model based on the light attenuation data, the following steps can also be performed: obtaining the grayscale data of the vertex normals of the target virtual model in each color channel; adjusting the color of the target virtual model based on the grayscale data of the vertex normals of the target virtual model in each color channel to obtain the lighting detail adjustment effect of the target virtual model.

[0135] In an optional implementation, based on the aforementioned scheme, the target virtual model is color-adjusted using the grayscale data of the vertex normals of the target virtual model in each color channel to obtain the lighting detail adjustment effect of the target virtual model. Specifically, this can be achieved through the following steps: determining the color data to be superimposed based on preset channel weight parameters and the grayscale data of the vertex normals of the target virtual model in each color channel; and performing color superposition on the target virtual model based on the color data to be superimposed to obtain the lighting detail adjustment effect of the target virtual model.

[0136] In an optional implementation, based on the aforementioned scheme, the above-mentioned color overlay on the target virtual model based on the color data to be overlaid to obtain the lighting detail adjustment effect of the target virtual model can be achieved through the following steps: determining transition color data based on the color data to be overlaid; adjusting the color of the target virtual model based on the transition color data to obtain the intermediate adjustment effect of the target virtual model; and adjusting the color of the target virtual model based on the intermediate adjustment effect based on the color data to be overlaid to obtain the final adjustment effect of the target virtual model.

[0137] In the above model rendering process, by determining the model bounding area of ​​the target virtual model, the lighting rendering is restricted to the model bounding area, which reduces unnecessary computational overhead and computational complexity. This not only improves the processing efficiency of model rendering to a certain extent and ensures the smoothness of the game, but also reduces the requirements for hardware performance. It can be well adapted to mobile devices and is suitable for multi-light source application scenarios.

[0138] Storage unit 820 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 821 and / or cache memory 822, and may further include a read-only memory (ROM) 823.

[0139] The storage unit 820 may also include a program / utility 824 having a set (at least one) of program modules 825, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0140] Bus 830 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0141] Electronic device 800 can also communicate with one or more external devices 900 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with the electronic device 800, and / or with any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed through input / output (I / O) interface 850. Furthermore, electronic device 800 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 860. Figure 8 As shown, network adapter 860 communicates with other modules of electronic device 800 via bus 830. It should be understood that, although... Figure 8 As not shown in the diagram, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID (Redundant Arrays of Independent Disks) systems, tape drives, and data backup storage systems.

[0142] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the method according to the exemplary embodiments of this disclosure.

[0143] Furthermore, the above figures are merely illustrative representations of the processes included in the methods according to exemplary embodiments of this disclosure, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0144] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to exemplary embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0145] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.

[0146] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A model rendering method, characterized in that, The method includes: Based on the model bounding box of the target virtual model, a model bounding region matching the target virtual model is determined, wherein the model bounding region is the area that encloses the target virtual model; Based on the illumination vector data of the preset light source under the current illumination direction, determine the illumination attenuation data corresponding to multiple orientations on the surface of the model-enclosed area; Based on the light attenuation data, the target virtual model is rendered with light.

2. The method according to claim 1, characterized in that, The model bounding box based on the target virtual model determines the model bounding region that matches the target virtual model, including: Based on the axis vector of the model bounding box in three-dimensional space, the model bounding area of ​​the target virtual model is determined.

3. The method according to claim 1, characterized in that, The model enclosure region includes a spherical enclosure region with the center of the model enclosure box as its center.

4. The method according to claim 1, characterized in that, The determination of illumination attenuation data corresponding to multiple orientations on the surface of the model-enclosed region based on the illumination vector data of a preset light source under the current illumination direction includes: The spatial vector data corresponding to multiple orientations on the surface of the model-enclosed area are multiplied by the illumination vector data of the preset light source under the current illumination direction to obtain the dot product result corresponding to multiple orientations on the surface of the model-enclosed area. The dot product results corresponding to multiple orientations on the surface of the model-enclosed region are mapped to light attenuation to obtain light attenuation data corresponding to multiple orientations on the surface of the model-enclosed region.

5. The method according to claim 1, characterized in that, The determination of illumination attenuation data corresponding to multiple orientations on the surface of the model-enclosed region based on the illumination vector data of a preset light source under the current illumination direction includes: Based on the illumination vector data of the preset light source under the current illumination direction, determine the illumination attenuation data corresponding to the preset orientation on the surface of the model-enclosed area; Based on the light attenuation data corresponding to adjacent preset locations, the light attenuation data corresponding to non-preset locations between the adjacent preset locations is determined by interpolation.

6. The method according to claim 1, characterized in that, The method further includes: Adjust the illumination parameters of the preset light source; The illumination attenuation data is updated based on the illumination parameters adjusted according to the preset light source. The lighting effect of the target virtual model is updated based on the updated illumination attenuation data.

7. The method according to claim 1, characterized in that, After rendering the target virtual model based on the light attenuation data, the method further includes: Obtain the grayscale data of the vertex normals of the target virtual model in each color channel; Based on the grayscale data of the vertex normals of the target virtual model in each color channel, the colors of the target virtual model are adjusted to obtain the lighting detail adjustment effect of the target virtual model.

8. The method according to claim 7, characterized in that, The process of adjusting the color of the target virtual model based on the grayscale data of the vertex normals in each color channel to obtain the lighting detail adjustment effect of the target virtual model includes: Based on the preset channel weight parameters and the grayscale data of the vertex normals of the target virtual model in each color channel, the color data to be superimposed is determined. Based on the color data to be superimposed, the target virtual model is overlaid with colors to obtain the lighting detail adjustment effect of the target virtual model.

9. The method according to claim 8, characterized in that, The process of performing color overlay on the target virtual model based on the color data to be overlaid, to obtain the lighting detail adjustment effect of the target virtual model, includes: Based on the color data to be superimposed, determine the transition color data; Based on the transition color data, the target virtual model is color-adjusted to obtain the intermediate adjustment effect of the target virtual model; Based on the color data to be superimposed, the target virtual model is color-adjusted based on the intermediate adjustment effect to obtain the final adjustment effect of the target virtual model.

10. A model rendering apparatus, characterized in that, The device includes: The bounding region determination module is used to determine a model bounding region that matches the target virtual model based on the model bounding box of the target virtual model, wherein the model bounding region is the area that encloses the target virtual model; The attenuation determination module is used to determine the light attenuation data corresponding to multiple orientations on the surface of the model-enclosed area based on the light vector data of the preset light source under the current light direction; The lighting rendering module is used to perform lighting rendering on the target virtual model based on the lighting attenuation data.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 9.

12. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the method of any one of claims 1 to 9 by executing the executable instructions.

Citation Information

Patent Citations

  • Virtual light source processing method and device, medium and electronic equipment

    CN111260766A

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

    CN113648652A