Virtual scene rendering method and device, electronic equipment and storage medium
By determining the image acquisition line-of-sight refracting ray and sampling point of the virtual camera, the problem of insufficient spatial sense simulation in the rendering of translucent volumes is solved, improving the realism of the virtual scene and reducing computational overhead.
Patent Information
- Application Number
- CN202411930576.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2044-12-25
AI Technical Summary
Existing rendering methods for transparent objects cannot effectively simulate the spatial relationship between the light source and the transparent object, resulting in low realism of virtual scenes.
By determining the ray refracted by the virtual camera's line of sight through the surface of the luminous object to be rendered, sampling points are determined based on the ray, the direction of the light source, and the position of the light source. Rendering is then performed based on the refraction data of the sampling points and the surface data of the luminous object, preserving the physical properties of refraction and enhancing the realism of the spatial sense.
It improves the realism of virtual scenes, alleviates the problem of low realism in rendered virtual scenes, and reduces computational overhead and performance requirements.
Smart Images

Figure CN119733235B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and in particular to a method, apparatus, electronic device, and storage medium for rendering virtual scenes. Background Technology
[0002] In virtual scenes, it is often necessary to render translucent objects. For example, rendering translucent objects with low transparency, such as frosted glass or dirty glass used on streetlights or lanterns; or rendering special effects or crystal effects on translucent objects that emit light from within.
[0003] Currently, rendering such translucent objects typically uses self-illuminating maps. For example, by drawing a self-illuminating map and offsetting it to a limited extent, the spatial sense of the light source is simulated, thus rendering the translucent object. However, this rendering method only displays the luminous pattern on the surface of the translucent object, resulting in poor simulation of the spatial sense between the light source and the translucent object, leading to low realism in the rendered virtual scene. Summary of the Invention
[0004] The purpose of this disclosure is to provide a method, apparatus, electronic device, and storage medium for rendering virtual scenes to alleviate the technical problem of low realism in rendered virtual scenes.
[0005] In a first aspect, embodiments of this disclosure provide 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 having a preset light source position and a preset light source orientation, and the preset refractive index corresponding to the light source to be rendered being used to characterize the surface properties of the light source to be rendered; the method includes:
[0006] Based on the preset refractive index, the ray of the image acquisition line of the virtual camera after refraction through the surface of the light source to be rendered is determined; wherein, the virtual camera is used to acquire images in the virtual scene, and the image acquisition line is a line connecting the virtual camera to the light source to be rendered;
[0007] Based on the ray, the orientation of the light source, and the position of the light source, sampling points are determined on the ray; wherein, the sampling points are used to sample refraction data related to the light source to be rendered; the light source to be rendered corresponds to preset light source surface data;
[0008] Based on the refraction data and the surface data of the light source corresponding to the sampling point, the light source to be rendered is rendered to obtain the rendering result.
[0009] Secondly, a rendering apparatus for a virtual scene is provided. 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. The preset refractive index of the light source to be rendered is used to characterize the surface properties of the light source. The apparatus includes:
[0010] The first determining module is used to determine, based on the preset refractive index, the ray after the image acquisition line of the virtual camera is refracted through the surface of the light-emitting body to be rendered; wherein, the virtual camera is used to acquire images in the virtual scene, and the image acquisition line is a line connecting the virtual camera to the light-emitting body to be rendered;
[0011] The second determining module is used to determine sampling points on the ray based on the ray, the orientation of the light source, and the position of the light source; wherein the sampling points are used to sample refraction data related to the light source to be rendered; the light source to be rendered corresponds to preset light source surface data;
[0012] The rendering module is used to render the light-emitting body to be rendered based on the refraction data and the surface data of the light-emitting body corresponding to the sampling point, and obtain the rendering result.
[0013] Thirdly, embodiments of this disclosure also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement the method described in the first aspect above.
[0014] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a processor, cause the processor to perform the method described in the first aspect above.
[0015] The embodiments disclosed herein bring the following beneficial effects:
[0016] This disclosure provides a virtual scene rendering method, apparatus, electronic device, and storage medium. It can determine the ray formed by the refraction of the image acquisition line of a virtual camera through the surface of the light-emitting body to be rendered, based on a preset refractive index corresponding to the light-emitting body to be rendered. The virtual camera is used for image acquisition in the virtual scene, and the image acquisition line is a line connecting the virtual camera to the light-emitting body to be rendered. Sampling points are determined on the ray based on the ray, the orientation of the virtual light source, and the position of the light source. These sampling points are used to sample refraction data related to the light-emitting body to be rendered. The light-emitting body to be rendered corresponds to preset light-emitting body surface data. Based on the refraction data corresponding to the sampling points and the light-emitting body surface data, the light-emitting 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 light source to be rendered. When the image acquisition line of sight touches the surface of the light source, the refractive index, which reflects the surface properties of the light source, is used to determine the ray refracted by the line of sight through the surface. Then, by using the ray and the orientation and position of the virtual light source, sampling points that reflect the refraction of the light source to be rendered are determined on the ray. This allows the light source to be rendered based on the refraction data of the sampling points and the light source's own data, thus preserving the physical properties of refraction and making the rendering of the light source more in line with physical laws. This results in a more realistic sense of space and improves the realism of the virtual scene, alleviating the technical problem of low realism in the rendered virtual scene.
[0017] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the specific embodiments of this disclosure or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0019] Figure 1 The illustration shows an application scenario provided by an embodiment of this disclosure;
[0020] Figure 2 A schematic diagram of the structure of an electronic terminal provided in an embodiment of this disclosure is shown;
[0021] Figure 3 A schematic flowchart illustrating the virtual scene rendering method provided in this embodiment of the disclosure;
[0022] Figure 4An example of a street lamp in the virtual scene rendering method provided in this disclosure embodiment;
[0023] Figure 5 An example of a virtual light-transmitting body on a street lamp in the virtual scene rendering method provided in this embodiment of the disclosure;
[0024] Figure 6 Another example of a virtual transparent body in the virtual scene rendering method provided in this disclosure embodiment;
[0025] Figure 7 An example of the light source position and direction in the virtual scene rendering method provided in this disclosure embodiment;
[0026] Figure 8 An example of a virtual scene rendering method provided in this disclosure that determines multiple other directions based on the direction of the light source;
[0027] Figure 9 Another example of determining multiple other directions based on the direction of the light source in the virtual scene rendering method provided in this disclosure embodiment;
[0028] Figure 10 An example of an auxiliary plane in the virtual scene rendering method provided in this disclosure embodiment;
[0029] Figure 11 An example of line-of-sight refraction in the virtual scene rendering method provided in this embodiment;
[0030] Figure 12 An example of the relative position of virtual light sources in the virtual scene rendering method provided in this disclosure embodiment;
[0031] Figure 13 An example of the shape of a virtual light source in the virtual scene rendering method provided in this embodiment of the present disclosure;
[0032] Figure 14 In the virtual scene rendering method provided in this embodiment, a virtual light source corresponds to an example of the rendering effect;
[0033] Figure 15 Another example of the rendering effect corresponding to the virtual light source in the virtual scene rendering method provided in this disclosure embodiment;
[0034] Figure 16 An example of a rendering method for a virtual scene provided in this embodiment of the present disclosure, wherein the light source to be rendered has a texture.
[0035] Figure 17 An example of the rendering effect of a light-emitting body to be rendered in the virtual scene rendering method provided in this embodiment of the present disclosure;
[0036] Figure 18 A schematic diagram of the structure of a virtual scene rendering device provided in an embodiment of this disclosure;
[0037] Figure 19 A schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure is shown. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0039] The terms “comprising” and “having”, and any variations thereof, used in the embodiments of this disclosure are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to such processes, methods, products, or devices.
[0040] Currently, rendering translucent objects typically uses self-illuminating maps. This involves drawing a self-illuminating map and offsetting it to a limited extent to simulate the spatial feel of a light source. However, this method can only simulate the spatial feel of a luminous object within an object to a limited extent; it mostly just displays luminous patterns on the object's surface. Even with parallax sampling, noticeable distortion can easily occur at certain viewpoints, affecting the effect and resulting in low realism in the rendered virtual scenes.
[0041] In existing technologies, the rendering of translucent objects can also be achieved through ray tracing. This involves using ray tracing or a similar step-by-step strategy to collect and integrate information about the luminous object, and finally rendering it through self-illumination. However, this method requires a large number of sampling operations, has high performance requirements, and is prone to noise, necessitating additional noise reduction calculations. It is not suitable for use on scenes with a large number of small luminous objects (such as streetlights).
[0042] Furthermore, the rendering of translucent objects can currently be achieved through semi-transparency, that is, by placing a solid luminous object inside a semi-transparent object. However, this method requires solving the semi-transparency sorting problem, cannot simulate 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 present disclosure provides a method, apparatus, electronic device and storage medium for rendering virtual scenes, which can alleviate the technical problem of low realism of rendered virtual scenes.
[0044] In one embodiment of this disclosure, the virtual scene rendering method can run on a local terminal device or a server. When the virtual scene rendering method runs 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, such as cloud gaming, can run under the cloud interaction system. Taking cloud gaming as an example, cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game program's execution and the game screen presentation are separated. The storage and execution of methods are completed on the cloud gaming server. The client device is used for data reception, transmission, and game screen presentation. For example, the client device can be a display device with data transmission capabilities located close to the user, such as a mobile terminal, television, computer, or PDA; however, information processing is performed by the cloud gaming server in the cloud. When playing the game, the player operates the client device to send operation commands to the cloud gaming server. The cloud gaming server runs the game according to the operation commands, encodes and compresses game screen data, returns it to the client device via the network, and finally, the client device decodes and outputs the game screen.
[0046] In an optional implementation, taking a game as an example, the local terminal device stores the game program and is used to display the game screen. The local terminal device is used to interact with the player through a graphical user interface (GUI), i.e., conventionally by downloading, installing, and running the game program via an electronic device. The local terminal device can provide the GUI to the player in various ways, such as rendering it on the terminal's display screen or providing it to the player via holographic projection. For example, the local terminal device can include a display screen for displaying the GUI, which includes game screens, and a processor for running the game, generating the GUI, and controlling the display of the GUI on the display screen.
[0047] In one possible implementation, this disclosure provides a method for rendering a virtual scene, which provides a graphical user interface through a terminal device. The terminal device can be either the aforementioned local terminal device or a client device in the aforementioned cloud interaction system.
[0048] For example, such as Figure 1 As shown, Figure 1This is a schematic diagram illustrating an application scenario provided by an embodiment of this disclosure. The application scenario may include a touch terminal (e.g., mobile phone 102) and a server 101. The touch terminal can communicate with the server 101 via a wired or wireless network. The touch terminal is used to run a virtual desktop, through which it can interact with the server 101 to process content on the server 101.
[0049] This embodiment uses a mobile phone 102 as an example to illustrate the touch terminal. 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 will understand that... Figure 2 The mobile phone structure shown does not constitute a limitation on the mobile phone and may include more or fewer components than shown, or combine or separate certain components, or have different component arrangements. Those skilled in the art will understand that the display screen 130 is a user interface (UI), and the mobile phone 102 may include a user interface with fewer components than shown.
[0050] The RF circuit 110 can also communicate wirelessly with networks and other devices. The wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, and Short Messaging Service (SMS).
[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 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function, etc.; the data storage area may store data created based on the use of the mobile phone 102, etc. In addition, the memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0052] The processor 140 is the control center of the mobile phone 102. It connects to various parts of the mobile phone through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 120, and calling data stored in the memory 120, it performs various functions of the mobile phone 102 and processes data, thereby monitoring the mobile phone as a whole.
[0053] The embodiments of this disclosure will be further described below with reference to the accompanying drawings.
[0054] Figure 3 This is a flowchart illustrating a virtual scene rendering method provided in an embodiment of the present disclosure.
[0055] This method can be applied to electronic devices capable of displaying graphical user interfaces. The virtual scene includes virtual light sources and light-emitting bodies to be rendered. The virtual light sources have preset light source positions and preset light source orientations, and the preset refractive index of the light-emitting bodies to be rendered is used to characterize the surface properties of the light-emitting bodies. For example... Figure 3 As shown, the method includes:
[0056] Step S310: Based on the preset refractive index, determine the ray after the image acquisition line of the virtual camera is refracted through the surface of the light source to be rendered.
[0057] The virtual camera is used to capture images within the virtual scene. The camera position represents the player's current viewing position, which is determined by the player's actions. The image capture line of sight is the line connecting the virtual camera to the light source to be rendered.
[0058] The aforementioned light source to be rendered can be any virtual object in the virtual scene capable of producing a light-emitting effect. As an optional implementation, the light source to be rendered can be a virtual translucent object in the virtual scene, achieving the light-emitting effect produced by light from a virtual light source passing through the virtual translucent object. Based on this, the virtual scene also includes a virtual translucent object; prior to this step, the method may further include the following step: in response to the spatial relationship between the virtual light source, the virtual camera, and the virtual translucent object satisfying preset conditions, the virtual translucent object is determined as the light source to be rendered. This method of determining the light source to be rendered makes the rendering timing of the light source to be rendered more precise.
[0059] For virtual transparent bodies, such as Figure 4 and Figure 5As shown, taking the translucent glass of a virtual street lamp as an example, a separate material is assigned to the part of the light source that needs to be rendered. For example, in addition to the opaque metal lamp frame and lampshade support on the virtual street lamp, the virtual street lamp also includes a translucent glass material. Through the surface of this glass material (the virtual translucent body), the virtual light source inside can be seen. By identifying the translucent part (the virtual translucent body), the data to be recorded can be accurately identified during subsequent data recording, and the part of the light source to be calculated can be accurately identified during rendering, avoiding performance waste.
[0060] In one optional implementation, the spatial relationship between the virtual light source, the virtual camera, and the virtual transparent body can be flexible and varied. For example, the spatial relationship between the virtual light source, the virtual camera, and the virtual transparent body can satisfy preset conditions, including: if the virtual transparent body is an enclosing structure, then the virtual light source is located inside the virtual transparent body, and the virtual camera is located outside the virtual transparent body; if the virtual transparent body is a planar structure, then the virtual light source is located on one side of the virtual transparent body, and the virtual camera is located on the other side of the virtual transparent body.
[0061] As an example, such as Figure 5 As shown, the virtual transparent body at least partially surrounds the virtual light source; that is, the virtual transparent body is an enclosing structure. The virtual light source is located inside the virtual transparent body, and the virtual camera (the player's current viewing position) is located outside the virtual transparent body. It should be noted that the virtual transparent body can either completely enclose the virtual light source or partially enclose it.
[0062] As another example, such as Figure 6 As shown, a virtual light source (such as a light bulb) is not necessarily inside a virtual light-transmitting object (such as a lampshade). It can also be a situation where the virtual light source shines through from one side of the virtual light-transmitting object. For example, the virtual camera (the player's current observation position) is outside the room, the light bulb is inside the room, and the two are separated by a window. The virtual camera can only see the light bulb inside the room through the window. At this time, the light bulb (virtual light source) and the virtual camera are located on opposite sides of the window (virtual light-transmitting object). It is determined that the virtual camera can see the light transmission effect of the virtual light source through the virtual light-transmitting object. At this time, it is necessary to render the light emission of the window, that is, to determine the window (virtual light-transmitting object) as the light source to be rendered.
[0063] For the position and orientation of a virtual light source, for example, such as Figure 7 As shown, virtual light sources are set inside the two lamps, with the light source orientation of one virtual light source set to the positive Z-axis and the light source orientation of the other virtual light source set to the positive Y-axis.
[0064] In this embodiment of the disclosure, the image acquisition line of the virtual camera is a line connecting the virtual camera to the light source to be rendered. In an optional implementation, this step may specifically include the following steps: determining the contact point of the image acquisition line of the virtual camera on the surface of the light source to be rendered relative to the normal direction of the surface; and determining the ray after the image acquisition line is refracted through the surface of the light source to be rendered, based on the normal direction and a preset refractive index.
[0065] For example, first, the location of the contact point is determined based on the intersection of the image acquisition line of sight and the surface of the light source to be rendered. Then, the surface normal direction at that location is determined. Based on the preset refractive index of the light source to be rendered, such as the ratio R of the refractive index of the medium inside the object to the refractive index of the external medium, the refracted ray LR is calculated. That is, the refracted ray LR is calculated using Fresnel's equations based on the refractive index ratio R and the normal direction of the contact point on the surface of the light source to be rendered. Here, the refractive index ratio R can be a preset value, which can be preset according to the actual effect requirements, for example, based on the actual physical quantity; or it can simply represent the ratio of refractive intensities, for example, 1 indicates no refraction, greater than 1 indicates entering a less optically denser medium or 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 light source to be rendered. When the image acquisition line of sight touches the surface of the light source to be rendered, the image acquisition line of sight can be refracted according to the surface properties of the light source to be rendered (such as normal and refractive index). Through this refraction effect, a certain physical property accuracy is maintained during calculation, so that the image has a spatial sense that is correct and conforms to the physical laws. Thus, the rendering of the light source with a realistic spatial sense and refractive physical properties is achieved.
[0067] Step S320: Determine sampling points on the ray based on the ray, the orientation of the light source, and the position of the light source.
[0068] The sampling points are used to sample refraction data related to the light source to be rendered. As an example, the specific method for determining these sampling points may include the following steps: selecting two first directions based on the light source orientation; wherein the two first directions are perpendicular to each other and both perpendicular to the light source orientation; determining a 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 onto the plane formed by the two first directions; determining a first plane passing through the center point of the light source position and perpendicular to the second direction; determining a second plane passing through the center point of the light source position and perpendicular to the projection direction; determining a first intersection point of the ray with the first plane and a second intersection point of the ray with the second plane; wherein the first intersection point and the second intersection point are two sampling points used to sample refraction data related to the light source to be rendered.
[0069] Conventional ray tracing schemes in the prior art require a large number of intersection and sampling points, typically ranging from tens to tens of thousands of samplings, and sometimes cannot even be completed within a single frame. However, in this embodiment, two auxiliary planes, namely the first plane and the second plane, are determined by the virtual camera, the position of the light source, and the orientation of the light source. Then, the two intersection points (the first and second intersection points) between these two auxiliary planes and the refracted ray in step S320 are calculated and used as two sampling points. This reduces computational and performance overhead, resulting in superior performance compared to existing ray tracing schemes in rendering virtual light sources.
[0070] Step S330: Based on the refraction data and surface data of the light source corresponding to the sampling points, render the light source to be rendered to obtain the rendering result.
[0071] It should be noted that the luminous object to be rendered corresponds to preset luminous object surface data. This surface data can include various aspects to make the rendering effect of the luminous object more accurate. For example, the luminous object surface data includes at least one of the following: the surface color, surface transmittance, and surface texture of the luminous object to be rendered.
[0072] In this embodiment, an image acquisition line of sight is emitted from a virtual camera toward the light source to be rendered. When the image acquisition line of sight touches the surface of the light source, the ray refracted by the line of sight through the surface is determined using the refractive index, which reflects the surface properties of the light source. Then, by using the ray and the orientation and position of the virtual light source, sampling points that reflect the refraction of the light source to be rendered are determined on the ray. This allows the light source to be rendered based on the refraction data of the sampling points and the light source's own data, thus maintaining the physical properties of refraction and making the rendering of the light source more in line with physical laws. This results in a more realistic sense of space and improves the realism of the virtual scene, alleviating the technical problem of low realism in the rendered virtual scene.
[0073] The steps described above will be explained in detail below.
[0074] In some embodiments, the data such as the position and orientation of the virtual light source can be stored in various data structures corresponding to the light source to be rendered, such as vertex colors, individual textures, UV layout data, or other data structures corresponding to the light source to be rendered, to make the data storage method of the light source position and orientation more flexible and improve the utilization of data storage space. As an example, step S330 above may specifically include the following steps:
[0075] The UV data structure of the model mesh corresponding to the light source to be rendered is read from the scene parameters of the virtual scene. The UV data structure records the position coordinates and orientation coordinates of the virtual light source in the corresponding three-dimensional coordinate system of the virtual scene. Based on the ray, the current camera position of the virtual camera, the position coordinates and orientation coordinates of the light source, the sampling point is determined on the ray.
[0076] The light source position coordinates can be in various forms. For example, the light source position coordinates can be the relative position coordinates of the virtual light source with respect to the lamp body model. For instance, as shown... Figure 12 As shown, the position coordinates of the light source are the relative position coordinates of the virtual light source with respect 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 a model mesh, it's important to understand that a model mesh is composed of a series of vertices. Based on the relationships between these vertices, points are connected to form surfaces, ultimately creating the 3D model we see. The data of this 3D model is stored on each of these individual vertices, such as the position of each vertex in space and its normal information. UV data is essentially a two-dimensional vector, typically used as a two-dimensional coordinate system mapped to a specific location on a two-dimensional image. This achieves the effect of pasting a two-dimensional image onto the surface of a 3D model.
[0078] As an optional implementation, the light source orientation and position can be recorded in the vertex data of the mesh corresponding to the light source to be rendered on the lamp body model. In this embodiment of the present disclosure, the light source orientation and position 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 for light source orientation and position in the aforementioned UV data structure, it should be noted that the typical function of UV data is to map two-dimensional images. Therefore, it is likely that 0-N sets of UV data will be used for other functions, which can be reserved as UVs for those functions. Since UV data exists as a series of two-dimensional vectors, that is, two floating-point numbers per group, each group of UV data has only two positions. For the three-dimensional vector data to be stored, in this embodiment, the xyz three-dimensional components can be distributed on the two-dimensional UV data according to the layout shown in the table below. This allows the data to be arranged into three consecutive groups of UV data in storage order without leaving empty spaces, facilitating reading and saving space.
[0080]
[0081] In this embodiment, 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 of the corresponding virtual light source set for the light source to be rendered, but the light source information is also recorded in the UV data space of the light source to be rendered, thus making full use of the data storage space.
[0082] In some embodiments, the two auxiliary planes determined based on the virtual camera and the light source position and orientation, and the two intersection points of the refracted ray in step S320 above, can be used as sampling points. This reduces the computational load by requiring only two samplings at these two sampling points. As an example, step S330 above may specifically include the following steps:
[0083] Two first directions are selected based on the light source orientation; wherein the two first directions are perpendicular to each other and both are perpendicular to the light source orientation; a second direction is determined from the center point of the light source position to the current camera position of the virtual camera; the 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 and the first plane, and a second intersection point of the ray and the second plane are determined on the ray; wherein the first intersection point and the second intersection point are two sampling points used to sample refraction data related to the light source to be rendered.
[0084] For the above selection of two first directions based on the light source orientation, for example, a coordinate system is created using the light source orientation (hereinafter referred to as UpDir) as a basis vector. The three basis vectors of this coordinate system are RightDirForwardDir and UpDir, which determine the other two mutually perpendicular directions that are also perpendicular to UpDir. The method for determining RightDir is as follows:
[0085] If the absolute values of both the x and y components of UpDir are less than 0.001, then RightDir = (1,0,0), which can be understood as UpDir approximately = (0,0,1). Originally, we should have checked for values less than 0, but considering computer precision errors, 0.001 is chosen as the criterion. Conversely, RightDir = Normalize(-UpDir.y,UpDir.x,0), [Normalize represents vector normalization], and ForwardDir = cross(UpDir,RightDir), [cross() represents the cross product of vectors]. This can also be understood as follows: when any two components of a 3D vector are not both 0, swap these two components, invert one of them (multiply by -1), and set the third component to 0. This quickly yields a vector that is perpendicular to both the original vector and the coordinate axis of the third component. For example, for a vector V = (x, y, z), when x and y are not both 0, 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 process of determining the second direction from the center point of the light source 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 and perpendicular to the second direction, and determining the second plane passing through the center point of the light source and perpendicular to the projection direction is performed. For example, assuming the unit vector from the center point of the light source to the current camera position of the virtual camera is CDir = Normalize(CameraPos - CenterPos), which is the second direction, is then determined. Two auxiliary planes are then determined: a plane in three-dimensional space can be defined based on a point on the plane and its normal. The two auxiliary planes are defined as follows: Plane1: a plane passing through the center point of the light source with the normal CDir; Plane2: a plane passing through the center point of the light source with the normal CDir as the unit vector of the projection direction of the projection direction of CDir on the plane spanned by RightDir and ForwardDir.
[0087] For example, in such Figure 8In the illustrated 3D scene diagram, the arrow pointing directly upwards represents the UpDir direction, and the two arrows perpendicular to it below represent the RightDir and ForwardDir directions. Figure 8 The arrow perpendicular to Plane1 (i.e., the first plane) shown in the diagram is in the CDir direction, as... Figure 10 As shown, plane Plane1 is a plane perpendicular to CDir and passes through the center of the light source. Figure 9 The plane Plane2 (i.e., the second plane) shown is normalized by the projection vector of CDir onto the ForwardDir-RightDir plane, and appears to be parallel to the original light source direction (UpDir).
[0088] Then, the process of determining the first intersection point of the ray with the first plane and the second intersection point of the ray with the second plane, as described above, is performed. For example, as shown... Figure 11 As shown, the first intersection point SampleP1 between the refracted ray LR and the first plane Plane1, and the second intersection point SampleP2 between the ray LR and the second plane Plane2 are calculated respectively in step S320 above.
[0089] By using the two intersection points of the refracted ray and two auxiliary planes determined based on the virtual camera and the position and orientation of the light source as sampling points, only two samplings corresponding to these two sampling points are required. Compared with the calculation of a large number of sampling points in the prior art, the computational and performance overhead of this embodiment is greatly reduced, resulting in better performance in the process of rendering virtual light sources.
[0090] In some embodiments, during the rendering process, the rendering data of the light-emitting body to be rendered can be determined first based on the refraction data and surface data of the light-emitting body corresponding to the sampling points before rendering, in order to improve rendering accuracy. As an example, the above step S340 may specifically include the following steps: determining the rendering data of the light-emitting body to be rendered based on the refraction data and surface data of the light-emitting body corresponding to the sampling points; rendering the light-emitting body to be rendered based on the rendering data to obtain the rendering result.
[0091] As an optional implementation, the body mapping data of the virtual light source on the light-emitting body to be rendered can be determined based on the light source size and the refraction data corresponding to the sampling points. This allows for more accurate rendering of the body mapping data corresponding to the virtual light source, thereby simulating a more realistic virtual light source transmission effect. As an example, the virtual light source also corresponds to a preset light source size; the determination of the rendering data of the light-emitting body to be rendered based on the refraction data corresponding to the sampling points and the surface data of the light-emitting body can specifically include the following steps:
[0092] Based on the light source size and the refraction data corresponding to the sampling points, determine the body mapping data of the virtual light source onto the light-emitting body to be rendered; based on the body mapping data and the surface data of the light-emitting body, determine the rendering data of the light-emitting body to be rendered.
[0093] In some embodiments, the size and shape of the virtual light source can be customized using the signed distance field function to more flexibly simulate anisotropic luminescence effects. Furthermore, the virtual light source can be estimated using the ontology mapping data of the virtual light source onto the object to be rendered, accurately restoring the physical state of the virtual light source inside the virtual translucent object. This supports normal rendering of light sources inside objects with low transparency, resulting in more accurate rendering of the light source effect. As an example, determining the ontology mapping data of the virtual light source onto the object to be rendered based on the light source size and the refraction data corresponding to the sampling points can specifically include the following steps:
[0094] The target symbolic distance field function corresponding to the virtual light source is determined based on the light source size; the target symbolic distance field function is used to characterize the light source shape and size of the virtual light source; the shortest distance from the sampling point to the virtual light source is obtained by calculating the target symbolic distance field function based on the sampling point; the ontology mapping data of the virtual light source onto the light source to be rendered is determined based on the shortest distance.
[0095] It should be noted that the signed distance field (SDF) is a directed or signed distance field. It is defined as follows: each pixel (voxel) records the distance between itself and the nearest object. If the pixel is inside an object, the distance is negative; if it is on the object's boundary, the distance is 0. Therefore, the SDF calculates the shortest distance from any point in space to a closed surface. The function value is a positive integer when the point is outside the surface, a negative integer when inside the surface, and 0 when on the surface. By using information such as the size and shape of the virtual light source, a target SDF expression that characterizes the shape and size of the light source can be determined, allowing for more accurate customization of the light source's shape and size.
[0096] As an optional implementation, the virtual light source can be shaped like a capsule, more closely resembling the effect of a real light source, to make the light transmission effect of the virtual light source more realistic. As an example, the virtual light source is capsule-shaped, and its size includes the radius parameters of the two semicircles within the capsule shape and the positions of their center points. The positions of the two center points characterize the height, orientation, and position of the virtual light source. The aforementioned determination of the target symbolic distance field function corresponding to the virtual light source based on its size can specifically include the following steps: determining the target symbolic distance field function corresponding to the virtual light source using the symbolic distance field function based on the radius parameters and the positions of the two center points.
[0097] Exemplarily, as Figure 13 shown, the capsule SDF function defined by two control points CP1, CP2 and radius R is selected to describe the shape of the light source. That is, CP1, CP2, and R are parameters representing the shape of the capsule. 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 surface of the capsule 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 Figure 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 length of the vector Cp1->SP, and when L > 1, the required distance is equal to the length of the vector 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 process described above, which calculates the shortest distance from the sampling point to the virtual light source using the target symbolic distance field function based on the sampling point, is performed. For example, the first sampling point SampleP1 and the second sampling point SampleP2 are substituted into the target symbolic distance field function to calculate the distance parameters, obtaining 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. The final distance field data SD is then calculated based on the orientation and positional relationship. For instance, the calculated two sampling points are substituted 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 process described above, which determines the body mapping data of the virtual light source onto the light-emitting body to be rendered based on the shortest distance, is executed. For example, the body mapping data of the virtual light source onto the light-emitting body to be rendered is calculated based on the shortest distance SD, i.e., SDL = max(-SD, 0), and the rendering result is as follows. Figure 14 As shown.
[0102] In existing technologies, conventional rendering pipelines follow an opacity blending strategy, which can obscure internal light sources at low opacity levels and prevent proper scattering calculations, thus unduly weakening the light source effect. However, in this embodiment, the virtual light source is estimated using the ontology mapping data of the virtual light source onto the light source to be rendered. This allows for a more accurate reconstruction of the physical state of the virtual light source within the virtual translucent object (the light source to be rendered). Therefore, it does not rely on semi-transparency blending, supports normal rendering of internal light sources in low-opacity objects, and renders the light source effect more accurately.
[0103] In some embodiments, the body mapping data of the virtual light source can be combined with a scattering effect to achieve a rendering effect of a light source with scattering physical properties, thereby improving the realism 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 surface data of the light source may specifically include the following steps:
[0104] Based on the shortest distance and scattering distance, determine the scattering data of the virtual light source; based on the body mapping data and scattering data, determine the overall mapping data of the virtual light source onto the light source to be rendered; based on the overall mapping data and the surface data of the light source, determine the rendering data of the light source to be rendered.
[0105] In this embodiment of the disclosure, the scattering data of the virtual light source can be determined based on the shortest distance calculated above and the preset scattering distance corresponding to the virtual light source. For example, the scattering data of the virtual light source is SDS = 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 process described above, which determines the overall mapping data of the virtual light source onto the luminous body to be rendered based on the ontological mapping data and scattering data, is executed. By simulating the scattering part using a Gaussian function and combining it with the value function of the natural constant e, a luminous body rendering effect with an apparent correct sense of space and scattering physical properties is achieved.
[0107] Furthermore, it should be noted that in the process of calculating the shortest distance from the two sampling points to the closed surface formed by the capsule (virtual light source), the target symbolic distance field function value is a positive integer when the point is outside the surface, a negative value when the point is inside the surface, and 0 when the point is on the boundary of the surface. Therefore, the shortest distances SD1 and SD2 obtained by substituting the two sampling points P1 and P2 into the expression of the target symbolic distance field function can be used to determine whether the ray refracted by the image acquisition line of sight intersects with the virtual light source, thus deciding whether to render both the virtual light source and its scattering data, or only the scattering data, thereby further improving the realism of the rendering effect. As an example, after calculating the shortest distance from the sampling point to the virtual light source based on the target symbolic distance field function, the method can further include the following steps:
[0108] If the shortest distance is less than or equal to zero, the sampling point is determined to be located on the virtual light source and the ray is determined to intersect with the virtual light source. The luminous body to be rendered is then determined to be rendered based on the body mapping data and scattering data. If the shortest distance is greater than zero, the sampling point is determined to be located outside the virtual light source and the ray is determined not to intersect with the virtual light source. The luminous body to be rendered is then determined to be rendered based on the scattering data.
[0109] In some embodiments, the virtual light source's body mapping data not only incorporates scattering effects but also the virtual light source's color, intensity, and scattering intensity to achieve a more realistic rendering effect. As an example, the virtual light source corresponds to preset light source color, preset light source intensity parameters, and preset scattering intensity parameters. The aforementioned determination of the overall mapping data of the virtual light source onto the light source to be rendered, based on the body mapping data and scattering data, may specifically include the following steps: determining the overall mapping data of the virtual light source onto the light source to be rendered based on the body mapping data, scattering data, light source color, light source intensity parameters, and scattering intensity parameters.
[0110] For the overall mapping data of the virtual light source onto the light source to be rendered, for example, the FinalColor of the overall mapping data is: FinalColor = SDS * ScatterStrength * LightColor + SDL * SourceStrength * LightColor, where: ScatterStrength is the scattering intensity adjustment parameter, with a value range of [0, infinity); SourceStrength is the light source intensity adjustment parameter, with a value range of [0, infinity); and LightColor is the light source color, which is an RGB value, with each value ranging from [0, 1]. The overall mapping result after combining the virtual light source's body mapping data and scattering data is as follows: Figure 15 As shown.
[0111] Finally, the process described above for determining the rendering data of the light source to be rendered based on the overall mapping data and the surface data of the light source is executed. For example, by superimposing the rendering calculation results of the overall mapping results with information such as the surface color, surface texture, and transmittance of the light source to be rendered, the final rendering result of the light source to be rendered can be obtained. For example, the final rendering result of the light source to be rendered, FinalResult = FinalColor * SurfaceOpacity * SurfaceColor; where SurfaceOpacity is provided by a separate texture, such as... Figure 16 As shown, the data represents grayscale values from 0 to 1; the smaller the value, the worse the light transmittance. The final rendering effect of the luminous object is as follows. Figure 17 The image shows the rendering effect of the light source after parameter mixing with the surface data of the light source. Through this method, the virtual light source's body mapping data not only incorporates scattering effects but also the light source's color, intensity, and scattering intensity, thus achieving a more realistic rendering effect.
[0112] Figure 18A schematic diagram of a virtual scene rendering device is provided. This 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 of the light source to be rendered is used to characterize the surface properties of the light source. Figure 18 As shown, the virtual scene rendering device 1800 includes:
[0113] The first determining module 1801 is used to determine, according to the preset refractive index, the ray after the image acquisition line of the virtual camera is refracted through the surface of the light-emitting body to be rendered; wherein, the virtual camera is used to acquire images in the virtual scene, and the image acquisition line is a line connecting the virtual camera to the light-emitting body to be rendered.
[0114] The second determining module 1802 is used to determine sampling points on the ray based on the ray, the orientation of the light source, and the position of the light source; wherein the sampling points are used to sample refraction data related to the light source to be rendered; the light source to be rendered corresponds to preset light source surface data;
[0115] The rendering module 1803 is used to render the light-emitting body to be rendered based on the refraction data and the surface data of the light-emitting body corresponding to the sampling point, and obtain the rendering result.
[0116] In this way, an image acquisition line of sight is emitted from the virtual camera toward the light source to be rendered. When the image acquisition line of sight touches the surface of the light source, the refractive index, which reflects the surface properties of the light source, is used to determine the ray refracted by the line of sight through the surface. Then, by using the ray and the orientation and position of the virtual light source, sampling points that reflect the refraction of the light source to be rendered are determined on the ray. This allows the light source to be rendered based on the refraction data of the sampling points and the light source's own data, thus preserving the physical properties of refraction and making the rendering of the light source more in line with physical laws. This results in a more realistic sense of space and improves the realism of the virtual scene, alleviating the technical problem of low realism in the rendered virtual scene.
[0117] In one feasible implementation, the second determining module is specifically used for:
[0118] Determine the contact point of the virtual camera's image acquisition line of sight on the surface of the light source to be rendered, relative to the normal direction of the surface;
[0119] Based on the normal direction and the preset refractive index, the ray refracted by the image acquisition line of sight after passing through the surface of the light source to be rendered is determined.
[0120] In one feasible implementation, the third determining module is specifically used for:
[0121] Two first directions are selected based on the orientation of the light source; wherein the two first directions are perpendicular to each other and both are perpendicular to the orientation of the light source;
[0122] Determine a second direction from the center point of the light source location to the current camera position of the virtual camera;
[0123] Determine the projection direction of the second direction onto the plane formed by the two first directions;
[0124] Determine a first plane that passes through the center point of the light source position and is perpendicular to the second direction;
[0125] Determine a second plane that passes through the center point of the light source position and is perpendicular to the projection direction;
[0126] On the ray, determine a first intersection point between the ray and the first plane, and a second intersection point between the ray and the second plane; wherein the first intersection point and the second intersection point are two sampling points used to sample refraction data related to the light source to be rendered.
[0127] In one feasible implementation, the third determining module is specifically used for:
[0128] The UV data structure of the model mesh corresponding to the light source 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 corresponding three-dimensional coordinate system of the virtual scene;
[0129] Based on the ray, the current camera position of the virtual camera, the position coordinates of the light source, and the orientation coordinates of the light source, a sampling point is determined on the ray.
[0130] In one feasible implementation, the rendering module is specifically used for:
[0131] Based on the refraction data corresponding to the sampling points and the surface data of the light source, the rendering data of the light source to be rendered is determined;
[0132] The luminous body to be rendered is rendered based on the rendering data to obtain the rendering result.
[0133] In one feasible implementation, the virtual light source also corresponds to a preset light source size; the rendering module is further used for:
[0134] Based on the light source size and the refraction data corresponding to the sampling point, determine the body mapping data of the virtual light source onto the light source to be rendered;
[0135] Based on the ontology mapping data and the surface data of the luminous body, the rendering data of the luminous body to be rendered is determined.
[0136] In one feasible implementation, the rendering module is specifically used for:
[0137] The target symbol distance field function corresponding to the virtual light source is determined based on the light source size; the target symbol distance field function is used to characterize the light source shape and the light source size of the virtual light source;
[0138] The shortest distance from the sampling point to the virtual light source is calculated using the target symbol distance field function based on the sampling point.
[0139] The ontology mapping data of the virtual light source on the light source to be rendered is determined based on the shortest distance.
[0140] In one feasible implementation, the virtual light source corresponds to a preset scattering distance; the rendering module is further used for:
[0141] The scattering data of the virtual light source is determined based on the shortest distance and the scattering distance;
[0142] Based on the ontology mapping data and the scattering data, determine the overall mapping data of the virtual light source onto the light source to be rendered;
[0143] Based on the overall mapping data and the surface data of the light source, the rendering data of the light source to be rendered is determined.
[0144] In one feasible implementation, 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 for:
[0145] Based on the ontology mapping data, the scattering data, the light source color, the light source intensity parameter, and the scattering intensity parameter, the overall mapping data of the virtual light source on the light source to be rendered is determined.
[0146] In one feasible implementation, the device further includes:
[0147] The fourth determining module is used to determine the shortest distance from the sampling point to the virtual light source after calculating the shortest distance based on the sampling point using the target symbolic distance field function. If the shortest distance is less than or equal to zero, the module determines that the sampling point is located on the virtual light source and that the ray intersects the virtual light source, and determines that the light source to be rendered is rendered based on the body mapping data and the scattering data. If the shortest distance is greater than zero, the module determines that the sampling point is located outside the virtual light source and that the ray does not intersect the virtual light source, and determines that the light source to be rendered is rendered based on the scattering data.
[0148] In one feasible implementation, the virtual light source is in the shape of a capsule, and the size of the light source includes the radius parameters of two semicircles in the capsule shape and the center point positions of the two semicircles. The two center point positions are used to characterize the light source height, the light source orientation, and the light source position of the virtual light source. The rendering module is further configured to: determine the target symbolic distance field function corresponding to the virtual light source by means of the symbolic distance field function based on the radius parameters and the two center point positions.
[0149] In one feasible implementation, the surface data of the light source includes at least one of the following: the surface color, surface transmittance, and surface texture of the light source to be rendered.
[0150] In one feasible implementation, the virtual scene further includes a virtual light-transmitting body; the device further includes: a fifth determining module, used to determine the virtual light-transmitting body as the light-transmitting body to be rendered before determining the ray after the image acquisition line of the virtual camera is refracted through the surface of the light-emitting body to be rendered, in response to the spatial positional relationship of the virtual light source, the virtual camera and the virtual light-transmitting body satisfying a preset condition.
[0151] In a feasible implementation, the spatial relationship between the virtual light source, the virtual camera, and the virtual transparent body satisfies the following preset conditions: if the virtual transparent body is an enclosing structure, then the virtual light source is located inside the virtual transparent body, and the virtual camera is located outside the virtual transparent body; if the virtual transparent body is a planar structure, then the virtual light source is located on one side of the virtual transparent body, and the virtual camera is located on the other side of the virtual transparent body.
[0152] The virtual scene rendering apparatus provided in this embodiment has the same technical features as the virtual scene rendering method provided in the above embodiments, so it can also solve the same technical problems and achieve the same technical effects.
[0153] Figure 19The diagram illustrates the structure of an electronic device according to an embodiment of this disclosure, including a memory 1901, a processor 1902, and a bus 1903. The memory 1901 stores machine-readable instructions executable by the processor 1902. When the electronic device runs a virtual scene rendering method as described in the embodiment, the processor 1902 communicates with the memory 1901 via the bus 1903. The processor 1902 executes the machine-readable instructions. The preamble of the method item of the processor 1902 performs the following steps:
[0154] Based on the preset refractive index, the ray of the image acquisition line of the virtual camera after refraction through the surface of the light source to be rendered is determined; wherein, the virtual camera is used to acquire images in the virtual scene, and the image acquisition line is a line connecting the virtual camera to the light source to be rendered;
[0155] Based on the ray, the orientation of the light source, and the position of the light source, sampling points are determined on the ray; wherein, the sampling points are used to sample refraction data related to the light source to be rendered; the light source to be rendered corresponds to preset light source surface data;
[0156] Based on the refraction data and the surface data of the light source corresponding to the sampling point, the light source to be rendered is rendered to obtain the rendering result.
[0157] In one feasible implementation, when the processor executes the process of determining the ray refracted by the virtual camera's image acquisition line of sight through the surface of the light source to be rendered, based on the preset refractive index, it is specifically used for:
[0158] Determine the contact point of the virtual camera's image acquisition line of sight on the surface of the light source to be rendered, relative to the normal direction of the surface;
[0159] Based on the normal direction and the preset refractive index, the ray refracted by the image acquisition line of sight after passing through the surface of the light source to be rendered is determined.
[0160] In one feasible implementation, when the processor determines a sampling point on the ray based on the ray, the light source orientation, and the light source position, it is specifically used for:
[0161] Two first directions are selected based on the orientation of the light source; wherein the two first directions are perpendicular to each other and both are perpendicular to the orientation of the light source;
[0162] Determine a second direction from the center point of the light source location to the current camera position of the virtual camera;
[0163] Determine the projection direction of the second direction onto the plane formed by the two first directions;
[0164] Determine a first plane that passes through the center point of the light source position and is perpendicular to the second direction;
[0165] Determine a second plane that passes through the center point of the light source position and is perpendicular to the projection direction;
[0166] On the ray, determine a first intersection point between the ray and the first plane, and a second intersection point between the ray and the second plane; wherein the first intersection point and the second intersection point are two sampling points used to sample refraction data related to the light source to be rendered.
[0167] In one feasible implementation, when the processor determines a sampling point on the ray based on the ray, the light source orientation, and the light source position, it is specifically used for:
[0168] The UV data structure of the model mesh corresponding to the light source 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 corresponding three-dimensional coordinate system of the virtual scene;
[0169] Based on the ray, the current camera position of the virtual camera, the position coordinates of the light source, and the orientation coordinates of the light source, a sampling point is determined on the ray.
[0170] In a feasible implementation, when the processor renders the light source to be rendered based on the refraction data and the surface data of the light source corresponding to the sampling points, and obtains the rendering result, it is specifically used for:
[0171] Based on the refraction data corresponding to the sampling points and the surface data of the light source, the rendering data of the light source to be rendered is determined;
[0172] The luminous body to be rendered is rendered based on the rendering data to obtain the rendering result.
[0173] In one feasible implementation, 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 based on the refraction data corresponding to the sampling point and the surface data of the light source, it is specifically used for:
[0174] Based on the light source size and the refraction data corresponding to the sampling point, determine the body mapping data of the virtual light source onto the light source to be rendered;
[0175] Based on the ontology mapping data and the surface data of the luminous body, the rendering data of the luminous body to be rendered is determined.
[0176] In one feasible implementation, when the processor executes the body mapping data of the virtual light source mapped onto the light source to be rendered based on the light source size and the refraction data corresponding to the sampling points, it is specifically used for:
[0177] The target symbol distance field function corresponding to the virtual light source is determined based on the light source size; the target symbol distance field function is used to characterize the light source shape and the light source size of the virtual light source;
[0178] The shortest distance from the sampling point to the virtual light source is calculated using the target symbol distance field function based on the sampling point.
[0179] The ontology mapping data of the virtual light source on the light source to be rendered is determined based on the shortest distance.
[0180] In one feasible implementation, the virtual light source corresponds to a preset scattering distance; when the processor determines the rendering data of the light source to be rendered based on the body mapping data and the surface data of the light source, it is specifically used for:
[0181] The scattering data of the virtual light source is determined based on the shortest distance and the scattering distance;
[0182] Based on the ontology mapping data and the scattering data, determine the overall mapping data of the virtual light source onto the light source to be rendered;
[0183] Based on the overall mapping data and the surface data of the light source, the rendering data of the light source to be rendered is determined.
[0184] In one feasible implementation, 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 executes the process of determining the overall mapping data of the virtual light source onto the light source to be rendered based on the body mapping data and the scattering data, it is specifically used for:
[0185] Based on the ontology mapping data, the scattering data, the light source color, the light source intensity parameter, and the scattering intensity parameter, the overall mapping data of the virtual light source on the light source to be rendered is determined.
[0186] In one feasible implementation, after calculating the shortest distance from the sampling point to the virtual light source based on the target symbolic distance field function, the processor is further configured 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 light source 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 with the virtual light source, and it is determined that the light source to be rendered is rendered based on the scattering data.
[0188] In one feasible implementation, the virtual light source is capsule-shaped, and the light source size includes the radius parameters of two semicircles within the capsule shape and the center positions of the two semicircles. The two center positions are used to characterize the light source height, light source orientation, and light source position of the virtual light source. When the processor executes the determination of the target symbolic distance field function corresponding to the virtual light source based on the light source size, it is specifically used for:
[0189] Based on the radius parameter and the positions of the two center points, the target symbolic distance field function corresponding to the virtual light source is determined by the symbolic distance field function.
[0190] In one feasible implementation, the surface data of the light source includes at least one of the following: the surface color, surface transmittance, and surface texture of the light source to be rendered.
[0191] In one feasible implementation, the virtual scene further includes a virtual translucent body; before determining the ray refracted by the virtual camera's image acquisition line of sight through the surface of the light source to be rendered according to the preset refractive index, the processor is further configured to: in response to the spatial positional 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 light source to be rendered.
[0192] In a feasible implementation, the spatial relationship between the virtual light source, the virtual camera, and the virtual light-transmitting body satisfies the following preset conditions: if the virtual light-transmitting body is an enclosing structure, then 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, then 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] In this way, an image acquisition line of sight is emitted from the virtual camera toward the light source to be rendered. When the image acquisition line of sight touches the surface of the light source, the refractive index, which reflects the surface properties of the light source, is used to determine the ray refracted by the line of sight through the surface. Then, by using the ray and the orientation and position of the virtual light source, sampling points that reflect the refraction of the light source to be rendered are determined on the ray. This allows the light source to be rendered based on the refraction data of the sampling points and the light source's own data, thus preserving the physical properties of refraction and making the rendering of the light source more in line with physical laws. This results in a more realistic sense of space and improves the realism of the virtual scene, alleviating the technical problem of low realism in the rendered virtual scene.
[0194] In practical applications, the memory 1901 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 1904 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc.
[0195] The bus 1903 can be an ISA bus, PCI bus, or EISA bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 19 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0196] The memory 1901 is used to store programs. After receiving an execution instruction, the processor 1902 executes the program. The method executed by the apparatus defined by the process disclosed in any of the foregoing embodiments of this 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 implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 1902 or by instructions in software form. The processor 1902 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may 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 gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 1901. Processor 1902 reads the information in memory 1901 and, in conjunction with its hardware, completes the steps of the above method.
[0198] This disclosure also provides a computer-readable storage medium storing a computer program that is executed by a processor, wherein the processor performs the following steps:
[0199] Based on the preset refractive index, the ray of the image acquisition line of the virtual camera after refraction through the surface of the light source to be rendered is determined; wherein, the virtual camera is used to acquire images in the virtual scene, and the image acquisition line is a line connecting the virtual camera to the light source to be rendered;
[0200] Based on the ray, the orientation of the light source, and the position of the light source, sampling points are determined on the ray; wherein, the sampling points are used to sample refraction data related to the light source to be rendered; the light source to be rendered corresponds to preset light source surface data;
[0201] Based on the refraction data and the surface data of the light source corresponding to the sampling point, the light source to be rendered is rendered to obtain the rendering result.
[0202] In one feasible implementation, when the processor executes the process of determining the ray refracted by the virtual camera's image acquisition line of sight through the surface of the light source to be rendered, based on the preset refractive index, it is specifically used for:
[0203] Determine the contact point of the virtual camera's image acquisition line of sight on the surface of the light source to be rendered, relative to the normal direction of the surface;
[0204] Based on the normal direction and the preset refractive index, the ray refracted by the image acquisition line of sight after passing through the surface of the light source to be rendered is determined.
[0205] In one feasible implementation, when the processor determines a sampling point on the ray based on the ray, the light source orientation, and the light source position, it is specifically used for:
[0206] Two first directions are selected based on the orientation of the light source; wherein the two first directions are perpendicular to each other and both are perpendicular to the orientation of the light source;
[0207] Determine a second direction from the center point of the light source location to the current camera position of the virtual camera;
[0208] Determine the projection direction of the second direction onto the plane formed by the two first directions;
[0209] Determine a first plane that passes through the center point of the light source position and is perpendicular to the second direction;
[0210] Determine a second plane that passes through the center point of the light source position and is perpendicular to the projection direction;
[0211] On the ray, determine a first intersection point between the ray and the first plane, and a second intersection point between the ray and the second plane; wherein the first intersection point and the second intersection point are two sampling points used to sample refraction data related to the light source to be rendered.
[0212] In one feasible implementation, when the processor determines a sampling point on the ray based on the ray, the light source orientation, and the light source position, it is specifically used for:
[0213] The UV data structure of the model mesh corresponding to the light source 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 corresponding three-dimensional coordinate system of the virtual scene;
[0214] Based on the ray, the current camera position of the virtual camera, the position coordinates of the light source, and the orientation coordinates of the light source, a sampling point is determined on the ray.
[0215] In a feasible implementation, when the processor renders the light source to be rendered based on the refraction data and the surface data of the light source corresponding to the sampling points, and obtains the rendering result, it is specifically used for:
[0216] Based on the refraction data corresponding to the sampling points and the surface data of the light source, the rendering data of the light source to be rendered is determined;
[0217] The luminous body to be rendered is rendered based on the rendering data to obtain the rendering result.
[0218] In one feasible implementation, 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 based on the refraction data corresponding to the sampling point and the surface data of the light source, it is specifically used for:
[0219] Based on the light source size and the refraction data corresponding to the sampling point, determine the body mapping data of the virtual light source onto the light source to be rendered;
[0220] Based on the ontology mapping data and the surface data of the luminous body, the rendering data of the luminous body to be rendered is determined.
[0221] In one feasible implementation, when the processor executes the body mapping data of the virtual light source mapped onto the light source to be rendered based on the light source size and the refraction data corresponding to the sampling points, it is specifically used for:
[0222] The target symbol distance field function corresponding to the virtual light source is determined based on the light source size; the target symbol distance field function is used to characterize the light source shape and the light source size of the virtual light source;
[0223] The shortest distance from the sampling point to the virtual light source is calculated using the target symbol distance field function based on the sampling point.
[0224] The ontology mapping data of the virtual light source on the light source to be rendered is determined based on the shortest distance.
[0225] In one feasible implementation, the virtual light source corresponds to a preset scattering distance; when the processor determines the rendering data of the light source to be rendered based on the body mapping data and the surface data of the light source, it is specifically used for:
[0226] The scattering data of the virtual light source is determined based on the shortest distance and the scattering distance;
[0227] Based on the ontology mapping data and the scattering data, determine the overall mapping data of the virtual light source onto the light source to be rendered;
[0228] Based on the overall mapping data and the surface data of the light source, the rendering data of the light source to be rendered is determined.
[0229] In one feasible implementation, 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 executes the process of determining the overall mapping data of the virtual light source onto the light source to be rendered based on the body mapping data and the scattering data, it is specifically used for:
[0230] Based on the ontology mapping data, the scattering data, the light source color, the light source intensity parameter, and the scattering intensity parameter, the overall mapping data of the virtual light source on the light source to be rendered is determined.
[0231] In one feasible implementation, after calculating the shortest distance from the sampling point to the virtual light source based on the target symbolic distance field function, the processor is further configured 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 light source 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 with the virtual light source, and it is determined that the light source to be rendered is rendered based on the scattering data.
[0233] In one feasible implementation, the virtual light source is capsule-shaped, and the light source size includes the radius parameters of two semicircles within the capsule shape and the center positions of the two semicircles. The two center positions are used to characterize the light source height, light source orientation, and light source position of the virtual light source. When the processor executes the determination of the target symbolic distance field function corresponding to the virtual light source based on the light source size, it is specifically used for:
[0234] Based on the radius parameter and the positions of the two center points, the target symbolic distance field function corresponding to the virtual light source is determined by the symbolic distance field function.
[0235] In one feasible implementation, the surface data of the light source includes at least one of the following: the surface color, surface transmittance, and surface texture of the light source to be rendered.
[0236] In one feasible implementation, the virtual scene further includes a virtual translucent body; before determining the ray refracted by the virtual camera's image acquisition line of sight through the surface of the light source to be rendered according to the preset refractive index, the processor is further configured to: in response to the spatial positional 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 light source to be rendered.
[0237] In a feasible implementation, the spatial relationship between the virtual light source, the virtual camera, and the virtual light-transmitting body satisfies the following preset conditions: if the virtual light-transmitting body is an enclosing structure, then 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, then 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] In this way, an image acquisition line of sight is emitted from the virtual camera toward the light source to be rendered. When the image acquisition line of sight touches the surface of the light source, the refractive index, which reflects the surface properties of the light source, is used to determine the ray refracted by the line of sight through the surface. Then, by using the ray and the orientation and position of the virtual light source, sampling points that reflect the refraction of the light source to be rendered are determined on the ray. This allows the light source to be rendered based on the refraction data of the sampling points and the light source's own data, thus preserving the physical properties of refraction and making the rendering of the light source more in line with physical laws. This results in a more realistic sense of space and improves the realism of the virtual scene, alleviating the technical problem of low realism in the rendered virtual scene.
[0239] In this embodiment of the disclosure, the computer program, when run by the processor, can also execute other machine-readable instructions to perform other methods as described in the embodiments. For details on the specific execution steps and principles, please refer to the description of the embodiments, which will not be repeated here.
[0240] In the embodiments provided in this disclosure, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings or direct couplings or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0241] For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0242] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0243] In addition, the functional units in the embodiments provided in this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0244] If the aforementioned functions are implemented as 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 this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the virtual scene rendering method described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0245] It should be noted that similar labels and letters in the following figures indicate similar items. 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 used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0246] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this disclosure. All should be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by 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 has a preset light source position and a preset light source orientation. The preset refractive index of the light source to be rendered is used to characterize the surface properties of the light source to be rendered. The method includes: Based on the preset refractive index, the ray of the image acquisition line of the virtual camera after refraction through the surface of the light source to be rendered is determined; wherein, the virtual camera is used to acquire images in the virtual scene, and the image acquisition line is a line connecting the virtual camera to the light source to be rendered; Based on the ray, the orientation of the light source, and the position of the light source, sampling points are determined on the ray; wherein, the sampling points are used to sample refraction data related to the light source to be rendered; the light source to be rendered corresponds to preset light source surface data; Based on the refraction data and the surface data of the light source corresponding to the sampling point, the light source to be rendered is rendered to obtain the rendering result.
2. The method according to claim 1, characterized in that, The step of determining the ray refracted by the virtual camera's image acquisition line of sight through the surface of the light source to be rendered, based on the preset refractive index, includes: Determine the contact point of the virtual camera's image acquisition line of sight on the surface of the light source to be rendered, relative to the normal direction of the surface; Based on the normal direction and the preset refractive index, the ray refracted by the image acquisition line of sight after passing through the surface of the light source to be rendered is determined.
3. The method according to claim 1, characterized in that, The step of determining sampling points on the ray based on the ray, the orientation of the light source, and the position of the light source includes: Two first directions are selected based on the orientation of the light source; wherein the two first directions are perpendicular to each other and both are perpendicular to the orientation of the light source; Determine a second direction from the center point of the light source location to the current camera position of the virtual camera; Determine the projection direction of the second direction onto the plane formed by the two first directions; Determine a first plane that passes through the center point of the light source position and is perpendicular to the second direction; Determine a second plane that passes through the center point of the light source position and is perpendicular to the projection direction; On the ray, determine a first intersection point between the ray and the first plane, and a second intersection point between the ray and the second plane; wherein the first intersection point and the second intersection point are two sampling points used to sample refraction data related to the light source to be rendered.
4. The method according to claim 1, characterized in that, The step of determining sampling points on the ray based on the ray, the orientation of the light source, and the position of the light source includes: The UV data structure of the model mesh corresponding to the light source 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 corresponding three-dimensional coordinate system of the virtual scene; Based on the ray, the current camera position of the virtual camera, the position coordinates of the light source, and the orientation coordinates of the light source, a sampling point is determined on the ray.
5. The method according to claim 1, characterized in that, The rendering of the light source to be rendered is performed based on the refraction data and the surface data of the light source corresponding to the sampling points, and the rendering result is obtained, including: Based on the refraction data corresponding to the sampling points and the surface data of the light source, the rendering data of the light source to be rendered is determined; The luminous body to be rendered is rendered based on the rendering data to obtain the 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 based on the refraction data corresponding to the sampling points and the surface data of the light source includes: Based on the light source size and the refraction data corresponding to the sampling point, determine the body mapping data of the virtual light source onto the light source to be rendered; Based on the ontology mapping data and the surface data of the luminous body, the rendering data of the luminous body to be rendered is determined.
7. The method according to claim 6, characterized in that, The step of determining the ontology mapping data of the virtual light source onto the light source to be rendered, based on the light source size and the refraction data corresponding to the sampling points, includes: The target symbol distance field function corresponding to the virtual light source is determined based on the light source size; the target symbol distance field function is used to characterize the light source shape and the light source size of the virtual light source; The shortest distance from the sampling point to the virtual light source is calculated using the target symbol distance field function based on the sampling point. The ontology mapping data of the virtual light source on the light source to be rendered is determined based on 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 source to be rendered based on the body mapping data and the light source surface data includes: The scattering data of the virtual light source is determined based on the shortest distance and the scattering distance; Based on the ontology mapping data and the scattering data, determine the overall mapping data of the virtual light source onto the light source to be rendered; Based on the overall mapping data and the surface data of the light source, the rendering data of the light source to be rendered is determined.
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 virtual light source onto the light source to be rendered, based on the body mapping data and the scattering data, includes: Based on the ontology mapping data, the scattering data, the light source color, the light source intensity parameter, and the scattering intensity parameter, the overall mapping data of the virtual light source on the light source to be rendered is determined.
10. The method according to claim 8, characterized in that, After calculating the shortest distance from the sampling point to the virtual light source based on the target symbolic distance field function using the sampling point, the process includes: If the shortest distance is less than or equal to zero, then it is determined that the sampling point is located on the virtual light source and that the ray intersects with the virtual light source, and that the light source 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 outside the virtual light source and that the ray does not intersect with the virtual light source, and it is determined that the light source to be rendered is 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. The size of the light source includes the radius parameters of the two semicircles in the capsule shape and the position of the center point of the two semicircles. The two center point positions are used to characterize the height of the virtual light source, the orientation of the light source, and the position of the light source. The step of determining the target symbol distance field function corresponding to the virtual light source based on the light source size includes: Based on the radius parameter and the positions of the two center points, the target symbolic distance field function corresponding to the virtual light source is determined by the symbolic distance field function.
12. The method according to claim 1, characterized in that, The surface data of the luminescent body includes at least one of the following: The surface color, surface transmittance, and surface texture of the light source 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 ray refracted by the virtual camera's image acquisition line of sight through the surface of the light-transmitting body according to the preset refractive index, the method further includes: In response to the spatial relationship between the virtual light source, the virtual camera, and the virtual translucent body satisfying a preset condition, the virtual translucent body is identified as the light source to be rendered.
14. The method according to claim 13, characterized in that, The spatial relationship between the virtual light source, the virtual camera, and the virtual light-transmitting body satisfies the following preset conditions: If the virtual light-transmitting body is an enclosed structure, then 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, then 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 rendering device for 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 has a preset light source position and a preset light source orientation. The preset refractive index of the light source to be rendered is used to characterize the surface properties of the light source to be rendered. The device includes: The first determining module is used to determine, based on the preset refractive index, the ray after the image acquisition line of the virtual camera is refracted through the surface of the light-emitting body to be rendered; wherein, the virtual camera is used to acquire images in the virtual scene, and the image acquisition line is a line connecting the virtual camera to the light-emitting body to be rendered; The second determining module is used to determine sampling points on the ray based on the ray, the orientation of the light source, and the position of the light source; wherein the sampling points are used to sample refraction data related to the light source to be rendered; the light source to be rendered corresponds to preset light source surface data; The rendering module is used to render the light-emitting body to be rendered based on the refraction data and the surface data of the light-emitting body corresponding to the sampling point, and obtain the rendering result.
16. An electronic terminal, comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 14.
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions that, when invoked and executed by a processor, cause the processor to perform the method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Three-dimensional model rendering method, rendering device, equipment and medium
CN116310056A
Method and device for rendering virtual model, storage medium and electronic equipment
CN117036573A