Virtual scene rendering method and device, electronic equipment and storage medium

By using a virtual light source and a preset refractive index in a virtual scene, the rays refracted by the virtual camera's sight through the surface of the luminescent body, and the sampling point is determined on the rays, the problem of low rendering of the light transmittance in the virtual scene in the prior art is solved, and a higher rendering authenticity and sense of space are achieved.

CN119733235AActive Publication Date: 2025-04-01NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411930576.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-01
Estimated Expiration
2044-12-25

AI Technical Summary

Technical Problem

The prior art has low trueness of the rendering effect of the light transmitting body when rendering a virtual scene, especially in simulating the spatial sense between the light source and the light transmitting body, which has poor effect.

Method used

By introducing a virtual light source and a light emitting object to be rendered in the virtual scene, using the preset light source position, light source orientation and refractive index, the rays whose image acquisition line of sight of the virtual camera are refracted by the luminescent surface, and a sampling point is determined on the rays, and rendering based on the refractive data of the sampling point and the luminescent surface data.

Benefits of technology

It improves the rendering authenticity of the luminescent body in the virtual scene, enhances the sense of space between the light source and the light transmitting body, and enhances the overall real effect of the virtual scene.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119733235A_ABST
    Figure CN119733235A_ABST
Patent Text Reader

Abstract

The invention provides a virtual scene rendering method and device, electronic equipment and a storage medium, relates to the technical field of data processing, and solves the technical problem that the reality degree of a rendered virtual scene is relatively low. The method comprises the following steps: according to a preset refractive index, determining rays after an image acquisition sight line of a virtual camera is refracted through the surface of a to-be-rendered luminous body; wherein the virtual camera is used for carrying out image acquisition in a virtual scene, and an image acquisition sight line is a connecting line from the virtual camera to a to-be-rendered luminous body; determining a sampling point on the ray according to the ray, the light source orientation and the light source position; wherein the sampling points are used for sampling refraction data related to the luminous body to be rendered; the to-be-rendered illuminant corresponds to preset illuminant surface data; and rendering the to-be-rendered illuminant based on the refraction data and the illuminant surface data corresponding to the sampling points to obtain a rendering result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, and in particular to a method, device, electronic device and storage medium for rendering a virtual scene. Background Art

[0002] In virtual scenes, it is often necessary to render translucent objects. For example, rendering translucent objects such as frosted glass or stained glass with low transparency used in street lamps or lanterns; or rendering special effects or crystal effects on some internally illuminated translucent objects.

[0003] At present, the rendering of such a translucent body is usually implemented using a self-luminous map. For example, a self-luminous map is drawn and the map is offset to a certain extent to simulate the spatial sense of the light source, thereby rendering the translucent body. However, this rendering method only displays a luminous pattern on the surface of the translucent body, and the simulation effect of the spatial sense between the light source and the translucent body is poor, resulting in a low degree of realism of the rendered virtual scene. Summary of the invention

[0004] The purpose of the present disclosure is to provide a method, device, electronic device and storage medium for rendering a virtual scene, so as to alleviate the technical problem of low realism of the rendered virtual scene.

[0005] In a first aspect, an embodiment of the present disclosure provides a method for rendering a virtual scene, wherein the virtual scene includes a virtual light source and a light source to be rendered, the virtual light source corresponds to a preset light source position and a preset light source orientation, and the preset refractive index corresponding to the light source to be rendered is used to characterize the surface properties of the light source to be rendered; the method includes:

[0006] According to the preset refractive index, determining the image acquisition sight line of the virtual camera through the ray refracted by the surface of the luminous body to be rendered; wherein the virtual camera is used to perform image acquisition in the virtual scene, and the image acquisition sight line is a line from the virtual camera to the luminous body to be rendered;

[0007] Determine a sampling point on the ray according to the ray, the direction of the light source and the position of the light source; wherein the sampling point is used to sample refraction data related to the luminous body to be rendered; the luminous body to be rendered corresponds to preset luminous body surface data;

[0008] Based on the refraction data corresponding to the sampling point and the surface data of the luminous body, the luminous body to be rendered is rendered to obtain a rendering result.

[0009] In a second aspect, a rendering device for a virtual scene is provided, wherein the virtual scene includes a virtual light source and a light source to be rendered, the virtual light source corresponds to a preset light source position and a preset light source orientation, and the preset refractive index corresponding to the light source to be rendered is used to characterize the surface properties of the light source to be rendered; the device includes:

[0010] A first determination module is used to determine, according to the preset refractive index, a ray refracted by an image acquisition sight line of a virtual camera through the surface of the luminous body to be rendered; wherein the virtual camera is used to perform image acquisition in the virtual scene, and the image acquisition sight line is a line from the virtual camera to the luminous body to be rendered;

[0011] A second determination module is used to determine a sampling point on the ray according to the ray, the direction of the light source and the position of the light source; wherein the sampling point is used to sample refraction data related to the luminous body to be rendered; the luminous body to be rendered corresponds to preset luminous body surface data;

[0012] A rendering module is used to render the luminous body to be rendered based on the refraction data corresponding to the sampling point and the surface data of the luminous body to obtain a rendering result.

[0013] In a third aspect, an embodiment of the present disclosure provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the computer program, the method described in the first aspect is implemented.

[0014] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to execute the method described in the first aspect.

[0015] The embodiments of the present disclosure bring the following beneficial effects:

[0016] A virtual scene rendering method, device, electronic device and storage medium provided by the embodiments of the present disclosure can determine the ray after the image acquisition line of sight of a virtual camera is refracted through the surface of the luminous body to be rendered according to the preset refractive index corresponding to the luminous body to be rendered, wherein the virtual camera is used to perform image acquisition in the virtual scene, the image acquisition line of sight is a line connecting the virtual camera to the luminous body to be rendered, and sampling points are determined on the ray according to the ray, the light source direction and the light source position of the virtual light source, wherein the sampling points are used to sample refraction data related to the luminous body to be rendered, the luminous body to be rendered corresponds to preset luminous body surface data, and based on the refraction data and luminous body surface data corresponding to the sampling points, the luminous body to be rendered is rendered to obtain a rendering result. In this solution, an image acquisition line of sight is emitted from a virtual camera toward the luminous body to be rendered. When the image acquisition line of sight contacts the surface of the luminous body, a ray refracted by the line of sight through the surface is determined using a refractive index that can reflect the surface properties of the luminous body. Then, a sampling point that can reflect the refraction conditions of the luminous body to be rendered is determined on the ray through the ray and the light source direction and light source position of the virtual light source, so that the luminous body to be rendered is rendered based on the refraction data of the sampling point and the data of the luminous body to be rendered, thereby maintaining the physical properties of refraction, making the rendering of the luminous body more in line with physical laws, and having a more realistic sense of space in terms of perception, thereby improving the real effect of the virtual scene and alleviating the technical problem of low realism of the rendered virtual scene.

[0017] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0019] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present disclosure is shown;

[0020] Figure 2 A schematic diagram of the structure of an electronic terminal provided by an embodiment of the present disclosure is shown;

[0021] Figure 3 A schematic diagram of a flow chart of a method for rendering a virtual scene provided in an embodiment of the present disclosure;

[0022] Figure 4In the virtual scene rendering method provided in the embodiment of the present disclosure, an example of a street lamp;

[0023] Figure 5 In the virtual scene rendering method provided in the embodiment of the present disclosure, an example of a virtual light-transmitting body on a street lamp;

[0024] Figure 6 Another example of a virtual light-transmitting body in the virtual scene rendering method provided by the embodiment of the present disclosure;

[0025] Figure 7 An example of a light source position and a light source direction in a virtual scene rendering method provided by an embodiment of the present disclosure;

[0026] Figure 8 In the virtual scene rendering method provided by the embodiment of the present disclosure, an example of determining multiple other directions based on the light source direction;

[0027] Fig. 9 Another example of determining multiple other directions based on the light source direction in the virtual scene rendering method provided by the embodiment of the present disclosure;

[0028] Fig.10 An example of an auxiliary plane in the virtual scene rendering method provided by the embodiment of the present disclosure;

[0029] Fig.11 An example of line of sight refraction in the virtual scene rendering method provided by the embodiment of the present disclosure;

[0030] Fig.12 An example of the relative position of a virtual light source in the virtual scene rendering method provided by an embodiment of the present disclosure;

[0031] Fig.13 An example of a light source shape of a virtual light source in the virtual scene rendering method provided by an embodiment of the present disclosure;

[0032] Fig.14 In the virtual scene rendering method provided in the embodiment of the present disclosure, a virtual light source corresponds to an example of a rendering effect;

[0033] Fig.15 In the virtual scene rendering method provided by the embodiment of the present disclosure, the virtual light source corresponds to another example of the rendering effect;

[0034] Fig.16 In the virtual scene rendering method provided in the embodiment of the present disclosure, an example of a self-textured light source to be rendered;

[0035] Fig.17 An example of the rendering effect of a light source to be rendered in the virtual scene rendering method provided by the embodiment of the present disclosure;

[0036] Fig.18 A schematic diagram of the structure of a virtual scene rendering device provided in an embodiment of the present disclosure;

[0037] Fig.19 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.

