Rendering method and device, electronic equipment and computer readable storage medium
By binding reference points of 3D models to virtual cameras in the game art production process, the shooting angle and range are automatically adjusted, solving the problem of low efficiency in manual adjustment and achieving efficient 2D image generation.
Patent Information
- Application Number
- CN202511265987.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-04
- Publication Date
- 2025-12-16
AI Technical Summary
In the game art production process, manually adjusting the shooting angle of the virtual camera is inefficient when converting 3D resources into 2D preview images or animation sequences, resulting in low efficiency in generating 2D preview images or animation sequences.
By reading the target 3D model from the 3D model file, configuring the reference point as the rotation pivot and binding it to the virtual camera, the target rotation angle is obtained, the model area of the 3D model within the shooting range of the virtual camera is automatically changed, and the virtual camera is controlled to shoot, thus achieving automatic rendering processing and generating a 2D image.
It eliminates the need for manual adjustment of the virtual camera angle, improving the efficiency of generating 2D images and enabling automatic rendering in multiple directions.
Smart Images

Figure CN121147294A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of rendering technology, specifically to a rendering method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] In the game art production process, in order to facilitate UI designers and planning teams to quickly review, evaluate and archive asset content, it is usually necessary to convert a large number of 3D resources, such as character models, weapons and props, environment components and scene fragments, into standardized 2D preview images or animation sequences.
[0003] In the process of converting 3D resources into 2D preview images or animation sequences, the shooting angle of the virtual camera needs to be manually adjusted in order to output the 2D effect of the 3D resources in different directions. However, manually adjusting the shooting angle of the virtual camera is inefficient, resulting in low efficiency in generating 2D preview images or animation sequences. Summary of the Invention
[0004] This application provides a rendering method, apparatus, electronic device, and computer-readable storage medium that can improve the efficiency of generating two-dimensional images.
[0005] In a first aspect, embodiments of this application provide a rendering method, the method comprising:
[0006] Read the target 3D model from the 3D model file, and configure the reference points on the target 3D model as rotation pivots, wherein the rotation pivots and the virtual camera are bound together;
[0007] Obtain at least one target rotation angle;
[0008] Based on each of the above target rotation angles and the above rotation pivots, the model area of the above target 3D model within the shooting range of the above virtual camera is changed, and the above virtual camera is controlled to shoot the above target 3D model each time it is changed, so as to obtain the shooting content;
[0009] Based on the above-mentioned captured content, a two-dimensional image of the above-mentioned target three-dimensional model is obtained through rendering.
[0010] Secondly, embodiments of this application also provide a rendering apparatus, the apparatus comprising:
[0011] The reading module is used to read the target 3D model from the 3D model file and configure the reference points on the target 3D model as rotation pivots, wherein the rotation pivots are bound to the virtual camera;
[0012] The acquisition module is used to acquire at least one target rotation angle;
[0013] The shooting module is used to change the model area of the three-dimensional model of the target within the shooting range of the virtual camera based on each of the above-mentioned target rotation angles and rotation pivots, and to control the virtual camera to shoot the three-dimensional model of the target each time the change is made, so as to obtain the shooting content;
[0014] The rendering module is used to perform rendering processing based on the above-mentioned captured content to obtain a two-dimensional image of the above-mentioned target three-dimensional model.
[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 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 rendering methods provided in embodiments of this application.
[0017] Beneficial effects: In this embodiment, the target 3D model is read from a 3D model file, and reference points on the target 3D model are configured as rotation pivots, wherein the rotation pivots and the virtual camera are bound together; at least one target rotation angle is obtained; based on each target rotation angle and rotation pivot, the model area of the target 3D model within the shooting range of the virtual camera is changed, and the virtual camera is controlled to shoot the target 3D model each time it is changed to obtain the captured content; based on the captured content, rendering processing is performed to obtain a 2D image of the target 3D model, thereby realizing the automatic change of the model area of the target 3D model within the shooting range of the virtual camera without the need to manually adjust the shooting angle of the virtual camera, thus improving the efficiency of generating 2D images. 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 diagram of the rendering system provided in an embodiment of this application;
[0020] Figure 2 This is a schematic flowchart of one embodiment of the rendering method provided in this application;
[0021] Figure 3 This is a schematic diagram of the rendering configuration interface provided in the embodiments of this application;
[0022] Figure 4 This is another schematic diagram of the rendering configuration interface provided in the embodiments of this application;
[0023] Figure 5 This is a schematic flowchart of one embodiment of the rendering method provided in this application.
[0024] Figure 6 This is a schematic diagram of the 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 rendering method, apparatus, electronic device, and computer-readable storage medium. Specifically, the 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] For example, such as Figure 1 As shown, the electronic device is illustrated using terminal 10 and server 20 as an example. Terminal 10 can send a 3D model file and at least one target rotation angle to server 20. Server 20 reads the target 3D model from the 3D model file and configures a reference point on the target 3D model as a rotation pivot. The rotation pivot and the virtual camera are bound together. Based on each target rotation angle and rotation pivot, the model area of the target 3D model within the shooting range of the virtual camera is changed. Each time the model is changed, the virtual camera is controlled to shoot the target 3D model to obtain the captured content. The captured content is then rendered to obtain a 2D image of the target 3D model, which is then returned to terminal 10 for storage.
[0033] 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.
[0034] In this embodiment, a terminal is used as an example for illustration. This embodiment provides a rendering method, such as... Figure 2 As shown, the specific process of this rendering method can be as follows:
[0035] 201. Read the target 3D model from the 3D model file and configure the reference points on the target 3D model as rotation pivots. The rotation pivots and the virtual camera are bound together.
[0036] In this embodiment, a 3D model file refers to a file that includes at least one 3D model. A 3D model is a digital 3D representation of an object; for example, a 3D model may include at least one of a virtual character, virtual equipment, and virtual buildings. This embodiment does not impose any limitation on this. A 3D model file may include at least one 3D model, and the target 3D model can be any one of the at least one 3D model. A reference point on the target 3D model can be any point on the target 3D model; for example, a reference point on the target 3D model can be the center point or a vertex of the target 3D model. This embodiment does not impose any limitation on this. A reference point may include at least one.
[0037] A rotation pivot refers to at least one fulcrum around which a rotation operation is performed. When the rotation pivot is represented by one fulcrum, there can be one reference point. When the rotation pivot is represented by multiple fulcrums, the rotation pivot can be understood as an axis, and there can be multiple reference points. Optionally, the rotation pivot can be represented by a position variable. The value of the position variable can be empty or a preset position. Configuring a reference point on the target 3D model as the rotation pivot can be understood as updating the value of the position variable to the position of the reference point. The virtual camera, as the rendering window, represents the user's viewpoint when viewing the target 3D model. The rotation pivot and the virtual camera are bound together; this can be understood as binding the position variable to the virtual camera so that the position and / or orientation of the virtual camera changes as the value of the position variable changes.
[0038] Optionally, the terminal may read the target 3D model from the 3D model file when it receives the rendering instruction, or the terminal may read the target 3D model from the 3D model file when it obtains the 3D model file. This embodiment does not limit this.
[0039] 202. Obtain at least one target rotation angle.
[0040] In this embodiment, at least one target rotation angle is used to indicate the deflection of the target 3D model or virtual camera. The number of such angles can be set according to the actual situation. For example, the number of at least one target rotation angle can be 8 or 16. This embodiment does not limit this.
[0041] Optionally, the target rotation angles of different target 3D models in the same 3D model file can be the same, and the target rotation angles of target 3D models in different 3D model files can be the same or different. For example, the 3D model files include files f1 and f2, file f1 includes models m1 and m2, and file f2 includes model m3. The target rotation angles of model m1 and model m2 are the same, and the target rotation angles of model m1 and model m2 can be the same or different from the target rotation angle of model m3.
[0042] Optionally, at least one target rotation angle can be a pre-set angle, or at least one target rotation angle can be dynamically set according to the user's needs. In this case, obtaining at least one target rotation angle includes:
[0043] The rendering configuration interface is displayed, showing at least one rotation angle;
[0044] In response to a selection operation for at least one rotation angle, at least one target rotation angle is obtained.
[0045] The target rotation angle can be at least one of the rotation angles. The method of displaying at least one rotation angle on the rendering configuration interface can be set according to the actual situation. For example, an angle control can be displayed on the rendering configuration interface, with an identifier or string displayed on the angle control. This embodiment does not limit this. When an identifier is displayed on the angle control, the identifier can be, for example, as shown in the example below. Figure 3 As shown, in Figure 3 It includes 8 angle controls, each with a different label. The 8 angle controls represent 8 rotation angles: top right, top, top left, left, bottom left, bottom, bottom right, and right.
[0046] Optionally, when an indicator is displayed on the angle control, the first indicator is normally displayed. When the cursor is over the angle control, the first indicator can be updated to the second indicator. After an angle control is selected, the indicator displayed on the selected angle control can be updated to the third indicator, thus realizing a three-state button animation. This allows users to better distinguish between the selected and unselected rotation angles and adds interest to the rendering process. The first, second, and third indicators can be set according to the actual situation. For example, the first indicator can be set as follows: Figure 3 The white background, stationary arrow, and stationary animal shown in the illustration can be used as the second identifier. Alternatively, the white background, stationary arrow, and moving animal can be used as the third identifier. This embodiment does not impose any limitations on these elements.
[0047] The rotation angle selection operation can be set according to the actual situation. For example, the selection operation can be a click operation or an input operation. This embodiment does not limit it here.
[0048] Optionally, the rendering configuration interface may also include at least one of the following: a file input control, a location selection control, a rendering size control, a range control, a single rendering control, and a batch rendering control. The file input control is used to select a 3D model file. Optionally, after selecting a 3D model file, the path information of the 3D model file can also be displayed in the file area of the rendering configuration interface, for example... Figure 2 As shown, "Add Folder" is used to select multiple 3D model files, and "Add File" is used to select a single 3D model file. The location selection control is used to set the location for storing 2D images, such as... Figure 2 As shown. The render size control is used to set the size of a 2D image, for example, as... Figure 3As shown, you can choose 1k or 500 as the size of the 2D image. Alternatively, you can set 1k and 500 to 256 or 2048 without modifying the core logic, offering strong scalability. The range control is used to set the frame range, indicating which frame images in the output 3D model file contain the 2D image of the 3D model, for example... Figure 3 As shown, this indicates the output of 2D images of the 3D model in frames 0-7 of the 3D model file. A single rendering control indicates the generation of 2D images of the 3D model in one 3D model file, while a batch rendering control indicates the generation of 2D images of the 3D model in multiple 3D model files.
[0049] In this embodiment, a rendering configuration interface is displayed, which shows at least one rotation angle. In response to the selection operation of at least one rotation angle, at least one target rotation angle is obtained, so that the user can dynamically adjust the target rotation angle according to their own needs, improving the flexibility of setting the target rotation angle. This makes the generated two-dimensional image more in line with the user's needs. In addition, the rendering configuration interface can also configure other rendering parameters, reducing the error rate of rendering parameter configuration.
[0050] In some embodiments, a rendering configuration interface is displayed, including:
[0051] Obtain a preset rotation angle table, which includes at least one rotation angle;
[0052] The rendering configuration interface is displayed based on a preset rotation angle table.
[0053] The preset rotation angle table is a pre-set table that can be configured according to actual conditions. For example, the preset rotation angle table may include 8 rotation angles or 16 rotation angles.
[0054] In this embodiment, since the rendering configuration interface can be displayed according to the preset rotation angle table, the preset rotation angle table can be modified when at least one rotation angle does not meet the requirements. For example, the 8 rotation angles can be modified to 16 rotation angles, so that the displayed at least one rotation angle better meets the user's needs, further improving the flexibility of subsequent generation of two-dimensional images. Moreover, there is no need to modify the core logic, and the scalability is strong.
[0055] 203. Based on the rotation angle and rotation pivot of each target, change the model area of the target 3D model within the shooting range of the virtual camera, and control the virtual camera to shoot the target 3D model each time it is changed to obtain the shooting content.
[0056] In this system, when controlling a virtual camera to capture images of a target 3D model, the content captured by the virtual camera is the area of the target 3D model within the camera's field of view. The virtual camera serves as the user's perspective for viewing the target 3D model. Because the area of the target 3D model within the virtual camera's field of view varies, the area captured by the virtual camera differs, resulting in different areas of the model viewed by the user. This allows the user to view different regions of the target 3D model through a 2D image.
[0057] Optionally, the process of controlling the virtual camera to capture the target 3D model and obtain the captured content can be triggered each time the model area of the target 3D model is changed within the shooting range of the virtual camera. Alternatively, the process of controlling the virtual camera to capture the target 3D model and obtain the captured content can be triggered before the model area of the target 3D model is changed within the shooting range of the virtual camera for the first time, and then the process of controlling the virtual camera to capture the target 3D model and obtain the captured content can be triggered each time the model area of the target 3D model is changed within the shooting range of the virtual camera. This embodiment does not limit the scope of the process.
[0058] Optionally, the target 3D model can be rotated to change the area of the target 3D model within the shooting range of the virtual camera; alternatively, the virtual camera can be rotated to change the area of the target 3D model within the shooting range of the virtual camera. That is, changing the area of the target 3D model within the shooting range of the virtual camera based on each target rotation angle and rotation pivot includes: controlling the target 3D model to rotate around a rotation pivot based on each target rotation angle to change the area of the target 3D model within the shooting range of the virtual camera; or, controlling the virtual camera to rotate around a rotation pivot based on each target rotation angle to change the area of the target 3D model within the shooting range of the virtual camera.
[0059] Specifically, when controlling the target 3D model to rotate around the rotation pivot based on each target rotation angle, the orientation and position of the virtual camera remain unchanged. Conversely, when controlling the virtual camera to rotate around the rotation pivot based on each target rotation angle, the position and orientation of the target 3D model remain unchanged. It can be understood that when controlling the target 3D model to rotate around the rotation pivot based on each target rotation angle, the virtual camera can be set according to the value of the position variable, a preset distance, and a preset direction when binding the rotation pivot and the virtual camera. Similarly, when controlling the virtual camera to rotate around the rotation pivot based on each target rotation angle, the virtual camera can be set according to the value of the position variable and a preset distance, with the orientation of the virtual camera determined by the target rotation angle.
[0060] It is understandable that when there are multiple target rotation angles, the target 3D model can be controlled to rotate around a rotation pivot based on one target rotation angle, and the virtual camera can be controlled to capture the target 3D model to obtain the captured content. Then, based on another target rotation angle, the target 3D model can be controlled to rotate around the rotation pivot, and the virtual camera can be controlled to capture the target 3D model to obtain the captured content. For example, if the target rotation angles include rotation angles a1, a2, and a3, the target 3D model can be controlled to rotate around the rotation pivot based on rotation angle a1, and the virtual camera can be controlled to capture the target 3D model to obtain captured content d1. Based on rotation angle a2, the target 3D model can be controlled to rotate around the rotation pivot, and the virtual camera can be controlled to capture the target 3D model to obtain captured content d2. Based on rotation angle a3, the target 3D model can be controlled to rotate around the rotation pivot, and the virtual camera can be controlled to capture the target 3D model to obtain captured content d3. The process of controlling the virtual camera to rotate around the rotation pivot based on each target rotation angle can be referred to as the process of controlling the target 3D model to rotate around the rotation pivot based on each target rotation angle, which will not be elaborated here.
[0061] 204. Render the captured content to obtain a two-dimensional image of the target 3D model.
[0062] In this process, after capturing the captured content, the terminal renders the content to obtain a two-dimensional image of the model area. Optionally, the number of two-dimensional images for each target 3D model can be the number of target rotation angles; for example, if the target rotation angle is 8, then 8 captured contents and 8 frames of two-dimensional images can be obtained. Optionally, two-dimensional images of the same target 3D model can be stored in the same file. Optionally, the terminal can render the target 3D model in a single 3D model file or in multiple 3D model files. Optionally, the terminal can perform rendering processing locally based on the captured content or through a server. When rendering processing is performed through a server based on the captured content, the resulting two-dimensional image of the target 3D model includes:
[0063] Scene description information is generated based on rendering parameters, including the target rotation angle.
[0064] The captured content and scene description information are sent to the server, so that the server can render the captured content based on the scene description information to obtain a two-dimensional image of the target three-dimensional model.
[0065] The scene description information, which instructs the server on how to render the captured content, can be in JSON format. Optionally, when other parameters are set, the rendering parameters may also include other parameters, such as at least one of the following: the location for storing the 2D image, the size of the 2D image, and the frame range.
[0066] The server can be a single entity or a server cluster. When using a server cluster, the terminal can generate at least two rendering tasks based on scene description information and the captured content. These tasks are then submitted to the server cluster, which performs rendering processing based on these tasks to obtain a 2D image of the target 3D model. Optionally, the server cluster can include a scheduler to distribute rendering tasks to the various servers within the cluster. The type of scheduler can be configured according to specific needs; for example, it could be Deadline, AWS Thinkbox, or a self-developed scheduler. This embodiment does not impose any limitations on this. Rendering through a server cluster can significantly improve GPU / CPU resource utilization and increase cluster utilization.
[0067] Optionally, when the target rotation angle is obtained through the rendering configuration interface, the rotation configuration interface may also include a rendering device selection control for selecting whether to render locally or via a server. For example, the rendering configuration interface may be as follows: Figure 3 As shown, in response to the first operation of "Render current file", the terminal performs rendering processing based on the captured content; in response to the second operation of "Render current file", a rendering device selection control is displayed, such as... Figure 4 As shown, in response to the trigger operation of the rendering device selection control, scene description information is generated based on interface parameters, and the captured content and scene description information are sent to the server for rendering processing. Alternatively, in response to the third operation of "batch rendering", batch rendering processing is performed on the terminal based on the captured content. In response to the fourth operation of "batch rendering", the rendering device selection control is displayed. In response to the trigger operation of the rendering device selection control, scene description information is generated based on rendering parameters, and the captured content and scene description information are sent to the server for batch rendering processing.
[0068] In this embodiment, scene description information is generated based on rendering parameters, including the target rotation angle. The captured content and scene description information are sent to the server so that the server can render the captured content based on the scene description information to obtain a two-dimensional image of the target three-dimensional model, thus achieving seamless switching between local rendering and a render farm.
[0069] Optionally, the application scenarios of this application can be set according to the actual situation. For example, it can be applied to game development to convert the three-dimensional models in the game scene into two-dimensional preview images or animation sequences, so that UI designers and / or planning teams can check and evaluate the asset content. Alternatively, it can be used to convert the three-dimensional effects of the UI into a two-dimensional process, such as converting skill effects or UI avatar bubbles into a two-dimensional process. This embodiment does not limit this.
[0070] Optionally, during the rendering process based on the captured content to obtain a 2D image of the target 3D model, the rendering progress can be displayed on the graphical user interface so that players can understand the rendering progress in real time. Optionally, a pop-up window can be displayed when a rendering error occurs, so as to display detailed error information through the pop-up window. Optionally, the storage method of the 2D image can be set according to the actual situation. For example, the rendering identifier (which can be used to indicate the purpose, quality level, processing method or production stage), file name and / or special tags (such as mask type or version) in the 3D model can be parsed, and a multi-level directory can be created based on the rendering identifier, file name and / or special tags. The rendering identifier, file name and / or special tags can be the names of the multi-level directory so that the 2D image can be stored in the corresponding directory. In addition, multiple 2D images of different sizes can also be output in parallel.
[0071] In this embodiment, based on the rotation angle and pivot of each target, the model area of the target 3D model within the shooting range of the virtual camera is changed, and the virtual camera is controlled to shoot the target 3D model each time it is changed to obtain the shooting content. The shooting content is then rendered to obtain a 2D image of the target 3D model, thereby realizing automatic rendering of the target 3D model from multiple directions and improving the efficiency of obtaining a 2D image of the target 3D model.
[0072] In some embodiments, this embodiment further includes:
[0073] Generate a transparent background 2D animation for preview based on a 2D image;
[0074] The two-dimensional image is de-opacified and a gray background is added to obtain the processed two-dimensional image.
[0075] A gray-background 2D animation is generated from the processed 2D image for preview.
[0076] In this embodiment, a transparent background 2D animated image refers to a 2D animated image with a transparent background, and a gray background 2D animated image refers to a 2D animated image with a gray background. The format of the 2D image can be set according to actual needs; for example, the format can be PNG or TGA, but this embodiment does not limit this. The format of the 2D animated image can be set according to actual needs; for example, the format can be GIF or WebP, but this embodiment does not limit this. Optionally, the method for generating the 2D animated image can be set according to actual needs; for example, a 2D animated image can be generated using Gifski at 10fps, but this embodiment does not limit this.
[0077] In related technologies, since the background of the 3D model in the 3D model file is usually transparent, the background of the 2D image is also transparent. The 2D image with a transparent background is not conducive to observation. Therefore, in this embodiment, a 2D animation with a transparent background for preview is generated based on the 2D image. The 2D image is then de-opacified and a gray background is added to obtain a processed 2D image. A 2D animation with a gray background for preview is generated based on the processed 2D image, so as to generate two preview files, a transparent version and a gray background version. This eliminates the need to generate the preview file of the 2D animation through third-party attacks, thus improving the generation efficiency.
[0078] In some embodiments, the 3D model file includes a main 3D model and a subsidiary 3D model. The subsidiary 3D model is attached to the main 3D model through attachment points on the main 3D model. The target 3D model may include the main 3D model and the subsidiary 3D model. In this case, the 2D image includes the 2D information of the main 3D model and the 2D information of the subsidiary 3D model. Alternatively, the target 3D model is the main 3D model. This embodiment also includes:
[0079] Obtain the 3D world coordinates of the target hanging point of the target 3D model relative to the 2D image from the 3D model file;
[0080] Based on the three-dimensional world coordinates, determine the two-dimensional screen coordinates of the target hanging point, and determine the distance between the target hanging point and the virtual camera;
[0081] Based on distance and two-dimensional screen coordinates, determine the target's three-dimensional coordinates at the target hanging point;
[0082] Based on the target's three-dimensional coordinates, the target's attached three-dimensional model is mapped onto the two-dimensional image to obtain the target's two-dimensional image. The target's attached three-dimensional model is the attached three-dimensional model that is attached to the target's three-dimensional model through the target's attachment point.
[0083] In this context, a "hanging point" refers to a marked point on the main 3D model that provides a connection location for the subordinate 3D model. The main 3D model refers to the 3D model being mounted, while the subordinate 3D model refers to the 3D model mounted onto the main 3D model. For example, if the main 3D model is a virtual game character and the subordinate 3D model is a virtual weapon or hat, the hanging point is the location where the virtual weapon is equipped or the hat is worn on the virtual game character. Or, if the main 3D model is a virtual weapon and the subordinate 3D model is an accessory, the hanging point is the location where the accessory is displayed on the virtual weapon.
[0084] The target 3D model's target anchor point relative to the 2D image can be understood as an anchor point on the model area within the virtual camera's field of view, which may include at least one. After obtaining the 3D world coordinates of the target anchor point, these coordinates can be first converted to first coordinates in camera space, then to second coordinates in clipping space, and finally to 2D screen coordinates in screen space. Optionally, the 2D screen coordinates can be obtained directly through the transformation of the 3D world coordinates, or they can be obtained by transforming and normalizing the 3D world coordinates. When obtained through the transformation and normalization of the 3D world coordinates, the process of determining the 2D screen coordinates of the target anchor point based on the 3D world coordinates can be as follows:
[0085] Get the viewport width and viewport height, as well as the rendering width and rendering height;
[0086] The scaling factor is determined based on the viewport width, viewport height, render width, and render height.
[0087] Determine the margins of the rendering area within the viewport based on the viewport width, viewport height, rendering width, rendering height, and scaling factor.
[0088] Convert 3D world coordinates to initial 2D screen coordinates in screen space;
[0089] The initial two-dimensional screen coordinates are normalized based on the margins, viewport width, and viewport height to obtain the two-dimensional screen coordinates.
[0090] The initial rendering height and initial rendering width can be obtained, where the rendering width is the initial rendering width and the rendering height is obtained by dividing the initial rendering height by the pixel aspect ratio, in order to further improve the accuracy of the two-dimensional screen coordinates. Optionally, the process of determining the scaling factor based on the viewport width, viewport height, rendering width, and rendering height can be as follows: divide the viewport width by the rendering width to obtain a first ratio, divide the viewport height by the rendering height to obtain a second ratio, divide the first ratio by the second ratio to obtain a target ratio, and determine the scaling factor based on the target ratio from the first ratio and the second ratio. Specifically, the viewport width, viewport height, rendering width, and rendering height can be substituted into formulas (1) and (2) for calculation to obtain the scaling factor:
[0091] r_ratio=(s_x / r_x) / (s_y / r_y)(1)
[0092] ratio=s_y / r_y if r_ratio>1esle s_x / r_x(2)
[0093] Where r_ratio represents the target ratio, s_x represents the viewport width, s_y represents the viewport height, r_x represents the rendering width, r_y represents the rendering height, s_x / r_x represents the first ratio, s_y / r_y represents the second ratio, and ratio represents the scaling factor.
[0094] After obtaining the scaling factor, the rendering width can be multiplied by the scaling factor to obtain the first adjustment value. The viewport width can be subtracted from the first adjustment value and divided by 2 to obtain the first margin. The rendering height can be multiplied by the scaling factor to obtain the second adjustment value. The viewport height can be subtracted from the second adjustment value and divided by 2 to obtain the second margin. Specifically, the scaling factor, rendering width, rendering height, viewport width, and viewport height can be substituted into formulas (3) and (4) for calculation to obtain the first margin and the second margin.
[0095] x_min=(s_x-(r_x*ratio)) / 2(3)
[0096] y_min=(s_y-(r_y*ratio)) / 2(4)
[0097] Where x_min represents the first margin, y_min represents the second margin, r_x*ratio represents the first adjustment value, and r_y*ratio represents the second adjustment value.
[0098] After obtaining the first and second margins, subtract the first margin from the first initial screen coordinates in the initial two-dimensional screen coordinates to obtain the first difference. Subtract twice the first margin from the viewport width to obtain the second difference. Divide the first difference by the second difference to obtain the third ratio. Multiply the third ratio by the rendering resolution (the rendering resolution is the size of the two-dimensional image) to obtain the first screen coordinates in the two-dimensional screen coordinates. Subtract the second margin from the second initial screen coordinates in the initial two-dimensional screen coordinates to obtain the third difference. Subtract twice the second margin from the viewport height to obtain the fourth difference. Divide the third difference by the fourth difference to obtain the fourth ratio. Based on the fourth ratio, the rendering resolution, and 1, obtain the second screen coordinates in the two-dimensional screen coordinates. Specifically, the two-dimensional screen coordinates can be obtained through formulas (5), (6), and (7):
[0099] x=(px-x_min) / (s_x-(x_min*2))(5)
[0100]
[0101] pixel=point_2d*render_pixel(7)
[0102] Where x represents the third ratio, px represents the first initial screen coordinates, (px-x_min) represents the first difference, (s_x-x_min*2) represents the second difference, y represents the fourth ratio, py represents the second initial screen coordinates, (py-y_min) represents the third difference, (s_y-y_min*2) represents the fourth difference, if not y_top indicates that the coordinate system is not in the top left, pixel represents the two-dimensional screen coordinates, point_2d represents the third and fourth ratios, and render_pixel represents the rendering resolution.
[0103] Optionally, the method for determining the distance between the target mounting point and the virtual camera can be set according to the actual situation. For example, the distance between the target mounting point and the virtual camera can be determined based on the three-dimensional world coordinates of the target mounting point and the coordinates of the virtual camera. Alternatively, the distance between the target mounting point and the virtual camera can be determined based on the coordinates of a sphere centered on the three-dimensional world coordinates of the target mounting point and the coordinates of the virtual camera. Then, the distance can be used as the third-dimensional coordinates and combined with the two-dimensional screen coordinates to form the target's three-dimensional coordinates.
[0104] Optionally, while rendering the captured content to obtain a two-dimensional image, the three-dimensional world coordinates of the target three-dimensional model relative to the two-dimensional image can be obtained from the three-dimensional model file to determine the target three-dimensional coordinates of the target hanging point. Alternatively, the three-dimensional world coordinates of the target three-dimensional model relative to the two-dimensional image can be obtained from the three-dimensional model file after obtaining the two-dimensional image to determine the target three-dimensional coordinates of the target hanging point. This embodiment does not limit this.
[0105] Optionally, when rendering the captured content to obtain a 2D image, the process of determining the target 3D coordinates of the target anchor point can be triggered by default. Alternatively, the process of determining the target 3D coordinates of the target anchor point can be triggered only when an output command is received. Or, the process of generating the 2D image and determining the target 3D coordinates of the target anchor point can be triggered simultaneously when an output command is received. The method of obtaining the output command can be set according to the actual situation. For example, when a rendering configuration interface exists, the rendering configuration interface can include anchor point output controls such as... Figure 4 As shown, the output command is a trigger command for the hanging point output control. Alternatively, the output command can also be obtained via voice, which is not limited in this embodiment. Optionally, when the process of generating a two-dimensional image and determining the target three-dimensional coordinates of the target hanging point are triggered simultaneously upon receiving the output command, a preview file of a two-dimensional animation can also be generated simultaneously, realizing a one-click completion of the entire process of hanging point coordinate output, rendering, and preview.
[0106] Optionally, in this embodiment, the process of generating a two-dimensional image of the target three-dimensional model and determining the target three-dimensional coordinates of the target attachment point can be executed in modeling and rendering software (such as 3ds Max or Blender). Based on the target three-dimensional coordinates of the target attachment point, the process of mapping the target's attached three-dimensional model to the two-dimensional image to obtain the target two-dimensional image can be executed in the game engine. The way the target three-dimensional coordinates of the target attachment point are determined in this embodiment allows the game engine to map the target's attached three-dimensional model to the two-dimensional image simply by parsing the target's three-dimensional coordinates, reducing the dependence on the underlying rendering engine (Sprite or Mesh) in the game engine and facilitating rapid iteration and porting.
[0107] In this embodiment, the 3D model file includes a main 3D model and an auxiliary 3D model. The auxiliary 3D model is mounted onto the main 3D model through mounting points on the main 3D model. The target 3D model is the main 3D model, meaning that the 2D image does not include the 2D information of the auxiliary 3D model. Therefore, the 3D world coordinates of the target mounting point of the target 3D model relative to the 2D image are obtained from the 3D model file. Based on the 3D world coordinates, the 2D screen coordinates of the target mounting point are determined, and the distance between the target mounting point and the virtual camera is determined. Based on the distance and the 2D screen coordinates, the target 3D coordinates of the target mounting point are determined. Based on the target 3D coordinates, the target auxiliary 3D model is mapped onto the 2D image to obtain the target 2D image. The target auxiliary 3D model is the auxiliary 3D model mounted onto the target 3D model through the target mounting point, so that the target 2D image includes the 2D information of the target auxiliary 3D model. Furthermore, the coordinates of the mounting point are automatically obtained without manual recording, and the target 3D coordinates of the target mounting point are obtained. During the coordinate process, the relative depth between the target attachment point and the virtual camera is preserved. This allows for simple comparisons during the mapping of the target's 3D model onto a 2D image based on the target's 3D coordinates. This ensures that the 2D information of the target's 3D model and the main 3D model have a hierarchical relationship in the target 2D image, enabling game-level layering without the need for additional z-layer design. Furthermore, it ensures that the position of the attachment point on the 3D model and its position in the target 2D image remain pixel-level consistent. This allows for dynamic binding of the target 3D coordinates of the attachment point and the skeleton of the 3D model during gameplay, eliminating the need for secondary fine-tuning by artists and reducing human communication costs. Additionally, whenever the target 3D model's area within the virtual camera's field of view changes, the target 3D coordinates of the attachment point are automatically determined, ensuring that the 2D information accurately fits the 3D model from any perspective, achieving true multi-angle compatibility.
[0108] In some embodiments, determining the target three-dimensional coordinates of the target hanging point based on distance and two-dimensional screen coordinates includes:
[0109] Subtract the target value from the distance to obtain the depth coordinates of the target anchor point relative to the virtual camera. The target value is a preset value or determined based on the target's attached 3D model.
[0110] Based on depth coordinates and two-dimensional screen coordinates, determine the target's three-dimensional coordinates at the target attachment point.
[0111] The preset value refers to a pre-set value, which can be set according to the actual situation. For example, the preset value can be 1700 or 1600, but this embodiment does not limit it. After obtaining the depth coordinates, the depth coordinates and the two-dimensional screen coordinates can be combined to form the target three-dimensional coordinates of the target hanging point.
[0112] In this embodiment, the distance is subtracted from the target value to obtain the depth coordinates of the target hanging point relative to the virtual camera. The target value is a preset value or determined based on the target's attached 3D model. Based on the depth coordinates and 2D screen coordinates, the target 3D coordinates of the target hanging point are determined to further improve the accuracy of the game hierarchy sorting.
[0113] In some embodiments, this embodiment further includes:
[0114] Determine the bounding box of the target's attached 3D model;
[0115] The maximum and minimum depth values of the target's attached 3D model are determined based on the bounding box.
[0116] The target value is determined based on the maximum and minimum depth values.
[0117] The maximum depth value is the maximum distance between the bounding box and the virtual camera, and the minimum depth value is the minimum distance between the bounding box and the virtual camera. The depth difference is obtained by subtracting the minimum depth value from the maximum depth value, and half of this depth difference is used as the target value.
[0118] In this embodiment, the bounding box of the target's attached 3D model is determined, and the maximum and minimum depth values of the target's attached 3D model are determined based on the bounding box. Based on the maximum and minimum depth values, the target value is determined, thereby improving the accuracy of the target value and further improving the accuracy of the game's hierarchical ranking.
[0119] In some embodiments, the target 3D coordinates of target hanging points for the same frame of 2D images are stored in the same hanging point sub-file, and the hanging point sub-files corresponding to the 2D images are stored in the hanging point files corresponding to the 3D model files according to the generation order of the 2D images. This embodiment also includes:
[0120] Copy the hanging point sub-file corresponding to the first frame of the target 3D model to the position after the hanging point sub-file corresponding to the last frame of the target 3D model.
[0121] Specifically, copying the attachment file corresponding to the first frame of the target 3D model's 2D image to the position after the attachment file corresponding to the last frame of the target 3D model can be understood as appending the attachment file corresponding to the first frame of the target 3D model's 2D image to the position after the attachment file corresponding to the last frame of the target 3D model's 2D image. The format of the attachment file can be set according to the actual situation; for example, the attachment file can be a Lua table or a dictionary. This embodiment does not limit this.
[0122] In this embodiment, the target 3D coordinates of the target attachment points for the same frame of 2D image are stored in the same attachment point sub-file. The attachment point sub-files corresponding to the 2D images are stored in the attachment point file corresponding to the 3D model file according to the generation order of the 2D images. The attachment point sub-file corresponding to the first frame of the target 3D model is copied to the position after the attachment point sub-file corresponding to the last frame of the target 3D model, ensuring that the target 3D coordinates of the first frame and the target 3D coordinates of the tail in the attachment point file are consistent. This allows the transition frame to be determined and played based on the last frame of the target 2D image of the target 3D model and the added target 3D coordinates during the display of the target 2D image of the target 3D model in the game engine, before playing the first frame of the target 2D image of the target 3D model, ensuring a seamless connection and avoiding frame skipping.
[0123] The following is based on Figure 5 The rendering method provided in this application will be further explained.
[0124] The rendering configuration interface is displayed through a graphical user interface;
[0125] Drag and drop the 3D model file into the file area on the rendering configuration interface;
[0126] Choose the rendering size (the rendering size is the size of the 2D image), frame range, and set the location to store the 2D image;
[0127] Select the target rotation angle from at least one rotation angle;
[0128] In response to a trigger operation on a single rendering control or a batch rendering control, the system controls the rotation of the 3D model in the 3D file or the rotation of the virtual camera based on the target rotation angle and rotation pivot. Upon completion of each rotation, the system controls the virtual camera to capture images of the 3D model and obtain the captured content.
[0129] Rendering is performed based on the captured content to obtain a two-dimensional image corresponding to the three-dimensional model;
[0130] Displays the rendering progress and the name of the 3D file being rendered;
[0131] After obtaining the two-dimensional image, the corresponding hanging point files for the two-dimensional animation and the three-dimensional file are generated and stored according to a multi-level directory.
[0132] As can be seen from the above, in this embodiment, the target 3D model is read from the 3D model file, and reference points on the target 3D model are configured as rotation pivots, wherein the rotation pivots and the virtual camera are bound together; at least one target rotation angle is obtained; based on each target rotation angle and rotation pivot, the model area of the target 3D model within the shooting range of the virtual camera is changed, and the virtual camera is controlled to shoot the target 3D model each time it is changed to obtain the captured content; based on the captured content, rendering processing is performed to obtain a 2D image of the target 3D model, thereby realizing the automatic change of the model area of the target 3D model within the shooting range of the virtual camera without the need to manually adjust the shooting angle of the virtual camera, thus improving the efficiency of generating 2D images.
[0133] To better implement the above methods, this application also provides a rendering device, which can be integrated into an electronic device, such as a computer device, which can be a terminal, server, or other device.
[0134] For example, in this embodiment, the method of this application embodiment will be described in detail with the example of the rendering device being specifically integrated into the terminal. This embodiment provides a rendering device, such as... Figure 6 As shown, the rendering apparatus may include:
[0135] The reading module 601 is used to read the target 3D model from the 3D model file and configure the reference points on the target 3D model as rotation pivots, wherein the rotation pivots and the virtual camera are bound together.
[0136] Acquisition module 602 is used to acquire at least one target rotation angle;
[0137] The shooting module 603 is used to change the model area of the target 3D model within the shooting range of the virtual camera based on the rotation angle and rotation pivot of each target, and to control the virtual camera to shoot the target 3D model each time it is changed, so as to obtain the shooting content;
[0138] The rendering module 604 is used to perform rendering processing based on the captured content to obtain a two-dimensional image of the target three-dimensional model.
[0139] In some embodiments, the imaging module 603 is specifically used for:
[0140] Based on each target rotation angle, control the target 3D model to rotate around the rotation pivot to change the model area of the target 3D model within the shooting range of the virtual camera;
[0141] Alternatively, based on the rotation angle of each target, the virtual camera can be controlled to rotate around a rotation pivot to change the area of the target 3D model within the virtual camera's field of view.
[0142] In some embodiments, the 3D model file includes a main 3D model and a subsidiary 3D model. The subsidiary 3D model is attached to the main 3D model through attachment points on the main 3D model. The target 3D model is the main 3D model. The above-described apparatus further includes a determining module, which is used to perform:
[0143] Obtain the 3D world coordinates of the target hanging point of the target 3D model relative to the 2D image from the 3D model file;
[0144] Based on the three-dimensional world coordinates, determine the two-dimensional screen coordinates of the target hanging point, and determine the distance between the target hanging point and the virtual camera;
[0145] Based on distance and two-dimensional screen coordinates, determine the target's three-dimensional coordinates at the target hanging point;
[0146] Based on the target's three-dimensional coordinates, the target's attached three-dimensional model is mapped onto the two-dimensional image to obtain the target's two-dimensional image. The target's attached three-dimensional model is the attached three-dimensional model that is attached to the target's three-dimensional model through the target's attachment point.
[0147] In some embodiments, the determining module is used to perform:
[0148] Subtract the target value from the distance to obtain the depth coordinates of the target anchor point relative to the virtual camera. The target value is a preset value or determined based on the target's attached 3D model.
[0149] Based on depth coordinates and two-dimensional screen coordinates, determine the target's three-dimensional coordinates at the target attachment point.
[0150] In some embodiments, the determining module is further configured to perform:
[0151] Determine the bounding box of the target's attached 3D model;
[0152] The maximum and minimum depth values of the target's attached 3D model are determined based on the bounding box.
[0153] The target value is determined based on the maximum and minimum depth values.
[0154] In some embodiments, the target 3D coordinates of target hanging points for the same frame of 2D images are stored in the same hanging point sub-file. The hanging point sub-files corresponding to the 2D images are stored in the hanging point files corresponding to the 3D model files according to the generation order of the 2D images. The determination module is also used to perform:
[0155] Copy the hanging point sub-file corresponding to the first frame of the target 3D model to the position after the hanging point sub-file corresponding to the last frame of the target 3D model.
[0156] In some embodiments, the acquisition module 602 is specifically used to perform:
[0157] The rendering configuration interface is displayed, showing at least one rotation angle;
[0158] In response to a selection operation for at least one rotation angle, at least one target rotation angle is obtained.
[0159] In some embodiments, the acquisition module 602 is specifically used to perform:
[0160] Obtain a preset rotation angle table, which includes at least one rotation angle;
[0161] The rendering configuration interface is displayed based on a preset rotation angle table.
[0162] In some embodiments, the determining module is further configured to perform:
[0163] Generate a transparent background 2D animation for preview based on a 2D image;
[0164] The two-dimensional image is de-opacified and a gray background is added to obtain the processed two-dimensional image.
[0165] A gray-background 2D animation is generated from the processed 2D image for preview.
[0166] 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.
[0167] 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.
[0168] 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.
[0169] 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:
[0170] Read the target 3D model from the 3D model file and configure the reference points on the target 3D model as rotation pivots, where the rotation pivots and the virtual camera are bound together;
[0171] Obtain at least one target rotation angle;
[0172] Based on each target rotation angle and rotation pivot, the model area of the target 3D model within the shooting range of the virtual camera is changed, and the virtual camera is controlled to shoot the target 3D model each time it is changed to obtain the shooting content;
[0173] The captured content is rendered to obtain a two-dimensional image of the target 3D model.
[0174] For details on the specific implementation methods and corresponding beneficial effects of the above operations, please refer to the detailed description of the rendering method above, which will not be repeated here.
[0175] 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.
[0176] 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.
[0177] 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.
[0178] 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.
[0179] 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.
[0180] 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.
[0181] 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.
[0182] 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.
[0183] 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.
[0184] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of computer programs that can be loaded by a processor to execute any of the rendering methods provided in embodiments of this application. For example, the computer program can perform the following steps:
[0185] Read the target 3D model from the 3D model file and configure the reference points on the target 3D model as rotation pivots, where the rotation pivots and the virtual camera are bound together;
[0186] Obtain at least one target rotation angle;
[0187] Based on each target rotation angle and rotation pivot, the model area of the target 3D model within the shooting range of the virtual camera is changed, and the virtual camera is controlled to shoot the target 3D model each time it is changed to obtain the shooting content;
[0188] The captured content is rendered to obtain a two-dimensional image of the target 3D model.
[0189] For details on the specific implementation methods and corresponding beneficial effects of the above operations, please refer to the detailed description of the rendering method above, which will not be repeated here.
[0190] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0191] Since the computer program stored in the computer-readable storage medium can execute any of the rendering methods provided in the embodiments of this application, the beneficial effects that any of the rendering methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0192] The rendering method, apparatus, electronic device, and computer-readable storage medium provided in the embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is 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 rendering method, characterized in that, The method includes: Read the target 3D model from the 3D model file and configure the reference points on the target 3D model as rotation pivots, wherein the rotation pivots and the virtual camera are bound together; Obtain at least one target rotation angle; Based on each target rotation angle and rotation pivot, the model area of the target 3D model within the shooting range of the virtual camera is changed, and the virtual camera is controlled to shoot the target 3D model each time it is changed to obtain the shooting content; The captured content is rendered to obtain a two-dimensional image of the target three-dimensional model.
2. The rendering method as described in claim 1, characterized in that, The step of changing the model area of the target 3D model within the shooting range of the virtual camera based on each target rotation angle and the rotation pivot axis includes: Based on each target rotation angle, the target 3D model is controlled to rotate around the rotation pivot axis to change the model area of the target 3D model within the shooting range of the virtual camera; Alternatively, based on each target rotation angle, the virtual camera is controlled to rotate around the rotation pivot to change the model area of the target 3D model within the shooting range of the virtual camera.
3. The rendering method as described in claim 1, characterized in that, The 3D model file includes a main 3D model and a secondary 3D model. The secondary 3D model is attached to the main 3D model through a mounting point on the main 3D model. The target 3D model is the main 3D model. The method further includes: Obtain the 3D world coordinates of the target hanging point of the target 3D model relative to the 2D image from the 3D model file; Based on the three-dimensional world coordinates, determine the two-dimensional screen coordinates of the target hanging point, and determine the distance between the target hanging point and the virtual camera; Based on the distance and the two-dimensional screen coordinates, determine the target three-dimensional coordinates of the target hanging point; Based on the target's three-dimensional coordinates, the target's attached three-dimensional model is mapped onto the two-dimensional image to obtain the target's two-dimensional image. The target's attached three-dimensional model is an attached three-dimensional model that is mounted to the target's three-dimensional model through the target's mounting point.
4. The rendering method as described in claim 3, characterized in that, Determining the target three-dimensional coordinates of the target hanging point based on the distance and the two-dimensional screen coordinates includes: Subtracting the target value from the distance yields the depth coordinates of the target anchor point relative to the virtual camera. The target value is a preset value or determined based on the target's attached 3D model. Based on the depth coordinates and the two-dimensional screen coordinates, the target three-dimensional coordinates of the target hanging point are determined.
5. The rendering method as described in claim 4, characterized in that, The method further includes: Determine the bounding box of the target's attached 3D model; The maximum and minimum depth values of the target's attached 3D model are determined based on the bounding box. The target value is determined based on the maximum depth value and the minimum depth value.
6. The rendering method as described in claim 3, characterized in that, The target 3D coordinates of the target attachment points for the same frame of the 2D image are stored in the same attachment point sub-file. The attachment point sub-files corresponding to the 2D images are stored in the attachment point files corresponding to the 3D model files according to the generation order of the 2D images. The method further includes: Copy the hanging point sub-file corresponding to the first frame of the two-dimensional image of the target three-dimensional model to the position after the hanging point sub-file corresponding to the last frame of the two-dimensional image of the target three-dimensional model.
7. The rendering method as described in claim 1, characterized in that, The process of obtaining at least one target rotation angle includes: The rendering configuration interface is displayed, and the rendering configuration interface displays at least one rotation angle; In response to the selection operation of the at least one rotation angle, the at least one target rotation angle is obtained.
8. The rendering method as described in claim 7, characterized in that, The display rendering configuration interface includes: Obtain a preset rotation angle table, wherein the preset rotation angle table includes at least one rotation angle; The rendering configuration interface is displayed based on the preset rotation angle table.
9. The rendering method according to any one of claims 1-8, characterized in that, The method further includes: A transparent background 2D animation is generated based on the 2D image for preview. The two-dimensional image is subjected to opacity reduction and gray background addition to obtain the processed two-dimensional image; A gray-background 2D animation is generated based on the processed 2D image for preview.
10. A rendering apparatus, characterized in that, The device includes: The reading module is used to read the target 3D model from the 3D model file and configure the reference points on the target 3D model as rotation pivots, wherein the rotation pivots and the virtual camera are bound together. The acquisition module is used to acquire at least one target rotation angle; The shooting module is used to change the model area of the target 3D model within the shooting range of the virtual camera based on each target rotation angle and the rotation pivot, and to control the virtual camera to shoot the target 3D model each time it is changed, so as to obtain the shooting content; The rendering module is used to perform rendering processing based on the captured content to obtain a two-dimensional image of the target three-dimensional model.
11. 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 rendering method as described in any one of claims 1 to 9.
12. 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 rendering method according to any one of claims 1 to 9.