Model rendering method and device, electronic equipment and storage medium
By setting the preset facets of the target model perpendicular to the virtual camera's line of sight in real-time rendering technology and controlling the light source components to rotate in the opposite direction, the problem of high memory consumption of the running device is solved, achieving natural and realistic dynamic rendering effects.
Patent Information
- Application Number
- CN202511122066.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-11
- Publication Date
- 2025-11-21
AI Technical Summary
Existing real-time rendering technologies result in high memory consumption and heavy operating pressure on the running device when rendering objects with soft edges, especially dynamic objects, making it difficult to achieve efficient dynamic rendering effects.
By obtaining the rotation parameters of the target model, aligning its preset facets with the virtual camera's line of sight, and controlling the rotation information of the light source component based on its opposite rotation angle, dynamic rendering of the target model is achieved.
It reduces the operating pressure on the equipment and achieves a more natural and realistic 3D effect and dynamic rendering of the target model.
Smart Images

Figure CN120997356A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a model rendering method and device, electronic equipment and storage medium. BACKGROUND
[0002] Real-time rendering technology is one of the core fields of computer graphics, mainly used for generating high-quality images in interactive applications such as electronic games, virtual reality (VR) and augmented reality (AR) in real time. The core goal is to complete complex graphics processing within a limited computing time (usually within 16 ms per frame) to achieve a smooth visual experience.
[0003] In the prior art, based on real-time rendering technology, when rendering objects with soft edges (such as smoke, clouds, soft shadows, etc.), it is often implemented based on Signed Distance Fields (SDF) technology.
[0004] However, the application of SDF technology usually requires pre-computation and storage of 3D voxel data, which can cause high memory consumption, especially for dynamic objects (such as moving smoke, explosion effects) that need to be advanced using a sequence frame-like method, further exacerbating the running pressure of the running device. SUMMARY
[0005] The purpose of the present application is to provide a model rendering method, device, electronic equipment and storage medium, which can reduce the running pressure of the running device, in view of the deficiencies in the prior art.
[0006] To achieve the above purpose, the technical solutions adopted by the embodiments of the present application are as follows:
[0007] In a first aspect, the present application provides a model rendering method, comprising:
[0008] obtaining a target rotation parameter of a target model in a target scene, wherein a preset face sheet of the target model is perpendicular to the line-of-sight direction of a virtual camera, and the target rotation parameter includes a target rotation direction and a target angle;
[0009] controlling a light source component in the target scene to rotate the target angle based on the opposite direction of the target rotation direction, obtaining target rotation information of the light source component, the target rotation information being used to indicate the information of the target position where the light source component is currently located after rotating the target angle;
[0010] rendering and displaying the target model in the target scene according to the target rotation information of the light source component.
[0011] In a second aspect, the present application provides a model rendering device, comprising:
[0012] The acquisition module is configured to acquire a target rotation parameter of a target model in a target scene, wherein a preset facet of the target model is perpendicular to a line-of-sight direction of a virtual camera, and the target rotation parameter comprises a target rotation direction and a target angle.
[0013] The control module is configured to control a light source component in the target scene to rotate the target angle based on a reverse direction of the target rotation direction, and acquire target rotation information of the light source component, wherein the target rotation information is used to indicate information of a target position where the light source component is currently located after the light source component rotates the target angle.
[0014] The rendering module is configured to render and display the target model in the target scene according to the target rotation information of the light source component.
[0015] In a third aspect, the present application provides an electronic device, which comprises a processor, a storage medium and a bus, the storage medium stores machine readable instructions executable by the processor, the processor and the storage medium communicate through the bus when the electronic device is running, and the processor executes the machine readable instructions to perform the steps of the model rendering method according to any one of the preceding embodiments.
[0016] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program performs the steps of the model rendering method according to any one of the preceding embodiments when executed by a processor.
[0017] The present application has the following beneficial effects:
[0018] In the model rendering method, device, electronic device and storage medium provided by the embodiments of the present application, the target rotation parameter of the target model in the target scene is acquired, wherein the preset facet of the target model is perpendicular to the line-of-sight direction of the virtual camera, and the target rotation parameter comprises the target rotation direction and the target angle. The light source component in the target scene is controlled to rotate the target angle based on the reverse direction of the target rotation direction, and the target rotation information of the light source component is acquired. The target model in the target scene is rendered and displayed according to the target rotation information of the light source component. In this process, by setting the preset facet of the target model to be perpendicular to the line-of-sight direction of the virtual camera, the target model can have a three-dimensional effect. Compared with the existing method of realizing a three-dimensional effect based on a directed distance field, the running pressure of the running device can be effectively reduced. In addition, by controlling the light source component in the target scene to rotate the target angle based on the reverse direction of the target rotation direction, the light rays of the light source component can be projected in the correct direction, the dynamic rendering effect of the target model according to the light rays is embodied, and the rendering effect is more natural and realistic. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be regarded as limiting the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor.
[0020] Figure 1 A flowchart of a model rendering method provided by an embodiment of the present application is shown in FIG. 2.
[0021] Figure 2 An effect diagram of model rendering provided by an embodiment of the present application is shown in FIG. 3.
[0022] Figure 3 A flowchart of another model rendering method provided by an embodiment of the present application is shown in FIG. 4.
[0023] Figure 4 A flowchart of another model rendering method provided by an embodiment of the present application is shown in FIG. 5.
[0024] Figure 5 A flowchart of another model rendering method provided by an embodiment of the present application is shown in FIG. 6.
[0025] Figure 6 A flowchart of another model rendering method provided by an embodiment of the present application is shown in FIG. 7.
[0026] Figure 7 A functional module diagram of a model rendering device provided by an embodiment of the present application is shown in FIG. 8.
[0027] Figure 8 An electronic device structure provided by an embodiment of the present application is shown in FIG. 9. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the following will combine the drawings in the embodiments of the present application to make a clear and complete description of the technical solutions in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, but not all the embodiments. The components of the embodiments of the present application described and shown in the drawings can be arranged and designed in various different configurations.
[0029] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0030] It should be noted that like reference numerals and characters refer to like items throughout the attached drawings and alternative embodiments thereof, noting that when a part or element is defined in one drawing, it need not be further defined and explained in subsequent drawings.
[0031] In the related art, based on the real-time rendering technology, when rendering objects with soft edges (such as smoke, clouds, soft shadows, etc.), it is often implemented based on the Signed Distance Fields (SDF) technology, which has the advantage of being able to achieve high-quality volume effects by accurately calculating the interaction of light and surface. However, the implementation of the SDF scheme requires pre-computing and storing 3D voxelized data (such as 1283 or higher resolution), resulting in high memory consumption, especially for dynamic objects (such as moving smoke, explosion effects) that need to use a similar sequence frame to advance, further exacerbating the running pressure of the running device.
[0032] Therefore, the embodiments of the present application provide a model rendering method, which can not only reduce the running pressure of the running device, but also reflect the dynamic rendering effect of the target model according to the change of light.
[0033] Figure 1 A flowchart of a model rendering method provided by the embodiments of the present application is shown. The execution subject of the method can be a computer, a server, a mobile terminal, or the like, which is not limited herein. Optionally, the method can be applied to the rendering of objects with soft edges in a two-dimensional scene. In some embodiments, the object can be a cloud, smoke, cloud mist, fireworks, water spray, etc., which is not limited herein. As shown in Figure 1 The method comprises the following steps:
[0034] Step 101, obtaining a target rotation parameter of a target model in a target scene, wherein a preset face sheet of the target model is perpendicular to the line-of-sight direction of a virtual camera, and the target rotation parameter comprises a target rotation direction and a target angle.
[0035] Optionally, the target scene can be any scene including the target model, such as a game scene, a film and television production scene, etc., which is not limited herein.
[0036] In some embodiments, the target model can be a 2D model corresponding to an object with soft edges, which can be a cloud, smoke, cloud mist, fireworks, water spray, etc., which is not limited herein. The target model can include a rectangular 2D face sheet, and the preset face sheet of the target model can be the rectangular 2D face sheet. In some embodiments, the rectangular 2D face sheet can be composed of two triangular face sheets, which is not limited herein.
[0037] The virtual camera in the target scene is a virtual lens for controlling the user's view angle in the scene. Taking a game scene as an example, the virtual camera in the game scene is a virtual lens for controlling the player's view angle in the game scene, which determines how the player observes the game world, in other words, it determines the content displayed on the screen, such as the picture seen by the character, the environmental range, and the like.
[0038] Optionally, taking a mobile terminal as an example, when the virtual camera moves or the target model moves, the angle between the preset facet of the target model and the line-of-sight direction of the virtual camera will change, and at this time, the preset facet of the target model can be set to be perpendicular to the line-of-sight direction of the virtual camera, that is, the preset facet of the target model is adjusted to always face the virtual camera, thereby simulating the visual effect of a 3D object.
[0039] In order to better understand the present application, taking a game scene as an example, in some embodiments, the movement operation of the virtual camera or the target model can be triggered by the user, or can be triggered according to a preset game logic, which is not limited herein.
[0040] When the virtual camera moves or the target model moves, the virtual camera in the target scene will rotate synchronously according to the movement operation; and in order to make the preset facet of the target model perpendicular to the line-of-sight direction of the virtual camera, the target model needs to be controlled to rotate synchronously, and at this time, the target rotation parameters of the virtual camera and the target model in the target scene can be obtained.
[0041] Optionally, the target rotation parameters can include a target rotation method and a target angle, and in some embodiments, the target rotation direction and the target angle can be determined according to a world coordinate system corresponding to the target scene, or can be determined according to a local coordinate system (such as a preset model coordinate system of the target model), which is not limited herein.
[0042] Step 102, based on the opposite direction of the target rotation direction, the light source component in the target scene is controlled to rotate the target angle, and target rotation information of the light source component is obtained.
[0043] The target rotation information is used to indicate the information of the current target position of the light source component after the light source component rotates the target angle. The light source component in the target scene is a light source module in the target scene that simulates the lighting conditions (such as sunlight, moonlight, indoor light).
[0044] Optionally, the position of the light source component in the target scene can be a fixed position, but is not limited thereto.
[0045] In some embodiments, if the position of the light source component in the target scene is a fixed position, and the target model is a 2D image corresponding to a cloud, when the virtual camera or the target model moves, the virtual camera and the target model are synchronously rotated according to the movement operation, and at this time, the light of the light source component cannot be correctly projected on the target model.
[0046] Therefore, when the virtual camera or the target model moves, the virtual camera and the target model are synchronously rotated according to the movement operation, and according to the target rotation direction, the rotation direction of the light source can be determined, wherein the rotation direction of the light source is the opposite direction of the target rotation direction; the light source component in the target scene is controlled to rotate the target angle in the rotation direction of the light source, and the target rotation information of the light source component is obtained.
[0047] Optionally, the target rotation information of the light source component can indicate the final orientation of the light source component in the target scene. In some embodiments, the final rotation angle of the light source component in the target scene can be determined according to the initial angle of the light source component in the target scene and the target angle. The initial angle of the light source component in the target scene is the angle of the light source component in the target scene before the virtual camera or the target model moves.
[0048] Step 103, rendering and displaying the target model in the target scene according to the target rotation information of the light source component.
[0049] Based on the above description, after obtaining the target rotation information of the light source component, the target model in the target scene can be rendered and displayed based on the target rotation information of the light source component, so that the light of the light source component can be projected in the correct direction, and the dynamic rendering effect of the target model according to the light change is realized, and the rendering effect is more natural.
[0050] Figure 2 An effect diagram of model rendering is provided for the embodiments of the present application. Based on the above description, in order to ensure the rendering efficiency, if the position of the light source component in the target scene is a fixed position, and the target model is a 2D model corresponding to a cloud, for the movement operation of the virtual camera or the target model, the target rotation parameters of the virtual camera and the target model in the target scene can be determined according to the method described above, and based on the target rotation direction, the light source component in the target scene is controlled to rotate the target angle, so that the light of the light source component can be projected in the correct direction, and the natural rendering effect as shown in Figure 2 is realized.
[0051] In summary, the embodiment of the present application provides a model rendering method, which comprises: obtaining a target rotation parameter of a target model in a target scene, wherein a preset face sheet of the target model is perpendicular to a line-of-sight direction of a virtual camera, and the target rotation parameter comprises a target rotation direction and a target angle; based on an opposite direction of the target rotation direction, controlling a light source component in the target scene to rotate the target angle, and obtaining target rotation information of the light source component; and rendering and displaying the target model in the target scene according to the target rotation information of the light source component. In this process, by setting the preset face sheet of the target model to be perpendicular to the line-of-sight direction of the virtual camera, the target model can have a three-dimensional effect. Compared with the existing three-dimensional effect based on a directional distance field, the running pressure of the running device can be effectively reduced. In addition, by controlling the light source component in the target scene to rotate the target angle according to the opposite direction of the target rotation direction, the light of the light source component can be projected in the correct direction, reflecting the dynamic rendering effect of the target model according to the light change, and the rendering effect is more natural and real.
[0052] In optional embodiments, the target rotation direction comprises a first rotation direction and a second rotation direction, and the target angle comprises a first angle and a second angle.
[0053] The first rotation direction and the first angle are respectively a rotation direction and a rotation angle of the preset face sheet rotating around a first coordinate axis based on a preset model coordinate system; and the second rotation direction and the second angle are respectively a rotation direction and a rotation angle of the preset face sheet rotating around a second coordinate axis based on the preset model coordinate system.
[0054] The preset model coordinate system is a local coordinate system of the target model with respect to a world coordinate system in the target scene. Optionally, the target rotation direction and the target angle can be determined based on the preset model coordinate system.
[0055] Optionally, the origin of the preset model coordinate system can be a center point of the target model and comprises three coordinate axes (X axis, Y axis and Z axis). In some embodiments, the first coordinate axis and the second coordinate axis can be any two of the three coordinate axes, which are not limited herein. For example, the first coordinate axis can be the X axis, and the second coordinate axis can be the Y axis.
[0056] In addition, it should be noted that the target model can comprise a plurality of face sheets, which can be triangular faces or quadrilaterals, and the preset face sheet can be a designated face sheet, which is not limited herein. Optionally, in some embodiments, the target model can comprise a quadrilateral face sheet or a triangular face sheet, which is not limited herein.
[0057] In combination with the patch in the target model, the first rotation direction is a rotation direction of the preset patch around the first coordinate axis based on the preset model coordinate system, the first angle is a rotation angle of the preset patch around the first coordinate axis based on the preset model coordinate system, the second rotation direction is a rotation direction of the preset patch around the second coordinate axis based on the preset model coordinate system, and the second angle is a rotation angle of the preset patch around the second coordinate axis based on the preset model coordinate system.
[0058] Figure 3 Another model rendering method provided by the embodiments of the present application is shown in a flowchart. In an optional implementation, as shown in FIG. 13, the above-mentioned target rotation direction is the reverse direction of the first rotation direction, and the target angle is the first angle. Figure 3 The method for controlling the light source component to rotate the target angle based on the reverse direction of the target rotation direction to obtain the target rotation information of the light source component includes the following steps.
[0059] In step 301, the first rotation direction and the first angle are respectively converted into a first target rotation direction and a first target angle in a world coordinate system; and the light source component in the target scene is controlled to rotate the first target angle based on the reverse direction of the first target rotation direction, so as to obtain initial rotation information of the light source component.
[0060] The initial rotation information is used to indicate the first position of the light source component after the light source component rotates the first target angle.
[0061] In some embodiments, when the rotation is specifically performed, the first rotation direction in the preset model coordinate system can be converted into the first target rotation direction in the world coordinate system, and the first angle in the preset model coordinate system can be converted into the first target angle in the world coordinate system according to the conversion relationship between the preset model coordinate system and the world coordinate system.
[0062] Based on the current position and the current angle of the light source component in the world coordinate, the light source component in the target scene is controlled to rotate the first target angle in the reverse direction of the first target rotation, so as to realize the preliminary rotation of the light source component, and the initial rotation information of the light source component is obtained accordingly. The initial rotation information can be used to indicate the first position of the light source component after the light source component rotates the first target angle, that is, the first orientation of the light source component after the light source component rotates the first target angle.
[0063] In step 302, the second rotation direction and the second angle are respectively converted into a second target rotation direction and a second target angle in the world coordinate system; and the light source component is controlled to rotate the second target angle based on the first position based on the reverse direction of the second target rotation direction according to the initial rotation information of the light source component, so as to obtain the target rotation information of the light source component.
[0064] The determination of the second target rotation direction and the second target angle can refer to the determination of the first target rotation direction and the first target angle, which will not be repeated here.
[0065] Based on the above description, after obtaining the initial rotation information of the light source component, the light source component in the target scene can be controlled to rotate the second target angle in the reverse direction of the second target rotation direction based on the current position and the current angle of the light source component in the world coordinate, thereby realizing secondary rotation of the light source component and obtaining the target rotation information of the light source component.
[0066] By applying the embodiments of the present application, when the virtual camera or the target model is moved, or the virtual camera and the target model in the target scene are rotated, the light rays of the light source component can be projected in the correct direction by controlling the light source component to perform secondary rotation operation according to the reverse direction of the first rotation direction, the reverse direction of the second rotation direction, the first angle and the second angle, thereby embodying the dynamic rendering effect of the target model according to the light rays, and the rendering effect is more natural.
[0067] Of course, in some embodiments, the light source component can be first controlled to rotate the second target angle based on the reverse direction of the second target rotation direction, and then controlled to rotate the first target angle based on the reverse direction of the first target rotation direction, which is not limited here and can be flexibly set according to the actual application scenario.
[0068] Figure 4 Another model rendering method provided by the embodiments of the present application is shown in the flowchart. In an optional implementation, as shown in Figure 4 The target angle of the virtual camera and the target model in the target scene is obtained, including:
[0069] Step 401, obtaining initial position information of the target model in a preset model coordinate system.
[0070] Step 402, obtaining current position information of the virtual camera in a camera coordinate system.
[0071] Step 403, calculating a target direction vector according to the current position information of the virtual camera in the camera coordinate system and the initial position information of the target model in the preset model coordinate system.
[0072] The current position of the virtual camera in the camera coordinate system is the position of the virtual camera in the camera coordinate system after the virtual camera or the target model is moved; and the initial position of the target model in the preset model coordinate system is the position of the target model in the preset model coordinate system before the virtual camera or the target model is moved.
[0073] Optionally, when calculating the target direction vector, for the movement operation of the virtual camera or the target model, the current position information of the virtual camera in the camera coordinate system can be converted into the current position information of the virtual camera in the preset model coordinate system based on the relationship between the camera coordinate system and the preset model coordinate system; and the target direction vector can be calculated according to the current position information of the virtual camera in the preset model coordinate system and the initial position information of the target model in the preset model coordinate system, wherein the target direction vector can point from the current position of the virtual camera in the preset model coordinate system to the initial position of the target model in the preset model coordinate system.
[0074] At step 404, the first angle and the first rotation direction, or the second angle and the second rotation direction, can be calculated respectively according to the target direction vector and the coordinate position of the target model in the preset model coordinate system.
[0075] After the target direction vector is obtained, the first angle and the first rotation direction, or the second angle and the second rotation direction, that the preset face needs to rotate around the first coordinate axis based on the preset model coordinate system can be further calculated in combination with the coordinate position of the target model in the preset model coordinate system.
[0076] In addition, it should be noted that in some embodiments, the first rotation direction and the second rotation direction can also be obtained by the following method: obtaining the current orientation information of the line-of-sight direction of the virtual camera in the preset model coordinate system and the initial orientation information of the preset face of the target model in the preset model coordinate system; and calculating the first rotation direction and the second rotation direction respectively according to the current orientation information of the line-of-sight direction of the virtual camera in the preset model coordinate system and the initial orientation information of the target model in the preset model coordinate system.
[0077] In the optional embodiment, the above-mentioned obtaining the target rotation parameter of the target model in the target scene comprises:
[0078] The preset face of the target model is set to be perpendicular to the line-of-sight direction of the virtual camera based on the billboard technology, and the target rotation parameter of the target model when the preset face of the target model is perpendicular to the line-of-sight direction of the virtual camera is obtained.
[0079] In some embodiments, when the virtual camera or the target model is subjected to a movement operation, the preset face of the target model can also be set to be perpendicular to the line-of-sight direction of the virtual camera based on the billboard technology, and the target rotation parameter can be obtained according to the first rotation parameter of the target model before the movement and the second rotation parameter of the target model after the movement. When calculating, the difference between the second rotation parameter and the first rotation parameter can be determined.
[0080] Optionally, the target rotation parameter can include the first rotation direction, the second rotation direction, the first angle, and the second angle. For example, the target model can include a rotation direction and a first angle on the X axis, and a rotation direction and a second angle on the Y axis. Of course, the specific selection direction is not limited thereto.
[0081] Figure 5 Another model rendering method provided by the embodiments of the present application is shown in the flowchart. In an optional implementation, the target model includes at least one patch, and the preset patch of the target model is set to be perpendicular to the line-of-sight direction of the virtual camera based on the billboard technique, including:
[0082] Step 501, output the world position offset information of the preset patch in the target model based on the billboard technique.
[0083] Optionally, when the virtual camera or the target model moves, the position information and / or the orientation information of the virtual camera in the target scene changes, and then, based on the billboard technique, the world position offset information (WPO) of the preset patch in the target model can be calculated according to the current position information and / or the current orientation information of the virtual camera in the target scene after the movement, and the initial position information and / or the initial orientation information of the target model in the preset model coordinate system or the world coordinate system before the movement.
[0084] Step 502, adjust the position of the preset patch to make the preset patch in the target model perpendicular to the line-of-sight direction of the virtual camera according to the world position offset information of the preset patch.
[0085] Further, the position of the preset patch can be adjusted according to the world position offset information of the preset patch, so that the preset patch in the target model is perpendicular to the line-of-sight direction of the virtual camera, and the target model can present a 3D effect.
[0086] In an optional implementation, the light source component is a light source with a fixed position in the target scene, or the light source component is a light source with a movable position in the target scene.
[0087] The light source component can be a light source with a fixed position or a movable position (not fixed position) in the target scene. It can be understood that if the light source component is a light source with a movable position in the target scene, the light source component can be controlled to rotate in the opposite direction of the target rotation direction by a target angle based on the real-time position of the light source component and based on the opposite direction of the target rotation direction.
[0088] By applying the embodiments of the present application, the method of the present application can be applied to light source components with various setting modes, and the flexibility of the method of the present application can be improved.
[0089] Figure 6 Another model rendering method provided by the embodiment of the present application is shown in the flowchart. In the optional implementation, the method of rendering and displaying the target model in the target scene according to the target rotation information of the light source component comprises the following steps.
[0090] In step 601, the target model in the target scene is rendered and displayed based on the two-dimensional ray marching algorithm according to the target rotation information of the light source component.
[0091] Optionally, when the target model in the target scene is rendered and displayed, the two-dimensional ray marching algorithm 2Draymarching can be used according to the target rotation information of the light source component, the light ray is advanced by a certain step each time, and it is detected whether the current light ray is located on the surface of the target model. The advancing amplitude of the light ray is adjusted accordingly until the surface of the target model is reached, thereby realizing the volume feeling. The method of the present application can be applied to the rendering of objects with soft edges in a two-dimensional scene, such as clouds, smoke, fog, fireworks, water splashes, etc.
[0092] For example, if the target model is a 2D model corresponding to smoke, the volume feeling of the smoke can be realized by applying the embodiment of the present application.
[0093] Figure 7 A functional module diagram of a model rendering device provided by the embodiment of the present application is shown in the figure. The basic principle and the technical effects of the device are the same as those of the corresponding method embodiment described above. For brief description, the parts not mentioned in the present embodiment can refer to the corresponding contents in the method embodiment. As shown in the figure, the model rendering device comprises: Figure 7
[0094] The acquisition module 110 is configured to acquire target rotation parameters of a target model in a target scene, wherein a preset facet of the target model is perpendicular to the line-of-sight direction of a virtual camera, and the target rotation parameters comprise a target rotation direction and a target angle.
[0095] The control module 120 is configured to control a light source component in the target scene to rotate the target angle based on the opposite direction of the target rotation direction, acquire target rotation information of the light source component, and use the target rotation information to indicate the information of the target position where the light source component is currently located after rotating the target angle.
[0096] The rendering module 130 is configured to render and display the target model in the target scene according to the target rotation information of the light source component.
[0097] In the optional implementation, the target rotation direction comprises a first rotation direction and a second rotation direction, and the target angle comprises a first angle and a second angle.
[0098] The first rotation direction and the first angle are respectively a rotation direction and a rotation angle of the preset surface patch rotating around a first coordinate axis based on a preset model coordinate system.
[0099] The second rotation direction and the second angle are respectively a rotation direction and a rotation angle of the preset surface patch rotating around a second coordinate axis based on the preset model coordinate system.
[0100] In an optional implementation, the obtaining module 110 is specifically configured to convert the first rotation direction and the first angle into a first target rotation direction and a first target angle in a world coordinate system respectively.
[0101] Based on a reverse direction of the first target rotation direction, the light source component in the target scene is controlled to rotate the first target angle, to obtain initial rotation information of the light source component, the initial rotation information being used to indicate information of a first position currently located by the light source component after rotating the first target angle.
[0102] The second rotation direction and the second angle are converted into a second target rotation direction and a second target angle in the world coordinate system respectively.
[0103] Based on a reverse direction of the second target rotation direction, the light source component is controlled to rotate the second target angle based on the first position according to the initial rotation information of the light source component, to obtain target rotation information of the light source component.
[0104] In an optional implementation, the obtaining module 110 is specifically configured to obtain initial position information of a target model in a preset model coordinate system.
[0105] Current position information of a virtual camera in a camera coordinate system is obtained.
[0106] A target direction vector is calculated according to the current position information of the virtual camera in the camera coordinate system and the initial position information of the target model in the preset model coordinate system.
[0107] The first angle and the first rotation direction are calculated respectively or the second angle and the second rotation direction are calculated respectively according to the target direction vector and a coordinate position of the target model in the preset model coordinate system.
[0108] In an optional implementation, the obtaining module 110 is specifically configured to set a preset surface patch of a target model to be perpendicular to a line-of-sight direction of a virtual camera based on a billboard technique, and obtain target rotation parameters of the target model when the preset surface patch of the target model is perpendicular to the line-of-sight direction of the virtual camera.
[0109] In an optional implementation, the target model comprises at least one patch, and the obtaining module is specifically configured to output world position offset information of a preset patch in the target model based on a billboard technique.
[0110] According to the world position offset information of the preset patch, the position of the preset patch is adjusted so that the preset patch in the target model is perpendicular to the line-of-sight direction of the virtual camera.
[0111] In an optional implementation, the light source component is a light source with a fixed position in the target scene, or the light source component is a light source with a movable position in the target scene.
[0112] In an optional implementation, the rendering module 130 is specifically configured to render and display the target model in the target scene based on a two-dimensional ray marching algorithm according to the target rotation information of the light source component.
[0113] The above device is used to execute the method provided by the foregoing embodiments, and has similar implementation principles and technical effects, which are not described here again.
[0114] The above modules can be one or more integrated circuits configured to implement the above method, for example, one or more application specific integrated circuits (ASICs), or one or more microprocessors, or one or more field programmable gate arrays (FPGAs), etc. For another example, when the above module is implemented in the form of a processing element scheduling code, the processing element can be a general-purpose processor, for example, a central processing unit (CPU) or other processor that can invoke program code. For another example, the modules can be integrated together in the form of a system on a chip (SOC).
[0115] Figure 8 An electronic device structure schematic diagram provided by an embodiment of the present application, the electronic device can be integrated in the above model rendering device. As shown in the figure, the electronic device can include a processor 210, a storage medium 220, and a bus 230, the storage medium 220 stores machine readable instructions executable by the processor 210, when the electronic device runs, the processor 210 and the storage medium 220 communicate through the bus 230, the processor 210 executes the machine readable instructions to execute the steps of the following method embodiments: Figure 8
[0116] obtaining a target rotation parameter of a target model in a target scene, wherein a preset face sheet of the target model is perpendicular to a line-of-sight direction of a virtual camera, and the target rotation parameter comprises a target rotation direction and a target angle;
[0117] controlling a light source component in the target scene to rotate the target angle based on a reverse direction of the target rotation direction, and obtaining target rotation information of the light source component, the target rotation information being used to indicate information of a target position where the light source component is currently located after rotating the target angle;
[0118] rendering and displaying the target model in the target scene according to the target rotation information of the light source component.
[0119] In an optional implementation, the target rotation direction comprises a first rotation direction and a second rotation direction, and the target angle comprises a first angle and a second angle.
[0120] The first rotation direction and the first angle are respectively a rotation direction and a rotation angle of the preset face sheet rotating around a first coordinate axis based on a preset model coordinate system.
[0121] The second rotation direction and the second angle are respectively a rotation direction and a rotation angle of the preset face sheet rotating around a second coordinate axis based on the preset model coordinate system.
[0122] In an optional implementation, the controlling the light source component in the target scene to rotate the target angle based on the reverse direction of the target rotation direction, and obtaining the target rotation information of the light source component, comprises:
[0123] respectively converting the first rotation direction and the first angle into a first target rotation direction and a first target angle in a world coordinate system;
[0124] controlling the light source component in the target scene to rotate the first target angle based on a reverse direction of the first target rotation direction, and obtaining initial rotation information of the light source component, the initial rotation information being used to indicate information of a first position where the light source component is currently located after rotating the first target angle;
[0125] respectively converting the second rotation direction and the second angle into a second target rotation direction and a second target angle in the world coordinate system;
[0126] controlling the light source component to rotate the second target angle based on the first position according to the initial rotation information of the light source component based on a reverse direction of the second target rotation direction, and obtaining the target rotation information of the light source component.
[0127] In an optional implementation, the obtaining the target rotation parameter of the target model in the target scene comprises:
[0128] obtain initial position information of the target model in a preset model coordinate system;
[0129] obtain current position information of the virtual camera in a camera coordinate system;
[0130] calculate a target direction vector according to the current position information of the virtual camera in the camera coordinate system and the initial position information of the target model in the preset model coordinate system;
[0131] calculate the first angle and the second angle respectively according to the target direction vector and the coordinate position of the target model in the preset model coordinate system.
[0132] In an optional implementation, the obtaining of the target rotation parameter of the target model in the target scene comprises:
[0133] setting a preset face sheet of the target model to be perpendicular to a line-of-sight direction of the virtual camera based on a billboard technique, and obtaining the target rotation parameter of the target model when the preset face sheet of the target model is perpendicular to the line-of-sight direction of the virtual camera.
[0134] In an optional implementation, the target model comprises at least one face sheet, and the setting of the preset face sheet of the target model to be perpendicular to the line-of-sight direction of the virtual camera based on the billboard technique comprises:
[0135] outputting world position offset information of the preset face sheet in the target model based on the billboard technique;
[0136] adjusting a position of the preset face sheet according to the world position offset information of the preset face sheet, so that the preset face sheet in the target model is perpendicular to the line-of-sight direction of the virtual camera.
[0137] In an optional implementation, the light source assembly is a light source with a fixed position in the target scene, or the light source assembly is a light source with a movable position in the target scene.
[0138] In an optional implementation, the rendering and displaying of the target model in the target scene according to the target rotation information of the light source assembly comprises:
[0139] rendering and displaying the target model in the target scene based on a two-dimensional ray stepping algorithm according to the target rotation information of the light source assembly.
[0140] The specific implementation manners and technical effects of the method embodiments are similar to those of the foregoing related embodiments, and will not be described here.
[0141] Optionally, the present application further provides a storage medium, and the storage medium stores a computer program. When the computer program is run by a processor, the steps of the method embodiments are executed.
[0142] obtaining a target rotation parameter of a target model in a target scene, wherein a preset facet of the target model is perpendicular to a line-of-sight direction of a virtual camera, and the target rotation parameter comprises a target rotation direction and a target angle;
[0143] controlling a light source component in the target scene to rotate the target angle based on a reverse direction of the target rotation direction, and obtaining target rotation information of the light source component, the target rotation information being used to indicate information of a target position of the light source component after the light source component rotates the target angle;
[0144] rendering and displaying the target model in the target scene according to the target rotation information of the light source component.
[0145] In an optional implementation, the target rotation direction comprises a first rotation direction and a second rotation direction, and the target angle comprises a first angle and a second angle.
[0146] The first rotation direction and the first angle are respectively a rotation direction and a rotation angle of the preset facet rotating around a first coordinate axis based on a preset model coordinate system.
[0147] The second rotation direction and the second angle are respectively a rotation direction and a rotation angle of the preset facet rotating around a second coordinate axis based on the preset model coordinate system.
[0148] In an optional implementation, the controlling the light source component in the target scene to rotate the target angle based on the reverse direction of the target rotation direction, and obtaining the target rotation information of the light source component, comprises:
[0149] respectively converting the first rotation direction and the first angle into a first target rotation direction and a first target angle in a world coordinate system;
[0150] controlling the light source component in the target scene to rotate the first target angle based on a reverse direction of the first target rotation direction, and obtaining initial rotation information of the light source component, the initial rotation information being used to indicate information of a first position of the light source component after the light source component rotates the first target angle;
[0151] respectively converting the second rotation direction and the second angle into a second target rotation direction and a second target angle in the world coordinate system;
[0152] controlling the light source component to rotate the second target angle based on the first position based on a reverse direction of the second target rotation direction according to the initial rotation information of the light source component, and obtaining the target rotation information of the light source component.
[0153] In an optional implementation, the obtaining the target rotation parameter of the target model in the target scene comprises:
[0154] obtaining initial position information of the target model in a preset model coordinate system;
[0155] obtaining current position information of the virtual camera in a camera coordinate system;
[0156] calculating a target direction vector according to the current position information of the virtual camera in the camera coordinate system and the initial position information of the target model in the preset model coordinate system;
[0157] calculating the first angle and the second angle respectively according to the target direction vector and the coordinate position of the target model in the preset model coordinate system.
[0158] In an optional implementation, the obtaining the target rotation parameter of the target model in the target scene comprises:
[0159] setting a preset patch of the target model to be perpendicular to a line-of-sight direction of the virtual camera based on a billboard technique, and obtaining the target rotation parameter of the target model when the preset patch of the target model is perpendicular to the line-of-sight direction of the virtual camera.
[0160] In an optional implementation, the target model comprises at least one patch, and the setting the preset patch of the target model to be perpendicular to the line-of-sight direction of the virtual camera based on the billboard technique comprises:
[0161] outputting world position offset information of the preset patch in the target model based on the billboard technique;
[0162] adjusting the position of the preset patch according to the world position offset information of the preset patch, so that the preset patch in the target model is perpendicular to the line-of-sight direction of the virtual camera.
[0163] In an optional implementation, the light source assembly is a light source with a fixed position in the target scene, or the light source assembly is a light source with a movable position in the target scene.
[0164] In an optional implementation, the rendering and displaying the target model in the target scene according to the target rotation information of the light source assembly comprises:
[0165] rendering and displaying the target model in the target scene based on a two-dimensional ray stepping algorithm according to the target rotation information of the light source assembly.
[0166] The specific implementation manners and technical effects of the above method embodiments are similar to those of the foregoing related embodiments, and will not be described here.
[0167] Optionally, the present application also provides a computer program product, the computer program product comprising instructions which, when executed on an electronic device, cause the electronic device to implement the steps of the above method embodiments.
[0168] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented by other manners. For example, the apparatus embodiments described above are only illustrative, for example, the division of units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interfaces, apparatuses or units, and can be electrical, mechanical or other forms.
[0169] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0170] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software functional unit.
[0171] The integrated unit realized in the form of software functional unit can be stored in a computer readable storage medium. The software functional unit is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to execute part of the steps of the method of each embodiment of the present application. The storage medium mentioned above includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, for short: ROM), random access memory (English: Random Access Memory, for short: RAM), magnetic disk or optical disk and various program code storage media.
[0172] It has to be noted that, in the present document, the terms "first", "second", etc. merely serve the purpose of differentiation and do not require or imply any kind of ordering or sequence of the entities or operations. Furthermore, the terms "comprising", "containing" or any other similar term are intended to encompass non-exclusive inclusions, such that a process, method, article or apparatus that comprises a list of elements does not include those elements solely, but can include other elements not expressly listed or inherent to such process, method, article or apparatus. An element proceeded by "comprises a..." does not, without further constraints, exclude the presence of additional identical elements in the process, method, article or apparatus that comprises the element.
[0173] The preferred embodiments of the present application are described above in detail with reference to only a few examples. However, various modifications and changes can be made thereto by those skilled in the art which fall within the scope of the application as defined by the appended claims. Any reference numerals in the claims shall not be construed as limiting the scope of the claims but are intended to address multiple embodiments. Moreover, certain language can be used by the patent to describe one example of the application including, for example, the terms "comprises", "comprising", "containing" or "containing" to connote "including, but not limited to" and, therefore, the use of such terms does not foreclose the use of other terms or phrases unless otherwise explicitly so limited. Also, the terms "first", "second", "third", etc. are used merely as labels, and are not intended to impose numerical requirements on their objects. The above description is merely illustrative of the application and is not intended to limit the scope of the application as defined by the appended claims.
Claims
1. A model rendering method, characterized by, The method includes: Obtain the target rotation parameters of the target model in the target scene, wherein the preset facet of the target model is perpendicular to the viewing direction of the virtual camera, and the target rotation parameters include: target rotation direction and target angle; Based on the opposite direction of the target rotation direction, the light source component in the target scene is controlled to rotate by the target angle to obtain the target rotation information of the light source component. The target rotation information is used to indicate the current target position of the light source component after rotating by the target angle. Based on the target rotation information of the light source component, the target model in the target scene is rendered and displayed.
2. The method according to claim 1, characterized in that, The target rotation direction includes a first rotation direction and a second rotation direction, and the target angle includes a first angle and a second angle; The first rotation direction and the first angle are respectively the rotation direction and rotation angle of the preset patch around the first coordinate axis based on the preset model coordinate system; The second rotation direction and the second angle are respectively the rotation direction and rotation angle of the preset patch around the second coordinate axis based on the preset model coordinate system.
3. The method according to claim 2, characterized in that, The step of controlling the light source component in the target scene to rotate by a target angle based on the opposite direction of the target rotation direction, and obtaining the target rotation information of the light source component, includes: The first rotation direction and the first angle are respectively converted into the first target rotation direction and the first target angle in the world coordinate system; Based on the opposite direction of the first target rotation direction, the light source component in the target scene is controlled to rotate by the first target angle to obtain the initial rotation information of the light source component. The initial rotation information is used to indicate the information of the first position of the light source component after rotating by the first target angle. The second rotation direction and the second angle are respectively converted into the second target rotation direction and the second target angle in the world coordinate system; Based on the opposite direction of the second target rotation direction, and according to the initial rotation information of the light source component, the light source component is controlled to rotate the second target angle based on the first position, thereby obtaining the target rotation information of the light source component.
4. The method according to claim 2, characterized in that, The process of obtaining the target rotation parameters of the target model in the target scene includes: Obtain the initial position information of the target model in the preset model coordinate system; Obtain the current position information of the virtual camera in the camera coordinate system; Calculate the target direction vector based on the current position information of the virtual camera in the camera coordinate system and the initial position information of the target model in the preset model coordinate system; Based on the target direction vector and the coordinate position of the target model in the preset model coordinate system, calculate the first angle and the first rotation direction, or calculate the second angle and the second rotation direction.
5. The method according to claim 1, characterized in that, The process of obtaining the target rotation parameters of the target model in the target scene includes: Based on bulletin board technology, the preset facets of the target model are set to be perpendicular to the viewing direction of the virtual camera, and the target rotation parameters of the target model are obtained when the preset facets of the target model are perpendicular to the viewing direction of the virtual camera.
6. The method according to claim 5, characterized in that, The step of setting the preset facets of the target model to be perpendicular to the line of sight of the virtual camera based on bulletin board technology includes: Output the world position offset information of preset patches in the target model based on bulletin board technology; Based on the world position offset information of the preset facet, adjust the position of the preset facet so that the preset facet in the target model is perpendicular to the viewing direction of the virtual camera.
7. The method according to claim 1, characterized in that, The light source component is either a fixed light source in the target scene, or a movable light source in the target scene.
8. The method according to any one of claims 1-7, characterized in that, The step of rendering and displaying the target model in the target scene based on the target rotation information of the light source component includes: Based on the target rotation information of the light source component, the target model in the target scene is rendered and displayed using a two-dimensional ray stepping algorithm.
9. A model rendering device, characterized in that, include: The acquisition module is used to acquire the target rotation parameters of the target model in the target scene, wherein the preset facet of the target model is perpendicular to the line of sight of the virtual camera, and the target rotation parameters include: target rotation direction and target angle; The control module is used to control the light source component in the target scene to rotate by the target angle based on the opposite direction of the target rotation direction, and to obtain the target rotation information of the light source component. The target rotation information is used to indicate the current target position of the light source component after rotating by the target angle. The rendering module is used to render and display the target model in the target scene based on the target rotation information of the light source component.
10. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the model rendering method as described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the model rendering method as described in any one of claims 1-8.