[0039] The terms "including" and "having" and any variations thereof mentioned in the embodiments of the present disclosure are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0040] Currently, the rendering of translucent objects is usually achieved using self-luminous maps, that is, by drawing a self-luminous map and offsetting the map to simulate the spatial sense of the light source. However, this method can only simulate the spatial sense of the luminous body inside the object to a limited extent, and mostly just displays the luminous pattern on the surface of the object. Even through parallax sampling, it is easy to have obvious distortion at some viewing angles, affecting the effect, resulting in low realism of the virtual scenes currently rendered.

[0041] In the prior art, the rendering of transparent objects can also be achieved through ray tracing, that is, the information of the luminous body is collected and integrated through ray tracing or a similar step-by-step strategy, and finally the rendering is achieved through self-luminescence. However, this method requires a large number of sampling operations, has high performance requirements, is prone to noise, and requires additional noise reduction calculations. It is not suitable for scenes with a large number of small luminous bodies (such as street lamps).

[0042] In addition, currently the rendering of translucent objects can also be achieved through translucency, that is, placing a solid luminous object inside a translucent object to achieve rendering. However, this method needs to solve the translucent sorting problem, cannot achieve the situation where there is a luminous object inside a low-transparency object, and is not conducive to simulating the scattering of light inside the object.

[0043] Based on this, the embodiments of the present disclosure provide a method, device, electronic device and storage medium for rendering a virtual scene, by which technical problems such as low realism of the rendered virtual scene can be alleviated.

[0044] The virtual scene rendering method in one embodiment of the present disclosure can be run on a local terminal device or a server. When the virtual scene 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.

[0045] 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 method 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 method are completed on the cloud game server, and 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 responsible 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.

[0046] In an optional embodiment, taking a game as an example, a local terminal device stores a game program and is used to present a game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, the game program is downloaded and installed by an electronic device and run conventionally. The local terminal device may provide the graphical user interface to the player in a variety of ways, for example, it may be rendered and displayed on a display screen of the terminal, or provided to the player through a holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present a graphical user interface, the graphical user interface includes a game screen, and the processor is used to run the game, generate a graphical user interface, and control the display of the graphical user interface on the display screen.

[0047] In a possible implementation, an embodiment of the present disclosure provides a method for rendering a virtual scene, providing a graphical user interface through a terminal device, wherein the terminal device may be the local terminal device mentioned above, or may be a client device in the cloud interaction system mentioned above.

[0048] For example, Figure 1 As shown, Figure 1Schematic diagram of an application scenario provided by an embodiment of the present disclosure. The application scenario may include a touch terminal (e.g., a mobile phone 102) and a server 101, and the touch terminal may communicate with the server 101 via a wired network or a wireless network. The touch terminal is used to run a virtual desktop, and through the virtual desktop, it can interact with the server 101 to process the content in the server 101.

[0049] The touch terminal of this embodiment is described by taking a mobile phone 102 as an example. The mobile phone 102 includes components such as a radio frequency (RF) circuit 110, a memory 120, a display screen 130, and a processor 140. Those skilled in the art can understand that Figure 2 The mobile phone structure shown in the figure does not constitute a limitation on the mobile phone, and may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. Those skilled in the art will understand that the display screen 130 belongs to the user interface (UI), and the mobile phone 102 may include more or fewer user interfaces than shown in the figure.

[0050] The RF circuit 110 can also communicate with the network and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobilecommunication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.

[0051] The memory 120 can be used to store software programs and modules. The processor 140 executes various functional applications and data processing of the mobile phone 102 by running the software programs and modules stored in the memory 120. The memory 120 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the mobile phone 102, etc. In addition, the memory 120 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0052] Processor 140 is the control center of mobile phone 102. It uses various interfaces and lines to connect various parts of the entire mobile phone. It executes various functions of mobile phone 102 and processes data by running or executing software programs and / or modules stored in memory 120, and calling data stored in memory 120, thereby monitoring the mobile phone as a whole.

[0053] The embodiments of the present disclosure are further described below in conjunction with the accompanying drawings.

[0054] Figure 3 A flowchart of a method for rendering a virtual scene provided in an embodiment of the present disclosure.

[0055] The method can be applied to electronic devices that can present a graphical user interface. The virtual scene includes a virtual light source and a light source to be rendered. The virtual light source corresponds to a preset light source position and a preset light source direction. The preset refractive index corresponding to the light source to be rendered is used to characterize the surface properties of the light source to be rendered. Figure 3 As shown, the method includes:

[0056] Step S310, according to a preset refractive index, determining the ray after the image acquisition line of sight of the virtual camera is refracted through the surface of the luminous body to be rendered.

[0057] The virtual camera is used to collect images in the virtual scene. The camera position of the virtual camera can represent the player's current observation position, and the camera position is determined according to the player's operation. The image collection line of sight is the line from the virtual camera to the luminous body to be rendered.

[0058] The above-mentioned luminous body to be rendered can be any virtual object that can produce a luminous effect in a virtual scene. As an optional implementation, the luminous body to be rendered is a virtual translucent body in a virtual scene, so as to achieve a luminous effect produced by the light of the virtual light source passing through the virtual translucent body. Based on this, the virtual scene also includes a virtual translucent body; before this step, the method may also include the following steps: in response to the spatial position relationship between the virtual light source, the virtual camera and the virtual translucent body meeting a preset condition, the virtual translucent body is determined as the luminous body to be rendered. Through this method of determining the luminous body to be rendered, the rendering timing of the luminous body to be rendered is made more accurate.

[0059] For a virtual transparent body, Figure 4 and Figure 5As shown, taking the virtual light-transmitting body as the light-transmitting glass on the virtual street lamp as an example, a separate material is assigned to the part of the light-emitting body that needs to be rendered. For example, in addition to the metal lamp stand and lampshade support that are not light-transmitting on the virtual street lamp, the virtual street lamp also contains a light-transmitting glass material. Through the surface of this glass material (the virtual light-transmitting body), the part of the virtual light source inside can be seen. By determining the light-transmitting part (the virtual light-transmitting body), the part of the data that needs to be recorded can be accurately identified when recording data later, and the part that needs to calculate the light source can be accurately identified when rendering, avoiding performance waste.

[0060] In an optional implementation, the spatial position relationship of the virtual light source, the virtual camera, and the virtual light-transmitting body can be flexible and diverse. For example, the spatial position relationship of the virtual light source, the virtual camera, and the virtual light-transmitting body satisfies the preset conditions, including: if the virtual light-transmitting body is an enclosing structure, the virtual light source is located inside the virtual light-transmitting body, and the virtual camera is located outside the virtual light-transmitting body; if the virtual light-transmitting body is a planar structure, the virtual light source is located on one side of the virtual light-transmitting body, and the virtual camera is located on the other side of the virtual light-transmitting body.

