Model rendering method and device, electronic equipment and computer readable storage medium
By acquiring ambient light information of the game scene and constructing a planar model, and combining virtual camera and light source rotation processing, the problem of poor rendering of 3D objects in low-to-medium quality graphics has been solved, achieving efficient rendering and a good visual experience.
Patent Information
- Application Number
- CN202510870700.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-10-31
AI Technical Summary
In existing technologies, the rendering effect of 3D objects with medium to low resolution is poor and the performance consumption is high, which cannot meet the visual requirements of games.
By acquiring ambient light information of the game scene, a planar model is constructed, and world space coordinates are determined based on the target vector of the virtual camera. The rotation of the target light source is controlled, and the planar model is rendered by combining lighting and shadow effects information and material information to generate game screens with preset image quality.
It improves the rendering effect of 3D objects in low to medium resolutions, reduces rendering performance consumption, and allows virtual objects to change with lighting and shadows, achieving a rendering effect close to high resolutions.
Smart Images

Figure CN120876704A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of rendering technology, specifically to a model rendering method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] As games have evolved, game perspectives have become increasingly diverse. Currently, the most common game perspectives are first-person perspective, third-person perspective, and fixed game perspective.
[0003] In a fixed game perspective, distant 3D objects are not visible. Game graphics typically configure different levels of detail (LOD) models for 3D objects according to the screen's graphics quality. High-quality graphics use high-polygon models, while medium- and low-quality graphics use low-polygon 3D models. However, currently, the rendering of 3D objects in medium- and low-quality graphics is poor, and the high polygon count results in high performance consumption. Summary of the Invention
[0004] This application provides a model rendering method, apparatus, electronic device, and computer-readable storage medium, which can improve the rendering effect of 3D objects with medium to low image quality and reduce rendering performance consumption.
[0005] In a first aspect, embodiments of this application provide a model rendering method, the method comprising:
[0006] The ambient light information of the game scene is obtained and a planar model is constructed. The display view of the game scene is a fixed view.
[0007] Based on the target vector of the virtual camera facing the above game scene, the world space coordinates of the above planar model in the above game scene are determined;
[0008] Control the target light source in the game scene to rotate towards the virtual camera, obtain the target light direction corresponding to the target light source, and determine the light and shadow effect information in the target light direction based on the target light direction and the ambient light information.
[0009] Based on the aforementioned lighting and shadow effects information, the material information of the target virtual object, and the aforementioned world space coordinates, the aforementioned planar model is rendered to obtain the target virtual object configured for the game screen of the aforementioned game scene with the preset image quality.
[0010] Secondly, embodiments of this application also provide a model rendering apparatus, the apparatus comprising:
[0011] The information acquisition module is used to acquire ambient light information of the game scene and construct a planar model. The display view of the game scene is a fixed view.
[0012] The first determining module is used to determine the world space coordinates of the planar model in the game scene based on the target vector of the virtual camera facing the game scene.
[0013] The second determining module is used to control the target light source in the game scene to rotate towards the virtual camera, obtain the target light direction corresponding to the target light source, and determine the light and shadow effect information in the target light direction based on the target light direction and the ambient light information.
[0014] The rendering processing module is used to render the planar model based on the above lighting and shadow effect information, the material information of the target virtual object, and the above world space coordinates, to obtain the target virtual object configured for the game screen with the preset image quality of the above game scene.
[0015] Thirdly, embodiments of this application also provide an electronic device, including a memory storing multiple instructions; the processor loads instructions from the memory to execute any of the model rendering methods provided in embodiments of this application.
[0016] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute any of the model rendering methods provided in embodiments of this application.
[0017] In this embodiment, ambient light information of the game scene is acquired, and a planar model is constructed. The display view of the game scene is a fixed view. Based on the target vector of the virtual camera facing the game scene, the world space coordinates of the planar model in the game scene are determined. The target light source in the game scene is controlled to rotate towards the virtual camera to obtain the target light direction corresponding to the target light source. Based on the target light direction and ambient light information, the light and shadow effect information in the target light direction is determined. Based on the light and shadow effect information, the material information of the target virtual object, and the world space coordinates, the planar model is rendered to obtain the target virtual object configured for the preset image quality of the game scene. This realizes the generation of the target virtual object in the preset image quality game scene through the planar model, without the need to use a 3D model to generate the target virtual object in the preset image quality game scene, reducing performance consumption. Furthermore, the target virtual object in this embodiment can change with the changes in light and shadow in the game scene, improving the presentation effect of the target virtual object. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a schematic flowchart of one embodiment of the model rendering method provided in this application;
[0020] Figure 2 This is a schematic diagram of the rendering interface provided in the embodiments of this application;
[0021] Figure 3 This is a schematic diagram of a texture including ambient light information and color information provided in the embodiments of this application;
[0022] Figure 4 This is a schematic diagram of the planar model provided in the embodiments of this application;
[0023] Figure 5 This is a schematic flowchart of another embodiment of the model rendering method provided in this application.
[0024] Figure 6 This is a schematic diagram of the structure of the model rendering apparatus provided in the embodiments of this application;
[0025] Figure 7 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0027] Before providing a detailed explanation of the embodiments of this application, some terms involved in the embodiments of this application will be explained.
[0028] In the description of the embodiments of this application, the terms "first," "second," etc., may be used herein to describe various concepts, but unless specifically stated otherwise, these concepts are not limited by these terms. These terms are used only to distinguish one concept from another. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or devices.
[0029] This application provides a model rendering method, apparatus, electronic device, and computer-readable storage medium. Specifically, the model rendering method of this application can be executed by an electronic device, which can be a terminal or a server, etc.
[0030] The terminal can be a smartphone, tablet, laptop, touch screen, game console, personal computer (PC), personal digital assistant (PDA), or other terminal device. The terminal can also include a client, which can be a game application client, a browser client with a game program, or an instant messaging client, etc.
[0031] A server can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0032] The following is a detailed description in conjunction with the accompanying drawings. It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments. Although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be performed in a different order than that shown in the drawings.
[0033] In this embodiment, a terminal is used as an example for illustration. This embodiment provides a model rendering method, such as... Figure 1 As shown, the specific process of this model rendering method can be as follows:
[0034] 101. Obtain the ambient light information of the game scene and construct a planar model. The display view of the game scene is a fixed view.
[0035] In this context, the game scene refers to the virtual environment in which the player is engaged in a game. Optionally, this virtual environment 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 either a two-dimensional or three-dimensional virtual environment. Optionally, the game scene in this embodiment can be a pre-constructed game scene, or it can be a game scene yet to be constructed.
[0036] The game scene is displayed from a fixed perspective, meaning that the display perspective does not change with user actions or the movement of the virtual character. The display perspective can be set according to actual conditions; for example, it can be a 45° overhead view or a 30° overhead view. This embodiment does not impose any limitations on this.
[0037] The game scene may include virtual characters. A virtual character refers to a controllable dynamic object in the game scene. Optionally, the dynamic object may be a virtual human, virtual animal, anime character, etc. The virtual character is a character controlled by the player through an input device, or an artificial intelligence (AI) trained and set up for battle in a virtual environment, or a non-player character (NPC) set up for battle in the game scene. Optionally, the virtual character is a virtual character competing in the game scene. Optionally, the number of virtual characters in the game scene battle is preset or dynamically determined according to the number of game clients joining the battle; this application embodiment does not limit this. In one possible implementation, the user can control the virtual character to move in the game scene, for example, control the virtual character to run, jump, crawl, etc., and can also control the virtual character to use skills, game props, etc. provided by the game client to fight with other virtual characters. Game items refer to virtual objects that virtual characters can use in a virtual environment to enhance their own attributes, assist in combat, or inflict damage on other virtual characters. These include, but are not limited to, shields, springboards, golems, scopes, and flash hiders. Controlled virtual characters are virtual characters in the game scene that are controlled by this terminal.
[0038] Ambient light information refers to the lighting information from various directions in the game scene. Its form can be set according to the actual situation. For example, ambient light information can be stored in the SH spherical harmonic function or the stereo texture. This embodiment does not limit it.
[0039] A planar model refers to a two-dimensional model, the type of which can be selected according to the actual situation. For example, a planar model can be a billboard or a quadrilateral; this embodiment does not limit this. Optionally, in order to make the three-dimensional effect of the target virtual object configured for the preset image quality game screen stronger, the planar model can be a planar model that meets preset bending conditions. When the planar model meets the preset bending conditions, it means that the planar model has a bending phenomenon; for example, the top of the planar model can be bent.
[0040] In some embodiments, acquiring ambient light information of the game scene includes:
[0041] The detailed model of the target virtual object that meets the preset detailed conditions is rendered to obtain the ambient light information of the game scene.
[0042] In this context, the target virtual object refers to the scene objects that make up the game scene. Its type can be set according to the actual situation; for example, the target virtual object can be a tree or grass. This embodiment does not impose any limitations on this. The preset detail condition can refer to being equal to or greater than a preset precision level. For example, if the preset precision level is the third highest precision level (LOD2), then the precision level equal to or greater than the preset precision level can be the highest precision level (LOD0) or the second highest precision level (LOD1). Alternatively, the preset detail condition can refer to the number in the name being less than or equal to a preset number. For example, if the preset number is 2, then the detail level model that satisfies the preset detail condition can be a LOD0 model or a LOD1 model. This embodiment does not impose any limitations on this.
[0043] It is understandable that the higher the precision level of the detail level model that meets the preset detail conditions, the more accurate the ambient light information obtained, resulting in better lighting and shadow effects of the target virtual object rendered based on the ambient light information.
[0044] Optionally, the game engine can be used to render the level-of-detail model of the target virtual object that meets preset detail conditions to obtain the ambient lighting information of the game scene. The game engine can be selected according to the actual situation. For example, the level-of-detail model of the target virtual object that meets preset detail conditions can be rendered using the UE engine or the Unity engine. This embodiment does not limit this to a specific engine.
[0045] Optionally, when the game engine is the UE engine, the AIlab department in the UE engine can be used to render the detailed level model of the target virtual object that meets the preset detail conditions, so as to obtain high-quality ambient light information, and make the lighting and shadow effects of the target virtual object rendered based on the ambient light information better.
[0046] When rendering a detailed model of a target virtual object that meets preset detail conditions using tools developed by the AIlab department, if the target virtual object is a tree, the rendering interface in the UE engine can be as follows: Figure 2 As shown, when rendering using the highest level of detail (LOD0) model, the obtained ambient light information can be as follows: Figure 3 As shown.
[0047] In this embodiment, the detail level model of the target virtual object that meets the preset detail conditions is rendered to obtain the ambient light information of the game scene. This achieves the acquisition of ambient light information through a high-precision detail level model, thereby improving the quality of the obtained ambient light information and making the lighting and shadow effects of the target virtual object obtained based on the ambient light information better.
[0048] In some embodiments, constructing a planar model includes:
[0049] Construct an initial planar model that meets the preset bending conditions;
[0050] Based on the color information of the target virtual object in the game scene, the initial planar model is clipped to obtain a planar model.
[0051] Specifically, when the initial planar model meets the preset bending conditions, it indicates that the planar model exhibits bending. For example, the preset bending conditions could be top bending or side bending of the initial planar model. The form in which the color information of the target virtual object corresponds to the game scene can be set according to the actual situation. For example, the color information of the target virtual object in the game scene can exist in the form of a KD diagram, that is, the KD diagram includes the color information of the target virtual object in the game scene. For example, such as... Figure 3 As shown, at this point, color information can be obtained by rendering the detail level model of the target virtual object that meets the preset detail conditions.
[0052] Optionally, the initial planar model is cropped based on the transparency information (alpha) in the color information corresponding to the target virtual object in the game scene to obtain a planar model. The cropped planar model can be, for example, as shown in the image below. Figure 4 As shown.
[0053] In this embodiment, an initial planar model that meets preset bending conditions is constructed. Based on the color information of the target virtual object in the game scene, the initial planar model is cropped to obtain a planar model. This results in a bending phenomenon in the planar model, which makes the three-dimensional effect of the target virtual object obtained from the planar model better. Furthermore, cropping the initial planar model based on color information can reduce the transparency area.
[0054] 102. Based on the target vector of the virtual camera for the game scene, determine the world space coordinates of the planar model in the game scene.
[0055] Virtual cameras are an essential component for presenting game scenes, used to capture and display the game world. Each game scene corresponds to at least one virtual camera. By setting the parameters of the virtual camera, the player's viewing angle of the game world can be adjusted, such as first-person, third-person, and fixed top-down views.
[0056] The target vector can be a unit vector, and its direction is used to point to the virtual camera. For example, when the Y-axis is locked, the target vector can be (0, 0, 1), and when the Z-axis is locked, the target vector can be (0, 1, 0).
[0057] In this embodiment, the world space coordinates of the planar model in the game scene are determined based on the target vector of the virtual camera facing the game scene, so that the planar model is rotated to face the virtual camera, thereby giving the target virtual object obtained based on the planar model a three-dimensional effect.
[0058] In some embodiments, determining the world space coordinates of the planar model in the game scene based on the target vector of the virtual camera oriented towards the game scene includes:
[0059] Determine the first world coordinates and initial orientation vector of the planar model in world space;
[0060] Based on the target vector of the virtual camera for the game scene, the initial direction vector is adjusted to obtain the direction vector of the planar model in world space;
[0061] Based on the direction vector and the first world coordinates, the world space coordinates of the planar model in the game scene are determined.
[0062] Here, the initial direction vector refers to the initial upward unit vector, initial forward unit vector, and / or initial rightward unit vector of the planar model in world space. The direction vectors are the corrected upward, forward, and rightward unit vectors of the planar model in world space. Optionally, the initial upward unit vector can be used as the upward unit vector. Based on the target vector and the upward unit vector, the rightward unit vector can be obtained. The forward unit vector can then be obtained by cross-product of the rightward unit vector and the upward unit vector. Specifically, the process of obtaining the rightward unit vector based on the target vector and the upward unit vector can be: cross-product of the target vector and the upward unit vector to obtain the rightward unit vector.
[0063] Optionally, the coordinates of the planar model in the model space can be transformed to obtain the first world coordinates of the planar model in the world space, and the direction vector of the planar model in the model space can be transformed to obtain the initial direction vector.
[0064] Optionally, the first world coordinates of the planar model may include the vertex coordinates and axis coordinates of the planar model in world space (the axis coordinates are obtained by transforming the origin of the planar model in model space). After obtaining the direction vector and the first world coordinates, the axis coordinates can be subtracted from the vertex coordinates to obtain the coordinate difference. The direction vector and the coordinate difference are then multiplied by a dot product, and the dot product result is added to the axis coordinates to obtain the world space coordinates of the planar model in the game scene.
[0065] In this embodiment, the first world coordinates and initial direction vector of the planar model in world space are determined. Based on the target vector of the virtual camera facing the game scene, the initial direction vector is adjusted to obtain the direction vector of the planar model in world space. Based on the direction vector and the first world coordinates, the world space coordinates corresponding to the planar model in the game scene are determined, so that the planar model rotates to face the virtual camera, thereby making the target virtual object obtained based on the planar model present a three-dimensional effect.
[0066] In some embodiments, determining the world space coordinates of the planar model in the game scene based on the direction vector and the first world coordinates includes:
[0067] Based on the direction vector and the first world coordinates, determine the second world coordinates of the planar model in world space;
[0068] The coordinate offset is determined based on the distance between the planar model and the virtual camera;
[0069] Based on the coordinate offset, the second world coordinates are offset to obtain the world space coordinates of the planar model in the game scene.
[0070] The first world coordinates of the planar model can include the vertex coordinates and axis coordinates of the planar model in world space (the axis coordinates are obtained by transforming the origin of the planar model in model space). After obtaining the direction vector and the first world coordinates, the axis coordinates can be subtracted from the vertex coordinates to obtain the coordinate difference. The direction vector and the coordinate difference are then dot-producted, and the dot product is added to the axis coordinates to obtain the second world coordinates. Optionally, the distance between the planar model and the virtual camera can be mapped to obtain the coordinate offset. Optionally, the distance between the planar model and the virtual camera can be the horizontal distance between the planar model and the virtual camera to improve accuracy.
[0071] After obtaining the second world coordinates and coordinate offset, the second world coordinates and coordinate offset can be added together to obtain the world space coordinates of the planar model in the game scene.
[0072] In this embodiment, the second world coordinates of the planar model in world space are determined based on the direction vector and the first world coordinates. The coordinate offset is determined based on the distance between the planar model and the virtual camera. Based on the coordinate offset, the second world coordinates are offset to obtain the world space coordinates of the planar model in the game scene. This realizes the determination of the tilt of the planar model based on the distance between the planar model and the virtual camera, so that the planar model tilts in the direction of the virtual camera, thereby ensuring that the virtual camera does not reveal the virtual object when passing through it.
[0073] In some embodiments, this embodiment further includes:
[0074] The masking range of the planar model is determined based on the texture coordinates of the planar model.
[0075] Based on the distance between the planar model and the virtual camera, determine the coordinate offset, including:
[0076] The coordinate offset is determined based on the distance between the planar model and the virtual camera, as well as the masking range.
[0077] Texture coordinates can also be called UV coordinates. The masking range represents the masking area at the top of the planar model. Optionally, smooth interpolation can be performed based on the distance between the planar model and the virtual camera to obtain a smoothed result. Then, based on the smoothed result and the masking range, the coordinate offset is determined. The smooth interpolation method can be set according to the actual situation; for example, it can be performed using the smoothstep or Smooth Hermite functions. This embodiment does not limit this to a specific method.
[0078] When performing smooth interpolation using the smoothstep function, the distance between the planar model and the virtual camera, as well as the masking range, can be substituted into the following formula to calculate the coordinate offset:
[0079] modeloffset=1-smoothstep(0, 0.3, length(viewdir.xz))*modelmask
[0080] Here, modeloffset represents the coordinate offset, length(viewdir.xz) represents the distance between the planar model and the virtual camera in the horizontal direction, modelmask represents the masking range, and 0 and 0.3 are preset values.
[0081] In this embodiment, the masking range of the planar model is determined based on the texture coordinates of the planar model. The coordinate offset is determined based on the distance between the planar model and the virtual camera and the masking range. Based on the coordinate offset, the second world coordinates are offset to obtain the world space coordinates of the planar model in the game scene. This enables the determination of the tilt of the top of the planar model based on the distance between the planar model and the virtual camera, so that the top of the planar model tilts towards the direction of the virtual camera, thus ensuring that the virtual camera does not appear to be visible when passing over the top of the target virtual object.
[0082] 103. Control the target light source in the game scene to rotate towards the virtual camera, obtain the target light direction corresponding to the target light source, and determine the light and shadow effect information in the target light direction based on the target light direction and ambient light information.
[0083] The target light source can be selected according to the actual situation. For example, the target light source can be sunlight or lamplight. This embodiment does not limit it.
[0084] In this embodiment, the target light source in the game scene is controlled to rotate towards the virtual camera to obtain the target light direction corresponding to the target light source. Based on the target light direction and ambient light information, the light and shadow effect information in the target light direction is determined, so that the target light source rotates towards the virtual camera like the planar model. This allows the target virtual object obtained based on the planar model to change with the change of the target light source, thereby improving the presentation effect of the target virtual object.
[0085] In some embodiments, controlling the target light source in the game scene to rotate towards the virtual camera to obtain the target light direction corresponding to the target light source includes:
[0086] The light direction and direction vector corresponding to the target light source in the game scene are processed by dot product to obtain the target light direction corresponding to the target light source, so as to control the rotation of the target light source in the game scene towards the virtual camera.
[0087] Here, the direction vector is the direction vector of the planar model in world space. The process of determining it can be as follows: determine the initial direction vector of the planar model in world space, and adjust the initial direction vector based on the target vector of the virtual camera facing the game scene to obtain the direction vector of the planar model in world space.
[0088] Understandably, when ambient light information is obtained through the first game engine, and the target light source in the game scene is rotated towards the virtual camera through the second game engine to obtain the target light direction, and the lighting and shadow effects along the target light direction are determined based on the target light direction and ambient light information, the lighting directions of the first and second game engines may differ. Therefore, the light direction corresponding to the target light source in the game scene can be first transformed to obtain the transformed light direction. Then, the transformed light direction and the direction vector are multiplied by a dot product to obtain the target light direction corresponding to the target light source. For example, when the first game engine is the UE engine and the second game engine is the Neox engine, the light direction corresponding to the target light source can be transformed using the following formula to obtain the transformed light direction:
[0089] UELightVector=normalize(float3(LightVector.z,-LightVector.y,-LightVector.x))
[0090] Wherein, UELightVector represents the converted light direction, and LightVector.z, LightVector.y, and LightVector.x refer to the light direction corresponding to the target light source.
[0091] In this embodiment, the light direction and direction vector corresponding to the target light source in the game scene are processed by dot product to obtain the target light direction corresponding to the target light source, so as to control the target light source in the game scene to rotate towards the virtual camera, thereby making the target light source rotate towards the virtual camera like the planar model.
[0092] In some embodiments, determining the light and shadow effect information in the target light direction based on the target light direction and ambient light information includes:
[0093] The dot product of the target light direction and ambient light information is used to obtain the light intensity information in the target light direction.
[0094] Multiply the light intensity information by the light color information to obtain the light and shadow effect information in the direction of the target light.
[0095] Here, the lighting color information can refer to the lighting color information of the target light source in the game engine. Optionally, since the target light direction is three-dimensional data and the ambient light information is four-dimensional data, the target light direction can be adjusted before performing a dot product operation on the target light direction and ambient light information to obtain the adjusted light direction. The adjusted light direction is four-dimensional data. Then, the adjusted light direction and ambient light information are subjected to a dot product operation to obtain the lighting intensity information along the adjusted light direction. Optionally, the target light direction can be adjusted using the following formula:
[0096] rotLight=float4(0.282,rotVec.y*-0.488,rotVec.x*0.488,rotVec.z*0.488);
[0097] Here, rotLight represents the adjusted light direction, and rotVec.y, rotVec.x, and rotVec.z represent the target light direction.
[0098] In this embodiment, the target light direction and ambient light information are processed by dot product to obtain the light intensity information in the target light direction. The light intensity information is multiplied by the light color information to obtain the light and shadow effect information in the target light direction. This allows the target virtual object obtained after rendering the planar model based on the light and shadow effect information to change with the change of the target light source, thereby enabling the target virtual object to achieve a better presentation effect.
[0099] 104. Based on the lighting and shadow effects, the material information of the target virtual object, and the world space coordinates, the planar model is rendered to obtain the target virtual object configured for the game screen with the preset image quality of the game scene.
[0100] The preset image quality can be set according to actual needs, such as low-end and / or medium-end quality. Different target virtual objects are configured for different image quality settings in the game scene. When the game scene is a scene to be created, after rendering the 2D model, game data for the preset image quality settings can be generated based on the target virtual objects. When the game scene is an already created scene, after rendering the 2D model, the low-polygon 3D virtual objects in the game data for the preset image quality settings can be replaced with the target virtual objects. The low-polygon 3D virtual objects and the target virtual objects are the same type of virtual object; for example, both the low-polygon 3D virtual objects and the target virtual objects are trees.
[0101] Optionally, when the lighting and shadow effects and world space coordinates are stored in the .gim file and the material information of the target virtual object is stored in the .mtl file, the .mtl file can be assigned to the .gim file to achieve rendering of the 2D model. Alternatively, based on the lighting and shadow effects and world space coordinates, the material information of the target virtual object can be rendered onto the 2D model to obtain the target virtual object configured for the game scene's preset image quality.
[0102] In this embodiment, based on the target vector of the virtual camera facing the game scene, the world space coordinates of the planar model in the game scene are determined. The target light source in the game scene is controlled to rotate towards the virtual camera to obtain the target light direction corresponding to the target light source. Based on the target light direction and ambient light information, the lighting and shadow effect information in the target light direction is determined. Based on the lighting and shadow effect information, the material information of the target virtual object, and the world space coordinates, the planar model is rendered to obtain the target virtual object configured for the game screen of the preset image quality of the game scene. This realizes the generation of target virtual objects in the game screen of the preset image quality of the game (fixed-view games are such as strategy games (SLG)) through the planar model. It is not necessary to use 3D models to generate target virtual objects in the game screen of the preset image quality, which greatly reduces the number of scene objects on the same screen, improves the frame rate, and reduces performance consumption. Furthermore, the target virtual object in this embodiment can change with the changes of lighting and shadow in the game scene, improving the presentation effect of the target virtual object in the game screen of the preset image quality, which is almost indistinguishable from the 3D model in the game screen of the high-quality image quality.
[0103] As can be seen from the above, in this embodiment, the ambient light information of the game scene is obtained, and a planar model is constructed. The display view of the game scene is a fixed view. Based on the target vector of the virtual camera facing the game scene, the world space coordinates of the planar model in the game scene are determined. The target light source in the game scene is controlled to rotate towards the virtual camera to obtain the target light direction corresponding to the target light source. Based on the target light direction and ambient light information, the light and shadow effect information in the target light direction is determined. Based on the light and shadow effect information, the material information of the target virtual object, and the world space coordinates, the planar model is rendered to obtain the target virtual object configured for the preset image quality of the game scene. This realizes the generation of the target virtual object in the preset image quality game scene through the planar model, without the need to use a 3D model to generate the target virtual object in the preset image quality game scene, reducing performance consumption. Furthermore, the target virtual object in this embodiment can change with the changes in light and shadow in the game scene, improving the presentation effect of the target virtual object.
[0104] The following is based on Figure 5 The rendering method for the model provided in this application will be further explained.
[0105] 501. Using the first game engine, the detailed level model of the target virtual object that meets the preset detailed conditions is rendered to obtain the ambient light information and color information of the game scene.
[0106] The first game engine could be, for example, the UE engine.
[0107] 502. In the first game engine, an initial planar model that meets the preset bending conditions is constructed. Based on the color information, the initial planar model is trimmed to obtain a planar model, and the planar model is sent to the second game engine.
[0108] The second game engine can be, for example, the NeoX2 game engine. After importing the 2D model into the second game engine, the 2D model can exist in .gim format.
[0109] 503. Using the second game engine, determine the first world coordinates and initial direction vector of the planar model in world space. Based on the target vector of the virtual camera facing the game scene, adjust the initial direction vector to obtain the direction vector of the planar model in world space.
[0110] 504. Using the second game engine, determine the second world coordinates of the planar model based on the direction vector and the first world coordinates.
[0111] 505. Using the second game engine, determine the masking range of the planar model based on its texture coordinates, and determine the coordinate offset based on the distance between the planar model and the virtual camera and the masking range.
[0112] 506. Using the second game engine, based on the coordinate offset, the second world coordinates are offset to obtain the world space coordinates of the planar model in the game scene.
[0113] 507. Using the second game engine, the light direction corresponding to the target light source in the game scene is transformed to obtain the transformed light direction. The transformed light direction and the direction vector are then multiplied to obtain the target light direction corresponding to the target light source.
[0114] 508. Using the second game engine, the target light direction is adjusted to obtain the adjusted light direction. The adjusted light direction and ambient light information are then multiplied by a dot product to obtain the light intensity information in the adjusted light direction. The light intensity information is then multiplied by the light color information to obtain the light and shadow effect information in the target light direction.
[0115] In this process, shaders can be created in the second game engine to implement steps 503-508 above.
[0116] 509. Using the second game engine, based on the lighting and shadow effects, the material information of the target virtual object, and the world space coordinates, the planar model is rendered to obtain the target virtual object configured for the game scene's preset image quality.
[0117] When steps 503-508 above are implemented through a shader, material information can be assigned to the GIF model in the shader, thereby realizing the rendering processing of the planar model based on the lighting effect information, the material information of the target virtual object and the world space coordinates, and obtaining the target virtual object with the game scene configured with the preset image quality.
[0118] The specific implementation method and corresponding beneficial effects of this embodiment can be referred to the above method embodiment, and this embodiment is not limited here.
[0119] To better implement the above methods, this application also provides a model rendering device, which can be integrated into an electronic device, such as a computer device, which can be a terminal, server or other device.
[0120] The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.
[0121] For example, in this embodiment, the method of this application embodiment will be described in detail by taking the model rendering device specifically integrated into the terminal as an example. This embodiment provides a model rendering device, such as... Figure 6 As shown, the model rendering device may include:
[0122] The information acquisition module 601 is used to acquire ambient light information of the game scene and construct a planar model. The display view of the game scene is a fixed view.
[0123] The first determining module 602 is used to determine the world space coordinates of the planar model in the game scene based on the target vector of the virtual camera oriented towards the game scene.
[0124] The second determining module 603 is used to control the target light source in the game scene to rotate towards the virtual camera, obtain the target light direction corresponding to the target light source, and determine the light and shadow effect information in the target light direction based on the target light direction and ambient light information.
[0125] The rendering processing module 604 is used to render the planar model based on the lighting and shadow effect information, the material information of the target virtual object, and the world space coordinates, so as to obtain the target virtual object configured for the game screen with the preset image quality of the game scene.
[0126] In some embodiments, the first determining module 602 is specifically used to perform:
[0127] Determine the first world coordinates and initial orientation vector of the planar model in world space;
[0128] Based on the target vector of the virtual camera for the game scene, the initial direction vector is adjusted to obtain the direction vector of the planar model in world space;
[0129] Based on the direction vector and the first world coordinates, the world space coordinates of the planar model in the game scene are determined.
[0130] In some embodiments, the first determining module 602 is specifically used to perform:
[0131] Based on the direction vector and the first world coordinates, determine the second world coordinates of the planar model in world space;
[0132] The coordinate offset is determined based on the distance between the planar model and the virtual camera;
[0133] Based on the coordinate offset, the second world coordinates are offset to obtain the world space coordinates of the planar model in the game scene.
[0134] In some embodiments, the first determining module 602 is specifically used to perform:
[0135] The masking range of the planar model is determined based on the texture coordinates of the planar model.
[0136] The coordinate offset is determined based on the distance between the planar model and the virtual camera, as well as the masking range.
[0137] In some embodiments, the second determining module 603 is specifically used for:
[0138] The light direction and direction vector corresponding to the target light source in the game scene are processed by dot product to obtain the target light direction corresponding to the target light source, so as to control the rotation of the target light source in the game scene towards the virtual camera.
[0139] In some embodiments, the second determining module 603 is specifically used for:
[0140] The dot product of the target light direction and ambient light information is used to obtain the light intensity information in the target light direction.
[0141] Multiply the light intensity information by the light color information to obtain the light and shadow effect information in the direction of the target light.
[0142] In some embodiments, the information acquisition module 601 is specifically used to perform:
[0143] Construct an initial planar model that meets the preset bending conditions;
[0144] Based on the color information of the target virtual object in the game scene, the initial planar model is clipped to obtain a planar model.
[0145] In some embodiments, the information acquisition module 601 is specifically used to perform:
[0146] The detailed model of the target virtual object that meets the preset detailed conditions is rendered to obtain the ambient light information of the game scene.
[0147] In practice, each of the above modules can be implemented as an independent entity or can be combined arbitrarily to be implemented as the same or several entities. For the specific implementation methods and corresponding beneficial effects of each of the above modules, please refer to the previous method embodiments, which will not be repeated here.
[0148] Accordingly, embodiments of this application also provide an electronic device, which can be a terminal, such as a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer (PC), personal digital assistant (PDA), or other terminal device. Figure 7 As shown, Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 700 includes a processor 701 with one or more processing cores, a memory 702 with one or more computer-readable storage media, and a computer program stored on the memory 702 and executable on the processor. The processor 701 and the memory 702 are electrically connected. Those skilled in the art will understand that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0149] The processor 701 is the control center of the electronic device 700. It connects various parts of the electronic device 700 through various interfaces and lines. By running or loading software programs and / or modules stored in the memory 702, and calling data stored in the memory 702, it performs various functions of the electronic device 700 and processes data, thereby monitoring the electronic device 700 as a whole.
[0150] In this embodiment, the processor 701 in the electronic device 700 loads the instructions corresponding to the processes of one or more application programs into the memory 702 according to the following steps, and the processor 701 runs the application programs stored in the memory 702 to achieve various functions, such as:
[0151] Acquire ambient lighting information of the game scene and construct a planar model. The display view of the game scene is a fixed view.
[0152] Based on the target vector of the virtual camera for the game scene, the world space coordinates of the planar model in the game scene are determined;
[0153] Control the target light source in the game scene to rotate towards the virtual camera, obtain the target light direction corresponding to the target light source, and determine the light and shadow effect information in the target light direction based on the target light direction and ambient light information;
[0154] Based on lighting and shadow effects, material information of the target virtual object, and world space coordinates, the planar model is rendered to obtain the target virtual object configured for the game scene's preset image quality.
[0155] For details on the specific implementation methods and corresponding beneficial effects of the above operations, please refer to the detailed description of the model rendering method above, which will not be repeated here.
[0156] Optional, such as Figure 7 As shown, the electronic device 700 also includes: a touch display screen 703, a radio frequency circuit 704, an audio circuit 705, an input unit 706, and a power supply 707. The processor 701 is electrically connected to the touch display screen 703, the radio frequency circuit 704, the audio circuit 705, the input unit 706, and the power supply 707. Those skilled in the art will understand that... Figure 7 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0157] The touch display screen 703 can be used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. The touch display screen 703 may include a display panel and a touch panel. The display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the electronic device. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Optionally, the display panel can be configured using a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar technologies. The touch panel can be used to collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel), generate corresponding operation commands, and execute the corresponding program according to the operation commands. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch location and the signal generated by the touch operation, transmitting the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 701. It can also receive and execute commands from the processor 701. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it transmits the information to the processor 701 to determine the type of touch event. Subsequently, the processor 701 provides corresponding visual output on the display panel based on the type of touch event. In this embodiment, the touch panel and the display panel can be integrated into the touch display screen 703 to achieve input and output functions. However, in some embodiments, the touch panel and the touch display screen 703 can be implemented as two independent components to achieve input and output functions. That is, the touch display screen 703 can also be used as part of the input unit 706 to achieve input functions.
[0158] The radio frequency circuit 704 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other electronic devices, and to transmit and receive signals with network devices or other electronic devices.
[0159] Audio circuitry 705 can be used to provide an audio interface between a user and an electronic device via a speaker and a microphone. Audio circuitry 705 converts received audio data into electrical signals, transmits them to the speaker, and the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuitry 705, converted back into audio data, and then processed by processor 701 before being transmitted via radio frequency circuitry 704 to, for example, another electronic device, or output to memory 702 for further processing. Audio circuitry 705 may also include an earphone jack to facilitate communication between peripheral headphones and electronic devices.
[0160] The input unit 706 can be used to receive input numbers, character information or user feature information (such as fingerprints, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0161] Power supply 707 is used to supply power to various components of electronic device 700. Optionally, power supply 707 can be logically connected to processor 701 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. Power supply 707 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0162] although Figure 7 As not shown in the diagram, the electronic device 700 may also include a camera, sensor, wireless fidelity module, Bluetooth module, etc., which will not be described in detail here.
[0163] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0164] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0165] Therefore, embodiments of this application provide a computer-readable storage medium storing multiple computer programs that can be loaded by a processor to execute any of the model rendering methods provided in embodiments of this application. For example, the computer program can perform the following steps:
[0166] Acquire ambient lighting information of the game scene and construct a planar model. The display view of the game scene is a fixed view.
[0167] Based on the target vector of the virtual camera for the game scene, the world space coordinates of the planar model in the game scene are determined;
[0168] Control the target light source in the game scene to rotate towards the virtual camera, obtain the target light direction corresponding to the target light source, and determine the light and shadow effect information in the target light direction based on the target light direction and ambient light information;
[0169] Based on lighting and shadow effects, material information of the target virtual object, and world space coordinates, the planar model is rendered to obtain the target virtual object configured for the game scene's preset image quality.
[0170] For details on the specific implementation methods and corresponding beneficial effects of the above operations, please refer to the detailed description of the model rendering method above, which will not be repeated here.
[0171] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0172] Since the computer program stored in the computer-readable storage medium can execute any of the model rendering methods provided in the embodiments of this application, it can achieve the beneficial effects that any of the model rendering methods provided in the embodiments of this application can achieve, as detailed in the preceding embodiments, and will not be repeated here.
[0173] The foregoing has provided a detailed description of a model rendering method, apparatus, electronic device, and computer-readable storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A model rendering method, characterized in that, include: The ambient light information of the game scene is acquired, and a planar model is constructed. The display view of the game scene is a fixed view. Based on the target vector of the virtual camera facing the game scene, determine the world space coordinates of the planar model in the game scene; Control the target light source in the game scene to rotate towards the virtual camera, obtain the target light direction corresponding to the target light source, and determine the light and shadow effect information in the target light direction based on the target light direction and the ambient light information; Based on the lighting and shadow effects information, the material information of the target virtual object, and the world space coordinates, the planar model is rendered to obtain the target virtual object configured for the game screen of the preset image quality of the game scene.
2. The model rendering method as described in claim 1, characterized in that, Determining the world space coordinates of the planar model in the game scene based on the target vector of the virtual camera facing the game scene includes: Determine the first world coordinates and initial direction vector of the planar model in the world space; Based on the target vector of the virtual camera facing the game scene, the initial direction vector is adjusted to obtain the direction vector of the planar model in world space; Based on the direction vector and the first world coordinates, the world space coordinates corresponding to the planar model in the game scene are determined.
3. The model rendering method as described in claim 2, characterized in that, Determining the world space coordinates of the planar model in the game scene based on the direction vector and the first world coordinates includes: Based on the direction vector and the first world coordinates, determine the second world coordinates of the planar model in the world space; The coordinate offset is determined based on the distance between the planar model and the virtual camera; Based on the coordinate offset, the second world coordinates are offset to obtain the world space coordinates of the planar model in the game scene.
4. The model rendering method as described in claim 3, characterized in that, The method further includes: Based on the texture coordinates of the planar model, the masking range of the planar model is determined; Determining the coordinate offset based on the distance between the planar model and the virtual camera includes: The coordinate offset is determined based on the distance between the planar model and the virtual camera, as well as the masking range.
5. The model rendering method as described in claim 2, characterized in that, The step of controlling the target light source in the game scene to rotate towards the virtual camera to obtain the target light direction corresponding to the target light source includes: The light direction corresponding to the target light source in the game scene is multiplied by the direction vector to obtain the target light direction corresponding to the target light source, so as to control the target light source in the game scene to rotate towards the virtual camera.
6. The model rendering method as described in claim 1, characterized in that, The determination of the light and shadow effect information in the target light direction based on the target light direction and the ambient light information includes: The target light direction and the ambient light information are dot-producted to obtain the light intensity information in the target light direction. Multiplying the light intensity information by the light color information yields the light and shadow effect information in the target light direction.
7. The model rendering method as described in claim 1, characterized in that, The construction of the planar model includes: Construct an initial planar model that meets the preset bending conditions; Based on the color information corresponding to the target virtual object in the game scene, the initial planar model is cropped to obtain the planar model.
8. The model rendering method according to any one of claims 1-7, characterized in that, The acquisition of ambient light information of the game scene includes: The detailed model of the target virtual object that meets the preset detailed conditions is rendered to obtain the ambient light information of the game scene.
9. A model rendering device, characterized in that, The device includes: The information acquisition module is used to acquire ambient light information of the game scene and construct a planar model. The display view of the game scene is a fixed view. The first determining module is used to determine the world space coordinates of the planar model in the game scene based on the target vector of the virtual camera facing the game scene; The second determining module is used to control the target light source in the game scene to rotate towards the virtual camera, obtain the target light direction corresponding to the target light source, and determine the light and shadow effect information in the target light direction based on the target light direction and the ambient light information; The rendering processing module is used to render the planar model based on the lighting effect information, the material information of the target virtual object, and the world space coordinates to obtain the target virtual object configured for the game screen with the preset image quality of the game scene.
10. An electronic device, characterized in that, The system includes a processor and a memory, the memory storing multiple instructions; the processor loads instructions from the memory to execute the model rendering method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to execute the model rendering method according to any one of claims 1 to 8.