Volume object rendering method and device, equipment and storage medium
By obtaining the shape profile of the volume object and performing density and shadow sampling, the problem of poor rendering of volume objects in the prior art is solved, and a more realistic and efficient rendering effect is achieved.
Patent Information
- Application Number
- CN202311646237.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-01
- Publication Date
- 2025-06-03
AI Technical Summary
The existing technology cannot completely restore the spatial shape of volume objects, resulting in poor rendering effect.
By obtaining the shape profile of the volume object, characterize the heterogeneous volume object with a volume texture including a narrow band horizontal set of density, and perform density sampling and shadow sampling on the shape profile to determine the target radiance of the volume object in the observation direction.
The space modeling of volume objects is restored completely, the authenticity of the rendering effect is improved, and the rendering efficiency is improved by reducing memory usage.
Smart Images

Figure CN120088390A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of image rendering, and in particular, to a method, device, equipment, and storage medium for rendering volume objects. Background Art
[0002] When rendering a virtual environment, in order to improve the authenticity of the virtual environment, it is often necessary to render volume objects such as clouds, fog, and water vapor in the virtual environment.
[0003] In the related art, volume objects are usually limited within a spherical layer, a 2D Texture is used to control the horizontal distribution, and interpolation is used to control the vertical plane distribution, that is, 2.5D information is combined from 2D information to describe volume objects, and then the volume objects are rendered based on the 2.5D information.
[0004] However, the 2.5D information cannot completely restore the spatial shape of the volume object, resulting in poor rendering effects of the volume object. Summary of the Invention
[0005] The embodiments of the present application provide a method, device, equipment, and storage medium for rendering volume objects. The technical solutions are as follows:
[0006] On the one hand, the embodiments of the present application provide a method for rendering a volume object, the method including:
[0007] Obtain the shape profile of the volume object, the volume object being a heterogeneous volume object, and the shape profile being a volume texture of a narrowband level set including density;
[0008] Perform density sampling on the shape profile according to the viewing direction of the virtual camera, and determine the transmittance of the sampling points in the viewing direction according to the sampling point density;
[0009] Perform shadow sampling on the sampling points in the shape profile to obtain the radiance of the sampling points;
[0010] Determine the target radiance of the volume object in the viewing direction according to the transmittance and the radiance of each sampling point;
[0011] Render the volume object according to the target radiance in each viewing direction.
[0012] On the other hand, the embodiments of the present application provide a device for rendering a volume object, the device including:
[0013] An obtaining module, configured to obtain the shape profile of the volume object, the volume object being a heterogeneous volume object, and the shape profile being a volume texture of a narrowband level set including density;
[0014] The first sampling module is configured to perform density sampling on the shape profile according to the viewing direction of the virtual camera, and determine the transmittance of the sampling points in the viewing direction according to the sampling point density;
[0015] The second sampling module is configured to perform shadow sampling on the sampling points in the shape profile to obtain the radiance of the sampling points;
[0016] The determination module is configured to determine the target radiance of the volume object in the viewing direction according to the transmittance and the radiance of each sampling point;
[0017] The rendering module is configured to render the volume object according to the target radiance in each viewing direction.
[0018] On the other hand, an embodiment of the present application provides a computer device, which includes a processor and a memory. At least one instruction is stored in the memory, and the at least one instruction is loaded and executed by the processor to implement the rendering method of the volume object as described in the above aspect.
[0019] On the other hand, an embodiment of the present application provides a computer-readable storage medium, in which at least one instruction is stored, and the at least one instruction is loaded and executed by a processor to implement the rendering method of the volume object as described in the above aspect.
[0020] On the other hand, an embodiment of the present application provides a computer program product. The computer program product or the computer program product includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the rendering method of the volume object provided in the above aspect.
[0021] In the embodiments of the present application, by introducing the concept of a shape profile and using volume textures of narrowband level sets including density to represent heterogeneous volume objects, the spatial shape of the volume object can be completely restored. When rendering the volume object subsequently, by performing density sampling and shadow sampling on the shape profile, the accuracy of the transmittance and radiance of multiple sampling points in the viewing direction can be improved, thereby improving the accuracy of determining the target radiance in the viewing direction according to the radiance and transmittance, and finally improving the authenticity of the rendering effect of the volume object. Moreover, compared with voxel rendering, since the memory space occupied by the shape profile is smaller, the rendering efficiency of the volume object can be improved, and both the rendering efficiency and the rendering effect can be taken into account in a real-time rendering scenario. Description of the Drawings
[0022] Figure 1The figure shows a flowchart of a rendering method for a volume object provided by an exemplary embodiment of the present application;
[0023] Figure 2 It is a schematic diagram of a shape profile shown by an exemplary embodiment of the present application;
[0024] Figure 3 It is a schematic diagram of a ray marching sampling process shown by an exemplary embodiment of the present application;
[0025] Figure 4 It is a flowchart of a shape profile generation process shown by an exemplary embodiment of the present application;
[0026] Figure 5 It is an implementation schematic diagram of a shape profile generation process shown by an exemplary embodiment of the present application;
[0027] Figure 6 It is an implementation schematic diagram of a process for adjusting a sampling level according to a distance shown by an exemplary embodiment of the present application;
[0028] Figure 7 It is an implementation schematic diagram of shadow sampling shown by an exemplary embodiment of the present application;
[0029] Figure 8 It is a comparison diagram of the effects of single-scattering and multi-scattering rendering shown by an exemplary embodiment of the present application;
[0030] Figure 9 It is a schematic diagram of a volume cloud in a volume cloud built-in library shown by an exemplary embodiment of the present application;
[0031] Figure 10 It is a structural block diagram of a rendering device for a volume object provided by an exemplary embodiment of the present application;
[0032] Figure 11 The figure shows a schematic diagram of the structure of a computer device provided by an exemplary embodiment of the present application. Detailed implementation manners
[0033] To make the objectives, technical solutions, and advantages of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the accompanying drawings.
[0034] For the convenience of understanding, the following first explains the terms involved in the embodiments of the present application.
[0035] Inhomogeneous volume object: It refers to a volume object with different densities everywhere. Common inhomogeneous volume objects include clouds, smoke, fog, atmosphere, combustion medium, etc. The radiance of light propagating in an inhomogeneous volume object is mainly affected by three effects: absorption, emission, and scattering. The rendering method involved in the embodiments of this application is used to render inhomogeneous volume objects in real time in a virtual environment, such as rendering clouds in different forms in real time and rendering flowing smoke in real time in a virtual environment.
[0036] Shape profile: A volume texture used to describe the spatial shape and density distribution of an inhomogeneous volume object. In some embodiments, the shape profile is stored in the form of a two-dimensional texture atlas (2D Atlas Texture), which contains narrow-band level sets including density corresponding to different cross-sections in the inhomogeneous volume object, and the narrow-band level set is used to characterize the cross-section profile and the density distribution of the cross-section.
[0037] Raymarching: It refers to the process of sampling a ray in the observation direction at a certain step length in a volume object. During the sampling process, it is necessary to determine the radiance and transmittance of each sampling point, so as to determine the target radiance of the volume object in the observation direction based on the radiance and transmittance of multiple sampling points, so as to render the volume object based on the target radiance. The raymarching sampling process is called the main marching sampling. For the sampling points obtained by the main marching sampling, since the radiance of the sampling points is related to the light source, it is also necessary to further perform shadow sampling on the sampling points. Among them, shadow sampling refers to the process of determining shadow sampling points between the sampling point and the light source. Based on the radiance of the light source and the extinction situation of the shadow sampling points, the radiance at the sampling point can be determined.
[0038] The rendering method of the volume object provided by the embodiments of this application can be applied to a real-time volume renderer, and the real-time volume renderer can be applied to game development applications or game applications.
[0039] Game development scenario
[0040] Developers can select the volume objects to be added to the game virtual scene from the volume object library according to their needs. The real-time volume renderer generates the shape profile of the volume object based on the original voxel data of the volume object and renders the volume object based on the shape profile.
[0041] The real-time volume renderer also provides an editing function, through which developers can adjust the object parameters of the volume object and the rendering parameters during the rendering process, such as adjusting the number of main steps, the number of shadow sampling times, the detail scaling, the self-luminous coefficient of the volume object, the albedo, etc., so as to customize the rendering effect of the volume object.
[0042] Game application scenarios
[0043] The real-time volume renderer can obtain the shape profile of the volume object that needs to be rendered in the current virtual scene according to the virtual scene rendering requirements (the game application can directly store the shape profile, or store the original voxel data of the volume object, and the real-time volume renderer will perform real-time data conversion), and perform real-time rendering based on the shape profile and the current observation angle.
[0044] In some embodiments, the game application may provide some adjustment interfaces, through which the user can adjust the rendering effect of the volume object, such as adjusting the rendering refinement of the volume object. Of course, the game application may also automatically adjust the rendering effect of the volume object according to the complexity of the current virtual scene to ensure the smoothness of the game screen.
[0045] The volume object rendering method provided in the embodiments of the present application can be applied to electronic devices with volume object rendering requirements, such as smart phones, tablet computers, personal computers, wearable devices, workstations, etc. For the convenience of description, the following embodiments are described by taking the execution subject as a computer device as an example.
[0046] Figure 1 A flow chart of a method for rendering a volume object provided by an exemplary embodiment of the present application is shown. This embodiment is described by taking the method used in a computer device as an example, and the method includes the following steps.
[0047] Step 101 : obtaining a shape profile of a volume object, where the volume object is a non-homogeneous volume object and the shape profile is a volume texture including a narrow-band level set of density.
[0048] The heterogeneous volume object may be a virtual cloud, virtual smoke, virtual atmosphere, or virtual combustion medium, etc. In the following embodiments, the heterogeneous volume object is described as a virtual cloud, but this is not a limitation.
[0049] In some embodiments, the shape profile is obtained by converting original voxel data of the volume object by a computer device, or the shape profile of the volume object is stored in the computer device.
[0050] In the embodiments of the present application, the shape profile is a volumetric texture composed of several narrow-band level sets. Different narrow-band level sets are used to characterize the profile contours of different profiles of the volumetric object and the density distribution of the profile.
[0051] Optionally, the narrow-band level set is a two-dimensional texture image, and the two-dimensional texture image characterizes the density distribution through color.
[0052] Schematically, as Figure 2 shown, the shape profile 21 corresponding to the virtual cloud contains 21×18 narrow-band level sets 211. The narrow-band level sets 211 characterize the density distribution of the corresponding profile through the depth of color. Among them, the profile contours in the narrow-band level sets 211 show different density distributions, while the density inside the profile is 0.
[0053] Step 103, perform density sampling on the shape profile according to the viewing direction of the virtual camera, and determine the transmittance of the sampling points in the viewing direction according to the sampling point density.
[0054] In a possible implementation manner, the computer device performs volume rendering in a ray marching manner.
[0055] In some embodiments, during the ray marching process, the virtual camera emits a ray along the viewing direction, and a series of sampling points are determined along the ray according to the step size. For each sampling point, the computer device determines the narrow-band level set in which the sampling point is located in the shape profile, and then obtains the sampling point density of the sampling point from the narrow-band level set to complete the density sampling.
[0056] Optionally, the volumetric object corresponds to a bounding box. When the ray emitted by the virtual camera intersects with the bounding box, the computer device starts density sampling, and does not perform density sampling when the ray does not intersect with the bounding box.
[0057] Optionally, the bounding box is a Ray-AABB bounding box. The computer device can determine whether the ray intersects with the bounding box and the intersection position with the bounding box through a bounding box intersection test, and start density sampling based on the intersection position.
[0058] Since the final color presented by the volumetric object is related to the light transmitted through the volumetric object, and the density of the volumetric object affects the transmission of light, the computer device determines the transmittance of each sampling point in the viewing direction according to the sampling point density obtained by density sampling.
[0059] Among them, the transmittance is used to characterize the proportion of the remaining radiation after the light passes through the sampling point. Since the densities at different sampling points may be different, the transmittances corresponding to different sampling points may be different.
[0060] Schematically, as Figure 3As shown, the computer device performs density sampling according to the viewing direction of the virtual camera 31, and obtains the sampling point densities of the first sampling point 32, the second sampling point 33, the third sampling point 34, the fourth sampling point 35, and the fifth sampling point 36 respectively.
[0061] Step 105: Perform shadow sampling on the sampling points in the shape profile to obtain the radiance of the sampling points.
[0062] The above process of sampling along the viewing direction is called primary stepping sampling. Since the color presented by the volume object is also related to the radiance at the sampling point, in addition to primary stepping sampling, the computer device also needs to perform shadow sampling on the sampling points to obtain the radiance of the sampling points. Among them, the radiance is used to characterize the radiation intensity of light.
[0063] In some embodiments, the computer device performs shadow sampling between the light source and the sampling point to obtain a number of shadow sampling points. Since the light emitted by the light source will experience multiple attenuations during the process of reaching the sampling point, and the density of the participating medium at different shadow sampling points may be different (i.e., the degree of attenuation of light is different), the computer device needs to determine the shadow sampling point density at each shadow sampling point, and then determine the radiance of the sampling point based on the shadow sampling point density and the light source radiance of the light source.
[0064] In a possible implementation manner, the computer device determines the narrowband level set where the shadow sampling point is located in the shape profile, and then obtains the shadow sampling point density of the shadow sampling point from the narrowband level set.
[0065] Schematically, as Figure 3 shown, the computer device performs shadow sampling on the path between the first sampling point 32 and the light source 37, performs shadow sampling on the path between the second sampling point 33 and the light source 37, performs shadow sampling on the path between the third sampling point 34 and the light source 37, performs shadow sampling on the path between the fourth sampling point 35 and the light source 37, and performs shadow sampling on the path between the fifth sampling point 36 and the light source 37, so as to determine the radiance of each sampling point based on the shadow sampling point density of each shadow sampling point and the light source radiance of the light source 37.
[0066] Step 107: Determine the target radiance of the volume object in the viewing direction according to the transmittance and radiance of each sampling point.
[0067] Furthermore, the computer device performs radiance accumulation calculation based on the transmittance and radiance of each sampling point, so as to obtain the target radiance of the volume object in the viewing direction.
[0068] In a schematic example, the transmittances of the first sampling point 32 to the fifth sampling point 36 are T1, T2, T3, T4, and T5 in sequence, and the radiances of the first sampling point 32 to the fifth sampling point 36 are L1, L2, L3, L4, and L5 in sequence. Then, the target radiance of the volume object in this viewing direction is (L1 * T1) + L2 * (T1 * T2) + L3 * (T1 * T2 * T3) + L4 * (T1 * T2 * T3 * T4) + L5 * (T1 * T2 * T3 * T4 * T5).
[0069] Step 109: Render the volume object according to the target radiance in each viewing direction.
[0070] In a possible implementation, the computer device starts from a virtual camera and executes the above sampling process along different viewing directions to obtain the target radiance of the volume object in each viewing direction, so as to render the volume object based on the target radiance in different viewing directions.
[0071] In summary, in the embodiments of the present application, by introducing the concept of a shape profile and using the volume texture of a narrowband level set including density to characterize the heterogeneous volume object, the spatial shape of the volume object can be completely restored. When rendering the volume object subsequently, by performing density sampling and shadow sampling on the shape profile, the accuracy of the transmittance and radiance of multiple sampling points in the viewing direction can be improved, thereby improving the accuracy of determining the target radiance in the viewing direction based on the radiance and transmittance, and ultimately improving the authenticity of the rendering effect of the volume object. Moreover, compared with voxel rendering, since the memory space occupied by the shape profile is smaller, the rendering efficiency of the volume object can be improved, and the dual considerations of rendering efficiency and rendering effect can be achieved in a real-time rendering scenario.
[0072] Regarding the acquisition method of the shape profile, in a possible implementation, as Figure 4 shown, the above step 101 may include the following steps:
[0073] Step 101A: Perform level set partitioning on the volume object to obtain a plurality of narrowband level sets.
[0074] In some embodiments, the computer device performs level set partitioning on the volume object along a fixed direction to obtain a plurality of narrowband level sets. Wherein, the fixed direction may be a horizontal direction or a vertical direction, and this embodiment does not make a limitation thereon.
[0075] Schematically, as Figure 5 shown, the volume object 51 is composed of 4 * 4 * 4 voxels. The computer device performs level set partitioning on the voxel object 51 along the XY plane to obtain 4 narrowband level sets 52.
[0076] To improve rendering efficiency, in some embodiments, the computer device performs level set partitioning on a voxel file that supports the GPU to obtain a narrow band level set.
[0077] In a possible implementation, the computer device obtains the original voxel file of the volume object, and the original voxel file contains the voxel data of the volume object.
[0078] When the original voxel file is a first type of file, the computer device performs file conversion on the original voxel file to obtain a second type of file; when the original voxel file is a second type of file, the computer device directly generates a shape profile based on the original voxel file. Among them, the second type of file is a voxel file that supports the GPU (GPU-friendly).
[0079] Optionally, the computer device identifies the first type of file and the second type of file according to the file extension of the original voxel file.
[0080] Optionally, the way for the computer device to perform file conversion on the original voxel file can be GPU linear snapshot.
[0081] Generally, the voxel file of the volume object can be a VDB (Volumn DataBase) file or a NanoVBD file. Among them, the Nano VDB file is obtained by converting the VDB file through GPU linear snapshot, and quantization compression is performed during the conversion process. The specification of quantization compression can be 32bit, 16bit, 8bit, 4bit per voxel.
[0082] Compared with the VDB file, the Nano VDB file adds support for the GPU, so it can bring an order of magnitude acceleration to the rendering process. Therefore, during real-time rendering, the computer device performs level set partitioning on the volume object according to the Nano VDB file of the volume object to obtain multiple narrow band level sets.
[0083] In some embodiments, the computer device identifies whether the original voxel file is a VDB file or a Nano VDB file according to the file extension. Among them, when the file extension is ".vdb", the computer device calls the VDB library method to convert the VDB file into the corresponding GPU linear snapshot (that is, the Nano VDB file); when the file extension is ".nvdb", the computer device performs the subsequent shape profile conversion steps.
[0084] Step 101B, for each narrow band level set, convert the density value corresponding to the voxel in the narrow band level set into the color channel value of the target color channel to obtain the shape profile of the volume object.
[0085] In some embodiments, the computer device converts the density value corresponding to each voxel into a color channel value in the target color channel. After the above conversion operation, the narrowband level set is converted into a two-dimensional texture. Correspondingly, the density of the voxels in the narrowband level set is characterized by the pixel values of the pixels in the two-dimensional texture.
[0086] Schematically, as Figure 5 shown, the density values of the voxels in the narrowband level set 52 are converted into color channel values, obtaining the two-dimensional texture corresponding to the narrowband level set 52. When the voxel size is 8*8*8, the tiling resolution of the two-dimensional texture corresponding to the narrowband level set 52 is 32*32, and the tiling resolution of the finally generated shape profile 53 is 64*64, and the corresponding volume texture resolution is 32*32*4.
[0087] In a possible implementation manner, the process of converting the density value into a color channel value may include the following steps:
[0088] 1. Determine the maximum density value of the voxels in the volume object.
[0089] In a possible implementation manner, the computer device normalizes the density values of the voxels based on the voxel with the maximum density in the volume object, and converts the density value into a color channel value based on the normalization result.
[0090] In some embodiments, the computer device traverses the density values of the voxels in the volume object to determine the maximum density value.
[0091] 2. For each voxel, determine the ratio of the density value corresponding to the voxel to the maximum density value.
[0092] Further, the computer device calculates the ratio of the density value corresponding to each voxel to the maximum density value (a positive number less than or equal to 1), that is, obtains the density normalization result of each voxel.
[0093] 3. According to the ratio, convert the density value into a color channel value of the target color channel, obtaining the shape profile of the volume object.
[0094] Wherein, the target color channel may be a specified color channel in the color space. For example, for the RGB color space, the target color channel may be the R channel, the G channel or the B channel. Also for example, for the GRAY color space, the target color channel may be the gray channel. The embodiments of the present application do not limit the specific type of the target color channel.
[0095] In a possible implementation manner, the computer device determines the product of the ratio and the maximum color channel value of the target color channel as the color channel value corresponding to the voxel.
[0096] In a schematic example, when the maximum density value of the voxels in the volume object is 10, the density value of the current voxel is 5, and the channel value range of the target color channel is (0, 255), the color channel value corresponding to the current voxel is 128.
[0097] In the subsequent process, when performing density sampling on the shape profile, that is, obtaining the color channel value of the pixel corresponding to the sampling point in the target color channel, and determining the sampling point density based on this color channel value. Optionally, the computer device can restore the original sampling point density based on the maximum color channel value and the maximum density value of the target color channel for subsequent transmittance calculation. Of course, the computer device can directly use the color channel value as the sampling point density for subsequent transmittance calculation.
[0098] Furthermore, the shape profile of the volume object is finally serialized and written to the disk in the form of a volume texture for subsequent use.
[0099] From Figure 2 It can be seen that since the conversion and writing processes are dense, some invalid textures (i.e., textures corresponding to voxels outside the volume object in the bounding box) will occupy storage space. Therefore, in order to further reduce memory occupancy and improve rendering efficiency, the computer device can compress the invalid textures or adopt sparse conversion writing (such as sparse writing for areas outside the profile contour and dense writing for the profile contour area).
[0100] In the embodiments of the present application, based on the normalized ratio between each voxel in the volume object and the maximum voxel density value, the density value corresponding to the voxel is converted into a color channel value to obtain the shape profile of the volume object, which not only ensures the completeness of the description of the spatial shape and density distribution of the volume object, but also can reduce memory occupancy and improve rendering efficiency on the premise of ensuring the rendering effect of the volume object.
[0101] When constructing a volume object using the spherical shell intersection algorithm and volume object construction strategy in the related technology, there will be a large number of invalid samplings, and it is not conducive to the spatial positioning of the volume object. Therefore, in the embodiments of the present application, the computer device sets a corresponding bounding box for each volume object to reduce subsequent invalid samplings and improve the accuracy of the spatial positioning of the volume object.
[0102] For volume objects located outside the field of view of the virtual camera, rendering such volume objects will cause waste of processing resources. Therefore, the computer device can determine whether to render the volume objects in the bounding box according to the spatial positioning result of the bounding box.
[0103] In a possible implementation, before density sampling, the computer device determines the spatial position and size of the bounding box corresponding to the volume object, and determines whether the volume object is located in the viewing direction of the virtual camera based on the size and spatial position of the bounding box.
[0104] If it is located in the viewing direction of the virtual camera, density sampling is performed on the shape profile according to the viewing direction of the virtual camera; if it is located outside the viewing direction of the virtual camera, density sampling is not performed in this viewing direction.
[0105] Among them, the process of determining whether the volume object is located in the viewing direction is to determine whether the ray corresponding to the viewing direction intersects the bounding box corresponding to the volume object.
[0106] Optionally, the computer device uses the Slap or Slop algorithm for the bounding box intersection test. Among them, the number of instructions of the Slop algorithm is less than that of the Slap algorithm. Therefore, using the Slop algorithm can improve the efficiency of the bounding box intersection test.
[0107] In order to further reduce performance consumption while ensuring rendering quality, in a possible implementation, the computer device can set shape profiles with different sampling levels. Among them, the sampling level can be represented by Miplevel. The higher the sampling level, the lower the rendering fineness of the volume object, that is, the rendering fineness of the volume object is negatively correlated with the sampling level.
[0108] For volume objects that are farther away, the fewer details can be observed by the human eye. Therefore, in some embodiments, when it is determined that the volume object is located in the viewing direction of the virtual camera based on the spatial position and the size of the bounding box, the computer device further determines the distance between the virtual camera and the bounding box, and determines the sampling level based on this distance, so as to perform density sampling on the shape profile corresponding to this sampling level according to the viewing direction of the virtual camera. Among them, the sampling level is positively correlated with the distance, that is, the greater the distance between the virtual camera and the bounding box, the higher the sampling level, and the rougher the rendering of the volume object; the smaller the distance between the virtual camera and the bounding box, the lower the sampling level, and the finer the rendering of the volume object.
[0109] In some embodiments, shape profiles with different sampling levels can be obtained by performing LOD (Level Of Detail) processing on the shape profile with the lowest sampling level.
[0110] In some embodiments, the computer device can set corresponding sampling levels for different distance ranges. The embodiments of the present application do not limit the specific number of sampling levels.
[0111] Schematically, such as Figure 6As shown, the computer device determines the distance between the virtual camera 61 and the virtual cloud corresponding bounding box 62. When the distance is within the range of (0, D1), the computer device performs density sampling using the shape profile corresponding to sampling level 1; when the distance is within the range of (D1, D2), the computer device performs density sampling using the shape profile corresponding to sampling level 2.
[0112] When the spherical shell intersection scheme is adopted, since the volume object is limited within the spherical layer and the position of the spherical layer is surrounded by the upper and lower spherical surfaces in the coordinate system, the overall coordinate system is restricted, so the spherical object cannot be freely edited. After adopting the bounding box scheme, each volume object is not restricted by the position of the spherical layer, so the user can freely edit the volume object. Especially in the development scenario, developers can freely adjust the position, size, angle, etc. of the volume object in the virtual environment, improving the editing freedom of the volume object.
[0113] In a possible implementation manner, when receiving an adjustment operation on the volume object, the computer device adjusts the volume object and the bounding box according to the adjustment operation, and the adjustment operation includes at least one of a scaling operation, a rotation operation, and a translation operation.
[0114] In some embodiments, the volume object is supported to be scaled within a certain scaling range to ensure the rendering accuracy of the volume object. And the scaling ratios of the volume object and the bounding box are kept consistent to ensure that the volume object is still within the bounding box after scaling.
[0115] In this embodiment, the bounding box intersection algorithm is adopted to determine whether sampling needs to be performed in the viewing direction, which can avoid wasting processing resources caused by rendering volume objects outside the rendering field of view; in addition, before performing density sampling, based on the distance between the virtual camera and the bounding box, the sampling level of the shape profile is determined, which can achieve different rendering accuracies for distant volume objects and near volume objects. On the premise of ensuring the rendering effect, it helps to further reduce performance consumption and improve the rendering speed of real-time volume objects.
[0116] When rendering a volume object by the ray marching method, the rendering process is the light transport integration process of the participating medium. Among them, the light transport integration process can be expressed by the following formula:
[0117]
[0118] where ω represents the incident direction, x is the starting position, x s is the position of the occluder, x t is the sampling point position, S is the distance between x and x s and T r (x, x s ) represents the distance between x and xs The transmittance of light between (or the transmittance at x s ), L(x s , ω) represents the radiance of the light reflected by the occluder, and T r (x, x t ) represents the transmittance of light between x and x t (or the transmittance at x t ). L s (x t , ω) represents the incident radiance at the sampling point, and σ s (x t ) represents the scattering coefficient at the sampling point.
[0119] As can be seen from the above formula, when determining the target radiance, it is necessary to determine the scattering coefficient, the radiance at each sampling point, and the transmittance at the sampling point in the main stepping direction. Among them, the radiance at the sampling point is determined from the shadow sampling results in the shadow sampling direction.
[0120] In a possible implementation, the process of determining the transmittance of the sampling point may include the following steps:
[0121] 1. For each sampling point, determine the first extinction coefficient of the sampling point according to the sampling point density, the main stepping sampling step size, and the density gain value, where the density gain value is used to control the solidity of the volume object.
[0122] The extinction coefficient is used to characterize the attenuation degree of the participating medium to light, and this attenuation degree is affected by both external scattering and absorption. In some embodiments, the computer device takes the unit distance density as the unit extinction coefficient and determines the transmittance of the corresponding path of the sampling point based on the Beer's law (the transmittance is linearly related to the distance).
[0123] To further enhance the diversity of the rendering effect of the volume object, in a possible implementation, the computer device provides a custom function for the density gain value. By adjusting the density gain value, the solidity of the rendered volume object can be controlled. Among them, the solidity of the volume object is positively correlated with the density gain value, that is, the larger the set density gain value, the higher the solidity of the volume object, and the smaller the set density gain value, the lower the solidity of the volume object.
[0124] In a possible implementation, after the computer device obtains the sampling point density of the sampling point, it determines the product of the sampling point density, the main stepping sampling step size, and the density gain value as the first extinction coefficient of the sampling point (corresponding path).
[0125] It should be noted that when the sampling point density sampled from the shape profile is the color channel value, if the density gain value is the maximum density value / the maximum color channel value, the first extinction coefficient determined is the original extinction coefficient (the extinction coefficient corresponding to the voxel density). If the density gain value is greater than the maximum density value / the maximum color channel value, the first extinction coefficient determined is greater than the original extinction coefficient (the rendering effect of the volume object is more solid). If the density gain value is less than the maximum density value / the maximum color channel value, the first extinction coefficient determined is less than the original extinction coefficient (the rendering effect of the volume object is more void).
[0126] 2. Determine the transmittance of the sampling point according to the first extinction coefficient.
[0127] Since the transmittance is used to characterize the attenuation degree of light on the propagation path, and the extinction coefficients of the paths corresponding to different sampling points in the inhomogeneous volume object are different, the computer device determines the transmittance of the target sampling point based on the first extinction coefficients of each sampling point between the target sampling point and the starting position. For the starting position x and the target sampling point x t , the target sampling point x t 's transmittance can be expressed as:
[0128]
[0129] where σ t represents the extinction coefficient.
[0130] To further improve the rendering performance, the computer device sets a main step sampling interruption mechanism to control the number of main step samplings through this mechanism. Optionally, the main step sampling interruption mechanism may include at least one of the following.
[0131] Mechanism 1: Stop sampling when the main step sampling point exceeds the bounding box range.
[0132] In some embodiments, after determining the main step sampling point according to the main step sampling step, the computer device determines whether the main step sampling point is located within the bounding box. If it is located within the bounding box, the main step sampling point is retained and the main step sampling continues along the viewing direction. If it is located outside the bounding box, the main step sampling point is discarded and the main step sampling is stopped. That is, during the main step density sampling process, the computer device performs density sampling on the shape profile within the bounding box corresponding to the volume object according to the main step sampling step and the viewing direction.
[0133] Mechanism 2: Stop sampling when the density accumulation of the main step sampling point reaches the threshold.
[0134] Since the attenuation of light by the participating medium accumulates, and after the light attenuates to a certain extent, further light attenuation has little impact on the final display effect. Therefore, in order to reduce the computational load, each time the computer device performs a main step sampling, it accumulates the sampling point density of the main step sampling points and detects whether the accumulated value reaches the density accumulation threshold. If the density accumulation threshold is reached, the computer device stops performing the main step sampling; if the density accumulation threshold is not reached, the computer device continues to perform the main step sampling. That is, the computer device performs density sampling on the shape profile according to the main step sampling point step size, the viewing direction, and the density accumulation threshold, where the accumulated value of the sampling point density of each sampling point is not greater than the density accumulation threshold.
[0135] Mechanism 3: Stop sampling when contacting an opaque object.
[0136] Since the volume object may contact other virtual objects in the virtual environment, and light cannot penetrate opaque objects, each time the main step sampling is performed, the computer device detects whether the line connecting the current main step sampling point and the previous main step sampling point intersects with an opaque object. If it intersects, the main step sampling is stopped.
[0137] As shown in the formula of the above light transport integration process, when there is an occluder and the distance between the occluder and the starting position is S, the total distance of the main step sampling is S.
[0138] The incident radiance rate of the light source reaching the sampling point after scattering and absorption in the incident direction can be expressed as:
[0139]
[0140] Vis(x,L) = Shadowmap(x,L) * VolumeShadow(x,L)
[0141] VolumeShadow(x,L) = T r (x,x L )
[0142] where L is the light source, P(ω,L) is the phase function used to describe the distribution of radiation in various directions, Vis(x,L) is used to represent shadow occlusion and the attenuation of light by the participating medium, L i (x,L) represents the radiance rate of the light between x and L, Shadowmap(x,L) represents shadow occlusion, VolumeShadow(x,L) represents the attenuation of light by the participating medium, and T r (x,x L ) represents the transmittance between x and L.
[0143] In a possible implementation, the process of determining the emissivity of a sampling point may include the following steps:
[0144] 1. Determine the shadow sampling points between the sampling point and the light source.
[0145] For each sampling point in the main stepping direction, the computer device performs shadow sampling between the sampling point and the light source to obtain a number of shadow sampling points between the sampling point and the light source.
[0146] In some embodiments, the computer device may use linear shadow sampling (i.e., the spacing between shadow sampling points is equal), non-linear shadow sampling, or conical shadow sampling (i.e., random shadow sampling within the cone corresponding to the sampling point) to determine the shadow sampling points.
[0147] When using linear shadow sampling, if the sampling step length is set too long, the rendering effect will be poor; if the sampling compensation is set too small, the rendering computation amount will be too large. When using conical shadow sampling, although the rendering quality can be guaranteed, it will bring the problem of excessive computation amount.
[0148] In order to improve the efficiency of real-time volume rendering and reduce the computation amount of real-time volume rendering while ensuring the quality of real-time volume rendering, in a possible implementation, the computer device uses non-linear shadow sampling to determine the shadow sampling points. This process may include the following steps:
[0149] I. Determine the shadow sampling point step length between adjacent shadow sampling points, and the shadow sampling point step length forms an arithmetic sequence.
[0150] In the embodiments of the present application, the computer device performs shadow sampling according to the shadow sampling point compensation in an arithmetic sequence. In some embodiments, the shadow sampling point step length increases along the direction from the main stepping sampling point to the light source, that is, the shadow sampling density is higher closer to the main stepping sampling point (increasing the number of shadow sampling points within the volume object), and the shadow sampling density is lower closer to the light source (reducing the number of shadow sampling points outside the volume object and reducing invalid calculations).
[0151] In a possible implementation, the shadow sampling point step length between adjacent shadow sampling points is a fixed arithmetic sequence. For example, the arithmetic sequence is 1, 3, 5, 7, 9.
[0152] Schematically, as Figure 7 shown, for each main stepping sampling point 72 in the viewing direction of the virtual camera 71, the computer device determines the shadow sampling point 74 between the main stepping sampling point 72 and the light source 73, where the shadow sampling point step lengths between adjacent shadow sampling points 74 are different and form an arithmetic sequence.
[0153] In another possible implementation, to increase the number of shadow sampling points in the volume object as much as possible, the computer device determines the boundary distance between the (primary step) sampling point and the boundary of the target bounding box (the boundary of the bounding box that intersects the line connecting the primary step sampling point and the light source), and determines the target arithmetic progression based on this boundary distance on the basis of the reference arithmetic progression. The target arithmetic progression can be obtained by scaling the reference arithmetic progression, and the scaling ratio is positively correlated with the boundary distance.
[0154] For example, the reference arithmetic progression is 1, 3, 5, 7, 9. When the boundary distance is less than the first distance, the computer device determines the target arithmetic progression as 0.5, 1.5, 2.5, 3.5, 4.5 based on the scaling ratio of 0.5; when the boundary distance is greater than the first distance and less than the second distance, the computer device determines the target arithmetic progression as 1, 3, 5, 7, 9 based on the scaling ratio of 1; when the boundary distance is greater than the second distance and within the range of the third distance, the computer device determines the target arithmetic progression as 2, 6, 10, 14, 18 based on the scaling ratio of 2.
[0155] II. Determine the shadow sampling points between the sampling point and the light source according to the shadow sampling point step size.
[0156] Furthermore, the computer device performs shadow sampling according to the shadow sampling point step size to obtain a number of shadow sampling points.
[0157] To further improve the rendering performance, the computer device sets a shadow sampling interruption mechanism to control the number of shadow samplings through this mechanism. Optionally, the shadow sampling interruption mechanism may include at least one of the following.
[0158] Mechanism 1: Stop sampling when the shadow sampling point exceeds the bounding box range.
[0159] In some embodiments, after determining the shadow sampling points according to the shadow sampling point step size, the computer device determines whether the shadow sampling point is located within the bounding box. If it is located within the bounding box, the shadow sampling point is retained and shadow sampling continues; if it is located outside the bounding box, the shadow sampling point is discarded and shadow sampling stops. That is, the computer device determines the shadow sampling points between the sampling point and the light source within the bounding box corresponding to the volume object according to the shadow sampling point step size.
[0160] Schematically, as Figure 7 shown, the computer device discards the shadow sampling points that exceed the bounding box range (the shadow sampling point 74 marked with "×" in the figure), and only retains the shadow sampling points located within the bounding box.
[0161] Mechanism 2: Stop sampling when the density of the shadow sampling points accumulates to a threshold.
[0162] Since the attenuation of light by the participating medium accumulates, and after the light attenuates to a certain extent, further light attenuation has a relatively small impact on the final display effect. Therefore, in order to reduce the computational load, after each shadow sampling by the computer device, the shadow sampling point density of the shadow sampling points on the same path is accumulated, and it is detected whether the accumulated value reaches the density accumulation threshold. If the density accumulation threshold is reached, the computer device stops shadow sampling; if the density accumulation threshold is not reached, the computer device continues shadow sampling. That is, the computer device determines the shadow sampling points between the sampling point and the light source according to the shadow sampling point step size and the density accumulation threshold, where the accumulated value of the shadow sampling point density of each shadow sampling point is not greater than the density accumulation threshold.
[0163] Mechanism 3: Stop sampling when contacting an opaque object.
[0164] Since the volume object may contact other virtual objects in the virtual environment, and light cannot penetrate opaque objects, therefore, during each shadow sampling, the computer device detects whether the line connecting the current shadow sampling point and the previous shadow sampling point intersects with an opaque object. If it intersects, sampling stops.
[0165] 2. Obtain the shadow sampling point density of the shadow sampling point from the shape profile.
[0166] In a possible implementation, the computer device determines the narrowband level set where the shadow sampling point is located in the shape profile, and then obtains the shadow sampling point density of the shadow sampling point from this narrowband level set.
[0167] 3. Determine the second extinction coefficient of the shadow sampling point according to the shadow sampling point density, the shadow sampling step size, and the density gain value, where the density gain value is used to control the solidity of the volume object.
[0168] Similar to determining the extinction coefficient of the main step sampling point during the main step sampling process, in order to further enhance the diversity of the rendering effect of the volume object, the density gain value is also used to determine the second extinction coefficient of the shadow sampling point.
[0169] In a possible implementation, after the computer device obtains the shadow sampling point density, it determines the product of the shadow sampling point density, the shadow sampling step size, and the density gain value as the second extinction coefficient of the shadow sampling point (corresponding path).
[0170] 4. Determine the radiance of the sampling point according to the second extinction coefficient of each shadow sampling point, the light source radiance of the light source, the phase coefficient, and the scattering coefficient of the sampling point.
[0171] In some embodiments, the computer device substitutes the second extinction coefficient, the light source radiation rate of the light source, and the phase coefficient into the calculation formula of the incident radiation rate at the sampling point to obtain the incident radiation rate at the sampling point, and further determines the radiation rate at the sampling point according to the scattering coefficient and the incident radiation rate at the sampling point.
[0172] In a possible implementation manner, when determining the phase coefficient, the computer device first determines the scattering type according to the average particle radius r of the medium corresponding to the volume object and the light wavelength λ, where the scattering type may include Rayleigh scattering, Mie scattering, and geometric scattering. Further, the computer device determines the phase coefficient of the sampling point based on the phase function corresponding to the scattering type.
[0173] Light usually undergoes Mie scattering in inhomogeneous volume objects such as clouds and fog. Mie scattering has strong directivity, and the obvious directivity of the main lobe of the directional scattering will cause the lack of back-facing surface light, which in turn leads to the lack of layering of the inhomogeneous volume object in the front-light view when the virtual camera is between the inhomogeneous volume object and the light source.
[0174] To improve the layering of the volume object in the front-light view, in a possible implementation manner, the computer device uses the method of phase mixing to linearly interpolate two phase coefficients to obtain the final phase coefficient. Among them, the interpolation ratio of the phase coefficient can be set by default or customized.
[0175] Regarding the determination method of the scattering coefficient at the sampling point, in a possible implementation manner, the computer device determines the scattering coefficient at the sampling point according to the extinction coefficient and the albedo at the sampling point.
[0176] Among them, the scattering coefficient can be the product of the extinction coefficient and the albedo. The albedo can be determined according to the medium type of the volume object or can be customized.
[0177] In a possible implementation manner, in order to further enhance the in-scattering effect, the computer device can correct the scattering coefficient according to the scattering correction coefficient output by the scatter probability model. The scatter probability model includes a depth probability function and a vertical probability function. The depth probability function is used to fit the scattering occurrence probability in the depth direction, and the vertical probability function is used to fit the scattering occurrence probability in the vertical direction. The scattering correction coefficient is the product of the scattering occurrence probabilities in the depth direction and the vertical direction.
[0178] Correspondingly, the scattering coefficient at the sampling point is the product of the extinction coefficient, the albedo, and the scattering correction coefficient.
[0179] In the above embodiments, by setting a sampling interruption mechanism for the main step sampling and the shadow sampling, the number of samples can be reduced on the premise of ensuring the rendering effect, thereby reducing the computational amount in the volume rendering process and improving the efficiency of real-time volume rendering.
[0180] In addition, in the above embodiments, based on an arithmetic progression, the step size of the shadow sampling points in the shadow sampling process is determined. Under the condition of ensuring the number of shadow sampling times within the volume object, the number of invalid shadow sampling times outside the volume object can be reduced, which not only ensures the rendering effect but also reduces the computational amount in the rendering process.
[0181] Moreover, in the above embodiments, by introducing a density gain value, the user can adjust the density gain value to achieve the adjustment of the solidity degree of the volume object, improving the diversity of the rendering effect of the volume object.
[0182] It should be noted that in the above embodiments, single scattering is taken as an example for illustration. In other possible implementation manners, the computer device may provide a scattering order setting interface for the user to manually adjust the scattering order. Among them, the higher the scattering order, the more realistic the rendering effect of the volume object. Schematically, for the same volume object, the rendering effects of single scattering and multiple scattering are as Figure 8 shown.
[0183] To support the rendering of various types of volume objects, such as in addition to supporting the rendering of conventional clouds, smoke, and fog, it also supports the rendering of glowing clouds, nacreous clouds, black holes, and stars, etc., the computer device expands the radiance of the sampling points.
[0184] In some embodiments, when the sampling point supports self-luminescence, the computer device determines the target self-luminescence radiance according to the basic self-luminescence radiance of the sampling point and the absorption coefficient, and updates the radiance of the sampling point according to the target self-luminescence radiance.
[0185] When the sampling point supports self-luminescence, the calculation process of the radiance of the sampling point can be expressed as:
[0186]
[0187] Among them, L e (x t , ω) represents the basic self-luminescence radiance of the sampling point, and σ a (x t ) represents the absorption coefficient of the sampling point.
[0188] Regarding the determination method of the absorption coefficient of the sampling point, since the extinction of the sampling point is affected by both scattering and absorption, and the extinction coefficient can be determined based on the sampling point density, and the scattering coefficient can be determined based on the albedo. Therefore, in a possible implementation, the computer device determines the extinction coefficient of the sampling point, and determines the scattering coefficient of the sampling point according to the extinction coefficient and the albedo, so as to determine the difference between the extinction coefficient and the scattering coefficient as the absorption coefficient of the sampling point. Among them, by introducing the absorption coefficient for the self-luminous term, the rendering authenticity of the self-luminous volume object can be improved.
[0189] Schematically, the absorption coefficient of the sampling point can be expressed as:
[0190] σ a (x t ) = σ t (x t ) - σ t (x t ) × ρ
[0191] Wherein, σ t (x t ) is the extinction coefficient, and ρ is the albedo.
[0192] In the process of determining the scattering coefficient, in order to improve the accuracy of the scattering coefficient, in a possible implementation, the computer device obtains the scattering correction coefficient output by the scatter point probability model, so as to correct the scattering coefficient of the sampling point according to the scattering correction coefficient.
[0193] Among them, the scatter point probability model includes a depth probability function and a vertical probability function. The depth probability function is used to fit the scattering occurrence probability in the depth direction, and the vertical probability function is used to fit the scattering occurrence probability in the vertical direction. And the scattering correction coefficient is the product of the scattering occurrence probabilities in the depth direction and the vertical direction.
[0194] In some embodiments, when the volume object supports blackbody radiation, the computer device updates the radiation rate of the sampling point according to the blackbody emissivity of the sampling point.
[0195] When the sampling point supports blackbody radiation, the calculation process of the radiation rate of the sampling point can be expressed as:
[0196]
[0197] Wherein, LBlackbody is the blackbody emissivity.
[0198] Of course, in addition to additionally introducing the self-luminous radiation term and the blackbody radiation term, other radiation rate influence terms can also be added according to the type of the volume object, which is not limited in the embodiments of the present application.
[0199] In a possible application scenario, for volumetric cloud rendering, the real-time volume renderer provides the following interfaces at the editor level for users to adjust parameters.
[0200] Shape Profile: Shape profile, used to provide the original density signal
[0201] Noise Mod: Noise mixing mode
[0202] View Steps: Main step count
[0203] Shadow Steps: Shadow sampling count
[0204] Density: Density gain value
[0205] Shadow Multiplier: Used to scale the attenuation of the medium to the light source
[0206] Shadow Threshold: Shadow sampling interruption threshold
[0207] Detail Noise Scale: Detail scale
[0208] Wind: Wind field
[0209] Phase A,B,Weight: Phase coefficient
[0210] Color: Medium albedo
[0211] Emissive: Self-luminescence
[0212] Black Body: Blackbody radiation, selectively enabled
[0213] Ambient: Ambient light ratio
[0214] Optionally, Noise Mod, Shape Profile, View Steps, Shadow Steps, Density, and Shadow Multiplier are encapsulated and preset as core parameters, and a built-in volumetric cloud library is configured for the real-time volume renderer. This built-in volumetric cloud library contains common cloud genera within the cloud family tree, such as Figure 9 as shown.
[0215] In the preset mode, the user only needs to select the volume cloud to be deployed from the built-in library of the volume cloud, and the real-time volume renderer will automatically parse the data packet corresponding to the volume cloud and perform automatic scaling of the volume cloud. Among them, some parameter interfaces are frozen in the preset mode, and the user cannot perform parameter editing. When the user wants to further fine-tune the relevant parameters, only need to switch the preset mode to the custom mode, and the originally frozen parameter interfaces will be reactivated for the user to customize the parameters.
[0216] Figure 10 is a structural block diagram of a rendering device for a volume object provided by an exemplary embodiment of the present application. The device includes:
[0217] An acquisition module 1001, configured to acquire a shape profile of the volume object, where the volume object is a heterogeneous volume object, and the shape profile is a volume texture including a narrow-band level set of density;
[0218] A first sampling module 1002, configured to perform density sampling on the shape profile according to the viewing direction of the virtual camera, and determine the transmittance of the sampling points in the viewing direction according to the sampling point density;
[0219] A second sampling module 1003, configured to perform shadow sampling on the sampling points in the shape profile to obtain the radiance of the sampling points;
[0220] A determination module 1004, configured to determine the target radiance of the volume object in the viewing direction according to the transmittance and the radiance of each sampling point;
[0221] A rendering module 1005, configured to render the volume object according to the target radiance in each viewing direction.
[0222] Optionally, the acquisition module 1001 is configured to:
[0223] Perform level set partitioning on the volume object to obtain a plurality of narrow-band level sets;
[0224] For each narrow-band level set, convert the density value corresponding to the voxels in the narrow-band level set into a color channel value of a target color channel to obtain the shape profile of the volume object.
[0225] Optionally, the acquisition module 1001 is configured to:
[0226] Determine the maximum density value of the voxels in the volume object;
[0227] For each voxel, determine the ratio of the density value corresponding to the voxel to the maximum density value;
[0228] Convert the density value to the color channel value of the target color channel according to the ratio to obtain the shape profile of the volume object.
[0229] Optionally, the acquisition module 1001 is further configured to:
[0230] Acquire the original voxel file of the volume object, where the original voxel file contains the voxel data of the volume object;
[0231] When the original voxel file is a first type of file, perform file conversion on the original voxel file to obtain a second type of file, where the second type of file is a voxel file that supports the GPU;
[0232] Perform level set partitioning on the volume object according to the second type of file to obtain a plurality of narrowband level sets.
[0233] Optionally, the first sampling module 1002 is configured to:
[0234] For each sampling point, determine the first extinction coefficient of the sampling point according to the sampling point density, the main step sampling step size, and the density gain value, where the density gain value is used to control the solidity degree of the volume object;
[0235] Determine the transmittance of the sampling point according to the first extinction coefficient;
[0236] The second sampling module 1003 is configured to: determine the shadow sampling point between the sampling point and the light source;
[0237] Obtain the shadow sampling point density of the shadow sampling point from the shape profile;
[0238] Determine the second extinction coefficient of the shadow sampling point according to the shadow sampling point density, the shadow sampling step size, and the density gain value, where the density gain value is used to control the solidity degree of the volume object;
[0239] Determine the radiance of the sampling point according to the second extinction coefficient of each shadow sampling point, the light source radiance of the light source, the phase coefficient, and the scattering coefficient of the sampling point.
[0240] Optionally, the second sampling module 1003 is configured to:
[0241] Determine the shadow sampling point step size between adjacent shadow sampling points, where the shadow sampling point step size forms an arithmetic progression;
[0242] Determine the shadow sampling point between the sampling point and the light source according to the shadow sampling point step size.
[0243] Optionally, the second sampling module 1003 is configured to:
[0244] Determine the shadow sampling points located between the sampling point and the light source within the bounding box corresponding to the volume object according to the shadow sampling point step size;
[0245] Determine the shadow sampling points between the sampling point and the light source according to the shadow sampling point step size and the density accumulation threshold, wherein the cumulative value of the shadow sampling point densities of each of the shadow sampling points is not greater than the density accumulation threshold.
[0246] Optionally, the first sampling module 1002 is configured to: perform density sampling on the shape profile within the bounding box corresponding to the volume object according to the main step sampling step size and the viewing direction;
[0247] Perform density sampling on the shape profile according to the main step sampling point step size, the viewing direction, and the density accumulation threshold, wherein the cumulative value of the sampling point densities of each of the sampling points is not greater than the density accumulation threshold.
[0248] Optionally, the device further includes:
[0249] A self-luminous module, configured to, when the sampling point supports self-luminance, determine a target self-luminous radiance according to the base self-luminous radiance and the absorption coefficient of the sampling point; update the radiance of the sampling point according to the target self-luminous radiance;
[0250] A blackbody radiation module, configured to, when the volume object supports blackbody radiation, update the radiance of the sampling point according to the blackbody radiance of the sampling point.
[0251] Optionally, the self-luminous module is configured to:
[0252] Determine the extinction coefficient of the sampling point;
[0253] Determine the scattering coefficient of the sampling point according to the extinction coefficient and the albedo;
[0254] Determine the difference between the extinction coefficient and the scattering coefficient as the absorption coefficient of the sampling point.
[0255] Optionally, the self-luminous module is further configured to:
[0256] Obtain a scattering correction coefficient output by a scatter point probability model, where the scatter point probability model includes a depth probability function and a vertical probability function, the depth probability function is used to fit the scattering occurrence probability in the depth direction, the vertical probability function is used to fit the scattering occurrence probability in the vertical direction, and the scattering correction coefficient is used to enhance the internal scattering effect;
[0257] The scattering coefficient of the sampling point is corrected according to the scattering correction coefficient.
[0258] Optionally, the device further includes:
[0259] A bounding box positioning module, used to determine the spatial position and size of the bounding box corresponding to the volume object;
[0260] The first sampling module 1002 is used to:
[0261] When it is determined that the volume object is located in the viewing direction of the virtual camera based on the spatial position and the size of the bounding box, density sampling is performed on the shape profile according to the viewing direction of the virtual camera.
[0262] Optionally, the first sampling module 1002 is used to:
[0263] In a case where it is determined based on the spatial position and the size of the bounding box that the volume object is located in the viewing direction of the virtual camera, determining a distance between the virtual camera and the bounding box;
[0264] Determining a sampling level based on the distance, wherein the sampling level is positively correlated with the distance, and the rendering fineness of the volume object is negatively correlated with the sampling level;
[0265] According to the viewing direction of the virtual camera, density sampling is performed on the shape profile corresponding to the sampling level.
[0266] Optionally, the device further comprises:
[0267] The adjustment module is used to adjust the volume object and the bounding box according to the adjustment operation when receiving the adjustment operation on the volume object, wherein the adjustment operation includes at least one of a scaling operation, a rotation operation and a movement operation.
[0268] In summary, in the embodiment of the present application, by introducing the concept of shape profile and using volume textures including narrowband level sets of density to represent non-homogeneous volume objects, the spatial modeling of volume objects can be completely restored; when subsequently rendering volume objects, density sampling and shadow sampling can be performed on the shape profile to improve the accuracy of the transmittance and radiance of multiple sampling points in the viewing direction, thereby improving the accuracy of determining the target radiance in the viewing direction based on the radiance and transmittance, and ultimately improving the authenticity of the volume object rendering effect. Moreover, compared to voxel rendering, since the shape profile occupies less memory space, it can improve the rendering efficiency of volume objects, and can achieve a dual consideration of rendering efficiency and rendering effect in real-time rendering scenarios.
[0269] Please refer to Figure 11 Figure 11 , which shows a schematic structural diagram of a computer device provided by an exemplary embodiment of the present application. Specifically: The computer device 1600 includes a central processing unit (CPU) 1601, a system memory 1604 including a random access memory 1602 and a read-only memory 1603, and a system bus 1605 connecting the system memory 1604 and the central processing unit 1601. The computer device 1600 also includes a basic input / output system (Input / Output, I / O system) 1606 for facilitating the transfer of information between various components within the computer, and a mass storage device 1607 for storing an operating system 1613, application programs 1614, and other program modules 1615.
[0270] The basic input / output system 1606 includes a display 1608 for displaying information and input devices 1609 such as a mouse, keyboard, etc. for user input. Among them, both the display 1608 and the input devices 1609 are connected to the central processing unit 1601 through an input / output controller 1610 connected to the system bus 1605. The basic input / output system 1606 may also include an input / output controller 1610 for receiving and processing inputs from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1610 also provides output to a display screen, printer, or other types of output devices.
[0271] The mass storage device 1607 is connected to the central processing unit 1601 through a mass storage controller (not shown) connected to the system bus 1605. The mass storage device 1607 and its associated computer-readable medium provide non-volatile storage for the computer device 1600. That is to say, the mass storage device 1607 may include a computer-readable medium (not shown) such as a hard disk or a drive.
[0272] Without loss of generality, the computer-readable medium may include a computer storage medium and a communication medium. The computer storage medium includes volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. The computer storage medium includes random access memory (RAM), read-only memory (ROM), flash memory or other solid-state storage technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic tape cartridges, tapes, magnetic disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer storage medium is not limited to the above several types. The above-mentioned system memory 1604 and mass storage device 1607 can be collectively referred to as memory.
[0273] The memory stores one or more programs, and the one or more programs are configured to be executed by one or more central processing units 1601. The one or more programs include instructions for implementing the above method, and the central processing unit 1601 executes the one or more programs to implement the methods provided by the above various method embodiments.
[0274] According to various embodiments of the present application, the computer device 1600 can also run on a remote computer on the network through a network such as the Internet. That is, the computer device 1600 can be connected to the network 1612 through the network interface unit 1611 connected to the system bus 1605. Or rather, the network interface unit 1611 can also be used to connect to other types of networks or remote computer systems (not shown).
[0275] The embodiments of the present application also provide a computer-readable storage medium, in which at least one instruction is stored, and the at least one instruction is loaded and executed by a processor to implement the rendering method of the volume object provided by the above embodiments.
[0276] Optionally, the computer-readable storage medium may include: ROM, RAM, solid state drives (SSD), or optical discs, etc. Among them, RAM may include resistive random access memory (ReRAM) and dynamic random access memory (DRAM).
[0277] An embodiment of the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the rendering method of the volume object described in the above embodiment.
[0278] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above embodiments can be completed by hardware, or can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable storage medium, and the storage medium mentioned above can be a read-only memory, a magnetic disk, an optical disc, or the like.
[0279] The above are only optional embodiments of the present application, and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A rendering method for a volume object, characterized in that, the method includes: obtaining a shape profile of the volume object, where the volume object is a heterogeneous volume object, and the shape profile is a volume texture of a narrowband level set including density; performing density sampling on the shape profile according to the viewing direction of a virtual camera, and determining the transmittance of a sampling point in the viewing direction according to the sampling point density; performing shadow sampling on the sampling point in the shape profile to obtain the radiance of the sampling point; determining the target radiance of the volume object in the viewing direction according to the transmittance and the radiance of each sampling point; rendering the volume object according to the target radiance in each viewing direction.
2. The method according to claim 1, characterized in that, the obtaining of the shape profile of the volume object includes: performing level set partitioning on the volume object to obtain a plurality of narrowband level sets; for each narrowband level set, converting the density value corresponding to the voxels in the narrowband level set into a color channel value of a target color channel to obtain the shape profile of the volume object.
3. The method according to claim 2, characterized in that, the converting the density value corresponding to the voxels in the narrowband level set into a color channel value of a target color channel to obtain the shape profile of the volume object includes: determining the maximum density value of the voxels in the volume object; for each voxel, determining the ratio of the density value corresponding to the voxel to the maximum density value; converting the density value into the color channel value of the target color channel according to the ratio to obtain the shape profile of the volume object.
4. The method according to claim 2, characterized in that, the method further includes: obtaining the original voxel file of the volume object, where the original voxel file contains the voxel data of the volume object; when the original voxel file is a first type of file, performing file conversion on the original voxel file to obtain a second type of file, and the second type of file is a voxel file supporting GPU; the performing level set partitioning on the volume object to obtain a plurality of narrowband level sets includes: performing level set partitioning on the volume object according to the second type of file to obtain a plurality of narrowband level sets.
5. The method according to claim 1, characterized in that, the determining the transmittance of a sampling point in the viewing direction according to the sampling point density includes: for each sampling point, determining a first extinction coefficient of the sampling point according to the sampling point density, a main step sampling step size, and a density gain value, where the density gain value is used to control the solidity of the volume object; determining the transmittance of the sampling point according to the first extinction coefficient; the performing shadow sampling on the sampling point in the shape profile to obtain the radiance of the sampling point includes: determining a shadow sampling point between the sampling point and a light source; obtaining the shadow sampling point density of the shadow sampling point from the shape profile; Determine the second extinction coefficient of the shadow sampling points according to the shadow sampling point density, the shadow sampling step size, and the density gain value, where the density gain value is used to control the solidity of the volume object; Determine the radiance of the sampling point according to the second extinction coefficient of each shadow sampling point, the radiant exitance of the light source, the phase coefficient, and the scattering coefficient of the sampling point.
6. The method according to claim 5, wherein, the determination of the shadow sampling points between the sampling point and the light source includes: Determine the shadow sampling point step size between adjacent shadow sampling points, and the shadow sampling point step size forms an arithmetic progression; Determine the shadow sampling points between the sampling point and the light source according to the shadow sampling point step size.
7. The method according to claim 6, wherein, the determination of the shadow sampling points between the sampling point and the light source according to the shadow sampling point step size includes at least one of the following methods: Determine the shadow sampling points between the sampling point and the light source within the bounding box corresponding to the volume object according to the shadow sampling point step size; Determine the shadow sampling points between the sampling point and the light source according to the shadow sampling point step size and the density accumulation threshold, where the cumulative value of the shadow sampling point density of each shadow sampling point is not greater than the density accumulation threshold.
8. The method according to claim 5, wherein, the density sampling of the shape profile according to the viewing direction of the virtual camera includes at least one of the following methods: Perform density sampling on the shape profile within the bounding box corresponding to the volume object according to the main step sampling step size and the viewing direction; Perform density sampling on the shape profile according to the main step sampling point step size, the viewing direction, and the density accumulation threshold, where the cumulative value of the sampling point density of each sampling point is not greater than the density accumulation threshold.
9. The method according to claim 1, wherein, after performing shadow sampling on the sampling point in the shape profile to obtain the radiance of the sampling point, the method further includes: When the sampling point supports self-luminous, determine the target self-luminous radiance according to the basic self-luminous radiance and the absorption coefficient of the sampling point; update the radiance of the sampling point according to the target self-luminous radiance; When the volume object supports blackbody radiation, update the radiance of the sampling point according to the blackbody radiance of the sampling point.
10. The method according to claim 9, wherein, before determining the target self-luminous radiance according to the basic self-luminous radiance and the absorption coefficient of the sampling point, the method further includes: Determine the extinction coefficient of the sampling point; Determine the scattering coefficient of the sampling point according to the extinction coefficient and the albedo; Determine the difference between the extinction coefficient and the scattering coefficient as the absorption coefficient of the sampling point.
11. The method according to claim 9, wherein, After determining the scattering coefficient of the sampling point according to the extinction coefficient and the albedo, the method further includes: Obtaining a scattering correction coefficient output by a scatter probability model, where the scatter probability model includes a depth probability function and a vertical probability function. The depth probability function is used to fit the probability of scattering occurring in the depth direction, the vertical probability function is used to fit the probability of scattering occurring in the vertical direction, and the scattering correction coefficient is used to enhance the internal scattering effect; Correcting the scattering coefficient of the sampling point according to the scattering correction coefficient.
12. The method according to claim 1, wherein, Before performing density sampling on the shape profile according to the viewing direction of the virtual camera, the method further includes: Determining the spatial position and size of the bounding box corresponding to the volume object; The performing density sampling on the shape profile according to the viewing direction of the virtual camera includes: When it is determined that the volume object is located in the viewing direction of the virtual camera based on the spatial position and the size of the bounding box, performing density sampling on the shape profile according to the viewing direction of the virtual camera.
13. The method according to claim 12, wherein, The performing density sampling on the shape profile according to the viewing direction of the virtual camera when it is determined that the volume object is located in the viewing direction of the virtual camera based on the spatial position and the size of the bounding box includes: When it is determined that the volume object is located in the viewing direction of the virtual camera based on the spatial position and the size of the bounding box, determining the distance between the virtual camera and the bounding box; Determining a sampling level based on the distance, where the sampling level has a positive correlation with the distance, and the rendering fineness of the volume object has a negative correlation with the sampling level; Performing density sampling on the shape profile corresponding to the sampling level according to the viewing direction of the virtual camera.
14. The method according to claim 12, wherein, The method further includes: When receiving an adjustment operation on the volume object, adjusting the volume object and the bounding box according to the adjustment operation, where the adjustment operation includes at least one of a scaling operation, a rotation operation, and a translation operation.
15. A rendering device for a volume object, wherein, The device includes: An acquisition module, configured to acquire a shape profile of a volume object, where the volume object is a heterogeneous volume object, and the shape profile is a volume texture including a density of a narrow-band level set; A first sampling module, configured to perform density sampling on the shape profile according to the viewing direction of a virtual camera, and determine the transmittance of a sampling point in the viewing direction according to the sampling point density; A second sampling module, configured to perform shadow sampling on the sampling point in the shape profile to obtain the radiance of the sampling point; A determination module, configured to determine the target radiance of the volume object in the viewing direction according to the transmittance and the radiance of each sampling point. A rendering module, configured to render the volume object according to the target emissivity in each viewing direction.
16. A computer device, characterized in that the computer device includes a processor and a memory, and at least one instruction is stored in the memory, and the at least one instruction is loaded and executed by the processor to implement the rendering method of the volume object according to any one of claims 1 to 14.
17. A computer-readable storage medium, characterized in that at least one instruction is stored in the readable storage medium, and the at least one instruction is loaded and executed by a processor to implement the rendering method of the volume object according to any one of claims 1 to 14.
18. A computer program product, characterized in that the computer program product includes computer instructions, and the computer instructions are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the rendering method of the volume object according to any one of claims 1 to 14.
Citation Information
Cited By
Object rendering method and device, equipment, medium and product
CN121725122A
Object rendering method, apparatus, device, medium, and product
CN121725122B