[0061] As an example, Figure 5 As shown, at least part of the virtual light-transmitting body surrounds the virtual light source, that is, the virtual light-transmitting body is an enclosing structure, the virtual light source is located inside the virtual light-transmitting body, and the virtual camera (the player's current observation position) is located outside the virtual light-transmitting body. It should be clear that the virtual light-transmitting body can surround the virtual light source in a closed manner or in an unclosed manner.

[0062] As another example, Figure 6 As shown, the virtual light source (such as a light bulb) is not necessarily inside the virtual translucent body (such as a lampshade), and the virtual light source may also be transmitted from one side of the virtual translucent body. For example, the virtual camera (the player's current observation position) is outside the room, and the light bulb is inside the room, and there is a window in the room between the two. The virtual camera can only see the light bulb in the room through the window. At this time, the light bulb (virtual light source) and the virtual camera are located on both sides of the window (virtual translucent body). To determine that the virtual camera can see the light transmission effect of the virtual light source through the virtual translucent body, the light emission of the window needs to be rendered, that is, the window (virtual translucent body) is determined as the light source to be rendered.

[0063] For the light source position and light source orientation of the virtual light source, for example, Figure 7 As shown, virtual light sources are set inside the two lamps, and the light source direction of one virtual light source is set to the positive Z axis, and the light source direction of the other virtual light source is set to the positive Y axis.

[0064] In the disclosed embodiment, the image acquisition line of sight of the virtual camera is a line from the virtual camera to the light source to be rendered. In an optional implementation, this step may specifically include the following steps: determining the direction of the normal line of the surface relative to the contact point of the image acquisition line of sight of the virtual camera on the surface of the light source to be rendered; and determining the ray after the image acquisition line of sight is refracted through the surface of the light source to be rendered based on the normal line direction and a preset refractive index.

[0065] Exemplarily, the position of the contact point is first determined based on the intersection of the line of sight of the image acquisition and the surface of the luminous body to be rendered, and then the surface normal direction of the position is determined. According to the preset refractive index corresponding to the luminous body to be rendered, such as the refractive index ratio R of the medium inside the object and the refractive index ratio R of the external medium, the refracted ray LR is calculated, that is, the refracted ray LR is calculated by the Fresnel equation according to the refractive index ratio R and the normal direction of the contact point position on the surface of the luminous body to be rendered. Among them, the refractive index ratio R can be a preset value, which can be preset according to the actual effect requirements, for example, according to the actual physical quantity; it can also only represent the ratio of the refractive intensity, for example, 1 means no refraction, and greater than 1 means entering a light-sparse medium into a light-dense medium, and vice versa.

[0066] The image observed by the virtual camera is determined by emitting an image acquisition line of sight from the virtual camera and finding the intersection point between the image acquisition line of sight and the surface of the luminous body to be rendered. When the image acquisition line of sight contacts the surface of the luminous body to be rendered, the image acquisition line of sight can be refracted according to the surface properties of the luminous body to be rendered (such as normal, refractive index). Through this refraction effect, a certain physical property correctness is maintained during calculation, which can make the image look and feel with a sense of space that correctly conforms to the laws of physics, thereby realizing the rendering of luminous bodies with an apparently real sense of space and refractive physical properties.

[0067] Step S320: determining a sampling point on the ray according to the ray, the direction of the light source and the position of the light source.

[0068] The sampling point is used to sample the refraction data related to the luminous body to be rendered. As an example, the specific method of determining the sampling point may include the following steps: selecting two first directions based on the direction of the light source; wherein the two first directions are perpendicular to each other and are perpendicular to the direction of the light source; determining the second direction from the center point of the light source position to the current camera position of the virtual camera; determining the projection direction of the second direction on the plane formed by the two first directions; determining the first plane passing through the center point of the light source position and perpendicular to the second direction; determining the second plane passing through the center point of the light source position and perpendicular to the projection direction; determining the first intersection of the ray and the first plane, and the second intersection of the ray and the second plane on the ray; wherein the first intersection and the second intersection are respectively two sampling points for sampling the refraction data related to the luminous body to be rendered.

[0069] Conventional ray tracing solutions in the prior art require the intersection and sampling of a large number of points, usually ranging from dozens to tens of thousands of samples, and may not even be completed within one frame. In the disclosed embodiment, two auxiliary planes, namely the first plane and the second plane, are determined by the virtual camera and the position of the light source and the direction of the light source, and then the two intersection points (namely the first intersection point and the second intersection point) of the two auxiliary planes with the refracted rays in the above step S320 are calculated and used as two sampling points, so that only two samples are required, so that the computational overhead and performance overhead are reduced, and better performance is achieved in the process of rendering virtual light sources than existing ray tracing solutions.

[0070] Step S330, rendering the luminous body to be rendered based on the refraction data corresponding to the sampling point and the luminous body surface data to obtain a rendering result.

[0071] It should be noted that the luminous body to be rendered corresponds to preset luminous body surface data. The luminous body surface data may include multiple aspects of data to make the rendering effect of the luminous body to be rendered more accurate. For example, the luminous body surface data includes at least one of the following: surface color, surface transmittance, and surface texture of the luminous body to be rendered.

[0072] In the disclosed embodiment, an image acquisition line of sight is emitted from a virtual camera toward a light source to be rendered. When the image acquisition line of sight contacts the surface of the light source, a ray refracted by the line of sight through the surface is determined using a refractive index that can reflect the surface properties of the light source. Then, a sampling point that can reflect the refraction conditions of the light source to be rendered is determined on the ray through the ray and the light source direction and light source position of the virtual light source. This allows the light source to be rendered based on the refraction data of the sampling point and the data of the light source itself, thereby maintaining the physical properties of refraction, making the rendering of the light source more in line with physical laws, and providing a more realistic sense of space in terms of perception, thereby improving the real effect of the virtual scene and alleviating the technical problem of low realism of the rendered virtual scene.

[0073] The above steps are described in detail below.

[0074] In some embodiments, the data such as the light source position and light source direction of the virtual light source can be stored in a variety of data structures corresponding to the light source to be rendered, for example, in the vertex color, separate texture, UV layout data or other data structures corresponding to the light source to be rendered, so as to make the data storage method of the light source position and light source direction more flexible and improve the utilization rate of data storage space. As an example, the above step S330 can specifically include the following steps:

[0075] The uv data structure of the model grid corresponding to the luminous body to be rendered is read from the scene parameters of the virtual scene; the uv data structure records the light source position coordinates and light source orientation coordinates of the virtual light source in the three-dimensional coordinate system corresponding to the virtual scene; the sampling point is determined on the ray according to the ray, the current camera position of the virtual camera, the light source position coordinates and the light source orientation coordinates.

[0076] The light source position coordinates may be in various forms. For example, the light source position coordinates may be the relative position coordinates of the virtual light source relative to the lamp body model. Fig.12 As shown, the light source position coordinates are the relative position coordinates of the virtual light source relative to the axis point C of the lamp body model, that is, the difference between the virtual light source and the axis point C.

[0077] Regarding the uv data structure of the model mesh, it should be noted that the model mesh is composed of a series of vertices, and according to the relationship between the vertices, the points are connected into planes, and finally become the three-dimensional model you see. The data of the three-dimensional model is stored in these vertices, for example, the position of each vertex in space, normal information, etc. The uv data is actually a two-dimensional vector, and its typical usage is as a two-dimensional coordinate, mapped to a certain position on a two-dimensional image, so as to achieve the effect of pasting a two-dimensional image to the surface of a three-dimensional model.

[0078] As an optional implementation, the direction and position of the light source can be recorded in the vertex data of the mesh corresponding to the light source to be rendered on the lamp body model. In the embodiment of the present disclosure, the direction and position of the light source are recorded in the uv data structure of the mesh corresponding to the light source to be rendered on the lamp body model.

[0079] Regarding the storage method of the light source direction and light source position in the above uv data structure, it should be noted that the typical function of uv data is to map a two-dimensional image. It can be seen that there are likely to be 0-N groups of uv data used for other functions, which can be used as uv reserved for other functions. Since the uv data exists in the form of a series of two-dimensional vectors, that is, two floating-point numbers in a group, that is, each group of uv data has only two positions, for the three-dimensional vector data to be stored, in the embodiment of the present disclosure, the xyz three-dimensional components can be distributed on the two-dimensional uv data in the layout method shown in the following table, so that the data can be arranged in three groups of continuous uv data in storage order without leaving any empty space, which is convenient for reading and saving space.

[0080]

[0081] In the embodiment of the present disclosure, the space for recording UV data in the model data is used to store relevant data of the virtual light source. Not only is the light source information corresponding to the virtual light source set for the luminous body to be rendered, but the light source information is also recorded in the model UV data space of the luminous body to be rendered, thereby achieving full utilization of the data storage space.

[0082] In some embodiments, the two intersection points of the two auxiliary planes determined based on the virtual camera and the light source position and the light source direction and the refracted rays in step S320 above can be used as sampling points, so that only two samplings corresponding to the two sampling points need to be performed, so that the amount of calculation is reduced. As an example, step S330 above may specifically include the following steps:

[0083] Two first directions are selected based on the direction of the light source; wherein the two first directions are perpendicular to each other and to the direction of the light source; a second direction from the center point of the light source position to the current camera position of the virtual camera is determined; a projection direction of the second direction on the plane formed by the two first directions is determined; a first plane passing through the center point of the light source position and perpendicular to the second direction is determined; a second plane passing through the center point of the light source position and perpendicular to the projection direction is determined; a first intersection point of the ray with the first plane and a second intersection point of the ray with the second plane are determined on the ray; wherein the first intersection point and the second intersection point are respectively two sampling points for sampling refraction data related to the light source to be rendered.

[0084] For the above two first directions selected based on the light source direction, illustratively, a coordinate system is created with the light source direction (hereinafter referred to as UpDir) as a basis vector, and the three basis vectors of this coordinate system are RightDirForwardDir and UpDir, that is, the other two directions perpendicular to each other and UpDir are determined. Among them, RightDir is determined as follows:

[0085] If the absolute values ​​of the x and y components of UpDir are both less than 0.001, then RightDir = (1, 0, 0), which can be understood as UpDir approximately = (0, 0, 1). Originally, it should be judged whether it is less than 0, but considering the computer precision error, 0.001 is selected as the judgment standard. On the contrary, RightDir = Normalize (-UpDir.y, UpDir.x, 0), [Normalize means vector normalization], ForwardDir = cross (UpDir, RightDir), [cross() means vector cross product]. It can also be understood that when any two components of a three-dimensional vector are not all 0, the two components are swapped, one of them is inverted (multiplied by -1), and the third component is set to 0, so that a vector that is perpendicular to the coordinate axis of the original vector and the third component can be quickly obtained. For example, for a vector V = (x, y, z), when x and y are not all zero, we can get a vector, V1 = (-y, x, 0), where V1 satisfies dot(V, V1) = 0; dot((0, 0, 1), V1) = 0.

[0086] Then, the above process of determining the second direction from the center point of the light source position to the current camera position of the virtual camera, determining the projection direction of the second direction on the plane formed by the two first directions, determining the first plane passing through the center point of the light source position and perpendicular to the second direction, and determining the second plane passing through the center point of the light source position and perpendicular to the projection direction is performed. Exemplarily, it is assumed that the unit vector from the center point of the light source position to the current camera position of the virtual camera is CDir=Normalize(CameraPos-CenterPos), that is, the second direction, and then two auxiliary planes are determined: the plane in the three-dimensional space can be defined according to a point on the plane and its normal, and the definitions of the two auxiliary planes are: Plane1: a plane passing through the center point of the light source, with a normal of CDir; Plane2: a plane passing through the center point of the light source; a normal is a unit vector of the projection direction of CDir on the plane spanned by RightDir and ForwardDir.

[0087] For example, in Figure 8In the three-dimensional scene diagram shown in the figure, the arrow pointing upward is the UpDir direction, and the two vertical arrows below are the RightDir and ForwardDir directions. Figure 8 The arrow perpendicular to the plane Plane1 (i.e., the first plane) shown in FIG. 1 is the CDir direction, as shown in FIG. Fig.10 As shown, the plane Plane1 is a plane perpendicular to CDir and passing through the center of the light source. Fig. 9 The plane Plane2 (i.e. the second plane) shown in the figure uses the projection vector of CDir on the ForwardDir-RightDir plane as its normal, and is parallel to the original light source direction (UpDir).

[0088] Then, the above process of determining the first intersection point between the ray and the first plane and the second intersection point between the ray and the second plane is performed. Fig.11 As shown, the first intersection point SampleP1 between the refracted ray LR and the first plane Plane1 in the above step S320 and the second intersection point SampleP2 between the ray LR and the second plane Plane2 are calculated respectively.

[0089] By taking the two intersection points of the refracted ray and the two auxiliary planes determined based on the positions of the virtual camera and the light source and the direction of the light source as sampling points, only two samplings corresponding to the two sampling points are required. Compared with the calculation of a large number of sampling points in the prior art, the computational overhead and performance overhead in the embodiments of the present disclosure are greatly reduced, and better performance is achieved in the process of rendering the virtual light source.

[0090] In some embodiments, during the rendering process, the rendering data of the light source to be rendered may be determined based on the refraction data and the light source surface data corresponding to the sampling points before rendering is performed to improve rendering accuracy. As an example, the above step S340 may specifically include the following steps: determining the rendering data of the light source to be rendered based on the refraction data and the light source surface data corresponding to the sampling points; and rendering the light source to be rendered based on the rendering data to obtain a rendering result.

[0091] As an optional implementation, the body mapping data of the virtual light source's body mapping on the luminous body to be rendered can be determined based on the light source size and the refraction data corresponding to the sampling points, so as to render the body mapping data corresponding to the virtual light source more accurately, thereby simulating a more realistic virtual light source light transmission effect. As an example, the virtual light source also corresponds to a preset light source size; the above-mentioned determination of the rendering data of the luminous body to be rendered based on the refraction data corresponding to the sampling points and the luminous body surface data can specifically include the following steps:

[0092] According to the light source size and the refraction data corresponding to the sampling point, the body mapping data of the virtual light source on the luminous body to be rendered is determined; according to the body mapping data and the luminous body surface data, the rendering data of the luminous body to be rendered is determined.

[0093] In some embodiments, the light source size and light source shape of the virtual light source can be customized through the signed distance field function to more flexibly simulate the anisotropic luminous performance effects. Moreover, the virtual light source can be estimated through the body mapping data of the virtual light source's body mapping on the luminous body to be rendered, so as to accurately restore the physical state of the virtual light source inside the virtual translucent body, support the normal rendering of the light source inside the low-transparency object, and render the light source effect more accurately. As an example, the above-mentioned determination of the body mapping data of the virtual light source's body mapping on the luminous body to be rendered based on the light source size and the refraction data corresponding to the sampling point can specifically include the following steps:

[0094] The target signed distance field function corresponding to the virtual light source is determined according to the light source size; the target signed distance field function is used to characterize the light source shape and light source size of the virtual light source; the target signed distance field function is used to calculate based on the sampling point to obtain the shortest distance from the sampling point to the virtual light source; the body mapping data of the body mapping of the virtual light source on the luminous body to be rendered is determined according to the shortest distance.

[0095] It should be noted that the signed distance field (SDF) is a signed distance field or a signed distance field, which is defined as each pixel (voxel) recording the distance between itself and the nearest object. If it is inside the object, the distance is negative, and if it is exactly on the boundary of the object, the distance is 0. It can be seen that the function of the signed distance field function is to calculate the shortest distance from any point in space to a closed surface. When the point is outside the surface, the function value is an integer positive number, when it is inside the surface, the function value is negative, and when it is on the surface, the function value is 0. By determining the target signed distance field function expression that can characterize the shape and size of the light source through information such as the light source size and light source shape of the virtual light source, the shape and size of the light source can be customized more accurately.

[0096] As an optional implementation, the shape of the virtual light source can be a capsule shape that is closer to the display effect of the real light source, so that the light transmission effect of the virtual light source is more realistic. As an example, the virtual light source is in the shape of a capsule, and the light source size includes the radius parameters of the two semicircles in the capsule shape and the positions of the center points of the two semicircles. The two center point positions are used to characterize the light source height, light source direction and light source position of the virtual light source; the above-mentioned determination of the target signed distance field function corresponding to the virtual light source according to the light source size can specifically include the following steps: according to the radius parameter and the two center point positions, the target signed distance field function corresponding to the virtual light source is determined by the signed distance field function.

[0097] Exemplarily, as Fig.13 shown, the light source shape is described by selecting the capsule SDF function defined by two control points CP1, CP2 and radius R. That is, CP1, CP2, and R are parameters representing the capsule shape. The capsule is a geometric body composed of a cylinder and two hemispheres. CP1 and CP2 are the centers at both ends of the cylinder and also the centers of the two hemispheres. R is the radius of the hemispheres and the cylinder, and its value range is [0, infinity). The calculation methods of CP1 and CP2 are: CP1 = CenterPos + Height * UpDir; CP2 = CenterPos - Height * UpDir; where CenterPos is the preset light source position corresponding to the virtual light source, and Height is the preset light source height corresponding to the virtual light source, and its value range is [0, infinity).

[0098] It should be noted that for a capsule with control points CP1 and CP2 and radius R, the shortest distance from any point on its surface to the line segment formed by Cp1 and Cp2 is R. It can be seen that if the shortest distance from any point in space to the capsule surface is required, it is actually to find the shortest distance D from the point in space to the line segment Cp1 - Cp2, and then subtract R.

[0099] By constructing the pa vector from Cp1 to the sampling point SampleP, and the ba vector from Cp1 to Cp2, it is convenient to calculate the ratio L of the projection of pa on ba to the length of ba. As Fig.13 shown, when the sampling point is outside Cp1, L < 0, and when the sampling point is outside Cp2, L > 1. Furthermore, when L < 0, the required distance is equal to the vector length of Cp1->SP, and when L > 1, the required distance is equal to the vector length of Cp2->SP. In other cases, it is the perpendicular distance from SP to the line segment. The above vectors can be unified as: V = (Cp1->SP) - h * (Cp1->Cp2), where h satisfies the following conditions: if L < 0, then h = 0; if 0 < L ≤ 1, then h = L; if L > 1, then h = 1. Then calculate V = pa - ba * h, and then find the length and subtract R.

[0100] Then, the above process of calculating based on the sampling point through the target symbol distance field function to obtain the shortest distance from the sampling point to the virtual light source is performed. Exemplarily, the above-mentioned first sampling point SampleP1 and the second sampling point SampleP2 are brought into the target symbol distance field function to calculate the distance parameter, and the shortest distance SD1 from the first sampling point SampleP1 to the virtual light source and the shortest distance SD2 from the second sampling point SampleP2 to the virtual light source are obtained, and the final distance field data SD is calculated according to the orientation and position relationship. For example, the two calculated sampling points are brought into the SDF function to obtain two distance results SD1 and SD2, where: SD1 = sdCapsule (SampleP1, Cp1, Cp2, R); SD2 = sdCapsule (SampleP2, Cp1, Cp2, R). The final SDF result is: Term = Pow (dot (CDir, UpDir), 4); SD = min (SD1, lerp (SD1, SD2, Term)).

[0101] Then, the above process of determining the entity mapping data of the virtual light source on the luminous body to be rendered according to the shortest distance is performed. Exemplarily, the entity mapping data of the virtual light source on the luminous body to be rendered is calculated according to the shortest distance SD, that is, SDL = max (-SD, 0), and the rendering result is as follows Fig.14 shown.

[0102] In the prior art, since the conventional rendering pipeline follows the transparency blending strategy, the internal luminous body will be covered up at low transparency, and there is no way to perform correct scattering calculations, so the effect of the light source will be abnormally weakened. In the disclosed embodiment, the virtual light source is estimated by mapping the virtual light source onto the luminous body to be rendered, and the physical state of the virtual light source inside the virtual translucent body (luminous body to be rendered) can be restored more accurately. Therefore, it does not rely on translucent blending, supports the normal rendering of the light source inside the low-transparency object, and can render the light source effect more accurately.

[0103] In some embodiments, the body mapping data of the virtual light source can be combined with the scattering effect to achieve the rendering effect of the light source with scattering physical characteristics, so as to improve the authenticity of the rendering. As an example, the virtual light source corresponds to a preset scattering distance; the above-mentioned determination of the rendering data of the light source to be rendered based on the body mapping data and the light source surface data can specifically include the following steps:

[0104] According to the shortest distance and the scattering distance, the scattering data of the virtual light source is determined; according to the body mapping data and the scattering data, the overall mapping data of the virtual light source on the luminous body to be rendered is determined; according to the overall mapping data and the luminous body surface data, the rendering data of the luminous body to be rendered is determined.

[0105] In the disclosed embodiment, the scattering data of the virtual light source can be determined according to the shortest distance calculated above and the preset scattering distance corresponding to the virtual light source. Exemplarily, the scattering data SDS of the virtual light source = exp(-pow(max(SD,0),2) / DiffDis), where DiffDis is the scattering distance, and exp() is an exponential function of the natural constant e (whose value is approximately 2.718281828459045).

[0106] Then, the above process of determining the overall mapping data of the virtual light source on the luminous body to be rendered based on the body mapping data and the scattering data is performed. The scattering part is simulated by the Gaussian function, and combined with the value function of the natural constant e, the luminous body rendering effect with the apparent correct spatial sense and scattering physical characteristics is achieved.

[0107] In addition, it should be noted that, for the process of calculating the shortest distance from the above two sampling points to the closed surface formed by the above capsule (virtual light source), when the point is outside the surface, the target signed distance field function value is an integer positive number, when the point is inside the surface, the target signed distance field function value is a negative number, and when the point is on the boundary of the surface, the target signed distance field function value is 0. It can be seen that for the shortest distances SD1 and SD2 obtained after the two sampling points P1 and P2 are substituted into the expression of the target signed distance field function, it can be judged whether the ray refracted by the image acquisition line of sight currently intersects with the virtual light source according to the positive or negative value of the shortest distance, thereby deciding whether to render both the virtual light source and its scattered data, or only render the scattered data, thereby further improving the authenticity of the rendering effect. As an example, after the above calculation based on the sampling point through the target signed distance field function to obtain the shortest distance from the sampling point to the virtual light source, the method can also include the following steps:

[0108] If the shortest distance is less than or equal to zero, it is determined that the sampling point is located on the virtual light source and that the ray intersects the virtual light source, and it is determined that the luminous object to be rendered is rendered based on the body mapping data and the scattering data; if the shortest distance is greater than zero, it is determined that the sampling point is located outside the virtual light source and that the ray does not intersect the virtual light source, and it is determined that the luminous object to be rendered is rendered based on the scattering data.

[0109] In some embodiments, the body mapping data of the virtual light source not only combines the scattering effect, but also combines the light source color, light source intensity and scattering intensity of the virtual light source to achieve a more realistic rendering effect. As an example, the virtual light source corresponds to a preset light source color, a preset light source intensity parameter and a preset scattering intensity parameter; the above-mentioned overall mapping data of the virtual light source on the luminous body to be rendered is determined based on the body mapping data and the scattering data, and specifically can include the following steps: determining the overall mapping data of the virtual light source on the luminous body to be rendered based on the body mapping data, the scattering data, the light source color, the light source intensity parameter and the scattering intensity parameter.

[0110] For the overall mapping data of the virtual light source on the luminous body to be rendered, for example, FinalColor of the overall mapping data = SDS*ScatterStrength*LightColor+SDL*SourceStrength*LightColor, where: ScatterStrength is the scattering strength adjustment parameter, with a value range of [0, infinity); SourceStrength is the light source strength adjustment parameter, with a value range of [0, infinity); LightColor is the light source color, which is an RGB value, and each value ranges from [0,1]. The overall mapping result after combining the virtual light source's body mapping data and scattering data is as follows: Fig.15 shown.

[0111] Finally, the above process of determining the rendering data of the light source to be rendered based on the overall mapping data and the light source surface data is performed. Exemplarily, the rendering calculation result of the overall mapping result is superimposed with the surface color, surface texture, and transmittance information of the light source to be rendered, so as to obtain the final rendering result of the light source to be rendered. For example, the final rendering result of the light source to be rendered FinalResult = FinalColor*SurfaceOpacity*SurfaceColor; wherein SurfaceOpacity is provided by a separate texture, such as Fig.16 As shown in the figure, the data is a grayscale value of 0-1. The smaller the value, the worse the light transmittance. The final rendering effect of the luminous body to be rendered is as follows Fig.17 As shown, the rendering effect of the light source to be rendered after parameter mixing with the light source surface data. Through the above method, the virtual light source body mapping data is combined with not only the scattering effect, but also the light source color, light source intensity and scattering intensity of the virtual light source, so as to achieve a more realistic rendering effect.

[0112] Fig.18A schematic diagram of the structure of a virtual scene rendering device is provided. The device can be applied to electronic devices; the virtual scene includes a virtual light source and a light source to be rendered, the virtual light source corresponds to a preset light source position and a preset light source orientation, and the preset refractive index corresponding to the light source to be rendered is used to characterize the surface properties of the light source to be rendered. Fig.18 As shown, the virtual scene rendering device 1800 includes:

[0113] The first determination module 1801 is used to determine, according to the preset refractive index, a ray refracted by the image acquisition sight line of the virtual camera through the surface of the luminous body to be rendered; wherein the virtual camera is used to perform image acquisition in the virtual scene, and the image acquisition sight line is a line from the virtual camera to the luminous body to be rendered;

[0114] The second determination module 1802 is used to determine a sampling point on the ray according to the ray, the direction of the light source and the position of the light source; wherein the sampling point is used to sample refraction data related to the luminous body to be rendered; the luminous body to be rendered corresponds to preset luminous body surface data;

[0115] The rendering module 1803 is used to render the light-emitting body to be rendered based on the refraction data corresponding to the sampling point and the light-emitting body surface data to obtain a rendering result.

[0116] Through the above method, an image acquisition line of sight is emitted from the virtual camera toward the luminous body to be rendered. When the image acquisition line of sight contacts the surface of the luminous body, the ray refracted by the line of sight through the surface is determined by using the refractive index that can reflect the surface properties of the luminous body, and then a sampling point that can reflect the refraction situation of the luminous body to be rendered is determined on the ray through the ray and the light source direction and light source position of the virtual light source, so as to render the luminous body to be rendered based on the refraction data of the sampling point and the self data of the luminous body to be rendered, thereby maintaining the physical properties of refraction, making the rendering of the luminous body more in line with the physical laws, and having a more realistic sense of space in terms of perception, thereby improving the real effect of the virtual scene and alleviating the technical problem of low realism of the rendered virtual scene.

[0117] In a feasible implementation scheme, the second determination module is specifically used for:

[0118] Determine the contact point of the image acquisition line of sight of the virtual camera on the surface of the luminous object to be rendered relative to the normal direction of the surface;

[0119] According to the normal direction and the preset refractive index, a ray of the image acquisition line of sight after being refracted through the surface of the luminous object to be rendered is determined.

[0120] In a feasible implementation scheme, the third determination module is specifically used for:

[0121] Selecting two first directions based on the direction of the light source; wherein the two first directions are perpendicular to each other and are both perpendicular to the direction of the light source;

[0122] Determine a second direction from the center point of the light source position to the current camera position of the virtual camera;

[0123] determining a projection direction of the second direction on a plane formed by two of the first directions;

[0124] Determine a first plane passing through the center point of the light source and perpendicular to the second direction;

[0125] Determine a second plane passing through the center point of the light source position and perpendicular to the projection direction;

[0126] A first intersection point between the ray and the first plane and a second intersection point between the ray and the second plane are determined on the ray; wherein the first intersection point and the second intersection point are respectively two sampling points for sampling refraction data related to the light source to be rendered.

[0127] In a feasible implementation scheme, the third determination module is specifically used for:

[0128] Reading the uv data structure of the model grid corresponding to the luminous body to be rendered from the scene parameters of the virtual scene; the uv data structure records the light source position coordinates and light source orientation coordinates of the virtual light source in the three-dimensional coordinate system corresponding to the virtual scene;

[0129] A sampling point is determined on the ray according to the ray, the current camera position of the virtual camera, the light source position coordinates and the light source orientation coordinates.

[0130] In a feasible implementation scheme, the rendering module is specifically used for:

[0131] Determine rendering data of the light emitting body to be rendered according to the refraction data and the light emitting body surface data corresponding to the sampling point;

[0132] The luminous body to be rendered is rendered based on the rendering data to obtain a rendering result.

[0133] In a feasible implementation manner, the virtual light source further corresponds to a preset light source size; and the rendering module is further used for:

[0134] Determine, according to the light source size and the refraction data corresponding to the sampling point, body mapping data of the body of the virtual light source mapped on the luminous body to be rendered;

[0135] The rendering data of the light-emitting body to be rendered is determined according to the body mapping data and the light-emitting body surface data.

[0136] In a feasible implementation scheme, the rendering module is specifically used for:

[0137] Determining a target signed distance field function corresponding to the virtual light source according to the light source size; the target signed distance field function is used to characterize the light source shape and the light source size of the virtual light source;

[0138] Calculating the target signed distance field function based on the sampling point to obtain the shortest distance from the sampling point to the virtual light source;

[0139] Determine the body mapping data of the body of the virtual light source mapped on the luminous body to be rendered according to the shortest distance.

[0140] In a feasible implementation manner, the virtual light source corresponds to a preset scattering distance; and the rendering module is further used for:

[0141] Determining scattering data of the virtual light source according to the shortest distance and the scattering distance;

[0142] Determine overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered according to the body mapping data and the scattering data;

[0143] The rendering data of the light emitting body to be rendered is determined according to the overall mapping data and the light emitting body surface data.

[0144] In a feasible implementation scheme, the virtual light source corresponds to a preset light source color, a preset light source intensity parameter, and a preset scattering intensity parameter; the rendering module is further used to:

[0145] The overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered is determined according to the body mapping data, the scattering data, the light source color, the light source intensity parameter and the scattering intensity parameter.

[0146] In a feasible embodiment, the device further comprises:

[0147] A fourth determination module is used to determine, after calculating based on the sampling point through the target signed distance field function to obtain the shortest distance from the sampling point to the virtual light source, if the shortest distance is less than or equal to zero, that the sampling point is located on the virtual light source and that the ray intersects the virtual light source, and to determine to render the luminous body to be rendered based on the body mapping data and the scattering data; if the shortest distance is greater than zero, determine that the sampling point is located outside the virtual light source and that the ray does not intersect the virtual light source, and to determine to render the luminous body to be rendered based on the scattering data.

[0148] In a feasible implementation manner, the virtual light source is in the shape of a capsule, and the light source size includes radius parameters of two semicircles in the capsule shape and the positions of the center points of the two semicircles, and the two center point positions are used to characterize the light source height, the light source direction and the light source position of the virtual light source; the rendering module is also used to: determine the target signed distance field function corresponding to the virtual light source through a signed distance field function according to the radius parameters and the two center point positions.

[0149] In a feasible implementation manner, the light source surface data includes at least one of the following: surface color, surface transmittance, and surface texture of the light source to be rendered.

[0150] In a feasible embodiment, the virtual scene also includes a virtual translucent body; the device also includes: a fifth determination module, which is used to determine the virtual translucent body as the luminous body to be rendered in response to the spatial position relationship between the virtual light source, the virtual camera and the virtual translucent body satisfying a preset condition before the image acquisition line of sight of the virtual camera is determined according to the preset refractive index to refract the ray through the surface of the luminous body to be rendered.

[0151] In a feasible implementation scheme, the spatial position relationship between the virtual light source, the virtual camera and the virtual light-transmitting body satisfies preset conditions, including: if the virtual light-transmitting body is an enclosing structure, the virtual light source is located inside the virtual light-transmitting body, and the virtual camera is located outside the virtual light-transmitting body; if the virtual light-transmitting body is a planar structure, the virtual light source is located on one side of the virtual light-transmitting body, and the virtual camera is located on the other side of the virtual light-transmitting body.

[0152] The virtual scene rendering device provided in the embodiment of the present disclosure has the same technical features as the virtual scene rendering method provided in the above-mentioned embodiment, so it can also solve the same technical problems and achieve the same technical effects.

[0153] Fig.19A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure is shown, including: a memory 1901, a processor 1902 and a bus 1903, wherein the memory 1901 stores machine-readable instructions executable by the processor 1902, and when the electronic device runs a virtual scene rendering method in the embodiment, the processor 1902 communicates with the memory 1901 through the bus 1903, and the processor 1902 executes the machine-readable instructions, and the processor 1902 executes the preamble of the method item to perform the following steps:

[0154] According to the preset refractive index, determining the image acquisition sight line of the virtual camera through the ray refracted by the surface of the luminous body to be rendered; wherein the virtual camera is used to perform image acquisition in the virtual scene, and the image acquisition sight line is a line from the virtual camera to the luminous body to be rendered;

[0155] Determine a sampling point on the ray according to the ray, the direction of the light source and the position of the light source; wherein the sampling point is used to sample refraction data related to the luminous body to be rendered; the luminous body to be rendered corresponds to preset luminous body surface data;

[0156] Based on the refraction data corresponding to the sampling point and the surface data of the luminous body, the luminous body to be rendered is rendered to obtain a rendering result.

[0157] In a feasible implementation manner, when the processor determines, according to the preset refractive index, the ray after the image acquisition sight line of the virtual camera passes through the surface of the luminous body to be rendered and refracted, it is specifically used to:

[0158] Determine the contact point of the image acquisition line of sight of the virtual camera on the surface of the luminous object to be rendered relative to the normal direction of the surface;

[0159] According to the normal direction and the preset refractive index, a ray of the image acquisition line of sight after being refracted through the surface of the luminous object to be rendered is determined.

[0160] In a feasible implementation manner, when the processor determines the sampling point on the ray according to the ray, the direction of the light source and the position of the light source, it is specifically used to:

[0161] Selecting two first directions based on the direction of the light source; wherein the two first directions are perpendicular to each other and are both perpendicular to the direction of the light source;

[0162] Determine a second direction from the center point of the light source position to the current camera position of the virtual camera;

[0163] determining a projection direction of the second direction on a plane formed by two of the first directions;

[0164] Determine a first plane passing through the center point of the light source and perpendicular to the second direction;

[0165] Determine a second plane passing through the center point of the light source position and perpendicular to the projection direction;

[0166] A first intersection point between the ray and the first plane and a second intersection point between the ray and the second plane are determined on the ray; wherein the first intersection point and the second intersection point are respectively two sampling points for sampling refraction data related to the light source to be rendered.

[0167] In a feasible implementation manner, when the processor determines the sampling point on the ray according to the ray, the direction of the light source and the position of the light source, it is specifically used to:

[0168] Reading the uv data structure of the model grid corresponding to the luminous body to be rendered from the scene parameters of the virtual scene; the uv data structure records the light source position coordinates and light source orientation coordinates of the virtual light source in the three-dimensional coordinate system corresponding to the virtual scene;

[0169] A sampling point is determined on the ray according to the ray, the current camera position of the virtual camera, the light source position coordinates and the light source orientation coordinates.

[0170] In a feasible implementation manner, when the processor performs rendering of the luminous body to be rendered based on the refraction data corresponding to the sampling point and the luminous body surface data to obtain a rendering result, it is specifically used to:

[0171] Determine rendering data of the light emitting body to be rendered according to the refraction data and the light emitting body surface data corresponding to the sampling point;

[0172] The luminous body to be rendered is rendered based on the rendering data to obtain a rendering result.

[0173] In a feasible implementation manner, the virtual light source also corresponds to a preset light source size; when the processor determines the rendering data of the light source to be rendered according to the refraction data and the light source surface data corresponding to the sampling point, it is specifically used to:

[0174] Determine, according to the light source size and the refraction data corresponding to the sampling point, body mapping data of the body of the virtual light source mapped on the luminous body to be rendered;

[0175] The rendering data of the light-emitting body to be rendered is determined according to the body mapping data and the light-emitting body surface data.

[0176] In a feasible implementation manner, when the processor determines the body mapping data of the body mapping of the virtual light source on the luminous body to be rendered according to the light source size and the refraction data corresponding to the sampling point, it is specifically used to:

[0177] Determining a target signed distance field function corresponding to the virtual light source according to the light source size; the target signed distance field function is used to characterize the light source shape and the light source size of the virtual light source;

[0178] Calculating the target signed distance field function based on the sampling point to obtain the shortest distance from the sampling point to the virtual light source;

[0179] Determine the body mapping data of the body of the virtual light source mapped on the luminous body to be rendered according to the shortest distance.

[0180] In a feasible implementation manner, the virtual light source corresponds to a preset scattering distance; when the processor determines the rendering data of the light source to be rendered according to the body mapping data and the light source surface data, it is specifically used to:

[0181] Determining scattering data of the virtual light source according to the shortest distance and the scattering distance;

[0182] Determine overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered according to the body mapping data and the scattering data;

[0183] The rendering data of the light emitting body to be rendered is determined according to the overall mapping data and the light emitting body surface data.

[0184] In a feasible implementation scheme, the virtual light source corresponds to a preset light source color, a preset light source intensity parameter, and a preset scattering intensity parameter; when the processor determines the overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered according to the body mapping data and the scattering data, it is specifically used to:

[0185] The overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered is determined according to the body mapping data, the scattering data, the light source color, the light source intensity parameter and the scattering intensity parameter.

[0186] In a feasible implementation, after calculating based on the sampling point through the target signed distance field function to obtain the shortest distance from the sampling point to the virtual light source, the processor is further used to: if the shortest distance is less than or equal to zero, determine that the sampling point is located on the virtual light source and determine that the ray intersects with the virtual light source, and determine to render the luminous body to be rendered based on the body mapping data and the scattering data;

[0187] If the shortest distance is greater than zero, it is determined that the sampling point is outside the virtual light source and that the ray does not intersect the virtual light source, and it is determined to render the luminous body to be rendered based on the scattering data.

[0188] In a feasible implementation manner, the virtual light source is in the shape of a capsule, the light source size includes radius parameters of two semicircles in the capsule shape and the center point positions of the two semicircles, and the two center point positions are used to characterize the light source height, the light source direction and the light source position of the virtual light source; when the processor determines the target signed distance field function corresponding to the virtual light source according to the light source size, it is specifically used to:

[0189] According to the radius parameter and the positions of the two circle center points, a target signed distance field function corresponding to the virtual light source is determined through a signed distance field function.

[0190] In a feasible implementation manner, the light source surface data includes at least one of the following: surface color, surface transmittance, and surface texture of the light source to be rendered.

[0191] In a feasible embodiment, the virtual scene also includes a virtual translucent body; before determining the image acquisition line of sight of the virtual camera through the refracted rays on the surface of the luminous body to be rendered according to the preset refractive index, the processor is also used to: in response to the spatial position relationship between the virtual light source, the virtual camera and the virtual translucent body satisfying a preset condition, determine the virtual translucent body as the luminous body to be rendered.

[0192] In a feasible implementation scheme, the spatial position relationship between the virtual light source, the virtual camera and the virtual light-transmitting body satisfies preset conditions, including: if the virtual light-transmitting body is an enclosing structure, the virtual light source is located inside the virtual light-transmitting body, and the virtual camera is located outside the virtual light-transmitting body; if the virtual light-transmitting body is a planar structure, the virtual light source is located on one side of the virtual light-transmitting body, and the virtual camera is located on the other side of the virtual light-transmitting body.

[0193] Through the above method, an image acquisition line of sight is emitted from the virtual camera toward the luminous body to be rendered. When the image acquisition line of sight contacts the surface of the luminous body, the ray refracted by the line of sight through the surface is determined by using the refractive index that can reflect the surface properties of the luminous body, and then a sampling point that can reflect the refraction situation of the luminous body to be rendered is determined on the ray through the ray and the light source direction and light source position of the virtual light source, so as to render the luminous body to be rendered based on the refraction data of the sampling point and the self data of the luminous body to be rendered, thereby maintaining the physical properties of refraction, making the rendering of the luminous body more in line with the physical laws, and having a more realistic sense of space in terms of perception, thereby improving the real effect of the virtual scene and alleviating the technical problem of low realism of the rendered virtual scene.

[0194] In practical applications, the memory 1901 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 1904 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.

[0195] The bus 1903 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.19 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0196] Among them, the memory 1901 is used to store programs, and the processor 1902 executes the program after receiving the execution instruction. The method executed by the device defined by the process disclosed in any embodiment of the present disclosure can be applied to the processor 1902 or implemented by the processor 1902.

[0197] The processor 1902 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1902. The above processor 1902 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 1901, and the processor 1902 reads the information in the memory 1901 and completes the steps of the above method in combination with its hardware.

[0198] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored. The computer program is executed when a processor is running, and the processor performs the following steps:

[0199] According to the preset refractive index, determining the image acquisition sight line of the virtual camera through the ray refracted by the surface of the luminous body to be rendered; wherein the virtual camera is used to perform image acquisition in the virtual scene, and the image acquisition sight line is a line from the virtual camera to the luminous body to be rendered;

[0200] Determine a sampling point on the ray according to the ray, the direction of the light source and the position of the light source; wherein the sampling point is used to sample refraction data related to the luminous body to be rendered; the luminous body to be rendered corresponds to preset luminous body surface data;

[0201] Based on the refraction data corresponding to the sampling point and the surface data of the luminous body, the luminous body to be rendered is rendered to obtain a rendering result.

[0202] In a feasible implementation manner, when the processor determines, according to the preset refractive index, the ray after the image acquisition sight line of the virtual camera passes through the surface of the luminous body to be rendered and refracted, it is specifically used to:

[0203] Determine the contact point of the image acquisition line of sight of the virtual camera on the surface of the luminous object to be rendered relative to the normal direction of the surface;

[0204] According to the normal direction and the preset refractive index, a ray of the image acquisition line of sight after being refracted through the surface of the luminous object to be rendered is determined.

[0205] In a feasible implementation manner, when the processor determines the sampling point on the ray according to the ray, the direction of the light source and the position of the light source, it is specifically used to:

[0206] Selecting two first directions based on the direction of the light source; wherein the two first directions are perpendicular to each other and are both perpendicular to the direction of the light source;

[0207] Determine a second direction from the center point of the light source position to the current camera position of the virtual camera;

[0208] determining a projection direction of the second direction on a plane formed by two of the first directions;

[0209] Determine a first plane passing through the center point of the light source and perpendicular to the second direction;

[0210] Determine a second plane passing through the center point of the light source position and perpendicular to the projection direction;

[0211] A first intersection point between the ray and the first plane and a second intersection point between the ray and the second plane are determined on the ray; wherein the first intersection point and the second intersection point are respectively two sampling points for sampling refraction data related to the light source to be rendered.

[0212] In a feasible implementation manner, when the processor determines the sampling point on the ray according to the ray, the direction of the light source and the position of the light source, it is specifically used to:

[0213] Reading the uv data structure of the model grid corresponding to the luminous body to be rendered from the scene parameters of the virtual scene; the uv data structure records the light source position coordinates and light source orientation coordinates of the virtual light source in the three-dimensional coordinate system corresponding to the virtual scene;

[0214] A sampling point is determined on the ray according to the ray, the current camera position of the virtual camera, the light source position coordinates and the light source orientation coordinates.

[0215] In a feasible implementation manner, when the processor performs rendering of the luminous body to be rendered based on the refraction data corresponding to the sampling point and the luminous body surface data to obtain a rendering result, it is specifically used to:

[0216] Determine rendering data of the light emitting body to be rendered according to the refraction data and the light emitting body surface data corresponding to the sampling point;

[0217] The luminous body to be rendered is rendered based on the rendering data to obtain a rendering result.

[0218] In a feasible implementation manner, the virtual light source also corresponds to a preset light source size; when the processor determines the rendering data of the light source to be rendered according to the refraction data and the light source surface data corresponding to the sampling point, it is specifically used to:

[0219] Determine, according to the light source size and the refraction data corresponding to the sampling point, body mapping data of the body of the virtual light source mapped on the luminous body to be rendered;

[0220] The rendering data of the light-emitting body to be rendered is determined according to the body mapping data and the light-emitting body surface data.

[0221] In a feasible implementation manner, when the processor determines the body mapping data of the body mapping of the virtual light source on the luminous body to be rendered according to the light source size and the refraction data corresponding to the sampling point, it is specifically used to:

[0222] Determining a target signed distance field function corresponding to the virtual light source according to the light source size; the target signed distance field function is used to characterize the light source shape and the light source size of the virtual light source;

[0223] Calculating the target signed distance field function based on the sampling point to obtain the shortest distance from the sampling point to the virtual light source;

[0224] Determine the body mapping data of the body of the virtual light source mapped on the luminous body to be rendered according to the shortest distance.

[0225] In a feasible implementation manner, the virtual light source corresponds to a preset scattering distance; when the processor determines the rendering data of the light source to be rendered according to the body mapping data and the light source surface data, it is specifically used to:

[0226] Determining scattering data of the virtual light source according to the shortest distance and the scattering distance;

[0227] Determine overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered according to the body mapping data and the scattering data;

[0228] The rendering data of the light emitting body to be rendered is determined according to the overall mapping data and the light emitting body surface data.

[0229] In a feasible implementation scheme, the virtual light source corresponds to a preset light source color, a preset light source intensity parameter, and a preset scattering intensity parameter; when the processor determines the overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered according to the body mapping data and the scattering data, it is specifically used to:

[0230] The overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered is determined according to the body mapping data, the scattering data, the light source color, the light source intensity parameter and the scattering intensity parameter.

[0231] In a feasible implementation, after calculating based on the sampling point through the target signed distance field function to obtain the shortest distance from the sampling point to the virtual light source, the processor is further used to: if the shortest distance is less than or equal to zero, determine that the sampling point is located on the virtual light source and determine that the ray intersects with the virtual light source, and determine to render the luminous body to be rendered based on the body mapping data and the scattering data;

[0232] If the shortest distance is greater than zero, it is determined that the sampling point is outside the virtual light source and that the ray does not intersect the virtual light source, and it is determined to render the luminous body to be rendered based on the scattering data.

[0233] In a feasible implementation manner, the virtual light source is in the shape of a capsule, the light source size includes radius parameters of two semicircles in the capsule shape and the center point positions of the two semicircles, and the two center point positions are used to characterize the light source height, the light source direction and the light source position of the virtual light source; when the processor determines the target signed distance field function corresponding to the virtual light source according to the light source size, it is specifically used to:

[0234] According to the radius parameter and the positions of the two circle center points, a target signed distance field function corresponding to the virtual light source is determined through a signed distance field function.

[0235] In a feasible implementation manner, the light source surface data includes at least one of the following: surface color, surface transmittance, and surface texture of the light source to be rendered.

[0236] In a feasible embodiment, the virtual scene also includes a virtual translucent body; before determining the image acquisition line of sight of the virtual camera through the refracted rays on the surface of the luminous body to be rendered according to the preset refractive index, the processor is also used to: in response to the spatial position relationship between the virtual light source, the virtual camera and the virtual translucent body satisfying a preset condition, determine the virtual translucent body as the luminous body to be rendered.

[0237] In a feasible implementation scheme, the spatial position relationship between the virtual light source, the virtual camera and the virtual light-transmitting body satisfies preset conditions, including: if the virtual light-transmitting body is an enclosing structure, the virtual light source is located inside the virtual light-transmitting body, and the virtual camera is located outside the virtual light-transmitting body; if the virtual light-transmitting body is a planar structure, the virtual light source is located on one side of the virtual light-transmitting body, and the virtual camera is located on the other side of the virtual light-transmitting body.

[0238] Through the above method, an image acquisition line of sight is emitted from the virtual camera toward the luminous body to be rendered. When the image acquisition line of sight contacts the surface of the luminous body, the ray refracted by the line of sight through the surface is determined by using the refractive index that can reflect the surface properties of the luminous body, and then a sampling point that can reflect the refraction situation of the luminous body to be rendered is determined on the ray through the ray and the light source direction and light source position of the virtual light source, so as to render the luminous body to be rendered based on the refraction data of the sampling point and the self data of the luminous body to be rendered, thereby maintaining the physical properties of refraction, making the rendering of the luminous body more in line with the physical laws, and having a more realistic sense of space in terms of perception, thereby improving the real effect of the virtual scene and alleviating the technical problem of low realism of the rendered virtual scene.

[0239] In the embodiments of the present disclosure, the computer program can also execute other machine-readable instructions when run by the processor to execute other methods described in the embodiments. For the specific execution method steps and principles, please refer to the description of the embodiments, which will not be repeated here.

[0240] In the embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. 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 mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0241] For another example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0242] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0243] In addition, each functional unit in the embodiments provided in the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0244] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the rendering method of the virtual scene described in each embodiment of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.

