Virtual object rendering method, device, readable storage medium, and electronic device
By determining the observation angle of the game scene on the terminal device and dissolving the target map, the problem of low flexibility in the lunar eclipse effect of virtual moon objects is solved, and the lunar eclipse effect of virtual moon objects changes with the line of sight.
Patent Information
- Application Number
- CN202111527719.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2041-12-14
AI Technical Summary
In the prior art, the flexibility to display the lunar eclipse effect of virtual moon objects is low and cannot change with the change of vision.
The terminal device provides a graphical user interface to determine the observation angle of the game scene, and dissolve the target map based on the observation angle to obtain the dissolution result. Then, the target transparency value of the virtual object is determined based on the dissolution result, and the virtual object is displayed according to the target transparency value.
The lunar eclipse effect of virtual moon objects changes with the sight line, and improves the flexibility to display the lunar eclipse effect of moon objects.
Smart Images

Figure CN114299207B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular, to a method, device, readable storage medium, and electronic device for rendering virtual objects. Background Art
[0002] In the related art, for the lunar eclipse effect in a game scene, a black moon object covers the original moon object by the flow of model texture coordinates (UV) to achieve the lunar eclipse effect. However, the lunar eclipse image cannot change with the change of the field of view, resulting in a low flexibility in presenting the lunar eclipse effect of the virtual moon object.
[0003] Regarding the problem of low flexibility in presenting the lunar eclipse effect of the virtual moon object in the prior art, no effective solution has been proposed yet. Summary of the Invention
[0004] At least some embodiments of the present invention provide a method, device, readable storage medium, and electronic device for rendering virtual objects to at least solve the technical problem of low flexibility in presenting the lunar eclipse effect of the virtual moon object.
[0005] To achieve the above object, according to one embodiment of the present invention, a method for rendering virtual objects is provided. A graphical user interface is provided through a terminal device, and the graphical user interface at least partially displays a game scene, and the game scene at least partially includes a virtual object. The method may include: determining an observation angle of the game scene; performing a dissolution process on a first target texture map based on the observation angle to obtain a dissolution result, where the first target texture map is used to represent the texture image of the virtual object; determining a target transparency value of the virtual object based on the dissolution result; and rendering and displaying the virtual object according to the target transparency value.
[0006] Optionally, obtaining the observation angle of the game scene includes: obtaining in real time the observation field of view of a game character in the game scene, where the game scene includes a game character controlled by the terminal device; and determining the observation angle of the virtual object according to the observation field of view.
[0007] Optionally, obtaining a second target texture map, where the second target texture map is used to represent the texture image of a virtual cloud layer in the game scene and changes with time; determining the target color of the virtual object based on the second target texture map; and rendering and displaying the virtual object according to the target transparency value includes: rendering the virtual object according to the target transparency value and the target color.
[0008] Optionally, rendering the virtual object according to the target transparency value and the target color includes: rendering the virtual object according to the target transparency value and the target color corresponding to the target texture coordinates on the virtual object.
[0009] Optionally, performing a dissolving process on the first target map based on the observation angle to obtain a dissolving result includes: determining a target smoothing parameter based on the observation angle; and performing a smoothing process on the first target map based on the target smoothing parameter to obtain a dissolving result.
[0010] Optionally, determining a target smoothing parameter based on an observation angle includes: determining a target position corresponding to the observation angle, wherein a preset camera is used to shoot a game scene at the target position to obtain a scene image of the observation angle in the game scene; determining a first rotation angle of the target position relative to the position of the virtual object; and determining the target smoothing parameter based on the first rotation angle.
[0011] Optionally, determining a target smoothing parameter based on a first rotation angle includes: converting the first rotation angle to a second rotation angle within a first value range, wherein when the second rotation angle is an upper limit value of the first value range, the virtual object after rendering and display presents a first display state, and when the second rotation angle is a lower limit value of the first value range, the virtual object after rendering and display presents a second display state; determining the target smoothing parameter based on the second rotation angle.
[0012] Optionally, determining the target smoothing parameter based on the second rotation angle includes: converting the second rotation angle into a third rotation angle within a second value range, wherein the second value range is smaller than the first value range; determining a first smoothing parameter and a second smoothing parameter of a smoothing function based on the third rotation angle; smoothing the first target map based on the target smoothing parameter to obtain a dissolution result, including: inputting the first smoothing parameter, the second smoothing parameter and the first target map into a smoothing function for smoothing to obtain a dissolution result, wherein the dissolution result is between the first smoothing parameter and the second smoothing parameter.
[0013] Optionally, determining the target position corresponding to the observation angle includes: determining the target position corresponding to the observation angle in the model space.
[0014] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a virtual object rendering device is further provided, which provides a graphical user interface through a terminal device, and the graphical user interface at least partially displays a game scene, and the game scene at least partially includes a virtual object. The device may include: a first determination unit, used to determine the observation angle of the game scene; a dissolution unit, used to dissolve a first target map based on the observation angle to obtain a dissolution result, wherein the first target map is used to represent the texture image of the virtual object; a second determination unit, used to determine a target transparency value of the virtual object based on the dissolution result; and a rendering unit, used to render and display the virtual object according to the target transparency value.
[0015] To achieve the above object, according to another aspect of the present invention, there is also provided a computer-readable storage medium. A computer program is stored in the computer-readable storage medium. When the computer program is run by a processor, it controls the device where the computer-readable storage medium is located to execute the virtual object rendering method of the embodiment of the present invention.
[0016] To achieve the above object, according to another aspect of the present invention, there is also provided an electronic device. The electronic device may include a memory and a processor. It is characterized in that a computer program is stored in the memory, and the processor is configured to run the computer program by the processor to execute the virtual object rendering method of the embodiment of the present invention.
[0017] In at least some embodiments of the present invention, the viewing angle of the game scene is determined; the first target texture map is dissolved based on the viewing angle to obtain a dissolution result, where the first target texture map is used to represent the texture image of the virtual object; the target transparency value of the virtual object is determined based on the dissolution result; and the virtual object is rendered and displayed according to the target transparency value. That is to say, in this application, by dissolving the target texture map to obtain a dissolution result, and determining the target transparency channel of the virtual moon object based on the dissolution result, the purpose of showing the waxing and waning of the moon as the line of sight changes is achieved, the flexibility of showing the lunar eclipse effect of the moon object is improved, and thus the technical problem of low flexibility in showing the lunar eclipse effect of the virtual moon object is solved, and the technical effect of improving the flexibility of showing the lunar eclipse effect of the moon object is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present invention, form a part of this application, and the schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:
[0019] Figure 1 is a hardware structure block diagram of a mobile terminal of a virtual object rendering method according to one embodiment of the present invention;
[0020] Figure 2 is a flowchart of a virtual object rendering method according to one embodiment of the present invention;
[0021] Figure 3 is a schematic diagram of a lunar eclipse effect in the related art of the present invention;
[0022] Figure 4 is a schematic diagram of a lunar eclipse effect according to one embodiment of the present invention;
[0023] Figure 5 is a schematic diagram of the coordinates of a certain point on the spherical surface in the model space according to an embodiment of the present invention;
[0024] Figure 6 It is a schematic diagram of the coordinates of a certain point on the spherical surface in the world space according to an embodiment of the present invention;
[0025] Figure 7 It is a schematic diagram of the conversion result of calculating an angle according to the present invention;
[0026] Figure 8 It is a schematic diagram of the conversion result of a value range according to the present invention;
[0027] Figure 9 It is a schematic diagram of the conversion result of another value range according to the present invention;
[0028] Figure 10 It is a schematic diagram of a dissolve texture according to the present invention;
[0029] Figure 11 It is a structural block diagram of a virtual object rendering device according to an embodiment of the present invention. Detailed implementation manners
[0030] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" 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 does not have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0032] First of all, some nouns or terms that appear in the process of describing the embodiments of the present application are explained as follows:
[0033] Lightmap, a texture that describes and records the scene lighting data, is often used to enhance the lighting atmosphere and artistic effect of the scene;
[0034] The normal vector. The method of generating a lightmap is generally called baking, and this function is usually built into general game engines such as Unity / UE4.
[0035] Model space. In different game engines or software, model space is also referred to as object space or local space. For example, as Figure 5 shown, Figure 5 is a schematic diagram of the coordinates of a certain point on the spherical surface in the model space according to an embodiment of the present invention;
[0036] World space. World space is a macroscopic special coordinate system, which represents the largest coordinate system that we are concerned about. For example, as Figure 6 shown, Figure 6 is a schematic diagram of the coordinates of a certain point on the spherical surface in the world space according to an embodiment of the present invention;
[0037] Normalization, which changes the length of a vector to 1;
[0038] UV flow. UV flow or UV translation refers to moving the UV coordinates of a texture along the horizontal (U) direction or the vertical (V) direction to create an illusion of complex animation; UV flow can create effects such as flames, flowing water, or smoke.
[0039] According to one embodiment of the present invention, an embodiment of a virtual object rendering method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0040] This method embodiment can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking the operation on a mobile terminal as an example, the mobile terminal can be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a personal digital assistant, and mobile Internet devices (abbreviated as MID), a PAD, a game console, and other terminal devices. Figure 1 is a hardware structure block diagram of a mobile terminal for a virtual object rendering method according to one embodiment of the present invention. As Figure 1 shown, the mobile terminal can include one or more ( Figure 1Only one processor 102 is shown (the processor 102 may include, but is not limited to, processing devices such as a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microcontroller unit (MCU), a field-programmable gate array (FPGA), a neural network processor (NPU), a tensor processing unit (TPU), an artificial intelligence (AI)-type processor, etc.) and a memory 104 for storing data. Optionally, the above mobile terminal may further include a transmission device 106 for communication functions, an input / output device 108, and a display device 110. Those of ordinary skill in the art can understand that Figure 1 The structure shown is only illustrative and does not limit the structure of the above mobile terminal. For example, the mobile terminal may further include more or fewer components than Figure 1 shown therein, or have a different configuration from Figure 1 that shown.
[0041] The memory 104 can be used to store computer programs. For example, software programs and modules of application software, such as the computer program corresponding to the virtual object rendering method in the embodiments of the present invention. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, that is, implements the above object processing method. The memory 104 may include a high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the mobile terminal through a network. Examples of the above network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0042] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one instance, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0043] The inputs in the input / output device 108 may come from a plurality of human interface devices (HIDs), such as keyboards and mice, game controllers, and other dedicated game controllers (such as steering wheels, fishing rods, dance mats, remote controls, etc.). In addition to providing input functions, some human interface devices may also provide output functions, such as force feedback and vibration of game controllers, audio output of controllers, etc.
[0044] The display device 110 may be, for example, a head-up display (HUD), a touch-screen liquid crystal display (LCD), and a touch display (also referred to as a "touch screen" or "touch display screen"). The liquid crystal display may enable a user to interact with a user interface of the mobile terminal. In some embodiments, the mobile terminal has a graphical user interface (GUI), and a user may interact with the GUI by finger contacts and / or gestures on a touch-sensitive surface, wherein the human-computer interaction functions here may optionally include the following interactions: creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interfaces, playing digital videos, playing digital music, and / or web browsing, etc. The executable instructions for executing the above-mentioned human-computer interaction functions are configured / stored in a computer program product or a readable storage medium executable by one or more processors.
[0045] The virtual object rendering method in one embodiment of the present disclosure can be run on a local terminal device or a server. When the virtual object rendering method is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0046] In an optional implementation, various cloud applications can be run under the cloud interaction system, such as cloud games. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the operation mode of cloud games, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the virtual object rendering method are completed on the cloud game server. The role of the client device is used for receiving and sending data and presenting the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a mobile terminal, a TV, a computer, a handheld computer, etc.; but the cloud game server in the cloud is used for information processing. When playing the game, the player operates the client device to send an operation instruction to the cloud game server. The cloud game server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.
[0047] In an optional embodiment, taking a game as an example, the local terminal device stores a game program and is used to present game screens. The local terminal device is used to interact with players through a graphical user interface, that is, conventionally, the game program is downloaded and installed on an electronic device and run. The ways for the local terminal device to provide the graphical user interface to players can include various types. For example, it can be rendered and displayed on the display screen of the terminal, or provided to players through holographic projection. For example, the local terminal device can include a display screen and a processor. The display screen is used to present the graphical user interface, and the graphical user interface includes game screens. The processor is used to run the game, generate the graphical user interface, and control the display of the graphical user interface on the display screen.
[0048] In this embodiment, a virtual object rendering method running on the above-mentioned mobile terminal is provided. A graphical user interface is provided through the terminal device. Among them, the terminal device can be the aforementioned local terminal device or the client device in the aforementioned cloud interaction system. The graphical user interface at least partially displays a game scene, and the game scene at least partially includes a virtual object. Among them, the virtual object can be the moon, the sun, or other models.
[0049] Figure 2 It is a flowchart of a virtual object rendering method according to one embodiment of the present invention. A graphical user interface is provided through the terminal device, as Figure 2 shown. The method includes the following steps:
[0050] Step S202, determine the viewing angle of the game scene.
[0051] In the technical solution provided in step S202 of the present invention above, the game scene can be the picture obtained by shooting with a preset camera in the game scene, and the game scene can include virtual objects. The viewing angle can be the viewing angle relative to the game scene or the information that changes as the virtual game character moves.
[0052] In this embodiment, by binding the virtual camera to the orientation, the purpose of controlling the viewing angle of the virtual character is achieved. By controlling the orientation, the virtual camera rotates, so as to obtain a changing game scene; if the virtual camera is not bound to the orientation, at this time, only the virtual camera can be directly limited to cause a change in the viewing angle of the game scene.
[0053] Optionally, the position of the virtual camera can be moved to change the viewing angle of the virtual object in the game scene. For example, on the mobile side, by swiping the screen in a certain direction up, down, left, or right, the purpose of changing the viewing angle of the virtual object in the game scene is achieved. Or on the computer side, by long-pressing and swiping the game scene screen in the up, down, left, and right directions with the mouse, the viewing angle is changed.
[0054] Optionally, the game scene is captured by a preset camera to obtain a scene image, and by obtaining information in the game scene, the viewing angle of the virtual game character in the scene image is determined.
[0055] Step S204: Perform a dissolve process on the first target texture map based on the viewing angle to obtain a dissolve result, where the first target texture map is used to represent the texture image of the virtual object.
[0056] In the technical solution provided in step S204 of the present invention, a dissolve process is performed on the first target texture map based on the determined viewing angle of the game scene to obtain a dissolve result. Among them, the first target texture map can be a dissolve texture map, which can be used to generate a virtual object dissolve picture and can be represented by dissolve_tex. The dissolve process can be a smoothstep dissolve of the target texture map based on the game view information to obtain a dissolve result. The dissolve result is used to achieve the disappearance of the graphics on the scene image and can be represented by step_dissolve.
[0057] Step S206: Determine the target transparency value of the virtual object based on the dissolve result.
[0058] In the technical solution provided in step S206 of the present invention, the target transparency value can be a dissolve value, which can be used as the target transparency channel and can be the Alpha channel. It is used to represent the transparency information of the pixel points in the image. By changing the transparency channel of the virtual object, the effect of making the virtual object disappear can be achieved. The target transparency channel can be the transparency channel of the moon with clouds.
[0059] Optionally, by performing a dissolve process on the first target texture map based on the viewing angle to obtain a dissolve result, and then processing the dissolve result to obtain the target transparency value of the virtual object, and using the determined target transparency value as the transparency channel of the virtual object.
[0060] Step S208: Render and display the virtual object according to the target transparency value.
[0061] In the technical solution provided in step S208 of the present invention, the calculated target transparency value is used as the transparency channel of the virtual object, and the virtual object with a transparency channel is rendered and displayed, so as to obtain a virtual object that changes with the viewing angle.
[0062] In this embodiment, the obtained dissolve result can be used as the transparency value of the virtual object, and the transparency value can be used as the transparency channel of the virtual object to render and display the virtual object.
[0063] Through the above steps S202 to S208 of this application, the game field of view information of the scene picture is obtained; based on the game field of view information, the target texture map is dissolved to obtain a dissolution result, where the target texture map is used to generate an eclipse image of the virtual moon object; based on the dissolution result, the target transparency channel of the virtual moon object is determined, so as to convert the image of the virtual moon object from the first eclipse image to the second eclipse image. That is to say, through the dissolution process of the target texture map in this application, a dissolution result is obtained, and the target transparency channel of the virtual moon object is determined based on the dissolution result, so as to achieve the purpose of showing the waxing and waning of the full moon as the line of sight changes, improve the flexibility of showing the eclipse effect of the moon object, and then solve the technical problem of low flexibility in showing the eclipse effect of the virtual moon object, achieving the technical effect of improving the flexibility of showing the eclipse effect of the moon object.
[0064] The above method of this embodiment will be further introduced below.
[0065] As an optional implementation manner, step S202, obtaining the viewing angle of the game scene, includes: obtaining in real time the viewing field of the game character in the game scene, where the game scene includes a game character controlled by a terminal device; determining the viewing angle of the virtual object according to the viewing field.
[0066] In this embodiment, as the game character (virtual game character) moves, the viewing field of the game character in the game scene is obtained in real time, and the viewing angle of the virtual object is determined according to the obtained viewing field, where the viewing angle of the game character's field of view can be controlled by a terminal device.
[0067] Optionally, the adjustment of the field of view can be achieved by adjusting the free view in the game, thereby causing a change in the viewing angle of the game scene; or when the field of view is bound to the orientation of the game character, the viewing angle of the game scene can be adjusted by adjusting the field of view of the game character.
[0068] As an optional implementation manner, obtain a second target texture map, where the second target texture map is used to characterize the texture image of the virtual cloud layer in the game scene and changes over time; determine the target color of the virtual object based on the second target texture map; render and display the virtual object according to the target transparency value, including: rendering the virtual object according to the target transparency value and the target color.
[0069] Optionally, the second target texture map can be a texture map of the cloud layer, which is used to adjust the target color of the virtual object. The second target texture map, which is a texture map of the cloud layer, changes over time. By superimposing the target color and the target transparency value obtained by rendering and displaying the second target texture map, and rendering and displaying the superimposed result, a virtual object picture that changes over time is obtained.
[0070] Optionally, the texture map of the cloud layer is superimposed on the moon map to obtain the lunar eclipse change. Among them, the two maps correspond to the UV coordinates on the virtual target and then the virtual object is rendered and displayed. It should be noted that the texture map of the cloud layer adjusts the color, while the moon map adjusts the transparency, and the two do not interfere with each other.
[0071] As an optional implementation manner, rendering a virtual object according to a target transparency value and a target color includes: rendering a virtual object according to the target transparency value and the target color corresponding to the target texture coordinates on the virtual object.
[0072] In this embodiment, the target texture information is used to represent the texture coordinates of the cloud image that changes at a target speed within a target time; determining the target transparency channel of the virtual moon object based on the dissolution result includes: converting the original transparency channel of the virtual moon object into the target transparency channel based on the target texture information and the dissolution result.
[0073] Optionally, the target texture information is used to represent the texture coordinates of the cloud image that changes at a target speed within a target time, which can be represented by Tex2,input.uv. The texture coordinates can be UV coordinates, which are used to locate any pixel on the image. Through the texture coordinates, the vertices of the polygon can be corresponding to the pixels on the image file, so as to realize the positioning of the texture map on the polygon surface. Among them, the numerical ranges of the U and V coordinates of the map can both be from 0 to 1.
[0074] Optionally, the target texture information is obtained by adding the product of the generation time (FrameTime) of each frame within the target time and the target speed (CloudMoveSpeed) of the cloud movement to the texture coordinates of the virtual moon object. Among them, the target texture information can be represented by tex2Color and can be represented by the following formula:
[0075] HALF4
[0076] tex2color = SAMPLE_TEXTURE_LEVEL(Tex2,input.uv + float2(FrameTime * CloudMoveSpeed, 0), -1)
[0077] Among them, SAMPLE_TEXTURE_LEVEL represents texture sampling and is used to make the cloud UV flow.
[0078] In this embodiment, based on the target texture information and the dissolution result, the original transparency channel of the virtual moon object is converted into a target transparency value, and the virtual object is rendered according to the target transparency value and the target color corresponding to the target texture coordinates on the virtual object, where the original transparency channel can be represented by AlphaMt1.
[0079] As an alternative implementation, the first target texture map is dissolved based on the viewing angle to obtain a dissolution result, including: determining a target smoothing parameter based on the viewing angle; smoothing the first target texture map based on the target smoothing parameter to obtain a dissolution result.
[0080] In this embodiment, converting the original transparency channel of the virtual moon object into a target transparency channel based on the target texture information and the dissolution result includes: adding the cloud image corresponding to the target texture information to the original transparency channel; dissolving the original transparency channel with the cloud image based on the dissolution result to obtain the target transparency channel.
[0081] Optionally, adding the cloud image corresponding to the target texture information to the original transparency channel. For example, adding the effect of cloud uv flow to the original transparency channel of the moon, and dissolving the original transparency channel with the target texture information to obtain the target transparency channel, where the target transparency channel can be represented by finalcolor and can be expressed by the following formula:
[0082] HALF4
[0083] finalColor = HALF4((text0Color.rgb * lerp(float3(1.0), text2Color.rgb, CloudIntensity) + text3Color.rgb * text3Color.a * EmissiveIntensity), text0Color.a * step_dissolve * AlphaMt1) * ColorFactor
[0084] Among them, text0Color.rgb represents the red, green, and blue channels of the base color, lerp(float3(1.0) is used to determine the effect of cloud intensity, CloudIntensity represents the cloud intensity parameter, text3Color.rgb represents the red, green, and blue channels of the cloud map, text3Color.a represents the alpha channel of the cloud map, EmissiveIntensity represents the light emission intensity parameter of the target object, and ColorFactor is used to control the color grayscale.
[0085] In this embodiment, the smoothing parameter is used to make the image change more smoothly. It can be the minimum value of the smoothing parameter, s_min, and the maximum value of the smoothing parameter, s_max. The smoothing process can be a smooth step dissolution of the target patch. Optionally, the target smoothing parameter is used as the first two parameters of the smooth step function, and the target patch is input as the last parameter to obtain the dissolution result, which can be:
[0086] Float step_dissolve=smoothstep(s_min,s_max,dissolve_tex)
[0087] As an alternative implementation, determining the target smoothing parameter based on the viewing angle includes: determining the target position corresponding to the viewing angle, where a preset camera is used to capture the game scene at the target position to obtain the scene image of the viewing angle in the game scene; determining the first rotation angle of the target position relative to the position of the virtual moon object; and determining the target smoothing parameter based on the first rotation angle.
[0088] In this embodiment, a preset camera is used to capture the game scene at the target position to obtain the scene image, so as to determine the target position corresponding to the game field of view information. Among them, the target position can be the position where the scene captured by the camera is converted to the model space, which can be represented by locao_camera_position and can be expressed by the following formula:
[0089] float4 local_camera_position=mul(FLOAT4(CameraPosition.xyz,1.0),World);
[0090] frag.local_camera_position=local_camera_position.xyz
[0091] Optionally, determine the first rotation angle of the target position relative to the position of the virtual moon object. Among them, the position of the virtual moon object can be the positions of each vertex in the camera, which can be represented by cam_object. The first rotation angle can be the angle from the target position to the center point of the virtual moon object, which can be represented by distance, and the atan2 function can be used to calculate the angle.
[0092] Optionally, first add PI divided by 2 to the calculated angle, and then divide the result of adding PI divided by 2 to the calculated angle by PI, so as to convert the first rotation angle to the range of 0-1, which can be expressed by the following formula:
[0093] Float3 cam_object = normalize(input.local_camera_position)
[0094] Float distance = (atan2(cam_object.z, abs(cam_object.x)) + PI / 2.0) / PI; / / 1-0.5-0
[0095] Among them, normalize is a normalization function used to process the target position of the virtual moon object between 0 and 1. The abs(cam_object.x) function is used to obtain the absolute value of the target position on the x-axis, and cam_object.z represents the value of the target position on the z-axis.
[0096] As an alternative implementation, determining the target smoothing parameter based on the first rotation angle includes: converting the first rotation angle to a second rotation angle within a first value range. Among them, when the second rotation angle is the upper limit value of the first value range, the rendered virtual object presents a first display state. When the second rotation angle is the lower limit value of the first value range, the rendered virtual object presents a second display state; determining the target smoothing parameter based on the second rotation angle.
[0097] In this embodiment, due to requirements, when the virtual moon object turns 90 degrees to the side, it disappears, and when it turns 180 degrees, it appears again. Therefore, by calculation, the first rotation angle is converted to a second rotation angle within a first value range. Among them, the first value range can be within the range of 0 to 1, that is, the upper limit value is a value close to 0, and the lower limit value is a value close to 1. The value range can include changing the values less than 0 in the first rotation angle to 0 and changing the values exceeding 1 to 1, thereby obtaining the second rotation angle, which can be represented by the following formula:
[0098] Float distance = (atan2(cam_object.z, abs(cam_object.x)) + PI / 2.0) / PI; / / 1-0.5-0;
[0099] Float distance_fix = saturate(abs((distance - 0.5) * 2.0)); / / 1-0-1
[0100] Among them, distance_fix is used to represent the second rotation angle, and saturate is used to limit a number within the range of 0 to 1, changing the values less than 0 to 0 and changing the values exceeding 1 to 1.
[0101] Optionally, when the second rotation angle is the upper limit value of the first value range, the rendered virtual object presents a first display state. For example, if the virtual object is the moon, the first display state can be the full moon state. When the second rotation angle is the lower limit value of the first value range, the rendered virtual object presents a second display state. For example, if the virtual object is the moon, the second display state can be the total lunar eclipse state. Determine the target smoothing parameter based on the second rotation angle.
[0102] As an optional implementation manner, determining the target smoothing parameter based on the second rotation angle includes: converting the second rotation angle into a third rotation angle within a second value range, where the second value range is smaller than the first value range; determining a first smoothing parameter and a second smoothing parameter of the smoothing function based on the third rotation angle; performing smoothing processing on the first target texture map based on the target smoothing parameter to obtain a dissolution result, including: inputting the first smoothing parameter, the second smoothing parameter, and the first target texture map into the smoothing function for smoothing processing to obtain a dissolution result, where the dissolution result is between the first smoothing parameter and the second smoothing parameter.
[0103] In this embodiment, since the change near 0-1 is very slow during the process of rotating the camera angle, it is necessary to slightly reduce the first value range so that the angle change is smoother. Optionally, convert the second rotation angle into a third rotation angle within a second value range, where the second value range is smaller than the first value range. For example, the first value range can be 0-1, then the second value range can be 0.1-0.9 or 0.05-0.95, which is not limited here.
[0104] Optionally, use a smooth step function to adjust the second rotation angle to obtain a third rotation angle, which can be represented by distance_fix_smooth and can be expressed by the following formula:
[0105] Float distance_fix = saturate(abs((distance - 0.5) * 2.0)); / / 1-0-1;
[0106] Float distance_fix_smooth = smoothstep(0.05, 0.95, distance_fix); / / 0.9-1-0.9
[0107] Among them, the smoothstep function is specifically smoothstep(a, b, c), which will change the value range of c to between a and b, and is used to change the overall value range from 0-1 to 0.1-0.9 or 0.05-0.95.
[0108] In this embodiment, the results of the third rotation angle are respectively converted into a first smoothing parameter and a second smoothing parameter. Here, the first smoothing parameter can be represented by s_min, and the second smoothing parameter can be represented by s_max. The first smoothing parameter, the second smoothing parameter, and the first target texture map are input into a smoothing function for smoothing processing to obtain a dissolution result, which can be represented by the following formula:
[0109] Float s_min = saturate(distance_fix_smooth * (-2.0) + 1.0); / / saturate(-1~1)
[0110] Float s_max = 1.0 - (saturate(distance_fix_smooth - 0.5) * 2.0
[0111] Float step_dissolve = smoothstep(s_min, s_max, dissolve_tex)
[0112] Optionally, the smoothing function used can be smoothstep(a, b, c), which will change the value range of c to between a and b. Therefore, the dissolution result will be between the first smoothing parameter and the second smoothing parameter.
[0113] As an alternative implementation, determining the target position corresponding to the game field of view information includes: determining the target position corresponding to the game field of view information in the model space.
[0114] In this embodiment, the position corresponding to the game field of view information can be converted into the model space, so as to obtain the target position in the model space.
[0115] It should be noted that regarding the model space and the time space, it can be a conversion between a relative coordinate and a world coordinate. Usually, the model space coordinate system is established to facilitate the real-time adjustment and control of the angle and orientation of the virtual model. However, if the model space coordinate system is to be displayed on the graphical user interface, it must be converted into the world coordinate system, and then from the world coordinate system into the screen (graphical user interface) coordinate system, so as to complete the screen mapping display.
[0116] In this embodiment, the game field of view information of the scene screen is obtained; based on the game field of view information, the target map is dissolved to obtain a dissolution result, wherein the target map is used to generate a lunar eclipse image of the virtual moon object; based on the dissolution result, the target transparent channel of the virtual moon object is determined to convert the image of the virtual moon object from the first lunar eclipse image to the second lunar eclipse image. In other words, the present application dissolves the target map to obtain a dissolution result, and determines the target transparent channel of the virtual moon object based on the dissolution result, thereby achieving the purpose of showing the full moon and the new moon with the change of the line of sight, improving the flexibility of displaying the lunar eclipse effect of the moon object, and further solving the technical problem of low flexibility in displaying the lunar eclipse effect of the virtual moon object, and achieving the technical effect of improving the flexibility of displaying the lunar eclipse effect of the moon object.
[0117] The technical solution of the embodiment of the present invention is further introduced below with examples in combination with preferred implementation modes.
[0118] In the prior art, the natural phenomenon of lunar eclipse is achieved by covering the original moon with a UV flowing black moon, such as Figure 3 As shown, Figure 3 It is a schematic diagram of a lunar eclipse effect in the related technology according to the present invention. The existing technical solutions cannot achieve the feature of changing with the line of sight.
[0119] Therefore, this scheme proposes a scheme that can follow the changes in line of sight to achieve the effect of the full moon and the new moon, and realize the effect of changing the lunar eclipse. Figure 4 As shown, Figure 4 This is a schematic diagram of a lunar eclipse effect according to one embodiment of the present invention. When it is purely front-facing, it is a perfect circle, but it gradually dissipates as the viewing angle moves, and it disappears directly when it is purely back-facing. When dissipating, the starry sky particles do not dissipate in sheets, but have changes on the Z axis, which is similar to the effect of a lunar eclipse.
[0120] The above method of this embodiment is further introduced below.
[0121] The first step, at the vertex stage, is to transform the camera position into model space. This can be:
[0122] float4 local_camera_position=mul(FLOAT4(CameraPosition.xyz,1.0),World);
[0123] frag.local_camera_position=local_camera_position.xyz.
[0124] Step 2: Calculate the angle from the camera to the center point of the model, including: calculating the angle using the atan2 function (here in radians, dividing the angle by 2π and converting it to the range of 0 - 1. At this time, the value range is converted to 0 - 0.5 - 1, as Figure 7 shown, Figure 7 is a schematic diagram of the conversion result of calculating the angle according to one of the present inventions, and it can be:
[0125] Float3 cam_object = normalize(input.local_camera_position)
[0126] Float distance = (atan2(cam_object.z, abs(cam_object.x)) + PI / 2.0) / PI.
[0127] Step 3: Because the requirement is that the moon disappears when it turns to the side by 90 degrees and reappears when it turns to 180 degrees, so the value range is converted through calculation, as Figure 8 shown, Figure 8 is a schematic diagram of the conversion result of calculating the value range according to one of the present inventions, and it can be:
[0128] Float distance = (atan2(cam_object.z, abs(cam_object.x)) + PI / 2.0) / PI;
[0129] Float distance_fix = saturate(abs((distance - 0.5) * 2.0)).
[0130] Among them, when the center of the object is located at the center point of the cross and the camera is at various positions, the corresponding angle values change linearly and uniformly, and the calculation is saturate(abs((distance - 0.5) * 2)), Abs is to take the absolute value of a number, and Saturate is to limit a number within the range of 0 - 1, making the number less than 0 become 0 and the number exceeding 1 become 1. The result calculated in this way realizes Figure 8 the change from left to right in
[0131] i.e., converting the value range from 0 - 0.5 - 1 to the range of 1 - 0 - 1. Figure 9 shown, Figure 9It is a schematic diagram for calculating the conversion result of the value range in the present invention, which can be:
[0132] Float distance_fix = saturate(abs((distance - 0.5) * 2.0));
[0133] Float distance_fix_smooth = smoothstep(0.05, 0.95, distance_fix);
[0134] Among them, when approaching 1, the moon is complete, and when approaching 0, it is a total lunar eclipse. Here, the smoothstep function is used to change the overall value range from 1 - 0 - 1 to 0.9 - 1 - 0.9 or 0.05 - 0.95, so it will become Figure 9 The appearance in the right figure. The specific use of the function is smoothstep(a, b, c), which will change the value range of c to between a and b.
[0135] Step 5: Dissolve the dissolve texture using the smooth step function. Figure 10 It is a schematic diagram of a dissolve texture according to the present invention, as Figure 10 shown, including: converting the results in the fourth step into two values, s_min and s_max, as the first two parameters of smoothstep, the texture input as the last parameter, and using the dissolve value as the alpha channel of the moon to achieve the dissolve effect, which can be:
[0136] Float s_min = saturate(distance_fix_smooth * (-2.0) + 1.0); / / saturate(-1~1)
[0137] Float s_max = 1.0 - (saturate(distance_fix_smooth - 0.5) * 2.0
[0138] Float step_dissolve = smoothstep(s_min, s_max, dissolve_tex)
[0139] Step 6: Add the effect of cloud uv flow to the moon map, that is, UV + time * speed, so as to achieve a simple uv flow effect, which can be:
[0140] HALF4
[0141] tex2color = SAMPLE_TEXTURE_LEVEL(Tex2, input.uv + float2(FrameTime * CloudMoveSpeed, 0), -1).
[0142] Step 7: Dissolve the alpha channel of the moon with clouds according to the result of Step 4, so as to achieve the lunar eclipse effect that changes with the line of sight. It can be as follows:
[0143] HALF4
[0144] finalColor = HALF4((text0Color.rgb * lerp(float3(1.0), text2Color.rgb, CloudIntensity) + text3Color.rgb * text3Color.a * EmissiveIntensity), text0Color.a * step_dissolve * AlphaMt1) * ColorFactor.
[0145] In this embodiment, by converting the camera position into the model space, calculating the rotation angle of the camera relative to the center point of the model, converting the angle value to between 0 and 1, then dissolving the dissolve texture according to this value, and finally using the dissolve value as the alpha channel of the moon, the technical problem of low flexibility in presenting the lunar eclipse effect of the virtual moon object is solved, and the technical effect of improving the flexibility in presenting the lunar eclipse effect of the moon object is achieved.
[0146] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc), and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.
[0147] The embodiment of the present invention also provides a virtual object rendering device, which is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used below, the term "unit" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0148] Figure 11 It is a structural block diagram of a virtual object rendering device according to an embodiment of the present invention. A graphical user interface is provided through a terminal device, and the graphical user interface at least partially displays a game scene, and the game scene at least partially includes a virtual object, such as Figure 11 shown, the virtual object rendering device 110 may include: an acquisition unit 111, a dissolution unit 112, and a determination unit 113.
[0149] A first determination unit 111, configured to determine the viewing angle of the game scene.
[0150] The dissolution unit 112 is configured to perform a dissolution process on the first target texture map based on the viewing angle to obtain a dissolution result, where the first target texture map is used to represent the texture image of the virtual object.
[0151] A second determination unit 113, configured to determine the target transparency value of the virtual object based on the dissolution result.
[0152] The rendering unit 114 is configured to render and display the virtual object according to the target transparency value.
[0153] In the virtual object rendering device of this embodiment, the present application determines the viewing angle of the game scene through the first determination unit; uses the dissolution unit to perform a dissolution process on the first target texture map based on the viewing angle to obtain a dissolution result, where the first target texture map is used to represent the texture image of the virtual object; uses the second determination unit to determine the target transparency value of the virtual object based on the dissolution result; uses the rendering unit to render and display the virtual object according to the target transparency value, so as to determine the target transparency channel of the virtual moon object based on the dissolution result, achieve the purpose of showing the waxing and waning of the moon as the line of sight changes, improve the flexibility of showing the lunar eclipse effect of the moon object, and further solve the technical problem of low flexibility in showing the lunar eclipse effect of the virtual moon object, and achieve the technical effect of improving the flexibility of showing the lunar eclipse effect of the moon object.
[0154] It should be noted that the above-mentioned each unit can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above-mentioned units are all located in the same processor; or, the above-mentioned each unit is located in different processors in any combination form.
[0155] An embodiment of the present invention also provides a non-volatile storage medium, in which a computer program is stored, and the computer program is configured to execute the virtual object rendering method of the embodiment of the present invention when being run by a processor.
[0156] Optionally, in this embodiment, the above non-volatile storage medium may be configured to store a computer program for executing the following steps:
[0157] S1, Determine the viewing angle of the game scene;
[0158] S2, Based on the viewing angle, perform a dissolution process on the first target texture map to obtain a dissolution result, where the first target texture map is used to represent the texture image of the virtual object;
[0159] S3, Determine the target transparency value of the virtual object based on the dissolution result.
[0160] S4, Render and display the virtual object according to the target transparency value.
[0161] Optionally, in this embodiment, the above non-volatile storage medium may include, but is not limited to: various media such as USB flash drives, read-only memories (ROM), random access memories (RAM), mobile hard disks, magnetic disks, or optical discs that can store computer programs.
[0162] An embodiment of the present invention also provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0163] Optionally, the above electronic device may further include a transmission device and an input / output device, where the transmission device is connected to the above processor, and the input / output device is connected to the above processor.
[0164] Optionally, in this embodiment, the above processor may be configured to execute the following steps through a computer program:
[0165] S1, Determine the viewing angle of the game scene;
[0166] S2, Based on the viewing angle, perform a dissolution process on the first target texture map to obtain a dissolution result, where the first target texture map is used to represent the texture image of the virtual object;
[0167] S3, Determine the target transparency value of the virtual object based on the dissolution result.
[0168] S4, Render and display the virtual object according to the target transparency value.
[0169] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and will not be elaborated herein.
[0170] The above serial numbers of the embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0171] In the above embodiments of the present invention, the descriptions of the respective embodiments have their own focuses. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0172] In several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the units or modules can be in electrical or other forms.
[0173] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0174] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0175] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention. The foregoing storage medium includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs and other various media that can store program codes.
[0176] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A method for rendering a virtual object, characterized in that, a graphical user interface is provided by a terminal device, at least part of the graphical user interface displays a game scene, and at least part of the game scene includes a virtual object, and the method includes: determining an observation angle of the game scene; performing a dissolution process on a first target texture map based on the observation angle to obtain a dissolution result, wherein the first target texture map is used to represent a texture image of the virtual object; determining a target transparency value of the virtual object based on the dissolution result; rendering and displaying the virtual object according to the target transparency value; wherein, performing a dissolution process on the first target texture map based on the observation angle to obtain the dissolution result includes: determining a target smoothing parameter based on the observation angle, wherein the target smoothing parameter includes a first smoothing parameter of a smoothing function and a second smoothing parameter of the smoothing function; inputting the first smoothing parameter, the second smoothing parameter, and the first target texture map into the smoothing function for smoothing processing to obtain the dissolution result, wherein the dissolution result is between the first smoothing parameter and the second smoothing parameter.
2. The method according to claim 1, characterized in that, obtaining the observation angle of the game scene includes: real-time obtaining an observation field of view of a game character in the game scene, wherein the game scene includes the game character controlled by the terminal device; determining the observation angle of the virtual object according to the observation field of view.
3. The method according to claim 1, characterized in that, the method further includes: obtaining a second target texture map, wherein the second target texture map is used to represent a texture image of a virtual cloud layer in the game scene and changes with time; determining a target color of the virtual object based on the second target texture map; rendering and displaying the virtual object according to the target transparency value includes: rendering the virtual object according to the target transparency value and the target color.
4. The method according to claim 3, characterized in that, rendering the virtual object according to the target transparency value and the target color includes: rendering the virtual object according to the target transparency value and the target color corresponding to target texture coordinates on the virtual object.
5. The method according to claim 1, characterized in that, determining the target smoothing parameter based on the observation angle includes: determining a target position corresponding to the observation angle, wherein a preset camera is used to photograph the game scene at the target position to obtain a scene picture of the observation angle in the game scene; determining a first rotation angle of the target position relative to the position of the virtual object; determining the target smoothing parameter based on the first rotation angle.
6. The method according to claim 5, characterized in that, determining the target smoothing parameter based on the first rotation angle includes: Convert the first rotation angle to a second rotation angle within a first value range. When the second rotation angle is the upper limit value of the first value range, the rendered virtual object presents a first display state. When the second rotation angle is the lower limit value of the first value range, the rendered virtual object presents a second display state; Determine the target smoothing parameter based on the second rotation angle.
7. The method according to claim 6, wherein, Determining the target smoothing parameter based on the second rotation angle includes: converting the second rotation angle to a third rotation angle within a second value range, where the second value range is smaller than the first value range; determining the first smoothing parameter and the second smoothing parameter of the smoothing function based on the third rotation angle.
8. The method according to claim 5, wherein, Determining the target position corresponding to the viewing angle includes: Determining the target position corresponding to the viewing angle in the model space.
9. A virtual object rendering device, wherein, Provide a graphical user interface through a terminal device. The graphical user interface at least partially displays a game scene, and the game scene at least partially includes a virtual object. The device includes: A first determination unit for determining the viewing angle of the game scene; A dissolution unit for performing a dissolution process on a first target texture map based on the viewing angle to obtain a dissolution result, where the first target texture map is used to represent the texture image of the virtual object; A second determination unit for determining the target transparency value of the virtual object based on the dissolution result; A rendering unit for rendering and displaying the virtual object according to the target transparency value; wherein, the dissolution unit is used to perform a dissolution process on the first target texture map based on the viewing angle through the following steps to obtain the dissolution result, including: determining a target smoothing parameter based on the viewing angle, where the target smoothing parameter includes a first smoothing parameter and a second smoothing parameter of a smoothing function; inputting the first smoothing parameter, the second smoothing parameter, and the first target texture map into the smoothing function for smoothing processing to obtain the dissolution result, where the dissolution result is between the first smoothing parameter and the second smoothing parameter.
10. A computer-readable storage medium, wherein, A computer program is stored in the computer-readable storage medium, where the computer program is configured to execute the method described in any one of claims 1 to 8 when run by a processor.
11. An electronic device includes a memory and a processor, wherein, A computer program is stored in the memory, and the processor is configured to run the computer program to execute the method described in any one of claims 1 to 8.
Citation Information
Patent Citations
Object rendering method and device, storage medium and electronic device
CN108564646A
Virtual object interaction method and device, reward issuing method and device, equipment and medium
CN112973117A