Coke effect generation method and device, equipment and storage medium
By determining the visible points of caustics and filtering caustic rays in a three-dimensional scene, photon tracing and storage efficiency are optimized, which solves the problems of large storage space requirements and poor rendering performance in the existing technology for generating caustics effects, and realizes efficient and high-quality caustic effect generation.
Patent Information
- Application Number
- CN202510887775.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-10-17
AI Technical Summary
Existing photon mapping technology has large storage space requirements, poor rendering performance, low convergence efficiency and high noise when rendering caustics effects, making it difficult to efficiently generate high-quality caustics effects.
By determining the visible points of caustics in the three-dimensional scene, screening the caustic rays for photon tracing, generating a caustic photon map, and generating an image of the caustic effect based on the photon map and the three-dimensional scene, the virtual camera position and ray tracing are used to optimize the number of rays and storage efficiency.
Improved the speed and quality of caustics generation, reduced storage resource usage, improved rendering performance and photon tracing efficiency, and reduced noise interference.
Smart Images

Figure CN120807752A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer technology, and particularly relates to the technical field of three-dimensional modeling, ray tracing, three-dimensional scene rendering, etc. BACKGROUND
[0002] Focal scattering is a common optical phenomenon in nature, which is manifested as that light rays form focal lines or focal planes on another object surface after being reflected or refracted by an object. Photon mapping refers to that light rays start from a light source, are reflected or refracted, and then cache photons on a diffuse reflection object surface. In the calculation of light, the focal scattering contribution is calculated by searching for photons near the current position. Photon mapping uniformly samples the light source, and the probability of obtaining effective focal scattering photons is low, and the rendering performance is poor. Photon mapping caches photons in the form of Photon Map in the world space, and requires a large storage space. When rendering on a GPU, the memory pressure is large. The convergence efficiency of photon mapping is low, and there are many noise points, which requires high noise reduction. SUMMARY
[0003] The present disclosure provides a focal scattering effect generation method and device, equipment and storage medium, to solve or alleviate one or more technical problems in the prior art.
[0004] In a first aspect, the present disclosure provides a focal scattering effect generation method, comprising:
[0005] determining a plurality of focal scattering visible points in a world space of a three-dimensional scene according to a position of a virtual camera;
[0006] determining a plurality of focal scattering rays according to the plurality of focal scattering visible points;
[0007] performing photon tracing on the plurality of focal scattering rays to obtain a focal scattering photon map; wherein the focal scattering photon map comprises a plurality of focal scattering photons;
[0008] generating an image with a focal scattering effect according to the focal scattering photon map and the three-dimensional scene.
[0009] In a second aspect, the present disclosure provides a focal scattering effect generation device, comprising:
[0010] a visible point determination module configured to determine a plurality of focal scattering visible points in a world space of a three-dimensional scene according to a position of a virtual camera;
[0011] a ray determination module configured to determine a plurality of focal scattering rays according to the plurality of focal scattering visible points;
[0012] a tracing module configured to perform photon tracing on the plurality of focal scattering rays to obtain a focal scattering photon map; wherein the focal scattering photon map comprises a plurality of focal scattering photons;
[0013] generate an image with a caustic effect according to the plenoptic caustic map and the three-dimensional scene.
[0014] In a third aspect, an electronic device is provided, comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected with the at least one processor; wherein
[0017] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any of the embodiments of the present disclosure.
[0018] In a fourth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to perform the method according to any of the embodiments of the present disclosure.
[0019] In a fifth aspect, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the method according to any of the embodiments of the present disclosure.
[0020] It should be understood that the contents described in this part are not intended to identify key or important features of the embodiments of the present disclosure, nor are they used to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0021] In the drawings, like reference numerals refer to same or similar functionalities throughout the several views. The drawings are not necessarily to scale. It should be understood that the drawings only depict some embodiments in accordance with the present disclosure and should not be considered as limiting the scope of the present disclosure.
[0022] Figure 1 is a flowchart of a caustic effect generation method according to an embodiment of the present disclosure;
[0023] Figure 2a and Figure 2b is a schematic diagram of a caustic effect according to an embodiment of the present disclosure;
[0024] Figure 3 is a flowchart of a caustic effect generation method according to another embodiment of the present disclosure;
[0025] Figure 4 is a flowchart of a caustic effect generation method according to another embodiment of the present disclosure;
[0026] Figure 5is a flowchart of a caustics generation method according to another embodiment of the disclosure;
[0027] Figure 6 is a flowchart of a caustics generation method according to another embodiment of the disclosure;
[0028] Figure 7a and Figure 7b is a schematic diagram of a two-dimensional preview image with caustics according to an embodiment of the disclosure;
[0029] Figure 8 is a flowchart of a screen space based Photon Map precomputation method according to an embodiment of the disclosure;
[0030] Figure 9 is a schematic diagram of a guiding table according to an embodiment of the disclosure;
[0031] Figure 10 is a structural schematic diagram of a caustics generation apparatus according to an embodiment of the disclosure;
[0032] Figure 11 is a structural schematic diagram of a caustics generation apparatus according to another embodiment of the disclosure;
[0033] Figure 12 is a block diagram of an electronic device for implementing the method according to an embodiment of the disclosure. DETAILED DESCRIPTION
[0034] The disclosure will be described in further detail below with reference to the drawings. The same reference numerals in different drawings denote the same or similar elements. Although various aspects of the embodiments are shown in the drawings, the drawings are not necessarily drawn to scale unless specifically stated.
[0035] In addition, in order to better illustrate the disclosure, numerous specific details are given in the following detailed description. It should be understood by those skilled in the art that the disclosure can also be implemented without certain specific details. In some examples, methods, means, elements and circuits that are well known to those skilled in the art are not described in detail in order to highlight the main idea of the disclosure.
[0036] Figure 1 is a flowchart of a caustics generation method according to an embodiment of the disclosure. In an embodiment, the method can include:
[0037] S101, determining a plurality of caustic visible points in a world space of a three-dimensional scene according to a position of a virtual camera;
[0038] S102, determining a plurality of caustic rays according to the plurality of caustic visible points;
[0039] S103, performing photon tracing on the plurality of caustic rays to obtain a caustic photon map; wherein the caustic photon map includes a plurality of caustic photons;
[0040] S104: Generate an image with a caustic effect according to the caustic photon mapping and the three-dimensional scene.
[0041] In the disclosed embodiment, caustics is an indirect lighting effect. The principle of caustics is that after the indirect lighting light is emitted from the light source, it first passes through one (or more) reflections and refractions of the specular surface, and then is projected onto a diffuse reflection surface to form caustic photons, which are finally recorded by the camera in the form of diffuse. The specular surface in this process is called the caustic projection surface, and the diffuse surface is called the caustic receiving surface. For example, Figure 2a As shown in the figure, a beam of light illuminates a transparent glass ball. Since the surface of the ball is curved, the light will be offset on the projection surface after the light passes through the ball, forming a caustic effect. Figure 2b As shown in the figure, light originates from the light source, refracts through the water surface and reaches the bottom, creating a water-light effect. The intensity of the caustics depends on the transparency of the object, the distance between the object and the projection surface, and the intensity of the light itself.
[0042] In the disclosed embodiments, in 3D modeling software, virtual light sources set within a 3D scene can generate virtual light rays. These virtual light rays follow a designed path, undergo at least one refraction or reflection, and then strike a diffusely reflective surface, generating caustic photons. The multiple caustic photons generated by multiple virtual light rays can collectively create a caustic effect.
[0043] In an embodiment of the present disclosure, the position of a virtual camera can be set in a three-dimensional scene first, and multiple camera rays can be emitted from the position of the virtual camera in different directions. After the camera ray is refracted or reflected at least once, it is irradiated on a diffuse reflection surface to obtain a caustic visible point. The caustic visible point indicates that in the global light of the three-dimensional scene, it will be captured by the virtual camera at the current position and displayed at the position where the caustic effect may appear on the virtual camera screen. The caustic visible point utilizes the principle of reversibility of the light path. By emitting the camera ray in reverse from the virtual camera and then simulating the camera ray path based on the caustic generation principle, the area where the caustic of the global light in the three-dimensional scene may be captured by the virtual camera is determined. The area where the global light may produce a caustic effect is within the area formed by the caustic visible points formed by the camera light.
[0044] In the embodiments of the present disclosure, in the case of determining the caustic visible point, the caustic light rays can be screened out from the global light rays by using the caustic visible point. The caustic light rays can be light rays that can produce a caustic effect in a three-dimensional scene. The remaining light rays in the global light rays except the caustic light rays will not produce a caustic effect, and thus can not be tracked, simulated and calculated when the caustic effect is generated.
[0045] In the embodiments of the present disclosure, in the case of screening out the caustic light rays by using the caustic visible point, the obtained caustic light rays can be photon tracked. After the caustic light rays are irradiated on a diffuse reflection surface in the three-dimensional scene after at least one refraction or reflection, according to the irradiated position on the diffuse reflection surface, the caustic photons can be obtained. After all the caustic light rays are tracked, all the obtained caustic photons together form a caustic photon map.
[0046] In the embodiments of the present disclosure, after the caustic photon map is obtained, a two-dimensional preview image with a caustic effect in the camera screen of the virtual camera at the current position can be generated according to the caustic photon map and each element in the three-dimensional scene, such as a background, a texture, a material and a model.
[0047] According to the embodiments of the present disclosure, the number of light rays that need to be tracked can be reduced by determining the caustic visible point and then determining the caustic light rays according to the caustic visible point, the efficiency of photon tracking is improved, the generation speed of the caustic effect is improved, and the quality of the generated caustic effect is improved.
[0048] Figure 3 is a flow diagram of a caustic effect generation method according to another embodiment of the present disclosure. In an implementation, the method can be used to implement S101 of the caustic effect generation method described above. In an implementation, determining a plurality of caustic visible points in a world space of a three-dimensional scene according to a position of a virtual camera can further include:
[0049] S301, emitting a plurality of camera light rays from the position of the virtual camera, and recording coordinate information and normal information of a world space of a diffuse reflection surface in the case that the plurality of camera light rays reach the diffuse reflection surface after at least one reflection or refraction; wherein the normal information includes normal information of a face sheet on which the plurality of camera light rays reach points;
[0050] S302, obtaining the plurality of caustic visible points according to the normal information and a direction of the virtual camera.
[0051] In the embodiments of the present disclosure, the current position of the virtual camera can be determined first, and a light source is created at the current position of the virtual camera to obtain a camera light source. A plurality of camera light rays are emitted in different directions from the camera light source, and the information of each irradiation position on the diffuse reflection surface after at least one refraction or reflection is recorded using the principle of simulating the effect of caustics generated by the camera light rays to obtain all possible positions that can generate the effect of caustics in the current three-dimensional scene. The information of each irradiation position can include the coordinate information and normal information of the world space of the patch irradiated by the camera light rays after at least one refraction or reflection. The diffuse reflection surface can include a plurality of patches.
[0052] In the embodiments of the present disclosure, the world coordinate system is a fixed reference frame used to determine the position of an object in a three-dimensional scene. The world coordinate system is a kind of absolute coordinate system, which is independent of any specific object or viewing angle and is globally unique. The world coordinate system is usually composed of three mutually perpendicular coordinate axes, which represent different spatial directions. For example, in the world coordinate system, the positions of the X-axis, Y-axis and Z-axis of an object can be defined. The origin is usually regarded as the starting point of space. Each object has a specific position in the world coordinate system, which is determined by the relative distance and direction of the object from the origin of the world coordinate system. The coordinate information of the world space of the diffuse reflection surface (which can be referred to as world coordinates for short) can include the coordinate information of the point (camera light ray arrival point) on the diffuse reflection surface reached by the camera light ray, and the normal information of the diffuse reflection surface includes the normal information of the patch on which the point reached by the camera light ray is located.
[0053] In the embodiments of the present disclosure, in a three-dimensional scene, a patch can include a triangular patch, a quadrilateral patch or a patch of other shapes. Among them, a triangular patch is a two-dimensional geometric figure composed of three vertices and three edges. Each edge connects two vertices, and finally forms a closed triangle. Triangular patches are usually used to describe the surface of a three-dimensional object, and a complex shape can be constructed by combining a large number of adjacent triangular patches. In a three-dimensional scene, many models such as walls, various furniture and daily necessities can be composed of patches. Different models can have different materials, and the patches constituting the models also include different materials. In the embodiments of the present disclosure, the material types of the patches can include mirror patches, transparent patches and diffuse reflection patches, etc. When a virtual light ray irradiates a mirror patch, the reflection angle of the light ray is calculated according to the incident angle of the virtual light ray. When a virtual light ray irradiates a transparent patch, the refraction angle of the light ray is calculated according to the refractive index of the transparent patch and the incident angle of the virtual light ray. When a virtual light ray irradiates a diffuse reflection patch, diffuse reflection occurs.
[0054] In the embodiments of the present disclosure, the included angle between the direction of the virtual camera and the normal direction of the patch can be calculated according to the direction of the virtual camera and the normal information of the patch, and then it can be determined whether the photon on the patch can be captured by the virtual camera according to the included angle. The position of the photon that can be captured by the virtual camera can be the caustic visible point. For example, if the included angle between the direction of the virtual camera and the normal direction of the patch is greater than or equal to 90°, the photon on the patch can be captured by the virtual camera; if the included angle between the direction of the virtual camera and the normal direction of the patch is less than 90°, the photon on the patch cannot be captured by the virtual camera. By using the direction of the virtual camera and the normal information of the patch, the caustic visible point that can be captured by the virtual camera at the current position can be screened from the arrival points of the camera rays on the diffuse reflection surface.
[0055] Figure 4 is a flowchart of a caustic effect generation method according to another embodiment of the present disclosure. The method can be used to implement the features of the caustic effect generation method of any of the above embodiments. In an implementation, the method can further include:
[0056] S401, determining a photon mapping storage precision according to the position of the virtual camera and the distances of the plurality of caustic visible points;
[0057] S402, pre-allocating a caustic photon mapping storage space according to the plurality of caustic visible points and the photon mapping storage precision;
[0058] S403, storing the caustic photon mapping according to the caustic photon mapping storage space.
[0059] In the embodiments of the present disclosure, the distance between the virtual camera and each caustic visible point can be calculated using the coordinate position of the virtual camera in the world coordinate and the coordinate position of each caustic visible point in the world coordinate. According to the calculated distance between the virtual camera and each caustic visible point, the distance interval in which the distance is located can be determined. Different distance intervals correspond to different photon mapping storage precisions. According to the distance interval in which the distance is located, the photon mapping storage precision of the caustic visible point can be determined. The photon mapping storage precision can represent the accuracy of the caustic photon mapping stored in the computer memory. For example, if the photon mapping storage precision is 1, it means that all the caustic photons in the caustic photon mapping are stored; if the photon mapping storage precision is 0.5, it means that half of the caustic photons in the caustic photon mapping are randomly stored.
[0060] In the embodiments of the present disclosure, the size of the storage space required for the caustic effect generated in the three-dimensional scene can be calculated according to the number of caustic visible points in each distance interval and the photon mapping storage precision. According to the calculated size of the storage space, the caustic photon mapping storage space can be pre-allocated in the computer memory. For example, the number of caustic visible points in three distance intervals is 50000, 30000 and 10000 respectively, the storage precision in the three intervals is 1, 0.8 and 0.5 respectively, and the storage space required for the caustic effect that can be generated on each caustic visible point is expected to be 1 kilobyte (Kb). Through calculation, 50000*1*1+30000*0.8*1+10000*0.5*1=79000Kb≈77 megabytes (Mb) is obtained, so 77Mb of caustic photon mapping storage space can be pre-allocated.
[0061] In the embodiments of the present disclosure, in the case of obtaining the caustic photon mapping by photon tracing of the caustic light rays, the obtained caustic photon mapping can be stored in the pre-allocated caustic photon mapping storage space according to the photon mapping storage precision.
[0062] According to the embodiments of the present disclosure, by setting photon mapping storage precisions of different precisions, the total amount of data that needs to be stored can be reduced, the occupation of storage resources when generating the caustic effect is reduced, and the total amount of data that needs to be calculated when generating the caustic effect is also reduced, thereby improving the efficiency of generating the caustic effect.
[0063] Figure 5 is a flowchart of a caustic effect generation method according to another embodiment of the present disclosure. The method can be used to implement S401 of the caustic effect generation method of any of the above embodiments. In an implementation, determining the photon mapping storage precision according to the position of the virtual camera and the distance of the plurality of caustic visible points can further include:
[0064] S501, calculating the distance from each patch where the plurality of caustic visible points are located to the virtual camera according to the position of the virtual camera and the coordinate information of the world space of the plurality of caustic visible points;
[0065] S502, determining the photon mapping storage precision according to the distance interval where the distance is located.
[0066] In the embodiments of the present disclosure, according to the distance between the face sheet where each focal caustic visible point is located and the virtual camera, the distance interval where each focal caustic visible point is located can be determined. Different photon mapping storage precisions can be set for different distance intervals. The distance intervals can be continuous distance divisions, for example, a distance interval can include [0, 10), [10, 20) and [20, 30], etc. The photon mapping storage precision of [0, 10) can be set to 1, the photon mapping storage precision of [10, 20) can be set to 0.8, and the photon mapping storage precision of [20, 30] can be set to 0.5. If the distance between a certain focal caustic visible point and the virtual camera is 8, then the distance interval where this focal caustic visible point is located can be [0, 10), and the photon mapping storage precision of this focal caustic visible point is set to 1.
[0067] According to the embodiments of the present disclosure, the farther the position from the virtual camera, the less information (for example, focal caustic photons) that can be captured by the camera. By setting different photon mapping storage precisions for different distance intervals, the storage space occupied by the focal caustic photon mapping can be reduced, for example, the storage space occupied by the focal caustic photon mapping far from the virtual camera can be reduced, and the generated focal caustic effect will not be affected.
[0068] In an implementation manner, as shown in FIG. 5, Figure 5 In an implementation manner, the method can be used to implement S402 of the focal caustic effect generation method of any one of the above-mentioned embodiments. In an implementation manner, pre-allocating the focal caustic photon mapping storage space according to the plurality of focal caustic visible points and the photon mapping storage precision can further include:
[0069] S503, determining the focal caustic photon mapping storage space according to the plurality of focal caustic visible points, the photon mapping storage precision and the rendering resolution.
[0070] In the embodiments of the present disclosure, the rendering resolution can be the resolution of the digital image output by the graphics card or the video output device, for example, 1920x1080 pixels, 2560x1440 pixels and 3840x2160 pixels, etc. The rendering resolution can be directly set by the three-dimensional modeling software. According to the plurality of focal caustic visible points, the photon mapping storage precision and the rendering resolution, the storage space required for storing the focal caustic photon mapping can be calculated. The rendering resolution can affect the size of the storage space occupied by each focal caustic visible point that can generate a focal caustic effect, for example, the storage space occupied by each focal caustic visible point is 1Kb under the resolution of 1920x1080 pixels; the storage space occupied by each focal caustic visible point is 2Kb under the resolution of 3840x2160 pixels.
[0071] According to the embodiments of the present disclosure, the size of the focal caustic photon mapping storage space corresponding to the focal caustic visible point can be determined, and the storage space for storing the focal caustic photon mapping and generating the focal caustic effect is provided.
[0072] In an embodiment, as shown in Figure 5 The method can be used to implement S403 of the caustics effect generation method of any of the above embodiments. In an embodiment, storing the caustic photon map according to the caustic photon map storage space can further include:
[0073] S504, respectively creating a hash index for each of the caustic photons in the caustic photon map in the caustic photon map storage space.
[0074] In the embodiments of the present disclosure, in the case of storing the caustic photon map, a hash algorithm can be used to create a hash index for each caustic photon in the caustic photon map, and each caustic photon and its corresponding hash index, as well as its corresponding parameters, are stored in the pre-allocated caustic photon map storage space.
[0075] According to the embodiments of the present disclosure, the hash index can be used to query each caustic photon stored in the caustic photon map storage space.
[0076] In an embodiment, as shown in Figure 3 The method can be used to implement S102 of the caustics effect generation method of any of the above embodiments. Determining a plurality of caustic rays according to the plurality of caustic visible points can further include:
[0077] S303, obtaining a guide table according to the plurality of guide rays in the global rays and the plurality of caustic visible points;
[0078] S304, sampling the global rays according to the guide table to obtain a plurality of caustic rays.
[0079] In the embodiments of the present disclosure, the guide rays can be rays randomly sampled from the global rays. By the guide rays and the caustic visible points, it is determined whether a point on the diffuse reflection surface reached by a guide ray coincides with a caustic visible point determined by the method of the above embodiments. If so, the light source position and initial direction of the guide ray are recorded in the guide table. The guide table can include a filtering condition for the light source position and initial direction of the ray. By filtering the rays through the guide table, rays that can produce a caustic effect can be obtained. For example, the global rays can include 10,000 rays, and 1,000 guide rays can be randomly sampled from the global rays. According to the caustic visible points, 100 rays can be filtered from the 1,000 randomly sampled guide rays and recorded in the guide table.
[0080] In the embodiments of the present disclosure, the guide table can be used to sample the global rays to obtain a plurality of caustic rays in the global rays that can produce a caustic effect.
[0081] According to the embodiments of the present disclosure, the focal light rays in the global light rays can be determined through the guide table, the number of light rays to be processed in subsequent photon tracing is reduced, the speed of producing the focal photon mapping is improved, meanwhile, the noise possibly generated by other light rays is reduced, and the quality of the generated focal effect is improved.
[0082] In an implementation, obtaining the guide table according to the plurality of guide light rays in the global light rays and the plurality of focal visible points can comprise:
[0083] obtaining a plurality of guide light rays from the global light rays, performing photon tracing on the plurality of guide light rays according to the plurality of focal visible points to obtain a guide photon mapping, wherein the guide photon mapping comprises a plurality of guide photons.
[0084] in a case where the number of the guide photons in the guide photon mapping reaches a threshold, calculating a probability density distribution according to the guide photon mapping.
[0085] obtaining a guide table according to the plurality of guide light rays and the probability density distribution.
[0086] In the embodiments of the present disclosure, the guide light rays can be randomly sampled from the global light rays of the current three-dimensional scene, the guide light rays are traced, the guide photon mapping of the focal visible points of the diffuse reflection surface in the three-dimensional scene irradiated by the guide light rays after at least one refraction or reflection is recorded, and the light source position and initial direction of the current guide photon corresponding to the light ray are recorded.
[0087] In the embodiments of the present disclosure, after the global light rays are randomly sampled for multiple times, the principle of focal effect generation is simulated, and a sufficient number of guide photons are obtained according to the focal visible points, the probability density distribution of the guide photon mapping can be calculated according to the number of the guide light rays sampled in total and the number of the guide photons generated.
[0088] In the embodiments of the present disclosure, the guide table can be determined according to the probability density distribution of the guide photon mapping and the light source position and initial direction of the guide light ray corresponding to the guide photon. The guide table can comprise the light source position and initial direction of the light ray capable of generating the guide photon.
[0089] According to the embodiments of the present disclosure, the guide table for sampling the focal light rays can be determined, and the efficiency of sampling the focal light rays is improved.
[0090] Figure 6 is a flowchart of a focal effect generation method according to another embodiment of the present disclosure. The method can comprise one or more features of the focal effect generation method of any of the above embodiments. In an implementation, the method can further comprise:
[0091] S601: Sampling the caustic photon map in adjacent patches of each patch where the multiple caustic visible points are located to obtain the number of times each caustic photon is sampled; wherein the number is used to determine the irradiance contribution of each caustic photon;
[0092] S602: Determine the brightness of a pixel corresponding to each caustic photon according to the irradiance contribution of the caustic photon mapping.
[0093] In the embodiment of the present disclosure, the irradiance of photons refers to the radiation flux incident on the surface per unit area, that is, the brightness of the light irradiating this position. When all caustic light rays are photon traced to obtain a caustic photon map, the caustic photon map can be stored in the form of a hash index. The stored caustic photon map includes the position of each caustic photon, such as the surface where it is located. According to the hash index, the caustic visible points can be traversed, and the adjacent surfaces around each caustic visible point can be sampled. The number of times the caustic photons in the surrounding adjacent surfaces are sampled is recorded to obtain the irradiance contribution of each caustic photon. The more times a caustic photon is sampled, the higher its irradiance contribution, the higher the irradiance of the corresponding photon, and the higher the displayed brightness.
[0094] In the disclosed embodiments, when generating a 2D preview image with a caustic effect, each element in the 3D scene, including caustic photons, is projected onto each pixel in the virtual camera's screen space. After determining the irradiance contribution of the caustic photon mapping, the brightness of each corresponding pixel can be determined.
[0095] According to the embodiment of the present disclosure, the brightness of the corresponding pixel can be quickly obtained through the irradiance contribution of the caustic photon mapping, thereby improving the efficiency of generating the caustic effect.
[0096] In one embodiment, Figure 3 As shown, this method can be used to implement S104 of the caustic effect generation method of any of the above embodiments. Generating an image with a caustic effect according to the stored caustic photon map and the three-dimensional scene includes:
[0097] S305. Determine, based on the stored coordinates and irradiance contributions of the plurality of caustic photons, positions and brightnesses of caustic pixels corresponding to the plurality of caustic photons in the screen space of the virtual camera;
[0098] S306 : Generate a two-dimensional preview image with a caustic effect corresponding to the three-dimensional scene according to the position and brightness of the caustic pixel and other elements in the three-dimensional scene.
[0099] In the disclosed embodiments, the position of the caustic pixel corresponding to each caustic photon in the screen space of the virtual camera can be determined using the world coordinates of each caustic photon based on the conversion relationship between world coordinates and camera coordinates. The brightness of the corresponding caustic pixel in the screen space of the virtual camera can be determined based on the irradiance contribution of each caustic photon.
[0100] In the embodiment of the present disclosure, a two-dimensional preview image with a caustic effect corresponding to the three-dimensional scene can be generated based on the position and brightness of the caustic pixels, as well as the position, color, and brightness of the scene pixels projected on the camera screen by the conversion relationship between world coordinates and camera coordinates of other elements in the three-dimensional scene, such as models, lighting, materials, and textures. For example, a sphere with a diffuse reflective surface is placed in a swimming pool filled with water. After being processed by the caustic effect generation method in the above embodiment of the present disclosure, the following can be obtained: Figure 7a For example, two arc-shaped transparent ornaments are placed on a diffuse reflection surface, and after being processed by the caustic effect generation method in the above embodiment of the present disclosure, the following image can be obtained: Figure 7b 2D preview image shown.
[0101] According to the embodiments of the present disclosure, the efficiency and quality of generating a two-dimensional preview image with a caustic effect corresponding to a three-dimensional scene can be improved.
[0102] The structure of the Photon Map pre-calculation method based on screen space in one embodiment of the present disclosure is as follows: Figure 8 In one embodiment, the visible point of the caustic can be sampled first, and then the storage space of the PhotonMap is allocated according to the screen space. Then, photon tracing is performed from the light source, and the guidance table is calculated based on the generated valid photons. Finally, the contribution of the PhotonMap is calculated in the lighting calculation of the main rendering process to finally generate the caustic effect. The specific process is as follows:
[0103] S801. Calculate Visible Point
[0104] The Visible Point is a point visible relative to the camera. It's calculated by recording the world-space coordinates and normal information of a ray starting from the camera, after at least one reflection or refraction, and hitting a diffuse surface. Its primary function is to indicate the location visible to the camera (observer) that can produce a caustic effect. When subsequently storing a Photon Map, the Visible Point serves as a basis for determining whether to store the Photon Map, enabling efficient photon screening and caching of photons that contribute to the final result.
[0105] S802, allocate Photon Map
[0106] According to the distance from the object position to the camera screen, the storage precision of the Photon Map is higher when the distance is closer to the camera, and vice versa. Meanwhile, the photons are stored by the hash map idea. First, the storage space is pre-allocated according to the rendering resolution and the layering precision, and then when the photon (or Visible Point) is obtained, the storage index is calculated according to the world coordinates and the hash algorithm, and the photon (or Visible Point) is stored.
[0107] S803, calculate Photon Trace
[0108] The Photon Trace can include: first, sample the light source surface to obtain the initial position information of the light ray. Then sample the emission direction of the light ray according to the characteristics of the light source to obtain the initial light ray. Then trace in the scene to calculate the photon. For example, taking a spherical light source as an example, the position information is obtained by sampling the spherical surface, and then the light ray direction is obtained by sampling the hemisphere according to the normal at the sampling point.
[0109] In an embodiment of the present disclosure, the Photon Trace can be accelerated by the strategy of the guiding table. For fixed light sources, the sampling of the initial light ray can be represented as a two-order sampling of position and direction, as shown in Figure 9
[0110] The left side is the position table (Position Table), and the right side is the direction table (Direction Table). Each element in the Position Table corresponds to a Direction Table.
[0111] Furthermore, the Position Table and the Direction Table can be represented as two-dimensional random number sampling of [0, 1] x [0, 1]. Taking a spherical light source as an example, given the spherical center coordinates and the radius, the position sampling is performed on the spherical surface equation according to the input two-dimensional random number of [0, 1] x [0, 1], and then the direction sampling is performed on the hemisphere by another two-dimensional random number of [0, 1] x [0, 1]. Other types of light sources, such as area light sources and IES light sources, can be similarly applied.
[0112] After each light ray gets an effective photon, we record the initial position and initial direction of the light ray, and calculate the cumulative probability density distribution. When a certain number of photons are sampled, the initial position and initial direction of the light ray are sampled according to the guiding table, so as to improve the speed of sampling effective photons. Among them, the direction of sunlight is fixed, and only the initial light ray position needs to be sampled. We generate a disc by projecting the entire scene bounding sphere along the reverse direction of the sunlight direction, and obtain the initial position of the light ray by sampling the disc.
[0113] S804, calculate the caustic contribution
[0114] In the process of path tracing, while calculating the illumination, the photon map can be sampled according to the neighborhood of the world coordinates to calculate the contribution of the photon map to the radiance.
[0115] According to the embodiments of the present disclosure, the storage efficiency of the Photon Map is improved according to the calculation of the Visible Point in the screen space and the hash algorithm, and the storage space is saved. The efficiency of sampling effective photons is improved by caching the information of effective photons through the guiding table, and the caustic convergence is accelerated. The method of screen space distance division is applied to store photon information, without the need for photon collection, and the performance of caustic calculation is improved. The powerful parallel computing capability of GPU is utilized, and the calculation performance is good. According to the advantages of screen space distance division and hash algorithm, the storage efficiency of the Photon Map is improved. The convergence efficiency of the caustic is improved by using the Guiding Table idea.
[0116] Figure 10 is a structural schematic diagram of a caustic effect generation device according to an embodiment of the present disclosure. In an embodiment, the device can include:
[0117] The visible point determination module 1001 is configured to determine a plurality of caustic visible points in the world space of the three-dimensional scene according to the position of the virtual camera.
[0118] The light ray determination module 1002 is configured to determine a plurality of caustic light rays according to the plurality of caustic visible points.
[0119] The tracking module 1003 is configured to perform photon tracing on the plurality of caustic light rays to obtain a caustic photon map; wherein the caustic photon map includes a plurality of caustic photons.
[0120] The generation module 1004 is configured to generate an image with a caustic effect according to the caustic photon map and the three-dimensional scene.
[0121] Figure 11is a structural schematic diagram of a caustics generation device according to another embodiment of the present disclosure. The device can include a visible point determination module 1101, a light ray determination module 1102, a tracking module 1103, and a generation module 1104. The functions of the above modules can refer to the functions of the modules of the caustics generation device in the above embodiments. In an implementation, the visible point determination module 1001 can include:
[0122] A recording sub-module 11011 is configured to emit a plurality of camera light rays from the position of the virtual camera, and record coordinate information and normal information of a world space of a diffuse reflection surface in the case that the plurality of camera light rays reach the diffuse reflection surface after at least one reflection or refraction; wherein the normal information includes normal information of a patch on which the plurality of camera light rays reach points.
[0123] A determination sub-module 11012 is configured to obtain the plurality of caustic visible points according to the normal information and a direction of the virtual camera.
[0124] In an implementation, as shown in Figure 11 The device can further include:
[0125] A storage precision determination module 1105 is configured to determine a photon mapping storage precision according to a position of the virtual camera and distances of the plurality of caustic visible points.
[0126] An allocation module 1106 is configured to pre-allocate a caustic photon mapping storage space according to the plurality of caustic visible points and the photon mapping storage precision.
[0127] A storage module 1107 is configured to store the caustic photon mapping according to the caustic photon mapping storage space.
[0128] In an implementation, as shown in Figure 11 The storage precision determination module 1105 includes:
[0129] A distance determination sub-module 11051 is configured to calculate distances from each patch where the plurality of caustic visible points are located to the virtual camera according to the position of the virtual camera and coordinate information of a world space of the plurality of caustic visible points.
[0130] A precision determination sub-module 11052 is configured to determine the photon mapping storage precision according to a distance interval where the distances are located.
[0131] In an implementation, the allocation module 1106 is further configured to determine the caustic photon mapping storage space according to the plurality of caustic visible points, the photon mapping storage precision, and a rendering resolution.
[0132] In an implementation, the storage module 1107 is further configured to create a hash index for each of the plenoptic rays in the plenoptic ray map in the plenoptic storage space.
[0133] In an implementation, as shown in Figure 11 the ray determination module 1102 includes:
[0134] a guide table obtaining sub-module 11021 configured to obtain a guide table according to a plurality of guide rays in the global ray and the plurality of plenoptic visible points;
[0135] a sampling sub-module 11022 configured to sample the global ray according to the guide table to obtain a plurality of plenoptic rays.
[0136] In an implementation, the guide table obtaining sub-module is further configured to:
[0137] obtain a plurality of guide rays from the global ray, perform photon tracing on the plurality of guide rays according to the plurality of plenoptic visible points to obtain a guide plenoptic map; the guide plenoptic map includes a plurality of guide plenoptic points;
[0138] in a case where the number of the guide plenoptic points in the guide plenoptic map reaches a threshold, calculate a probability density distribution according to the guide plenoptic map;
[0139] obtain a guide table according to the plurality of guide rays and the probability density distribution.
[0140] In an implementation, as shown in Figure 11 the device can further include:
[0141] a sampling module 1108 configured to sample the plenoptic ray map in an adjacent patch of each patch where the plurality of plenoptic visible points are located to obtain a number of times each plenoptic point is sampled; wherein the number of times is used to determine the irradiance contribution of each plenoptic point;
[0142] a brightness determination module 1109 configured to determine the brightness of a pixel corresponding to each plenoptic point according to the irradiance contribution of the plenoptic ray map.
[0143] In an implementation, as shown in Figure 11 the generation module 1104 includes:
[0144] a plenoptic pixel determination sub-module 11041 configured to determine the position and brightness of a plenoptic pixel corresponding to the plurality of plenoptic points in the screen space of the virtual camera according to the stored coordinates and irradiance contribution of the plurality of plenoptic points;
[0145] The generating submodule 11042 is configured to generate a two-dimensional preview image with a caustic effect corresponding to the three-dimensional scene according to the position and brightness of the caustic pixels and other elements in the three-dimensional scene.
[0146] For the description of specific functions and examples of each module and submodule of the device in the embodiment of the present disclosure, please refer to the relevant description of the corresponding steps in the above method embodiment, which will not be repeated here.
[0147] In the technical solutions disclosed herein, the acquisition, storage, and application of user personal information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0148] Figure 12 FIG. 1 is a structural block diagram of an electronic device according to an embodiment of the present disclosure. Figure 12 As shown, the electronic device includes: a memory 1210 and a processor 1220. The memory 1210 stores a computer program that can be executed on the processor 1220. The number of memories 1210 and processors 1220 can be one or more. The memory 1210 can store one or more computer programs. When the one or more computer programs are executed by the electronic device, the electronic device performs the method provided by the above method embodiment. The electronic device may also include: a communication interface 1230 for communicating with external devices and performing data exchange.
[0149] If the memory 1210, the processor 1220, and the communication interface 1230 are implemented independently, the memory 1210, the processor 1220, and the communication interface 1230 can be connected to each other via a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 11 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0150] Optionally, in a specific implementation, if the memory 1210, the processor 1220 and the communication interface 1230 are integrated on a chip, the memory 1210, the processor 1220 and the communication interface 1230 can communicate with each other through an internal interface.
[0151] It is to be understood that the above-described processor can be a Central Processing Unit (CPU), but can also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic components, discrete hardware components, or the like. The general purpose processor can be a microprocessor or any conventional processor, or the like. It is to be appreciated that the processor can be an Advanced RISC Machines (ARM) architecture processor.
[0152] Further, the memory can optionally include a read-only memory and a random access memory, and can also include a non-volatile random access memory. The memory can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. The non-volatile memory can include a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically EPROM (EEPROM), or a flash memory. The volatile memory can include a Random Access Memory (RAM) used as an external cache. By way of example, but not limitation, many forms of RAM can be used. For example, a Static Random Access Memory (SRAM), a Dynamic Random Access Memory (DRAM), a Synchronous DRAM (SDRAM), a Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), an Enhanced SDRAM (ESDRAM), a Synchlink DRAM (SLDRAM), and a Direct RAMBUS RAM (DR RAM) can be used.
[0153] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present disclosure is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, data subscriber line (DSL)) or wireless (e.g., infrared, Bluetooth, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, or a magnetic tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid-state drive (SSD)). It is worth noting that the computer-readable storage medium mentioned in the present disclosure may be a non-volatile storage medium, in other words, a non-transient storage medium.
[0154] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.
[0155] In the description of the embodiments of the present disclosure, the reference terms "one embodiment," "some embodiments," "example," "specific example," or "some examples" mean that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. Moreover, the specific features, structures, materials, or characteristics described may be combined in any appropriate manner in any one or more embodiments or examples. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification, as well as features of different embodiments or examples, unless they are mutually inconsistent.
[0156] In the description of the embodiments of the present disclosure, unless otherwise specified, " / " means or, for example, A / B can mean A or B. "And / or" in this document only describes the relationship between associated objects, which means that there can be three relationships, for example, A and / or B, which can mean: A exists alone, A and B exist together, and B exists alone.
[0157] In the description of the embodiments of the present disclosure, the terms "first", "second" are only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, the meaning of "multiple" is two or more.
[0158] The above only describes exemplary embodiments of the present disclosure, and is not intended to limit the present disclosure. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for generating a caustic effect, comprising: According to the position of the virtual camera, multiple caustic visible points are determined in the world space of the three-dimensional scene; determining a plurality of caustic rays according to the plurality of caustic visible points; Performing photon tracing on the plurality of caustic rays to obtain a caustic photon map; wherein the caustic photon map includes a plurality of caustic photons; An image with a caustic effect is generated according to the caustic photon mapping and the three-dimensional scene.
2. The method according to claim 1, wherein Based on the position of the virtual camera, multiple caustic visible points are determined in the world space of the 3D scene, including: Emitting multiple camera rays from the position of the virtual camera, and recording world-space coordinate information and normal information of the diffuse reflective surface when the multiple camera rays reach the diffuse reflective surface after at least one reflection or refraction; wherein the normal information includes normal information of the surface patch on the diffuse reflective surface where the multiple camera rays arrive; The multiple caustic visible points are obtained according to the normal information and the direction of the virtual camera.
3. The method according to claim 1 or 2, further comprising: determining a photon mapping storage accuracy according to a position of the virtual camera and distances between the plurality of caustic visible points; pre-allocating caustic photon mapping storage space according to the plurality of caustic visible points and the photon mapping storage precision; The caustic photon map is stored according to the caustic photon map storage space.
4. The method according to claim 3, wherein: Determining a photon mapping storage accuracy according to a position of the virtual camera and distances between the plurality of caustic visible points includes: Calculate the distance from each patch where the multiple caustics visible points are located to the virtual camera according to the position of the virtual camera and the world space coordinate information of the multiple caustics visible points; The photon mapping storage accuracy is determined according to the distance interval in which the distance lies.
5. The method according to claim 3 or 4, wherein: Pre-allocating caustic photon mapping storage space according to the plurality of caustic visible points and the photon mapping storage precision includes: The caustic photon mapping storage space is determined according to the multiple caustic visible points, photon mapping storage accuracy and rendering resolution.
6. The method according to any one of claims 3 to 5, wherein Storing the caustic photon map according to the caustic photon map storage space includes: A hash index is created in the caustic photon map storage space for each of the caustic photons in the caustic photon map.
7. The method according to claim 1 or 2, wherein: Determining a plurality of caustic rays according to the plurality of caustic visible points includes: Obtaining a guide table according to the plurality of guide rays in the global light and the plurality of caustic visible points; The global light is sampled according to the guide table to obtain a plurality of caustic rays.
8. The method according to claim 7, wherein: According to the plurality of guide rays in the global light and the plurality of caustic visible points, a guide table is obtained, including: Acquire multiple guiding rays from the global ray, perform photon tracing on the multiple guiding rays according to the multiple caustic visible points, and obtain a guiding photon map; the guiding photon map includes multiple guiding photons; When the number of the guide photons in the guide photon map reaches a threshold, calculating a probability density distribution according to the guide photon map; A guide table is obtained according to the plurality of guide rays and the probability density distribution.
9. The method according to any one of claims 1 to 8, further comprising: Sampling the caustic photon map in adjacent patches of each patch where the multiple caustic visible points are located to obtain the number of times each caustic photon is sampled; wherein the number is used to determine the irradiance contribution of each caustic photon; The brightness of the pixel corresponding to each caustic photon is determined according to the irradiance contribution of the caustic photon mapping.
10. The method according to any one of claims 1 to 9, wherein Generating an image with a caustic effect according to the stored caustic photon map and the three-dimensional scene, comprising: Determining positions and brightnesses of caustic pixels corresponding to the plurality of caustic photons in the screen space of the virtual camera according to the stored coordinates and irradiance contributions of the plurality of caustic photons; A two-dimensional preview image with a caustic effect corresponding to the three-dimensional scene is generated according to the position and brightness of the caustic pixel and other elements in the three-dimensional scene.
11. A caustic effect generating device, comprising: A visible point determination module, for determining a plurality of caustic visible points in the world space of the three-dimensional scene according to the position of the virtual camera; a light determining module, configured to determine a plurality of caustic rays according to the plurality of caustic visible points; a tracing module, configured to perform photon tracing on the plurality of caustic rays to obtain a caustic photon map; wherein the caustic photon map includes a plurality of caustic photons; A generation module is used to generate an image with a caustic effect according to the caustic photon mapping and the three-dimensional scene.
12. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.
13. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 10.
14. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 10.