[0245] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.

[0246] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the aforementioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the aforementioned embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present disclosure. They should all be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be based on the protection scope of the claims.

Claims

1. A method for rendering a virtual scene, characterized in that: The virtual scene includes a virtual light source and a light source to be rendered, the virtual light source corresponds to a preset light source position and a preset light source orientation, and the preset refractive index corresponding to the light source to be rendered is used to characterize the surface properties of the light source to be rendered; The method comprises: According to the preset refractive index, determining the image acquisition sight line of the virtual camera through the ray refracted by the surface of the luminous body to be rendered; wherein the virtual camera is used to perform image acquisition in the virtual scene, and the image acquisition sight line is a line from the virtual camera to the luminous body to be rendered; Determine a sampling point on the ray according to the ray, the direction of the light source and the position of the light source; wherein the sampling point is used to sample refraction data related to the luminous body to be rendered; the luminous body to be rendered corresponds to preset luminous body surface data; Based on the refraction data corresponding to the sampling point and the surface data of the luminous body, the luminous body to be rendered is rendered to obtain a rendering result.

2. The method according to claim 1, characterized in that: The step of determining, according to the preset refractive index, a ray refracted by the image acquisition sight line of the virtual camera through the surface of the luminous body to be rendered, comprises: Determine the contact point of the image acquisition line of sight of the virtual camera on the surface of the luminous object to be rendered relative to the normal direction of the surface; According to the normal direction and the preset refractive index, a ray of the image acquisition line of sight after being refracted through the surface of the luminous object to be rendered is determined.

3. The method according to claim 1, characterized in that The step of determining a sampling point on the ray according to the ray, the direction of the light source and the position of the light source comprises: Selecting two first directions based on the direction of the light source; wherein the two first directions are perpendicular to each other and are both perpendicular to the direction of the light source; Determine a second direction from the center point of the light source position to the current camera position of the virtual camera; determining a projection direction of the second direction on a plane formed by two of the first directions; Determine a first plane passing through the center point of the light source and perpendicular to the second direction; Determine a second plane passing through the center point of the light source position and perpendicular to the projection direction; A first intersection point between the ray and the first plane and a second intersection point between the ray and the second plane are determined on the ray; wherein the first intersection point and the second intersection point are respectively two sampling points for sampling refraction data related to the light source to be rendered.

4. The method according to claim 1, characterized in that: The step of determining a sampling point on the ray according to the ray, the direction of the light source and the position of the light source comprises: Reading the uv data structure of the model grid corresponding to the luminous body to be rendered from the scene parameters of the virtual scene; the uv data structure records the light source position coordinates and light source orientation coordinates of the virtual light source in the three-dimensional coordinate system corresponding to the virtual scene; A sampling point is determined on the ray according to the ray, the current camera position of the virtual camera, the light source position coordinates and the light source orientation coordinates.

5. The method according to claim 1, characterized in that The step of rendering the luminous body to be rendered based on the refraction data corresponding to the sampling point and the luminous body surface data to obtain a rendering result includes: Determine rendering data of the light emitting body to be rendered according to the refraction data and the light emitting body surface data corresponding to the sampling point; The luminous body to be rendered is rendered based on the rendering data to obtain a rendering result.

6. The method according to claim 5, characterized in that The virtual light source also corresponds to a preset light source size; The step of determining the rendering data of the light source to be rendered according to the refraction data and the light source surface data corresponding to the sampling point includes: Determine, according to the light source size and the refraction data corresponding to the sampling point, body mapping data of the body of the virtual light source mapped on the luminous body to be rendered; The rendering data of the light-emitting body to be rendered is determined according to the body mapping data and the light-emitting body surface data.

7. The method according to claim 6, characterized in that The determining, according to the light source size and the refraction data corresponding to the sampling point, the body mapping data of the body of the virtual light source mapped on the luminous body to be rendered comprises: Determining a target signed distance field function corresponding to the virtual light source according to the light source size; the target signed distance field function is used to characterize the light source shape and the light source size of the virtual light source; Calculating the target signed distance field function based on the sampling point to obtain the shortest distance from the sampling point to the virtual light source; Determine the body mapping data of the body of the virtual light source mapped on the luminous body to be rendered according to the shortest distance.

8. The method according to claim 7, characterized in that The virtual light source corresponds to a preset scattering distance; The step of determining the rendering data of the light-emitting body to be rendered according to the body mapping data and the light-emitting body surface data comprises: Determining scattering data of the virtual light source according to the shortest distance and the scattering distance; Determine overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered according to the body mapping data and the scattering data; The rendering data of the light emitting body to be rendered is determined according to the overall mapping data and the light emitting body surface data.

9. The method according to claim 8, characterized in that The virtual light source corresponds to a preset light source color, a preset light source intensity parameter, and a preset scattering intensity parameter; The step of determining the overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered according to the body mapping data and the scattering data comprises: The overall mapping data of the overall mapping of the virtual light source on the luminous body to be rendered is determined according to the body mapping data, the scattering data, the light source color, the light source intensity parameter and the scattering intensity parameter.

10. The method according to claim 8, characterized in that After the shortest distance from the sampling point to the virtual light source is obtained by calculating the target signed distance field function based on the sampling point, the method further comprises: If the shortest distance is less than or equal to zero, determining that the sampling point is located on the virtual light source, determining that the ray intersects the virtual light source, and determining to render the luminous body to be rendered based on the body mapping data and the scattering data; If the shortest distance is greater than zero, it is determined that the sampling point is outside the virtual light source and that the ray does not intersect the virtual light source, and it is determined to render the luminous body to be rendered based on the scattering data.

11. The method according to claim 7, characterized in that The virtual light source is in the shape of a capsule, and the light source size includes radius parameters of two semicircles in the capsule shape and the positions of the center points of the two semicircles, and the two positions of the center points are used to characterize the light source height, the light source direction and the light source position of the virtual light source; The step of determining a target signed distance field function corresponding to the virtual light source according to the light source size includes: According to the radius parameter and the positions of the two circle center points, a target signed distance field function corresponding to the virtual light source is determined through a signed distance field function.

12. The method according to claim 1, characterized in that The light source surface data includes at least one of the following: The surface color, surface transmittance, and surface texture of the luminous object to be rendered.

13. The method according to claim 1, characterized in that The virtual scene also includes a virtual light-transmitting body; before determining the image acquisition line of sight of the virtual camera through the refracted ray of the surface of the light-emitting body to be rendered according to the preset refractive index, it also includes: In response to the spatial position relationship between the virtual light source, the virtual camera and the virtual light-transmitting body satisfying a preset condition, the virtual light-transmitting body is determined as the luminous body to be rendered.

14. The method according to claim 13, characterized in that The spatial position relationship between the virtual light source, the virtual camera and the virtual light-transmitting body meets the preset condition, which includes: If the virtual light-transmitting body is an enclosing structure, the virtual light source is located inside the virtual light-transmitting body, and the virtual camera is located outside the virtual light-transmitting body; If the virtual light-transmitting body is a planar structure, the virtual light source is located on one side of the virtual light-transmitting body, and the virtual camera is located on the other side of the virtual light-transmitting body.

15. A virtual scene rendering device, characterized in that: The virtual scene includes a virtual light source and a light source to be rendered, the virtual light source corresponds to a preset light source position and a preset light source orientation, and the preset refractive index corresponding to the light source to be rendered is used to characterize the surface properties of the light source to be rendered; The device comprises: A first determination module is used to determine, according to the preset refractive index, a ray refracted by an image acquisition sight line of a virtual camera through the surface of the luminous body to be rendered; wherein the virtual camera is used to perform image acquisition in the virtual scene, and the image acquisition sight line is a line from the virtual camera to the luminous body to be rendered; A second determination module is used to determine a sampling point on the ray according to the ray, the direction of the light source and the position of the light source; wherein the sampling point is used to sample refraction data related to the luminous body to be rendered; the luminous body to be rendered corresponds to preset luminous body surface data; A rendering module is used to render the luminous body to be rendered based on the refraction data corresponding to the sampling point and the surface data of the luminous body to obtain a rendering result.

16. An electronic terminal comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 14 are implemented.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to execute the method according to any one of claims 1 to 14.

Citation Information

Patent Citations

  • Image processing method and system, and image processing equipment

    CN113313808A

  • Three-dimensional model rendering method, rendering device, equipment and medium

    CN116310056A

  • Illumination control method and device, computer equipment and storage medium

    CN116503520A

  • Method and device for rendering virtual model, storage medium and electronic equipment

    CN117036573A

  • Luminescence rendering method and device, computer readable storage medium and electronic equipment

    CN117036579A