WO2015070618A1 - 多光源下的全局光照绘制方法及装置 - Google Patents

多光源下的全局光照绘制方法及装置 Download PDF

Info

Publication number
WO2015070618A1
WO2015070618A1 PCT/CN2014/080927 CN2014080927W WO2015070618A1 WO 2015070618 A1 WO2015070618 A1 WO 2015070618A1 CN 2014080927 W CN2014080927 W CN 2014080927W WO 2015070618 A1 WO2015070618 A1 WO 2015070618A1
Authority
WO
WIPO (PCT)
Prior art keywords
matrix
geometric
sub
virtual point
light source
Prior art date
Application number
PCT/CN2014/080927
Other languages
English (en)
French (fr)
Inventor
王锐
鲍虎军
霍宇驰
周炯
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2015070618A1 publication Critical patent/WO2015070618A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/506Illumination models

Definitions

  • the present invention relates to the field of illumination rendering, and in particular to a method and apparatus for global illumination rendering under multiple light sources. Background technique
  • Global illumination is a commonly used rendering technique used to generate lighting effects such as soft shadows and indirect refractions to enhance the realism of rendering effects.
  • the method based on a large number of point light sources (Many Point Lights) is one of the techniques for generating global illumination effects.
  • the principle is to generate a large number of virtual point light sources (VPLs) in the scene, and calculate the sampling points of each angle by separately. The degree to which these virtual point sources illuminate to achieve global illumination.
  • Wald et al. invented the Lightcuts method based on a large number of point source frames, built a hierarchical tree from virtual point sources and used a cut set of the hierarchical tree to represent all virtual point sources to reduce the amount of computation and speed up the operation.
  • the technical problem to be solved by the present invention is how to impose a large gauge on a plurality of objects.
  • the modal scene is drawn for global illumination.
  • a global illumination rendering method under multiple light sources for global illumination rendering of a scene containing a plurality of objects, the object being geometrically Described, the method is performed by a system having a memory and coupled to an external memory, the method comprising:
  • the third quantity is a number of clusters of the sampling points
  • the brightness contribution value of the virtual point source with the visibility is visible to the sampling point is added to the corresponding sampling point, and the total brightness of the sampling point is output.
  • the geometric patch and the virtual point light source in the scene are respectively processed based on position information, to obtain a first quantity of geometric blocks and a second quantity of light sources Block, including:
  • the first space bounding box comprises two spheres and a side connecting the two spheres, one sphere is a smallest sphere containing all sampling points in the sub-matrix, and the other sphere is included in all the sub-matrices a minimum sphere of a virtual point source, intersecting the two sections obtained by intersecting the planes perpendicular to the spheres of the two spheres on the two spheres
  • the sides are respectively connected to form the side.
  • All geometric patches of the geometric block are included in a second spatial bounding box, each geometric block corresponding to a second spatial bounding box,
  • the second space bounding box is composed of a minimum axis aligned cuboid containing all geometric patches in the geometric block.
  • the method before the sub-matrix and the geometric block are transferred from the external storage to the memory, the method further includes: Determining that the shortest distance from the central axis of the first space bounding box to the second space bounding box is If it is not greater than the radius of the larger sphere in the first space bounding box, it is determined that the corresponding sub-matrix and the geometric block need to be tested for visibility, otherwise it is determined that the corresponding sub-matrix and the geometric block do not need to be tested for visibility. And mark the virtual point source in the submatrix as visible to the sample point.
  • the sub-matrix and the geometric block are transferred from the external storage into the memory, according to the virtual
  • the material properties, attenuation properties, visibility, and light intensity of the point source are calculated, and the brightness contribution values of the virtual point source in the corresponding sub-matrix to the sampling point are calculated, including:
  • Sub-matrices and geometric blocks determined to require visibility testing are loaded from the external memory into the memory;
  • the virtual point source includes a virtual point source that is visible as a result of the visibility test and the virtual point source that is marked as visible.
  • the sub-matrix and the geometric block of the called are tested for visibility, including:
  • an intersection operation is performed with the geometric patches in the geometric block, and if the operation result is intersecting, it is determined that the virtual point light source pair The sampling point is not visible; if the operation result is disjoint, it is determined that the virtual point source is visible to the sampling point.
  • the sub-matrix and the geometric block are transferred from the external storage to the memory, including:
  • geometric blocks corresponding to sub-matrices determined to require visibility testing are loaded from the external memory into the memory.
  • the loading the sub-matrix and the geometric block from the external storage into the memory includes:
  • a global illumination rendering apparatus under multiple light sources for global illumination rendering of a scene including a plurality of objects, Described by a geometric patch, the method is performed by a system having a memory coupled to an external memory, the device comprising:
  • a block processing module configured to process the geometric patch and the virtual point light source in the scene based on the position information, respectively, to obtain a first number of geometric blocks and a second number of light source blocks;
  • An optical transfer matrix establishing module configured to establish, by using all the sampling points in the scene as row coordinates, a light transfer matrix by using all virtual point light sources as column coordinates;
  • a sub-matrix partitioning module configured to divide the optical transfer matrix into the second number of columns, each column corresponding to one of the light source blocks, and dividing the optical transfer matrix into a third number of rows, each row and Each column intersects to form a sub-matrix, and the third number is a cluster number brightness contribution value calculation module of the sampling point, configured to load the sub-matrix and the geometric block from the external memory into the memory Calculating a brightness contribution value of the virtual point source in the corresponding sub-matrix to the sampling point according to the material property, the attenuation property, the visibility, and the light intensity of the virtual point source;
  • the output module accumulates the brightness contribution value of the virtual point source with the visibility to the sampling point to the corresponding sampling point, and outputs the total brightness of the sampling point.
  • the block processing module is configured to: Calculating, respectively, a position code of a center of gravity of the geometric patch and a center of gravity of the virtual point source on an x-axis, a y-axis, and a z-axis, where a center of gravity of the geometric patch forms position information of the geometric patch,
  • the center of gravity of the virtual point source constitutes position information of the virtual point source;
  • the method further includes:
  • a space bounding box establishing module configured to establish a first space bounding box, and include a connection line of all the virtual point light sources and sampling points in the sub-matrix in a first space bounding box, where each sub-matrix corresponds to one a space bounding box,
  • the first space bounding box comprises two spheres and a side connecting the two spheres, one sphere is a smallest sphere containing all sampling points in the sub-matrix, and the other sphere is included in all the sub-matrices a minimum sphere of a virtual point source, intersecting the two sections obtained by intersecting the planes perpendicular to the spheres of the two spheres on the two spheres
  • the sides are respectively connected to form the side.
  • the space bounding box establishing module is further configured to establish a second space bounding box, and all geometric patches of the geometric block are Included in the second space bounding box, each geometric block corresponds to a second space enclosure.
  • the second space bounding box is composed of a minimum axis aligned cuboid containing all geometric patches in the geometric block.
  • the method further includes: a visibility test judging module, configured to determine whether a shortest distance from a central axis of the first space bounding box to the second space bounding box is not greater than a radius of a larger sphere in the first space bounding box, Visibility tests are required for the corresponding sub-matrices and geometric blocks. Otherwise, it is determined that the corresponding sub-matrices and geometric blocks do not need to be tested for visibility, and the virtual point sources in the sub-matrices are marked as visible to the sampling points.
  • a visibility test judging module configured to determine whether a shortest distance from a central axis of the first space bounding box to the second space bounding box is not greater than a radius of a larger sphere in the first space bounding box, Visibility tests are required for the corresponding sub-matrices and geometric blocks. Otherwise, it is determined that the corresponding sub-matrices and geometric blocks do not need to be tested for visibility, and the virtual point sources in the sub-matrices are marked as visible to the sampling points.
  • the brightness contribution value calculation module includes:
  • a call-in unit for transferring a sub-matrix and a geometric block that are determined to require a visibility test from the external memory into the memory
  • a test unit configured to perform a visibility test on the called sub-matrix and the geometric block; and a calculation unit, configured to calculate, according to a material property, an attenuation property, a visibility, and a light intensity of the virtual point light source in the sub-matrix
  • the visibility in the sub-matrix is a visible virtual point source contributing value to the sample point brightness, the visibility being a visible virtual point source including the result of the visibility test being a visible virtual point source and the mark being visible Virtual point source.
  • the testing unit is configured to:
  • an intersection operation is performed with the geometric patches in the geometric block, and if the operation result is intersecting, it is determined that the virtual point light source pair The sampling point is not visible; if the operation result is disjoint, it is determined that the virtual point source is visible to the sampling point.
  • the calling unit is configured to:
  • geometric blocks corresponding to sub-matrices determined to require visibility testing are loaded from the external memory into the memory.
  • the call-in unit is configured to:
  • a global illumination rendering method including:
  • the geometric patch and the virtual point source of the scene are respectively processed based on the Morton code to obtain a first number of geometric blocks and a second number of light source blocks;
  • the luminance contribution value of the visible light is accumulated on the sampling point of the corresponding sub-matrix, and the total luminance contribution value of the sampling point is output.
  • the geometric patch and the virtual point light source of the scene are respectively processed based on a Morton code to obtain a first number of geometric blocks and a second number of light source blocks.
  • the method further includes:
  • the shortest distance from the central axis of the first space bounding box to the second space bounding box is not greater than the radius of the larger sphere constituting the first space bounding box, it is determined that the corresponding sub-matrix and the geometric block need to be performed. Visibility test.
  • a sphere of the first space bounding box is centered on a space center of all sampling points in the sub-matrix The farthest distance from the sampling point to the center of the sphere is a radius.
  • Another sphere is centered on the space center of all the virtual point sources in the sub-matrix, and the farthest distance from the virtual point source to the center of the sphere is a radius.
  • the sides where the two intersecting faces intersect the two spheres are respectively joined to form the side faces by respectively cutting the spherical cores on the two spheres and perpendicular to the spherical center of the two spheres.
  • the second space bounding box is surrounded by the smallest X-axis, the y-axis of all geometric patches, The z-axis coordinates and the maximum X-axis, y-axis, and z-axis coordinates are enclosed.
  • the determining, according to a material attribute, an attenuation attribute, a visibility, and a light intensity of each virtual point source, a ray in the corresponding sub-matrix Brightness contribution values including:
  • the sub-matrix and the geometric block determined to be subjected to the visibility test are transferred from the external memory into the memory in units of blocks; the visibility test is performed on the transferred sub-matrices and geometric blocks;
  • a brightness contribution value of the light passing through the visibility test in the sub-matrix is calculated according to a material property, an attenuation property, a visibility, and a light intensity of the virtual point source in the sub-matrix.
  • the sub-matrix and the geometric block that are determined to require the visibility test are transferred from the external storage to the memory in block units.
  • the geometric block corresponding to the sub-matrix marked for visibility testing is loaded according to the Morton code number of the geometric block.
  • the sub-matrix and the geometric block that are determined to require the visibility test are transferred from the external storage to the memory in block units.
  • Each sub-matrix to be calculated is combined with a corresponding geometric block that needs to be tested for visibility as a node, and the amount of data read and write that needs to be performed by the first node to the second node is used as an edge connecting the two nodes.
  • Sub-matrices and geometry blocks marked as requiring visibility testing are loaded from memory to memory.
  • the performing the visibility test on the sub-matrix and the geometric block including:
  • a global illumination drawing apparatus including:
  • a block processing module configured to process the geometric patch and the virtual point source of the scene based on the Morton code, respectively, to obtain a first number of geometric blocks and a second number of light source blocks;
  • a matrix establishing module configured to use a sampling point of the scene as a row coordinate, and establish a light transmission matrix by using the virtual point source as a column coordinate;
  • a visibility test judging module configured to divide the optical transfer matrix into the second number of columns, divide the optical transfer matrix into a third number of rows, and each row intersects each column to form a sub-matrix,
  • the third quantity is a number of clusters of the sampling points
  • a brightness contribution value calculation module configured to calculate a brightness contribution value of the light in the corresponding sub-matrix according to the material property, the attenuation property, the visibility, and the light intensity of each virtual point light source;
  • an image output module configured to accumulate a brightness contribution value of the visible light to the sampling point of the corresponding sub-matrix, and output a total brightness contribution value of the sampling point.
  • the global illumination drawing method and device under multiple light sources divides the virtual point light into the light source block by dividing the geometric patch into geometric blocks, and the geometric patch and the virtual block in the block unit from the external memory.
  • the point source is read into the memory for processing, which significantly improves the global illumination rendering speed and efficiency, and is suitable for drawing large-scale, high-precision external scenes.
  • FIG. 1 shows a flow of a global illumination rendering method under multiple light sources in accordance with one embodiment of the present invention.
  • FIG. 2 is a flow chart showing a global illumination rendering method under multiple light sources according to another embodiment of the present invention.
  • FIG. 3 is a schematic diagram showing a scene to be drawn according to another embodiment of the present invention.
  • FIG. 4 is a schematic diagram showing generation of sampling points based on ray intersections according to another embodiment of the present invention.
  • FIG. 5 is a schematic diagram showing an optical transfer matrix according to another embodiment of the present invention.
  • FIG. 6 shows a schematic view of a vertebral body space bounding box according to another embodiment of the present invention.
  • Figure 7 is a schematic view showing a shaft-aligned space bounding box according to another embodiment of the present invention
  • Figure 8 is a view showing a distance between a vertebral body space bounding box and an axis-aligned space bounding box according to another embodiment of the present invention
  • Figure 9 shows a schematic diagram of a visibility test in accordance with another embodiment of the present invention.
  • 10a and 10b are schematic views respectively showing a light tree and a light cut in the prior art
  • Figure 11a and Figure lib respectively show schematic diagrams of the operations of loading into the geometry block
  • FIG. 12 illustrates a schematic diagram of a global illumination rendering method under multiple light sources in accordance with another embodiment of the present invention.
  • FIG. 13 is a block diagram showing the structure of a global illumination drawing device under multiple light sources according to another embodiment of the present invention.
  • FIG. 14 is a block diagram showing the structure of a network device according to another embodiment of the present invention. detailed description
  • FIG. 1 shows a flow diagram of a global illumination rendering method under multiple light sources, in accordance with an embodiment of the present invention. As shown in Figure 1, the method mainly includes:
  • Step 10 processing the geometric patch and the virtual point source of the scene based on the Morton code, respectively, obtaining a first number of geometric blocks and a second number of light source blocks;
  • Step 20 taking a sampling point of the scene as a row coordinate, and establishing a light transmission matrix by using the virtual point source as a column coordinate;
  • Step 30 Divide the optical transfer matrix into the second number of columns, divide the optical transfer matrix into a third number of rows, and each row intersects each column to form a sub-matrix, the third The number is the number of clusters of the sampling points;
  • Step 40 Calculate a brightness contribution value of the light in the corresponding sub-matrix according to the material property, the attenuation property, the visibility, and the light intensity of each virtual point source;
  • Step 50 Accumulate the brightness contribution value of the visible light to the sampling point of the corresponding sub-matrix, and output the total brightness of the sampling point.
  • FIG. 2 shows a flow chart of a global illumination rendering method in accordance with another embodiment of the present invention.
  • the global illumination rendering method is used to render a scene containing objects and shadows.
  • the method mainly includes:
  • Step 100 Read in and process the geometric information.
  • the steps specifically include:
  • Step 101 Read the triangle patch.
  • each The surface of each object is described by a patch.
  • the properties of the patch include triaxial coordinates, normal or texture. Patches can be produced by known commercial modeling software such as 3dsMax, Maya, and the like.
  • the disordered triangular patch is used as the geometric information, and the triangular patch is taken as an input, and all the properties are known, and other patches such as a quadrangular patch may be used for description.
  • Step 102 Sort the triangular patches.
  • the Out-of-Core sorting tool such as the ExSort library, is used to sort the triangular patches, and the sorting process includes:
  • Step 1011 Calculate a position code of a center of gravity of each triangular slice on the X axis, the y axis, and the z axis. Because the scenes drawn are stereo scenes, each triangle patch has X-axis, y-axis, and z-axis coordinates, and the center of gravity of the triangle patch is the intersection of the three centerlines of the triangle.
  • the X-axis between the maximum X-axis coordinate and the minimum X-axis coordinate of the center of gravity of the read triangular face piece is called L, and the L average is divided into 2 1Q segments, and each segment is made in order.
  • the mark requires a total of 10 bits of mark length, so that the X-axis coordinates correspond one-to-one with the mark; according to the X coordinate of the space point, the corresponding mark can be obtained, which is the X-axis position code of the space point.
  • the X-axis position code, the y-axis position code, and the z-axis position code of each triangular patch space point can be calculated.
  • Step 1022 Calculate a complete Morton code according to the X-axis position code, the y-axis position code, and the z-axis position code of the center of gravity.
  • the method of misalignment is used for calculation.
  • the first bit of the Morton code is the first bit of the X-axis position code
  • the second bit of the Morton code is the first bit of the y-axis position code
  • the Morton code is the third bit.
  • the bit is the first bit of the z-axis position code
  • the fourth bit of the Morton code is the second bit of the X-axis position code
  • the fifth bit of the Morton code is the second bit of the y-axis position code
  • the sixth bit of the Morton code is the z-axis position.
  • the second digit of the code, and so on, until a Morton code of 30 bits length is obtained.
  • Step 1023 Sort and divide the triangular patches according to the Morton code.
  • the triangular patches with similar spatial positions are similar, they have similar Morton Code, use Morton code to sort the triangle slices, that is, divide the triangle slices according to the spatial position, divide each block by 100,000 slices, and put the triangle faces with the same center of gravity Morton code The pieces are placed in the same block.
  • the patches having an occlusion relationship with a sub-matrix are concentrated in a small number of geometric blocks, which can effectively reduce the number of readings of the geometric blocks and improve the efficiency.
  • the processing speed of the memory is far greater than the processing speed of the external memory, the triangular slice is read into the memory from the external memory one or several pieces for processing, and the manner of reading and processing the block can also be improved. Processing speed and processing efficiency.
  • Step 103 Read the sorted triangular patches into the Out-of-Core Data Manager.
  • the geometry blocks from the previous step are registered in the Out-of-Core Data Manager as corresponding geometry blocks in the sorted order.
  • Step 200 Read in and process the light source information.
  • the execution order of the steps 200 and 100 is not limited to this, and may be performed at the same time, or the step 200 is executed first and then the step 100 is executed.
  • the light source information in this embodiment refers to a virtual point light source. It is assumed that a triangular point surface has a virtual point light source.
  • the virtual point light source has a light intensity value, a direction (normal direction), a three-axis coordinate, and a virtual point light source format may be Any format that can be read in, including custom file formats. Similar to the geometric information, the position code of the center of gravity of the virtual point source is first calculated, and then the Morton code is derived from the position code. After sorting the virtual point sources using Morton code, each 100,000 consecutive virtual point sources are divided into blocks, and the divided blocks are registered as corresponding source blocks in the Out-of-Core Data Manager.
  • Step 300 Establish an optical transfer matrix and divide it into several sub-matrices.
  • Step 301 The sampling point is used as a row coordinate, and the virtual point source is used as a column coordinate to establish an optical transmission matrix.
  • the sampling point is selected by the method of ray intersection.
  • the viewpoint is input by the user, and represents the position of the user's eyes or the photographing device in the scene coordinate system, the orientation directly above the eyes, and the orientation of the eyes.
  • the two-dimensional pixel on the finally drawn two-dimensional image is the projection of the three-dimensional sampling point in the three-dimensional scene on the imaging plane perpendicular to the viewpoint direction (ie, the two-dimensional image seen by the user).
  • the elements of the Xth row and the yth column of the light transfer matrix represent the brightness contribution of the yth virtual point source to the Xth line sampling point, and the behavior of the light transfer matrix is the pixel point corresponding to the projection of one sampling point.
  • Step 302 Divide the established optical transfer matrix into a plurality of sub-matrices.
  • Step 3021 Divide the optical transfer matrix into a corresponding number of columns according to the number of light source blocks obtained in step 200.
  • the light transfer matrix is divided into 43 columns, each of which contains a virtual point source of one light source block, that is, each column corresponds to one light source block.
  • Step 3022 Perform sampling points according to correlation between sampling points by using a clustering method such as a k-means method, a J-means method, a CLARANS method, a BIRCH method, a DBSCAN method, a PGCS method, or a CURE method.
  • a clustering method such as a k-means method, a J-means method, a CLARANS method, a BIRCH method, a DBSCAN method, a PGCS method, or a CURE method.
  • sampling points are grouped into 165 classes as an example.
  • One type of sampling points is called a sampling point block.
  • clustering is stopped when each class has a certain threshold value.
  • the optical transfer matrix is divided, and the sampling points are clustered into sampling point blocks ⁇ ,
  • the virtual point source is divided into the light source block ⁇ , and in Fig. 5, ⁇ - £ 4 is taken as an example, and each sample point block and each light source block form a sub-matrix.
  • Step 400 Determine whether the sub-matrix and the geometric block need to perform a visibility test.
  • the method includes: Step 401: For each sub-matrix, include all rays in the sub-matrix in a vertebral space bounding box, for each geometric block , Include all patches of the geometry block in an axis-aligned space bounding box.
  • the light is a connection between a sampling point and a virtual point source.
  • One submatrix corresponds to one A vertebral space bounding box, a geometric block corresponding to an axis-aligned space bounding box.
  • the vertebral space surrounding box in this embodiment is composed of two spheres and sides connecting the two spheres.
  • One sphere is the smallest sphere containing all the sample points in the submatrix
  • the other sphere is the smallest sphere containing all the virtual point sources in the submatrix.
  • one sphere takes the spatial center C1 of all the sampling points in the corresponding sub-matrix as the center of the sphere
  • the distance R1 from the sampling point farthest from the center of the sphere to the center of the sphere is a radius, including all the sampling points in the sub-matrix, That is, 5 points in the smaller sphere in Figure 6.
  • the sphere is centered at (1.5,0,0) with a radius of 0.5.
  • the other sphere is centered on the space center C2 of all the virtual point sources in the sub-matrix, and the distance from the virtual point source farthest from the center of the sphere to the center of the sphere R2 is a radius, and all the virtual point sources in the sub-matrix are included. That is, 4 points in the larger sphere in Fig. 6.
  • the two spheres respectively intercept the spherical center and the perpendicular to the two spheres, and the sides intersecting the spheres are joined to form the side of the vertebral space surrounding the box.
  • the four virtual point sources in the larger sphere are connected to the five sampling points in the smaller sphere to form 20 rays.
  • the axis-aligned space bounding box in this embodiment is composed of a minimum axis-aligned rectangular parallelepiped containing all geometric patches in the geometric block, such as the smallest X-axis and y-axis of all patches surrounded by it.
  • the z-axis coordinates that is, the Q-point coordinates and the maximum X-axis, y-axis, and z-axis coordinates, that is, the P-point coordinates are composed of a total of six quantities, indicating the space surrounded by the six quantities. These six quantities can be obtained by traversing all the patches of the corresponding geometric block and calculating their range in each axial direction.
  • the coordinates of the three vertices are (1,0,0), (0,1,0) and (0,0,1 ), which is used to wrap the axis alignment space of the triangle.
  • the bounding box consists of points (0,0,0) and (1,1,1), which describe the diagonally opposite corners of the axis-aligned space box, ie the triangular patches on each axis in three-dimensional space. Minimum and maximum coordinates.
  • Step 402 Determine whether the sub-matrix and the geometric block need to be tested for visibility.
  • the above distance is calculated as the shortest distance between the vertebral space bounding box and the axis-aligned space bounding box. It is defined to find a point on the surface of the axis-aligned space bounding box so that the distance to the central axis segment of the vertebral space bounding box is the smallest, which is the shortest distance between the two bounding boxes.
  • the central axis of the vertebral space bounding box is the line connecting the two centers, and the central axis is projected onto the surface of the axis-aligned space bounding box closest to the central axis to obtain a projection line.
  • the distance between the axis and the projection line is the shortest distance between the two bounding boxes.
  • L1 and L2 are two light source blocks
  • P1 is a sample point block
  • Ql, Q2, and Q3 are three geometric blocks.
  • the submatrix consisting of P1 and L1 and Q2 and Q3 need to be tested for visibility.
  • the submatrix consisting of P1 and L2 and Q1 and Q2 need to be tested for visibility.
  • Step 403 Mark sub-matrices and geometric blocks determined to require visibility testing.
  • the corresponding sub-matrix produces light that does not intersect any of the patches in the corresponding geometric block.
  • the sub-matrix and geometry The patch block does not need to be tested for visibility, that is, through the visibility test; otherwise, both need to be tested for visibility.
  • the sub-matrices and geometry blocks that need to be tested for visibility are marked.
  • Step 500 Put the sub-matrix and the corresponding geometric block into the memory or the memory, and then use the optical cutting technique to calculate the value of each element in the sub-matrix, that is, the virtual point source tributes to the brightness of the pixel Dedication.
  • the invention is a global illumination rendering method based on light cutting technology.
  • FIG. 10a there are four virtual point sources in the scene, which are labeled as 1, 2, 3, and 4, respectively, for each sampling point that needs to be drawn, for example: a scene sampling point corresponding to a pixel, and a brute force drawing method.
  • the contributions of the four virtual point sources to the sampling points are separately calculated and summed.
  • Light cutting is a technique that uses a large number of virtual point sources to draw global illumination effects. By combining the light sources that contribute less to the sampling points, the purpose of speeding up the drawing is achieved.
  • the common parent node of the set of virtual point light sources is used instead of all the child nodes to obtain a brightness contribution value, where the brightness contribution value is Refers to the position, normal, material coefficient and illumination brightness of the node to obtain the brightness contribution of the subtree to the sampling point.
  • the specific method may be to construct a binary tree according to the intensity of the light source, the type of light, the orientation, and the like.
  • Each virtual point source is used as a leaf node, and the intermediate representative node can be randomly selected according to the intensity of the light source.
  • the root node of the light tree is traversed as the beginning of the light cut, and each time the error generated by each parent node is replaced by the respective leaf node, if the error is larger than the set For a given threshold (eg, 2% error threshold), the node is replaced by two child nodes of the node, otherwise the node is kept in the optical cut.
  • a given threshold eg, 2% error threshold
  • the node is replaced by two child nodes of the node, otherwise the node is kept in the optical cut.
  • the corresponding light cut is used as the final selected light cut.
  • the thick lines in the three light cuts represent the light cuts selected in the light tree by three different sampling points in the scene.
  • the related content of light cutting can be Walter, B., et al., Lightcuts: a scalable approach to illumination. ACM Transactions on Graphics (TOG), 2005. 24(3): p. 1098-1107, and will not be repeated here.
  • the optical cutting technique used in the step 500 refers to using a light cut for each sample point block and a light source block that has passed the visibility test, and each light source block generates a light tree, and the sampling is performed. Each sample point in the point block performs a light cut calculation on the light tree.
  • Step 500 specifically includes: Step 501: Use the Out-of-Core data manager to load the visible sub-matrix and the corresponding geometric block into the video memory or the memory.
  • Visibility is visible as a result of the visibility test as a visible virtual point source and a virtual point source marked as requiring visibility testing.
  • the geometric block has been sorted according to the Morton code in step 100. If the sub-matrix 1 and the geometric blocks 2, 4, 7, and 8 are overlapped, the geometric block 2 is sequentially transferred when the sub-matrix 1 is calculated. 4, 7, 8.
  • Another method reduces the total number of calls by optimizing the order in which sub-matrices and geometry blocks are transferred, ie, reducing the amount of data read/write (10) operation.
  • a node composed of a sub-matrix having an overlapping relationship and a geometric block sets the operation cost of one node from one node to another as the weight of the edge between two points, and all nodes and edges constitute a graph.
  • Minimize the 10 operational cost by solving all the nodes in the traversal graph but passing the shortest path.
  • a and B are taken as a sub-matrix-geometry block combination aB, ie Node aB; If the geometry block C needs to be tested for visibility during the process of calculating a, then aC is also formed into a sub-matrix-geometry block combination aC.
  • aC is also formed into a sub-matrix-geometry block combination aC.
  • the memory (or memory) is larger than a single sub-matrix or a geometric block, there is a buffer that can store multiple sub-matrices in the memory (or memory) at the same time.
  • the geometric block in this embodiment, for convenience of explanation, it is assumed that the video memory (or memory) can store two sub-matrices and one geometric block at the same time.
  • the order of the nodes in the traversal graph is aB, aC, dB, and the 10 operations are as follows: 1. Transfer a, 2. Transfer B, traverse aB, 3, call B into C, traverse aC, 4, transfer d, 5, call C into B, traverse dB. A total of 5 operations are required.
  • the order of the nodes in the traversal graph is aB, dB, aC
  • the entered 10 operations are: 1. Transfer a, 2. Transfer B, traverse aB 3, tune d, traverse dB, 4, call B into C, traverse aC, because the weight of aB to dB side is small, so the method preferentially shifts from aB to dB. This only requires 4 operations 10 times, which is reduced once compared to the previous method.
  • the method of graph traversal can be more than 10 times faster than the method of sequential ordering, which greatly improves the efficiency.
  • the scene in Figure 3 in this article uses a picture resolution of 1600 x 1200 pixels, 32 million point light sources and 117 million geometric patches. There are 18 GB of geometric and virtual point source data, which can be traversed by traversing the graph. Significantly improved efficiency.
  • Step 502 Perform a visibility test on the transferred sub-matrix and the corresponding geometric block based on the optical cutting technique.
  • the geometry blocks marked for visibility testing are loaded, and each time a call is made to perform a visibility test to mark the ray that is determined to be occluded as invisible.
  • the visibility test includes several calculation methods.
  • the algorithm used in this embodiment is as follows: It is assumed that X rays are wrapped in the vertebral space surrounding box, and the axis-aligned space surrounding box encloses y triangular faces. For each ray, an intersection operation is performed with each of the y triangular patches, that is, whether the ray intersects with each triangular patch, and if intersected, it is determined that the ray is invisible, and the virtual point source at one end of the ray is the ray. The contribution of the sampling point at the other end is 0; if it does not intersect, it is judged that the light is visible. That is, the visibility test was passed.
  • Step 503 Calculate a brightness contribution value of the virtual point source corresponding to the light determined to be visible in the previous step to the sampling point.
  • the brightness contribution value can be calculated based on the material property, the attenuation property, the visibility, and the light intensity of the virtual point source at a certain position. For example, calculate the brightness contribution value according to equation (1):
  • the I-light cutting technique selects a cut in the light tree formed by the virtual point source as an input to select all the intermediate nodes in the cut, c denotes one of the intermediate nodes in the cut, and the intermediate node c includes The total brightness contribution of all virtual point sources to the currently calculated sample points.
  • the input parameter X represents the position of the virtual point source
  • represents the direction in which the virtual point source is connected to the sampling point
  • i represents all the virtual point sources contained in c
  • j represents a representative virtual point randomly selected with energy as the probability density. light source.
  • ⁇ ' ⁇ indicates the material item, indicating the energy generated by the first virtual point source at position X in the direction ⁇ , which is a geometric term, indicating the attenuation of the energy passed by the first virtual point source to the sampling point, and W is a visible term, indicating Whether the position point X is seen by the sampling point (that is, there is no geometric occlusion between the two), if it is 0, it means that it is not visible, if it is 1, it means it is visible, and ' ⁇ indicates the virtual point.
  • Step 600 Calculate the final brightness of each sub-matrix.
  • the brightness of the light passing through the visibility test is added to each sample point, that is, the pixel point, and the buffered output of all the pixel points is obtained to obtain the final image.
  • the final brightness of a sample point of the scene is accumulated by the energy of several thousand rays. Since each sample point may be the end point of multiple rays, the light passing the visibility test is taken in this step. The energy is added to the pixel buffer of the corresponding image according to the spatial position of the sampling point. This process is called integration. After completing the calculation and integration of all sub-matrices, the pixel is buffered and output, and the final image is obtained.
  • FIG. 13 is a schematic structural diagram of a global illumination drawing device under multiple light sources according to an embodiment of the present invention.
  • the device includes: a block processing module 10, a matrix establishing module 20, a visibility test judging module 30, and a brightness contribution value calculation.
  • the block processing module 10 is configured to read in the geometric information and the light source information, and process the read information. Specifically, the block processing module 10 includes: a reading unit 11, a dividing unit 12, and an output unit 13.
  • the reading unit 11 is used to read information of the triangular patch and the virtual point source.
  • the dividing unit 12 is configured to calculate the position code of the center of gravity of the triangular patch on the X-axis, the y-axis and the z-axis, and calculate the complete Mo according to the X-axis position code, the y-axis position code and the z-axis position code of the center of gravity of the triangular patch
  • the code is sorted and divided according to the Morton code to obtain the first number; and is also used to calculate the position code of the center of gravity of the virtual point source on the X-axis, the y-axis and the z-axis, according to the center of gravity of the virtual point source
  • the X-axis position code, the y-axis position code and the z-axis position code are calculated to obtain a complete Morton code, and the triangular patches are sorted and divided according to the Morton code.
  • the output unit 13 is used to output the
  • the matrix building module 20 is used to create an optical matrix and divide it into a number of sub-matrices.
  • the matrix establishing module 20 specifically includes: an optical transfer matrix establishing unit 21, a clustering unit 22, and a sub-matrix dividing unit 23.
  • the optical transfer matrix establishing unit 21, that is, the optical transfer matrix establishing module in the claims, is configured to establish a light transfer matrix with the virtual point light source as the column coordinate with the sampling point as the row coordinate.
  • the clustering unit 22 is configured to adopt a clustering method such as a k-means method according to the correlation between the sampling points, The J-means method, CLARANS method, BIRCH method, DBSCAN method, PGCS method or CURE method is used to cluster the sampling points to obtain the number of clusters.
  • the sub-matrix dividing unit 23, that is, the sub-matrix dividing module in the claim is configured to divide the optical transfer matrix into a corresponding number of columns according to the number of light source blocks obtained by dividing the dividing unit, and the number of clusters of sampling points obtained according to the clustering unit Divide the optical transfer matrix into a corresponding number of rows.
  • the visibility test judging module 30 is for judging whether the sub-matrix and the geometric block need to be tested for visibility.
  • the visibility test judging module 30 specifically includes: a space bounding box establishing unit 31, a judging unit 32, and a marking unit 33.
  • the space bounding box establishing unit 31 that is, the space bounding box building module in the claim, is configured to establish a vertebral space bounding box capable of including all the rays in the sub-matrix for each sub-matrix, and establish energy for each geometric block.
  • the judging unit 32 is used to determine whether the sub-matrix and the geometric block need to be tested for visibility by testing whether a vertebral space bounding box and an axis-aligned space bounding box have spatial overlap.
  • the tag unit 33 is used to mark sub-matrices and geometry blocks that the determination unit 32 determines to require visibility testing.
  • the brightness contribution value calculation module 40 is configured to load the sub-matrix and the corresponding geometric block into the memory or the memory, and then use the light-cutting technique to calculate the brightness contribution value of the virtual point source to the pixel point.
  • the brightness contribution value calculation module 40 specifically includes: a call-in unit 41, a test unit 42, and a calculation unit 43.
  • the loading unit 41 is configured to use the Out-of-Core data manager to mark the labeled unit 33 as a sub-matrix and corresponding geometric block that needs to be tested for visibility into the video memory or the memory.
  • the test unit 42 is configured to perform a visibility test on the called sub-matrix and the corresponding geometric block based on the optical cutting technique.
  • the calculating unit 43 is configured to calculate a brightness contribution value of the virtual point source to the sampling point corresponding to the light determined to be visible by the testing unit 42.
  • the image output module 50 is configured to add the brightness of the light passing the visibility test to each mining On the sample point, the light energy buffered by all the sample points is output to obtain the final image.
  • each component can be referred to the description of the global illumination rendering method in the above embodiment.
  • FIG. 14 is a block diagram showing the structure of a network device according to another embodiment of the present invention.
  • the network device 1100 may be a host server having a computing capability, a personal computer PC, or a portable computer or terminal that can be carried.
  • the specific embodiment of the present invention does not limit the specific implementation of the computing node.
  • the network device 1100 includes a processor 110, a communications interface 1120, a memory 130, and a bus 1140. Among them, the processor 1110, the communication interface 1120, and the memory 1130 complete communication with each other through the bus 1140.
  • Communication interface 1120 is for communicating with network devices, such as virtual machine management centers, shared storage, and the like.
  • the processor 1110 is for executing a program.
  • the processor 1110 may be a central processing unit CPU, or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.
  • ASIC Application Specific Integrated Circuit
  • the memory 1130 is used to store files.
  • the memory 1130 may include a high speed RAM memory, and may also include a non-volatile memory such as at least one disk memory.
  • Memory 1130 can also be a memory array.
  • the memory 1130 may also be partitioned, and the blocks may be combined into a virtual volume according to certain rules.
  • the above program may be a program code including computer operating instructions. This program can be used to:
  • the geometric patch and the virtual point source of the scene are respectively processed based on the Morton code to obtain a first number of geometric blocks and a second number of light source blocks;
  • the luminance contribution value of the visible light is accumulated on the sampling point of the corresponding sub-matrix, and the total luminance contribution value of the sampling point is output.
  • the geometric patch and the virtual point light source of the scene are respectively processed based on the Morton code, and the first number of geometric blocks and the second number of light source blocks are obtained, including: separately calculating the a position code of a center of gravity of the geometric patch and a center of gravity of the virtual point source on the X-axis, the y-axis, and the z-axis;
  • the program is also used to:
  • the shortest distance from the central axis of the first space bounding box to the second space bounding box is not greater than the radius of the larger sphere constituting the first space bounding box, it is determined that the corresponding sub-matrix and the geometric block need to be performed. Visibility test.
  • the first space encloses a sphere of the box at the sub-moment
  • the center of the space of all the sampling points in the array is the center of the sphere, and the farthest distance from the sampling point to the center of the sphere is the radius.
  • Another sphere is centered on the space center of all the virtual point sources in the sub-matrix, and the farthest distance from the virtual point source to the center of the sphere is a radius.
  • the sides where the two intersecting faces intersect the two spheres are respectively joined to form the side faces by respectively cutting the spherical cores on the two spheres and perpendicular to the spherical center of the two spheres.
  • the second space bounding box is surrounded by a minimum X-axis, a y-axis, a z-axis coordinate, and a maximum X-axis, y-axis, and z-axis coordinate of all geometric faces enclosed.
  • the calculating, according to a material property, an attenuation property, a visibility, and a light intensity of each virtual point light source, a brightness contribution value of the light in the corresponding sub-matrix including: determining that a visibility test is required
  • the sub-matrix and the geometric block are transferred from the external memory into the memory in units of blocks; the visibility test is performed on the sub-matrices and geometric blocks that are called in;
  • a brightness contribution value of the light passing through the visibility test in the sub-matrix is calculated according to a material property, an attenuation property, a visibility, and a light intensity of the virtual point source in the sub-matrix.
  • the sub-matrix and the geometric block that are determined to require the visibility test are loaded into the memory from the external storage in block units, including:
  • the geometric block corresponding to the sub-matrix marked for visibility testing is loaded according to the Morton code number of the geometric block.
  • the sub-matrix and the geometric block that are determined to require the visibility test are loaded into the memory from the external storage in block units, including:
  • Each sub-matrix to be calculated is combined with a corresponding geometric block that needs to be tested for visibility as a node, and the amount of data read and write that needs to be performed by the first node to the second node is used as an edge connecting the two nodes.
  • Weight, connecting all the points in the light transfer matrix to form a graph Calculating the path of all the nodes in the graph, and passing the smallest total weight of the edges, and sub-matrix and geometric blocks marked as need to be tested for visibility from the external storage according to the order of the nodes on the path Into the memory.
  • the performing the visibility test on the called sub-matrix and the geometric block including:
  • an intersection operation is performed with the geometric patches in the geometric block respectively, and if the operation result is intersection, it is determined that the ray is invisible; if the operation result is disjoint, It is judged that the light is visible.
  • the function is implemented in the form of computer software and sold or used as a stand-alone product, it may be considered to some extent that all or part of the technical solution of the present invention (for example, a part contributing to the prior art) is It is embodied in the form of computer software products.
  • the computer software product is typically stored in a computer readable non-volatile storage medium, including instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform all of the methods of various embodiments of the present invention. Or part of the step.
  • the foregoing storage medium includes various media that can store program codes, such as a USB flash drive, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
  • the global illumination rendering method and apparatus under multiple light sources can be applied to a scene in which a large-scale, high-precision required external scene is drawn, and the virtual patch is divided into geometric blocks, and the virtual point is The light source is divided into light source blocks, and the geometric patch and the virtual point light source are read into the memory from the external memory in units of blocks, which significantly improves the global illumination drawing speed and effect.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)

Abstract

一种多光源下的全局光照绘制方法及装置,用于对包含若干个物体的场景进行全局光照绘制,所述方法由具有内存并耦接至外存的系统来执行,所述方法包括:对场景中的几何面片和虚拟点光源分别进行处理,得到第一数量的几何块以及第二数量的光源块;以场景中的所有采样点为行坐标,以所有虚拟点光源为列坐标建立光传递矩阵;将光传递矩阵划分为第二数量的列,将光传递矩阵划分为第三数量的行;将子矩阵和几何块从所述外存调入到内存中,计算对应子矩阵中的虚拟点光源对采样点的亮度贡献值;将亮度贡献值累加到对应的采样点上,并输出采样点的总亮度。能够有效提高全局光照绘制速度和效率,适用于对大规模的外存场景进行绘制。

Description

多光源下的全局光照绘制方法及装置
技术领域
本发明涉及光照绘制领域, 尤其涉及一种多光源下的全局光照绘制方法 及装置。 背景技术
全局光照是常用的渲染技术, 用于生成软影、 间接折射等光照效果, 以 加强渲染效果的真实感。 基于大量点光源 (Many Point Lights) 的方法是生 成全局光照效果的技术之一,其原理是在场景中生成大量虚拟点光源 (Virtual Point Light, VPL) , 通过分别计算各视角采样点 (Sample) 被这些虚拟点光 源照亮的程度, 来获得全局光照效果。 Wald等人发明了基于大量点光源框架 的光割 (Lightcuts) 方法, 根据虚拟点光源建立层次结构树并使用层次结构 树的一个割集代表所有虚拟点光源, 以减少运算量和加快运算速度。 随着光 割方法的不断完善, 大量点光源框架在实现全局光照方法中效率较高。 但是 由于现有的光割技术是一种全局方法, 需要把所有点光源构建起统一的光 树, 并在上面进行光割的选取。 在求取光割的过程中, 每次计算割中节点的 误差, 还需要使用全局的几何数据进行求交运算。 当进行大规模、 高精度的 场景绘制时, 大量的虚拟点光源及几何数据都有可能超过了内存或者显存的 限制, 因而无法应用于外存 (Out-of-core)复杂场景的绘制, 无法构建全局的 光树, 以及进行全局求交运算。 发明内容
技术问题
有鉴于此, 本发明要解决的技术问题是, 如何对包含若干个物体的大规 模的场景进行全局光照绘制。
解决方案
为了解决上述技术问题, 根据本发明的一实施例, 第一方面, 提供了一 种多光源下的全局光照绘制方法,用于对包含若干个物体的场景进行全局光 照绘制, 所述物体由几何面片来描述, 所述方法由具有内存并耦接至外存的 系统来执行, 所述方法包括:
对所述场景中的几何面片和虚拟点光源分别基于位置信息进行处理,得 到第一数量的几何块以及第二数量的光源块;
以所述场景中的所有采样点为行坐标, 以所有虚拟点光源为列坐标建立 光传递矩阵;
将所述光传递矩阵划分为所述第二数量的列, 每一列对应一个所述光源 块, 将所述光传递矩阵划分为第三数量的行, 每一行与每一列相交构成为一 个子矩阵, 所述第三数量为所述采样点的聚类数量;
将所述子矩阵和几何块从所述外存调入到所述内存中, 根据所述虚拟点 光源的材质属性、 衰减属性、 可见性以及光强度, 计算对应子矩阵中的虚拟 点光源对采样点的亮度贡献值;
将可见性为可见的所述虚拟点光源对采样点的亮度贡献值累加到对应 的采样点上, 并输出所述采样点的总亮度。
结合第一方面, 在第一种可能的实现方式中, 所述对所述场景中的几何 面片和虚拟点光源分别基于位置信息进行处理, 得到第一数量的几何块以及 第二数量的光源块, 包括:
分别计算所述几何面片的重心和所述虚拟点光源的重心在 X轴、 y轴和 z 轴上的位置码, 所述几何面片的重心构成所述几何面片的位置信息, 所述虚 拟点光源的重心构成所述虚拟点光源的位置信息;
根据所述几何面片重心的位置码计算第一莫顿码, 根据所述虚拟点光源 重心的位置码计算第二莫顿码;
根据所述第一莫顿码对所述几何面片进行排序和划分, 得到第一顺序和 第一数量的几何块, 根据所述第二莫顿码对所述虚拟点光源进行排序和划 分, 得到第二顺序和第二数量的光源块。
结合第一方面,在第二种可能的实现方式中,所述将所述光传递矩阵划 分为所述第二数量的列, 每一列对应一个所述光源块,将所述光传递矩阵划 分为第三数量的行, 每一行与每一列相交构成为一个子矩阵之后, 还包括: 将所述子矩阵中的所有所述虚拟点光源和采样点的连线包含在第一空 间包围盒中, 每一个子矩阵对应一个第一空间包围盒,
其中, 所述第一空间包围盒包括两个球体及连接所述两个球体的侧面, 一个球体为包含所述子矩阵中所有采样点的最小球体,另一个球体为包含所 述子矩阵中所有虚拟点光源的最小球体,通过在所述两个球体上分别截取过 球心并与所述两个球体的球心连线垂直的切面,将所得到的两个切面与所述 两个球体相交的边分别连接构成所述侧面。
结合第一方面的第二种可能的实现方式, 在第三种可能的实现方式中, 所述将所述光传递矩阵划分为所述第二数量的列,每一列对应一个所述光源 块,将所述光传递矩阵划分为第三数量的行, 每一行与每一列相交构成为一 个子矩阵之后, 还包括:
将所述几何块的所有几何面片包含在第二空间包围盒中,每一个几何块 对应一个第二空间包围盒,
其中,所述第二空间包围盒由包含所述几何块中所有几何面片的最小轴 对齐长方体构成。
结合第一方面的第三种可能的实现方式, 在第四种可能的实现方式中, 所述将所述子矩阵和几何块从所述外存调入到所述内存中之前, 还包括: 判断所述第一空间包围盒的中轴到所述第二空间包围盒的最短距离是 否不大于所述第一空间包围盒中较大球体的半径,是则判断为对应的子矩阵 和几何块需要进行可见性测试,否则判断为对应的子矩阵和几何块不需要进 行可见性测试, 并将所述子矩阵中的虚拟点光源标记为对采样点可见。
结合第一方面的第四种可能的实现方式, 在第五种可能的实现方式中, 所述将所述子矩阵和几何块从所述外存调入到所述内存中,根据所述虚拟点 光源的材质属性、 衰减属性、 可见性以及光强度, 计算对应子矩阵中的虚拟 点光源对采样点的亮度贡献值, 包括:
将判断为需要进行可见性测试的子矩阵及几何块从所述外存调入到所 述内存中;
对调入的所述子矩阵和几何块进行可见性测试;
根据所述子矩阵中虚拟点光源的材质属性、衰减属性、可见性以及光强 度,计算所述子矩阵中可见性为可见的虚拟点光源对采样点亮度贡献值,所 述可见性为可见的虚拟点光源包括所述可见性测试的结果为可见的虚拟点 光源以及所述标记为可见的虚拟点光源。
结合第一方面的第五种可能的实现方式, 在第六种可能的实现方式中, 所述对调入的所述子矩阵和几何块进行可见性测试, 包括:
对于所述子矩阵中的每条虚拟点光源和采样点的连线,分别与所述几何 块中的几何面片进行求交运算, 如果运算结果为相交, 则判断为所述虚拟点 光源对采样点不可见; 如果运算结果为不相交, 则判断为所述虚拟点光源对 采样点可见。
结合第一方面的第五种可能的实现方式, 在第七种可能的实现方式中, 所述将所述子矩阵和几何块从所述外存调入到所述内存中, 包括:
根据所述几何块的所述第一顺序,将判断为需要进行可见性测试的子矩 阵对应的几何块从所述外存调入到所述内存中。
结合第一方面的第五种可能的实现方式, 在第八种可能的实现方式中, 所述将所述子矩阵和几何块从所述外存调入到所述内存中, 包括:
将所有子矩阵分别与对应的需要进行可见性测试的几何块组合为节点, 以由一个节点到另一个节点需要进行的数据读写量作为连接所述两个节点 的边的权值,将所有节点连接构成一张图,计算能够遍历所述图中所有节点, 并且所述遍历所通过的边的总权值最小的路径,选择所述路径, 并根据所述 路径上各节点的遍历顺序将对应的子矩阵及几何块从所述外存调入到所述 内存中。
为了解决上述技术问题, 根据本发明的另一实施例, 第二方面, 提供了 一种多光源下的全局光照绘制装置,用于对包含若干个物体的场景进行全局 光照绘制, 所述物体由几何面片来描述, 所述方法由具有内存并耦接至外存 的系统来执行, 所述装置包括:
块处理模块,用于对所述场景中的几何面片和虚拟点光源分别基于位置 信息进行处理, 得到第一数量的几何块以及第二数量的光源块;
光传递矩阵建立模块, 用于以所述场景中的所有采样点为行坐标, 以所 有虚拟点光源为列坐标建立光传递矩阵;
子矩阵划分模块, 用于并将所述光传递矩阵划分为所述第二数量的列, 每一列对应一个所述光源块, 将所述光传递矩阵划分为第三数量的行, 每一 行与每一列相交构成为一个子矩阵, 所述第三数量为所述采样点的聚类数 亮度贡献值计算模块,用于将所述子矩阵和几何块从所述外存调入到所 述内存中,根据所述虚拟点光源的材质属性、衰减属性、可见性以及光强度, 计算对应子矩阵中的虚拟点光源对采样点的亮度贡献值;
输出模块,将可见性为可见的所述虚拟点光源对采样点的亮度贡献值累 加到对应的采样点上, 并输出所述采样点的总亮度。
结合第二方面,在第一种可能的实现方式中,所述块处理模块被配置为: 分别计算所述几何面片的重心和所述虚拟点光源的重心在 x轴、 y轴和 z 轴上的位置码, 所述几何面片的重心构成所述几何面片的位置信息, 所述虚 拟点光源的重心构成所述虚拟点光源的位置信息;
根据所述几何面片重心的位置码计算第一莫顿码, 根据所述虚拟点光源 重心的位置码计算第二莫顿码;
根据所述第一莫顿码对所述几何面片进行排序和划分, 得到第一顺序和 第一数量的几何块, 根据所述第二莫顿码对所述虚拟点光源进行排序和划 分, 得到第二顺序和第二数量的光源块。
结合第二方面, 在第二种可能的实现方式中, 还包括:
空间包围盒建立模块,用于建立第一空间包围盒,将所述子矩阵中的所 有所述虚拟点光源和采样点的连线包含在第一空间包围盒中,每一个子矩阵 对应一个第一空间包围盒,
其中, 所述第一空间包围盒包括两个球体及连接所述两个球体的侧面, 一个球体为包含所述子矩阵中所有采样点的最小球体, 另一个球体为包含所 述子矩阵中所有虚拟点光源的最小球体,通过在所述两个球体上分别截取过 球心并与所述两个球体的球心连线垂直的切面,将所得到的两个切面与所述 两个球体相交的边分别连接构成所述侧面。
结合第二方面的第二种可能的实现方式, 在第三种可能的实现方式中, 所述空间包围盒建立模块还用于建立第二空间包围盒,将所述几何块的所有 几何面片包含在第二空间包围盒中, 每一个几何块对应一个第二空间包围 品.,
其中,所述第二空间包围盒由包含所述几何块中所有几何面片的最小轴 对齐长方体构成。
结合第二方面的第三种可能的实现方式, 在第四种可能的实现方式中, 还包括: 可见性测试判断模块,用于判断所述第一空间包围盒的中轴到所述第二 空间包围盒的最短距离是否不大于所述第一空间包围盒中较大球体的半径, 是则判断为对应的子矩阵和几何块需要进行可见性测试,否则判断为对应的 子矩阵和几何块不需要进行可见性测试,并将所述子矩阵中的虚拟点光源标 记为对采样点可见。
结合第二方面的第四种可能的实现方式, 在第五种可能的实现方式中, 所述亮度贡献值计算模块包括:
调入单元,用于将判断为需要进行可见性测试的子矩阵及几何块从所述 外存调入到所述内存中;
测试单元, 用于对调入的所述子矩阵和几何块进行可见性测试; 计算单元, 用于根据所述子矩阵中虚拟点光源的材质属性、 衰减属性、 可见性以及光强度,计算所述子矩阵中可见性为可见的虚拟点光源对采样点 亮度贡献值,所述可见性为可见的虚拟点光源包括所述可见性测试的结果为 可见的虚拟点光源以及所述标记为可见的虚拟点光源。
结合第二方面的第五种可能的实现方式, 在第六种可能的实现方式中, 所述测试单元被配置为:
对于所述子矩阵中的每条虚拟点光源和采样点的连线,分别与所述几何 块中的几何面片进行求交运算, 如果运算结果为相交, 则判断为所述虚拟点 光源对采样点不可见; 如果运算结果为不相交, 则判断为所述虚拟点光源对 采样点可见。
结合第二方面的第五种可能的实现方式, 在第七种可能的实现方式中, 所述调入单元被配置为:
根据所述几何块的所述第一顺序,将判断为需要进行可见性测试的子矩 阵对应的几何块从所述外存调入到所述内存中。
结合第二方面的第五种可能的实现方式, 在第八种可能的实现方式中, 所述调入单元被配置为:
将所有子矩阵分别与对应的需要进行可见性测试的几何块组合为节点, 以由一个节点到另一个节点需要进行的数据读写量作为连接所述两个节点 的边的权值,将所有节点连接构成一张图,计算能够遍历所述图中所有节点, 并且所述遍历所通过的边的总权值最小的路径,选择所述路径, 并根据所述 路径上各节点的遍历顺序将对应的子矩阵及几何块从所述外存调入到所述 内存中。
为了解决上述技术问题, 根据本发明的一实施例, 第三方面, 提供了一 种全局光照绘制方法, 包括:
对场景的几何面片和虚拟点光源分别基于莫顿码进行处理,得到第一数 量的几何块以及第二数量的光源块;
以场景的采样点为行坐标, 以所述虚拟点光源为列坐标建立光传递矩 阵;
将所述光传递矩阵划分为所述第二数量的列,将所述光传递矩阵划分为 第三数量的行, 每一行与每一列相交构成为一个子矩阵, 所述第三数量为所 述采样点的聚类数量;
根据各虚拟点光源的材质属性、 衰减属性、 可见性以及光强度计算对应 子矩阵中的光线的亮度贡献值;
将可见性为可见的光线的亮度贡献值累加到对应的子矩阵的采样点上, 并输出所述采样点的总亮度贡献值。
结合第三方面, 在第一种可能的实现方式中, 所述对场景的几何面片和 虚拟点光源分别基于莫顿码进行处理, 得到第一数量的几何块以及第二数量 的光源块, 包括:
分别计算所述几何面片的重心和所述虚拟点光源的重心在 X轴、 y轴和 z 轴上的位置码; 根据所述几何面片重心的位置码计算第一莫顿码, 根据所述虚拟点光源 重心的位置码计算第二莫顿码;
根据所述第一莫顿码对所述几何面片进行划分和排序, 得到第一数量的 几何块, 根据所述第二莫顿码对所述虚拟点光源进行划分和排序, 得到第二 数量的光源块。
结合第三方面的第一种可能的实现方式, 在第二种可能的实现方式中, 还包括:
将所述子矩阵中的所有所述光线包含在第一空间包围盒中,将所述几何 块的所有几何面片包含在第二空间包围盒中,所述第一空间包围盒由两个球 体以及连接所述两个球体的侧面构成,每一个子矩阵对应一个第一空间包围 盒, 每一个几何块对应一个第二空间包围盒;
若所述第一空间包围盒的中轴到所述第二空间包围盒的最短距离不大 于构成所述第一空间包围盒的较大球体的半径,判断为对应的子矩阵和几何 块需要进行可见性测试。
结合第三方面的第二种可能的实现方式, 在第三种可能的实现方式中, 所述第一空间包围盒的一个球体以所述子矩阵中所有采样点的空间中心为 球心, 以所述采样点到球心的最远距离为半径,
另一个球体以所述子矩阵中所有虚拟点光源的空间中心为球心,以所述 虚拟点光源到球心的最远距离为半径,
通过在所述两个球体上分别截取过球心并与所述两个球体的球心连线 垂直的切面,将所得到的两个切面与两个球体相交的边分别连接构成所述侧 面。
结合第三方面的第二种或第三种可能的实现方式,在第四种可能的实现 方式中, 所述第二空间包围盒由所包围的所有几何面片的最小 X轴、 y轴、 z 轴坐标和最大 X轴、 y轴、 z轴坐标包围构成。 结合第三方面的第四种可能的实现方式, 在第五种可能的实现方式中, 所述根据各虚拟点光源的材质属性、衰减属性、可见性以及光强度计算对应 子矩阵中的光线的亮度贡献值, 包括:
将判断为需要进行可见性测试的子矩阵及几何块以块为单位从外存调 入到内存中; 对调入的所述子矩阵和几何块进行可见性测试;
根据所述子矩阵中虚拟点光源的材质属性、衰减属性、可见性以及光强 度计算所述子矩阵中通过了可见性测试的光线的亮度贡献值。
结合第三方面的第五种可能的实现方式, 在第六种可能的实现方式中, 所述将判断为需要进行可见性测试的子矩阵及几何块以块为单位从外存调 入到内存中, 包括:
根据所述几何块的莫顿码序号,将标记为需要进行可见性测试的子矩阵 对应的几何块调入。
结合第三方面的第六种可能的实现方式, 在第七种可能的实现方式中, 所述将判断为需要进行可见性测试的子矩阵及几何块以块为单位从外存调 入到内存中, 包括:
将所要计算的每个子矩阵分别与对应的各需要进行可见性测试的几何 块组合为节点,以由第一节点到第二节点需要进行的数据读写量作为连结所 述两个节点的边的权值,将所述光传递矩阵中所有的点连接构成一张图,计 算能够遍历所述图中所有节点, 并且通过的边的总权值最小的路径, 根据所 述路径上各节点的顺序将标记为需要进行可见性测试的子矩阵及几何块从 外存调入到内存中。
结合第三方面的第五种可能的实现方式, 在第八种可能的实现方式中, 所述对调入的所述子矩阵和几何块进行可见性测试, 包括:
对于所述子矩阵中的每条光线,分别与所述几何块中的几何面片进行求 交运算, 如果运算结果为相交, 则判断为所述光线不可见; 如果运算结果为 不相交, 则判断为所述光线可见。
为了解决上述技术问题, 根据本发明的另一实施例, 第四方面, 提供了 一种全局光照绘制装置, 包括:
块处理模块,用于对场景的几何面片和虚拟点光源分别基于莫顿码进行 处理, 得到第一数量的几何块以及第二数量的光源块;
矩阵建立模块, 用于以场景的采样点为行坐标, 以所述虚拟点光源为列 坐标建立光传递矩阵;
可见性测试判断模块, 用于将所述光传递矩阵划分为所述第二数量的 列, 将所述光传递矩阵划分为第三数量的行, 每一行与每一列相交构成为一 个子矩阵, 所述第三数量为所述采样点的聚类数量;
亮度贡献值计算模块, 用于根据各虚拟点光源的材质属性、 衰减属性、 可见性以及光强度计算对应子矩阵中的光线的亮度贡献值;
图像输出模块,用于将可见性为可见的光线的亮度贡献值累加到对应的 子矩阵的采样点上, 并输出所述采样点的总亮度贡献值。
有益效果
本发明实施例提供的多光源下的全局光照绘制方法及装置,通过将几何 面片划分为几何块, 将虚拟点光源划分为光源块, 从外存中以块为单位将几 何面片和虚拟点光源读入到内存中进行处理, 显著的提高了全局光照绘制速 度和效率, 适用于对大规模、 高精度要求的外存场景进行绘制。
根据下面参考附图对示例性实施例的详细说明, 本发明的其它特征及方 面将变得清楚。 附图说明
图 1示出根据本发明一个实施例的多光源下的全局光照绘制方法的流程 图;
图 2示出根据本发明另一实施例的多光源下的全局光照绘制方法的流程 图;
图 3示出根据本发明另一实施例的要绘制的场景的示意图;
图 4示出根据本发明另一实施例的基于射线求交的采样点生成的示意 图;
图 5示出根据本发明另一实施例的光传递矩阵的示意图;
图 6示出根据本发明另一实施例的椎体空间包围盒的示意图;
图 7示出根据本发明另一实施例的轴对齐空间包围盒的示意图; 图 8示出根据本发明另一实施例的椎体空间包围盒与轴对齐空间包围盒 之间的距离的示意图;
图 9示出根据本发明另一实施例的可见性测试的示意图;
图 10a、 图 10b分别示出现有技术中光树及光割的示意图;
图 lla、 图 lib分别示出调入几何块的 10操作的示意图;
图 12示出根据本发明另一实施例的多光源下的全局光照绘制方法的示 意图;
图 13示出根据本发明另一实施例的多光源下的全局光照绘制装置的结 构示意图;
图 14示出根据本发明另一实施例的一种网络设备的结构框图。 具体实施方式
以下将参考附图详细说明本发明的各种示例性实施例、 特征和方面。 附 图中相同的附图标记表示功能相同或相似的元件。尽管在附图中示出了实施 例的各种方面, 但是除非特别指出, 不必按比例绘制附图。
在这里专用的词"示例性 "意为 "用作例子、 实施例或说明性"。 这里作为 "示例性"所说明的任何实施例不必解释为优于或好于其它实施例。
另外, 为了更好的说明本发明, 在下文的具体实施方式中给出了众多的 具体细节。 本领域技术人员应当理解, 没有某些具体细节, 本发明同样可以 实施。 在另外一些实例中, 对于本领域技术人员熟知的方法、 手段、 元件和 电路未作详细描述, 以便于凸显本发明的主旨。
图 1示出根据本发明一实施例的多光源下的全局光照绘制方法的流程 图。 如图 1所示, 该方法主要包括:
歩骤 10、 对场景的几何面片和虚拟点光源分别基于莫顿码进行处理, 得 到第一数量的几何块以及第二数量的光源块;
歩骤 20、 以场景的采样点为行坐标, 以所述虚拟点光源为列坐标建立光 传递矩阵;
歩骤 30、 将所述光传递矩阵划分为所述第二数量的列, 将所述光传递矩 阵划分为第三数量的行, 每一行与每一列相交构成为一个子矩阵, 所述第三 数量为所述采样点的聚类数量;
歩骤 40、 根据各虚拟点光源的材质属性、 衰减属性、 可见性以及光强度 计算对应子矩阵中的光线的亮度贡献值;
歩骤 50、将可见性为可见的光线的亮度贡献值累加到对应的子矩阵的采 样点上, 并输出所述采样点的总亮度。
图 2示出根据本发明另一实施例的全局光照绘制方法的流程图。 该全局 光照绘制方法用于渲染包含有物体和阴影的场景, 如图 2所示, 该方法主要 包括:
歩骤 100、 读入并处理几何信息。
该歩骤具体包括:
歩骤 101、 读入三角面片。
如图 3所示, 对于要绘制的场景, 场景里面有很多个物体(Object) , 每 个物体的表面都由面片来描述, 面片的属性包括三轴坐标、 法向或纹理等。 面片可以由已知商业建模软件产生, 如 3dsMax, Maya等。 本实施例中将无 序的三角面片作为几何信息, 将该三角面片作为输入, 并假设其全部属性都 已知, 也可以采用其它面片例如四边形面片来描述。
歩骤 102、 对三角面片进行排序。
具体地, 采用 Out-of-Core排序工具, 例如 ExSort库, 对三角面片进行 排序, 该排序的过程包括:
歩骤 1021、 计算各三角面片的重心在 X轴、 y轴和 z轴上的位置码。 因为所绘制的场景为立体场景, 每个三角面片都具有 X轴、 y轴和 z轴 坐标, 三角面片的重心即三角形三条中线的交点。
以 X轴为例,将读入的三角面片中重心的最大 X轴坐标和最小 X轴坐标 之间的 X轴称为 L, 把 L平均分为 21Q段, 按顺序把每一段做上标记, 共需 要 10个比特的标记长度, 从而 X轴坐标与所做的标记一一对应; 根据空间 点的 X坐标就能够得到对应的标记, 该标记即该空间点的 X轴位置码。 依照 该方法可以计算出每个三角面片空间点的 X轴位置码、 y轴位置码和 z轴位 置码。
歩骤 1022、 根据重心的 X轴位置码、 y轴位置码和 z轴位置码计算得到 完整的莫顿码。
本实施例采用错位组合的方法进行计算, 具体而言, 莫顿码第 1位为 X 轴位置码第 1位, 莫顿码第 2位为 y轴位置码第 1位, 莫顿码第 3位为 z轴 位置码第 1位, 莫顿码第 4位为 X轴位置码第 2位, 莫顿码第 5位为 y轴位 置码第 2位, 莫顿码第 6位为 z轴位置码第 2位, 以此类推, 直到取得 30 比特长度的莫顿码。
歩骤 1023、 根据莫顿码对三角面片进行排序和划分。
因为空间位置相近的三角面片的三轴坐标也相近, 因此具有相近的莫顿 码, 使用莫顿码可对三角面片进行排序, 也就是把三角面片根据空间位置进 行划分, 每读取 10万个面片就划分一个块, 把具有相同的重心莫顿码的三 角面片放入相同的块中。 这样在后续歩骤计算可见性时, 与一个子矩阵有遮 挡关系的面片都集中在少量的几何块中, 可以有效减少几何块的读取次数, 提高效率。 而且, 由于内存的处理速度远远大于外存的处理速度, 因此将三 角面片一块或几块地从外存读入到内存中进行处理, 这种分块读入和处理的 方式也可以提高处理速度和处理效率。
歩骤 103、 将排序后的三角面片读入到 Out-of-Core数据管理器中。 将上一歩骤划分的几何块按照排序后的顺序在 Out-of-Core数据管理器 中注册为对应的几何块。
歩骤 200、 读入并处理光源信息。
本歩骤 200与歩骤 100的执行顺序不限于此, 也可以同时执行, 或者先 执行歩骤 200再执行歩骤 100。 本实施例中的光源信息指虚拟点光源, 假设 一个三角面片上有一个虚拟点光源, 虚拟点光源的属性有光强值, 朝向 (法 向), 三轴坐标, 虚拟点光源的格式可以是任意能够读入的格式, 包括自定 义的文件格式。 与几何信息类似, 首先计算虚拟点光源的重心的位置码, 然 后根据位置码得出莫顿码。 使用莫顿码对虚拟点光源进行排序后, 将每 10 万个连续的虚拟点光源划分为一个块, 并将划分的块在 Out-of-Core数据管 理器中注册为对应的光源块。
歩骤 300、 建立光传递矩阵并将其划分为若干个子矩阵。
歩骤 301、 以采样点作为行坐标, 以虚拟点光源作为列坐标建立光传递 矩阵。
其中, 根据视点的位置、 最后绘制出的图像的大小, 通过射线求交的方 法来选取采样点。 具体地, 如图 4所示, 视点由用户输入, 代表的是用户的 眼睛或拍摄装置在场景坐标系中的位置, 双眼正上方的朝向以及眼睛的朝 向。最终绘制得到的两维图像上的两维像素点是三维场景中三维采样点根据 视点方向在与其垂直的成像平面 (即用户看到的该两维图像) 上的投影。
该光传递矩阵的第 X行第 y列的元素表示第 y个虚拟点光源对第 X行采 样点的亮度贡献, 光传递矩阵的一行为一个采样点所投影对应的像素点。
歩骤 302、 将建立的光传递矩阵划分为若干个子矩阵。
歩骤 3021、根据歩骤 200得到的光源块的数量将光传递矩阵划分为相应 数量的列。
例如, 在歩骤 200中输入了 43个光源块, 则把光传递矩阵划分为 43份 列, 每一份包含一个光源块的虚拟点光源, 即每一列对应一个光源块。
歩骤 3022、根据采样点之间的相关性,采用聚类方法例如 k-均值 (means ) 方法、 J-均值方法、 CLARANS方法、 BIRCH方法、 DBSCAN方法、 PGCS 方法或 CURE方法等对采样点进行的聚类。
本实施例以把采样点聚成 165类为例进行说明,一类采样点称为一个采 样点块, 本实施例中每一类剩一定阈值的采样点时停止聚类。
歩骤 3023、 根据聚类得到的数量将光传递矩阵划分为相应数量的行。 经过上述歩骤的聚类之后, 光传递矩阵被划分为 165个行, 43个列, 从 而光传递矩阵被划分为 165*43=7095个子矩阵。
如图 5所示, 将光传递矩阵进行划分, 将采样点聚类成采样点块 ^, 图
5中以 ^ - ^4为例进行说明,将虚拟点光源划分为光源块 ^,图 5中以 ^ - £4为 例进行说明, 每个采样点块和每个光源块组成一个子矩阵。
歩骤 400、 判断子矩阵和几何块是否需要进行可见性测试; 包括: 歩骤 401、 对于每个子矩阵, 将子矩阵中的所有光线包含在一个椎体空 间包围盒中, 对于每个几何块, 将几何块的所有面片包含在一个轴对齐空间 包围盒中。
其中, 光线即一个采样点与一个虚拟点光源的连线。 一个子矩阵对应一 个椎体空间包围盒, 一个几何块对应一个轴对齐空间包围盒。
如图 6所示,本实施例中的椎体空间包围盒由两个球体以及连接两球体 的侧面构成。 一个球体为包含所述子矩阵中所有采样点的最小球体, 另一个 球体为包含所述子矩阵中所有虚拟点光源的最小球体。 例如: 其中一个球体 以对应的子矩阵中所有采样点的空间中心 C1为球心, 以距球心最远的采样 点到球心的距离 R1为半径, 包含该子矩阵中所有的采样点, 即图 6中较小 球体中的 5 个点。 例如: 子矩阵中有两个采样点的坐标分别为 (1,0,0) 和 (2,0,0), 则这个球体以 (1.5,0,0) 为中心, 以 0.5为半径。 另一个球体以该 子矩阵中所有虚拟点光源的空间中心 C2为球心, 以距球心最远的虚拟点光 源到球心的距离 R2为半径, 包含该子矩阵中所有的虚拟点光源, 即图 6中 较大球体中的 4个点。最后在两个球体上分别截取过球心并与两个球心连线 垂直的切面, 两切面与球体相交的边连结起来就构成了椎体空间包围盒的侧 面。 较大球体中的 4个虚拟点光源与较小球体中的 5个采样点连接构成 20 条光线。
如图 7所示,本实施例中的轴对齐空间包围盒由包含所述几何块中所有 几何面片的最小轴对齐长方体构成,例如由其所包围的所有面片的最小 X轴、 y轴、 z轴坐标, 即 Q点坐标及最大 X轴、 y轴、 z轴坐标, 即 P点坐标共 6 个量组成, 表示被这 6个量围住的空间。 这 6个量可以通过遍历对应几何块 的所有面片并计算其在各轴向上的范围获得。
例如, 有一个三角形的几何块, 三个顶点的坐标分别为(1,0,0), (0,1,0) 和 (0,0,1 ), 则用于包裹这个三角形的轴对齐空间包围盒就由点 (0,0,0) 和 ( 1,1,1 )构成, 这两个点描述了轴对齐空间盒的斜对角, 即三维空间中三角 面片在每条轴上的最小坐标和最大坐标。
歩骤 402、 确定子矩阵与几何块是否需要进行可见性测试。
本实施例中,通过测试一个椎体空间包围盒与一个轴对齐空间包围盒在 空间上是否有重叠部分, 即光线与三角面片有没有重叠的部分来进行判断。 如果有重叠部分则确定该光线被几何块所遮挡, 与该光线对应的子矩阵和几 何块需要进行可见性测试。 具体的计算歩骤包括:
比较椎体空间包围盒的中轴到轴对齐空间包围盒的距离, 如果这一距离 不小于构成椎体空间包围盒的两个球体中的较大半径, 则确定为不存在重 叠,在计算椎体空间包围盒对应的子矩阵时不需要与轴对齐空间包围盒包裹 的几何块进行可见性测试; 反之, 如果计算出的距离小于构成椎体空间包围 盒的球体的半径, 则该子矩阵和几何块组成的对就需要进行可见性测试。
上述该距离的计算为椎体空间包围盒与轴对齐空间包围盒之间的最短 距离。 其定义是要在轴对齐空间包围盒的表面上找到某一个点, 使得这点到 椎体空间包围盒的中轴线段的距离最小, 这就是两个包围盒之间的最短距 离。 如图 8所示, 椎体空间包围盒的中轴即两个球心的连线, 将该中轴投影 到轴对齐空间包围盒距离该中轴最近的表面上, 得到一条投影线, 则中轴与 投影线之间的距离为两个包围盒之间的最短距离。
例如, 如图 9所示, L1与 L2是两个光源块, P1是一个采样点块, Ql、 Q2和 Q3是三个几何块。 P1与 L1组成的子矩阵与 Q2和 Q3需要进行可见 性测试, P1与 L2组成的子矩阵与 Q1和 Q2需要进行可见性测试。
歩骤 403、 对确定为需要进行可见性测试的子矩阵和几何块进行标记。 在应用中,如果椎体空间包围盒和轴对齐空间包围盒在空间上没有重叠 部分, 则对应的子矩阵产生的光线一定不会与对应几何块中的任何面片相 交, 该子矩阵和几何面片块不需要进行可见性测试, 即通过可见性测试; 反 之, 两者需要进行可见性测试, 本歩骤中对需要进行可见性测试的子矩阵和 几何块进行标记。
歩骤 500、 把子矩阵及对应的几何块调入显存或内存中, 然后对该子矩 阵使用光割技术计算子矩阵中各元素的值, 即虚拟点光源对像素点的亮度贡 献值。
本发明为基于光割技术的全局光照绘制方法。 如图 10a所示, 该场景中 存在四个虚拟点光源分别标注为 1,2,3,4,针对每个需要绘制的采样点,例如: 像素对应的场景采样点,基于蛮力的绘制方法是分别计算这四个虚拟点光源 对该采样点的贡献并求和。光割是一种利用大量虚拟点光源来绘制全局光照 效果的技术, 通过合并对采样点贡献较小的光源, 来达到加速绘制的目的。 使用光割技术, 当一组虚拟点光源对某个采样点的亮度贡献值较低时, 则使 用这组虚拟点光源的共同父节点来代替所有子节点求亮度贡献值, 这里亮度 贡献值是指利用节点的位置、 法向、 材质系数和光照亮度来求取子树对采样 点的亮度贡献值。 在实施光割之前, 需要对场景中的虚拟点光源构造出唯一 的光树。 具体方法可以是根据光源的强度, 光的类型, 朝向等属性构造二叉 树。 每个虚拟点光源作为叶子节点, 中间代表节点可以根据光源的强度做随 机选取。
图 10a场景构建完光树之后, 对于每个采样点, 从光树的根节点作为光 割的起始开始遍历, 每次计算各个父节点代替各自的叶节点所产生的误差, 如果误差大于设定的阈值 (如, 2%的误差阈值) , 则使用该节点的两个子 节点代替该节点, 否则保留该节点在光割中。 当所有的节点都在误差要求之 内时对应的光割作为最终选择的光割。 在图 10b中, 三个光割图中的粗线分 别代表了场景中三个不同采样点在光树中选取的光割。光割的相关内容可以 Walter, B., et al., Lightcuts: a scalable approach to illumination. ACM Transactions on Graphics (TOG), 2005. 24(3): p. 1098-1107, 在此不再赘述。
在本实施例中, 歩骤 500所采用的光割技术, 指的是对每个采样点块和 通过了可见性测试的光源块使用光割, 每个光源块生成一棵光树, 对采样点 块中的每个采样点在这棵光树上进行光割计算。
歩骤 500具体包括: 歩骤 501、使用 Out-of-Core数据管理器将可见性为可见的子矩阵及对应 的几何块调入到显存或内存中。
可见性为可见包括可见性测试的结果为可见的虚拟点光源以及被标记 为需要进行可见性测试的虚拟点光源。
本实施例中, 在计算某个子矩阵的元素时, 所有与该子矩阵在前述歩骤 中被判断为存在重叠部分(相交) 的几何块, 都需要被调入一次, 调入几何 块的顺序下面具体说明。
一种简单的方法是按照几何块的序号调入。歩骤 100中已经根据莫顿码 对几何块进行了排序, 如果计算出子矩阵 1和几何块 2、 4、 7、 8相重叠, 则在计算该子矩阵 1时依次调入几何块 2、 4、 7、 8。
另一种方法通过优化调入子矩阵和几何块的顺序, 来减少总的调入次 数, 即减少数据读写量(10)操作代价。 具体地, 把有重叠关系的子矩阵和 几何块组成的节点, 把由一个节点到另一个节点的 10操作代价设为两点之 间的边的权值, 所有的节点和边构成图。 通过求解遍历图中所有节点, 但是 经过的路径最短的一个路径, 来最小化 10操作代价。
举例说明: 如图 lla、 图 lib所示, 如果在计算某个子矩阵 a的过程中 需要对某个几何块 B进行可见性测试, 则把 a和 B作为一个子矩阵-几何块 组合 a-B, 即节点 a-B ; 如果计算 a的过程中还需要对几何块 C进行可见性 测试, 则把 a-C也组成一个子矩阵 -几何块组合 a-C。 以此类推, 把所有符合 上述关系的子矩阵和几何块都组合起来, 每个子矩阵-几何块组合作为图的 一个节点, 则节点之间的边的权值为由一个节点移到另一个节点需要传输的 数据大小。 同理, 如果存在另一个子矩阵 d, 计算子矩阵 d的过程中需要对 几何块 B进行可见性测试, 则构成的组合是 d-B。
在实际的应用中, 由于显存(或者内存)是大于单个子矩阵或者几何块 的, 所以会有一个缓冲区, 可以同时在显存 (或者内存) 中存储多个子矩阵 和几何块, 本实施例为了方便说明, 假设显存(或者内存)可以同时存储两 个子矩阵和一个几何块。
如图 11a所示, 如果按照几何块序号的方法进行调入, 那遍历图中节点 的次序为 a-B, a-C, d-B, 进行的 10操作为: 1、 调入 a, 2、 调入 B, 遍历 a-B , 3、 调出 B调入 C, 遍历 a-C, 4、 调入 d, 5、 调出 C调入 B, 遍历 d-B。 共需要 5次 10操作。
如图 lib所示, 如果按照遍历图的方法进行调入, 则遍历图中节点的次 序为 a-B, d-B , a-C, 进入的 10操作为: 1、 调入 a, 2、 调入 B, 遍历 a-B, 3、 调入 d, 遍历 d-B, 4、 调出 B调入 C, 遍历 a-C, 由于 a-B到 d-B的边的 权值较小, 因此本方法中优先从 a-B转到 d-B。 这样就只需要 4次 10操作, 比前一种方法减少了一次。
实际应用中, 由于外存可以容纳更多的子矩阵和几何块, 图遍历的方法 可以比按序号顺序调入的方法快 10倍以上, 极大的提高了效率。 比如本文中 图 3的场景,使用 1600 x 1200像素的图片分辨率,有 3200万点光源和 1.17亿的 几何面片, 共有 18GB的几何和虚拟点光源数据, 采用遍历图的方法来调入 能够明显提高效率。
歩骤 502、 基于光割技术对调入的子矩阵及对应的几何块进行可见性测 试。
本歩骤中调入被标记为需要进行可见性测试的几何块, 每调入一块进行 一次可见性测试, 把确定为被遮挡的光线标记为不可见。
可见性测试包括若干种计算方法, 本实施例中所采用的算法为: 假设椎 体空间包围盒中包裹了 X条光线, 轴对齐空间包围盒包裹了 y个三角面片。 对于每条光线, 分别与 y个三角面片进行求交运算, 即检测该光线与各三角 面片是否相交, 如果相交, 则判断为该光线不可见, 该光线一端的虚拟点光 源对该光线另一端的采样点的贡献为 0;如果不相交,则判断为该光线可见, 即通过了可见性测试。
歩骤 503、 计算上一歩骤中确定为可见的光线对应的虚拟点光源对采样 点的亮度贡献值。
具体地, 可以根据虚拟点光源在某一位置的材质属性、 衰减属性、 可见 性以及光强度来计算亮度贡献值。 例如, 根据式 (1 ) 计算亮度贡献值:
Lc (x, ω) = jMi (χ, ώ)Οι {x)Vi (x)I, ^ Mj (x, ω)ϋ] (x)Vj (x)^ /, ( 1 ) 其中, 使I光割技术在虚拟点光源构成的光树 ΐ选取一个割作为输入, 来选定割中的所有中间节点, c表示这个割中的其中一个中间节点, 中间节 点 c下包含的所有虚拟点光源对当前计算的采样点产生的亮度总贡献值。输 入的参数 X表示虚拟点光源的位置, ω表示虚拟点光源与采样点连线的方向, i表示 c中包含的所有虚拟点光源, j表示以能量为概率密度随机选出的一个 代表虚拟点光源。 Μ'· )表示材质项, 表示第 个虚拟点光源在位置 X对方 向 ω产生的能量, 是几何项, 表示能量由第 个虚拟点光源到达采样点 所经过的衰减, W为可见项, 表示位置点 X是否被采样点看见(即二者之 间没有几何遮挡), 若为 0则表示不可见, 若为 1则表示可见, '·表示虚拟点
Τ Mi (χ, ω Οί {x)Vi (χ)Ι, Μ ,· (χ, ω)Οί (x)Vi (χ)Υ /, 光源本身的光强度, ^ 表示真实值, ^ 表 示求取光割后的逼近值, 意即光选取出一个光割后, 割中的每一个中间节点 下的所有虚拟点光源可以使用一个代表点光源来计算。 ^
Mj (x, )Gj (x)Vj (x) j Ii
使用所有虚拟点光源求和算总亮度贡献值, - 使用一个随 机选择的代表光源点 j来逼近节点包含的所有虚拟点光源的总贡献。 歩骤 600、 计算每一个子矩阵的最终亮度。
具体而言, 将通过了可见性测试的光线的亮度累加到每个采样点, 即像 素点上, 将所有像素点的缓存的输出得到最终的图像。 如图 12所示, 场景的一个采样点的最终亮度由几千个光线的能量累加 得到, 由于每一个采样点可能为多个光线的端点, 因此本歩骤中把通过可见 性测试的光线的能量根据采样点的空间位置累加到对应的图像的像素点缓 存上, 这一过程就称为积分。 完成所有子矩阵的计算及积分后, 把像素点缓 存输出, 就得到了最终的图像。
如图 13所示, 为本发明一个实施例的多光源下的全局光照绘制装置的结 构示意图, 该装置包括: 块处理模块 10、 矩阵建立模块 20、 可见性测试判断 模块 30、 亮度贡献值计算模块 40以及图像输出模块 50。
其中, 块处理模块 10用于读入几何信息和光源信息, 并对读入的信息进 行处理。 具体而言, 块处理模块 10包括: 读入单元 11、 划分单元 12以及输出 单元 13。
读入单元 11用于读入三角面片以及虚拟点光源的信息。划分单元 12用于 计算三角面片的重心在 X轴、 y轴和 z轴上的位置码, 根据三角面片重心的 X轴 位置码、 y轴位置码和 z轴位置码计算得到完整的莫顿码, 根据莫顿码对三角 面片进行排序和划分, 得到第一数量的; 还用于计算虚拟点光源的重心在 X 轴、 y轴和 z轴上的位置码, 根据虚拟点光源重心的 X轴位置码、 y轴位置码和 z轴位置码计算得到完整的莫顿码, 根据莫顿码对三角面片进行排序和划分。 输出单元 13用于将排序后的几何块和光源块输出到 Out-of-Core数据管理器 中。
矩阵建立模块 20用于建立光矩阵并将其划分为若干个子矩阵。该矩阵建 立模块 20具体包括: 光传递矩阵建立单元 21、 聚类单元 22以及子矩阵划分单 元 23。
其中光传递矩阵建立单元 21, 即权利要求中的光传递矩阵建立模块用于 以采样点作为行坐标, 以虚拟点光源作为列坐标建立光传递矩阵。 聚类单元 22用于根据采样点之间的相关性, 采用聚类方法例如 k-均值 (means) 方法、 J-均值方法、 CLARANS方法、 BIRCH方法、 DBSCAN方法、 PGCS方法或 CURE 方法等对采样点进行的聚类, 得到聚类数量。 子矩阵划分单元 23, 即权利要 求中的子矩阵划分模块用于根据划分单元划分得到的光源块的数量将光传 递矩阵划分为相应数量的列, 根据聚类单元得到的采样点的聚类数量将光传 递矩阵划分为相应数量的行。
可见性测试判断模块 30用于判断子矩阵和几何块是否需要进行可见性 测试。 该可见性测试判断模块 30具体包括: 空间包围盒建立单元 31、 判断单 元 32以及标记单元 33。
其中, 空间包围盒建立单元 31, 即权利要求中的空间包围盒建立模块, 用于为每个子矩阵建立能包含该子矩阵中所有光线的椎体空间包围盒, 以及 为每个几何块建立能包含该几何块中所有面片的轴对齐空间包围盒。判断单 元 32用于通过测试一个椎体空间包围盒与一个轴对齐空间包围盒在空间上 是否有重叠部分, 来确定子矩阵与几何块是否需要进行可见性测试。 标记单 元 33用于对判断单元 32确定为需要进行可见性测试的子矩阵和几何块进行 标记。
亮度贡献值计算模块 40用于把子矩阵及对应的几何块调入显存或内存 中, 然后对该子矩阵使用光割技术计算虚拟点光源对像素点的亮度贡献值。 该亮度贡献值计算模块 40具体包括: 调入单元 41、 测试单元 42以及计算单元 43。
其中, 调入单元 41用于通过 Out-of-Core数据管理器将被标记单元 33标记 为需要进行可见性测试的子矩阵及对应的几何块调入到显存或内存中。测试 单元 42用于基于光割技术对调入的子矩阵及对应的几何块进行可见性测试。 计算单元 43用于计算被测试单元 42确定为可见的光线对应的虚拟点光源对 采样点的亮度贡献值。
图像输出模块 50用于将通过了可见性测试的光线的亮度累加到每个采 样点上, 将所有采样点缓存的光能量输出得到最终图像。
各个部件的具体作用可以参照上述实施例中关于全局光照绘制方法的 描述。
图 14示出了本发明的另一实施例的一种网络设备的结构框图。所述网络 设备 1100可以是具备计算能力的主机服务器、个人计算机 PC、或者可携带的 便携式计算机或终端等。本发明具体实施例并不对计算节点的具体实现做限 定。
所述网络设备 1100包括处理器(processor)lllO、 通信接 口 (Communications Interface) 1120,存储器 (memory)l 130和总线 1140。 其中, 处 理器 1110、通信接口 1120、以及存储器 1130通过总线 1140完成相互间的通信。
通信接口 1120用于与网络设备通信, 其中网络设备包括例如虚拟机管理 中心、 共享存储等。
处理器 1110用于执行程序。 处理器 1110可能是一个中央处理器 CPU, 或 者是专用集成电路 ASIC (Application Specific Integrated Circuit) , 或者是被 配置成实施本发明实施例的一个或多个集成电路。
存储器 1130用于存放文件。存储器 1130可能包含高速 RAM存储器, 也可 能还包括非易失性存储器 (non-volatile memory), 例如至少一个磁盘存储器。 存储器 1130也可以是存储器阵列。 存储器 1130还可能被分块, 并且所述块可 按一定的规则组合成虚拟卷。
在一种可能的实施方式中, 上述程序可为包括计算机操作指令的程序代 码。 该程序具体可用于:
对场景的几何面片和虚拟点光源分别基于莫顿码进行处理,得到第一数 量的几何块以及第二数量的光源块;
以场景的采样点为行坐标, 以所述虚拟点光源为列坐标建立光传递矩 阵; 将所述光传递矩阵划分为所述第二数量的列,将所述光传递矩阵划分为 第三数量的行, 每一行与每一列相交构成为一个子矩阵, 所述第三数量为所 述采样点的聚类数量;
根据各虚拟点光源的材质属性、 衰减属性、 可见性以及光强度计算对应 子矩阵中的光线的亮度贡献值;
将可见性为可见的光线的亮度贡献值累加到对应的子矩阵的采样点上, 并输出所述采样点的总亮度贡献值。
在一种可能的实现方式中,所述对场景的几何面片和虚拟点光源分别基 于莫顿码进行处理, 得到第一数量的几何块以及第二数量的光源块, 包括: 分别计算所述几何面片的重心和所述虚拟点光源的重心在 X轴、 y轴和 z 轴上的位置码;
根据所述几何面片重心的位置码计算第一莫顿码, 根据所述虚拟点光源 重心的位置码计算第二莫顿码;
根据所述第一莫顿码对所述几何面片进行划分和排序, 得到第一数量的 几何块, 根据所述第二莫顿码对所述虚拟点光源进行划分和排序, 得到第二 数量的光源块。
在一种可能的实现方式中, 该程序还用于:
将所述子矩阵中的所有所述光线包含在第一空间包围盒中,将所述几何 块的所有几何面片包含在第二空间包围盒中,所述第一空间包围盒由两个球 体以及连接所述两个球体的侧面构成,每一个子矩阵对应一个第一空间包围 盒, 每一个几何块对应一个第二空间包围盒;
若所述第一空间包围盒的中轴到所述第二空间包围盒的最短距离不大 于构成所述第一空间包围盒的较大球体的半径,判断为对应的子矩阵和几何 块需要进行可见性测试。
在一种可能的实现方式中,所述第一空间包围盒的一个球体以所述子矩 阵中所有采样点的空间中心为球心, 以所述采样点到球心的最远距离为半 径,
另一个球体以所述子矩阵中所有虚拟点光源的空间中心为球心,以所述 虚拟点光源到球心的最远距离为半径,
通过在所述两个球体上分别截取过球心并与所述两个球体的球心连线 垂直的切面,将所得到的两个切面与两个球体相交的边分别连接构成所述侧 面。
在一种可能的实现方式中,所述第二空间包围盒由所包围的所有几何面 片的最小 X轴、 y轴、 z轴坐标和最大 X轴、 y轴、 z轴坐标包围构成。
在一种可能的实现方式中,所述根据各虚拟点光源的材质属性、衰减属 性、 可见性以及光强度计算对应子矩阵中的光线的亮度贡献值, 包括: 将判断为需要进行可见性测试的子矩阵及几何块以块为单位从外存调 入到内存中; 对调入的所述子矩阵和几何块进行可见性测试;
根据所述子矩阵中虚拟点光源的材质属性、衰减属性、可见性以及光强 度计算所述子矩阵中通过了可见性测试的光线的亮度贡献值。
在一种可能的实现方式中,所述将判断为需要进行可见性测试的子矩阵 及几何块以块为单位从外存调入到内存中, 包括:
根据所述几何块的莫顿码序号,将标记为需要进行可见性测试的子矩阵 对应的几何块调入。
在一种可能的实现方式中,所述将判断为需要进行可见性测试的子矩阵 及几何块以块为单位从外存调入到内存中, 包括:
将所要计算的每个子矩阵分别与对应的各需要进行可见性测试的几何 块组合为节点,以由第一节点到第二节点需要进行的数据读写量作为连结所 述两个节点的边的权值,将所述光传递矩阵中所有的点连接构成一张图,计 算能够遍历所述图中所有节点, 并且通过的边的总权值最小的路径, 根据所 述路径上各节点的顺序将标记为需要进行可见性测试的子矩阵及几何块从 外存调入到内存中。
在一种可能的实现方式中,所述对调入的所述子矩阵和几何块进行可见 性测试, 包括:
对于所述子矩阵中的每条光线,分别与所述几何块中的几何面片进行求 交运算, 如果运算结果为相交, 则判断为所述光线不可见; 如果运算结果为 不相交, 则判断为所述光线可见。
本领域普通技术人员可以意识到, 本文所描述的实施例中的各示例性单 元及算法歩骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。 这些功能究竟以硬件还是软件形式来实现,取决于技术方案的特定应用和设 计约束条件。专业技术人员可以针对特定的应用选择不同的方法来实现所描 述的功能, 但是这种实现不应认为超出本发明的范围。
如果以计算机软件的形式来实现所述功能并作为独立的产品销售或使 用时, 则在一定程度上可认为本发明的技术方案的全部或部分(例如对现有 技术做出贡献的部分)是以计算机软件产品的形式体现的。 该计算机软件产 品通常存储在计算机可读取的非易失性存储介质中,包括若干指令用以使得 计算机设备(可以是个人计算机、 服务器、 或者网络设备等)执行本发明各 实施例方法的全部或部分歩骤。 而前述的存储介质包括 U盘、 移动硬盘、 只 读存储器 (ROM, Read-Only Memory )、 随机存取存储器 (RAM, Random Access Memory), 磁碟或者光盘等各种可以存储程序代码的介质。
以上所述, 仅为本发明的具体实施方式, 但本发明的保护范围并不局 限于此, 任何熟悉本技术领域的技术人员在本发明揭露的技术范围内, 可轻 易想到变化或替换, 都应涵盖在本发明的保护范围之内。 因此, 本发明的保 护范围应以所述权利要求的保护范围为准。 实用性
根据本发明实施例所提供的多光源下的全局光照绘制方法及装置可应 用于对大规模、 高精度要求的外存场景进行绘制的场景, 通过将几何面片划 分为几何块, 将虚拟点光源划分为光源块, 从外存中以块为单位将几何面片 和虚拟点光源读入到内存中进行处理, 显著的提高了全局光照绘制速度和效

Claims

权 利 要 求 书
1、 一种多光源下的全局光照绘制方法, 其特征在于, 用于对包含若干 个物体的场景进行全局光照绘制, 所述物体由几何面片来描述, 所述方法由 具有内存并耦接至外存的系统来执行, 所述方法包括:
对所述场景中的几何面片和虚拟点光源分别基于位置信息进行处理,得 到第一数量的几何块以及第二数量的光源块;
以所述场景中的所有采样点为行坐标, 以所有虚拟点光源为列坐标建立 光传递矩阵;
将所述光传递矩阵划分为所述第二数量的列, 每一列对应一个所述光源 块, 将所述光传递矩阵划分为第三数量的行, 每一行与每一列相交构成为一 个子矩阵, 所述第三数量为所述采样点的聚类数量;
将所述子矩阵和几何块从所述外存调入到所述内存中, 根据所述虚拟点 光源的材质属性、 衰减属性、 可见性以及光强度, 计算对应子矩阵中的虚拟 点光源对采样点的亮度贡献值;
将可见性为可见的所述虚拟点光源对采样点的亮度贡献值累加到对应 的采样点上, 并输出所述采样点的总亮度。
2、 根据权利要求 1所述的多光源下的全局光照绘制方法, 其特征在于, 所述对所述场景中的几何面片和虚拟点光源分别基于位置信息进行处理, 得 到第一数量的几何块以及第二数量的光源块, 包括:
分别计算所述几何面片的重心和所述虚拟点光源的重心在 X轴、 y轴和 z 轴上的位置码, 所述几何面片的重心构成所述几何面片的位置信息, 所述虚 拟点光源的重心构成所述虚拟点光源的位置信息;
根据所述几何面片重心的位置码计算第一莫顿码, 根据所述虚拟点光源 重心的位置码计算第二莫顿码;
根据所述第一莫顿码对所述几何面片进行排序和划分, 得到第一顺序和 第一数量的几何块, 根据所述第二莫顿码对所述虚拟点光源进行排序和划 分, 得到第二顺序和第二数量的光源块。
3、 根据权利要求 1所述的多光源下的全局光照绘制方法, 其特征在于, 所述将所述光传递矩阵划分为所述第二数量的列,每一列对应一个所述光源 块,将所述光传递矩阵划分为第三数量的行, 每一行与每一列相交构成为一 个子矩阵之后, 还包括:
将所述子矩阵中的所有所述虚拟点光源和采样点的连线包含在第一空 间包围盒中, 每一个子矩阵对应一个第一空间包围盒,
其中, 所述第一空间包围盒包括两个球体及连接所述两个球体的侧面, 一个球体为包含所述子矩阵中所有采样点的最小球体,另一个球体为包含所 述子矩阵中所有虚拟点光源的最小球体,通过在所述两个球体上分别截取过 球心并与所述两个球体的球心连线垂直的切面,将所得到的两个切面与所述 两个球体相交的边分别连接构成所述侧面。
4、 根据权利要求 3所述的多光源下的全局光照绘制方法, 其特征在于, 所述将所述光传递矩阵划分为所述第二数量的列,每一列对应一个所述光源 块,将所述光传递矩阵划分为第三数量的行, 每一行与每一列相交构成为一 个子矩阵之后, 还包括:
将所述几何块的所有几何面片包含在第二空间包围盒中,每一个几何块 对应一个第二空间包围盒,
其中,所述第二空间包围盒由包含所述几何块中所有几何面片的最小轴 对齐长方体构成。
5、 根据权利要求 4所述的多光源下的全局光照绘制方法, 其特征在于, 所述将所述子矩阵和几何块从所述外存调入到所述内存中之前, 还包括: 判断所述第一空间包围盒的中轴到所述第二空间包围盒的最短距离是 否不大于所述第一空间包围盒中较大球体的半径,是则判断为对应的子矩阵 和几何块需要进行可见性测试,否则判断为对应的子矩阵和几何块不需要进 行可见性测试, 并将所述子矩阵中的虚拟点光源标记为对采样点可见。
6、 根据权利要求 5所述的多光源下的全局光照绘制方法, 其特征在于, 所述将所述子矩阵和几何块从所述外存调入到所述内存中,根据所述虚拟点 光源的材质属性、 衰减属性、 可见性以及光强度, 计算对应子矩阵中的虚拟 点光源对采样点的亮度贡献值, 包括:
将判断为需要进行可见性测试的子矩阵及几何块从所述外存调入到所 述内存中;
对调入的所述子矩阵和几何块进行可见性测试;
根据所述子矩阵中虚拟点光源的材质属性、衰减属性、可见性以及光强 度,计算所述子矩阵中可见性为可见的虚拟点光源对采样点亮度贡献值,所 述可见性为可见的虚拟点光源包括所述可见性测试的结果为可见的虚拟点 光源以及所述标记为可见的虚拟点光源。
7、 根据权利要求 6所述的多光源下的全局光照绘制方法, 其特征在于, 所述对调入的所述子矩阵和几何块进行可见性测试, 包括:
对于所述子矩阵中的每条虚拟点光源和采样点的连线,分别与所述几何 块中的几何面片进行求交运算, 如果运算结果为相交, 则判断为所述虚拟点 光源对采样点不可见; 如果运算结果为不相交, 则判断为所述虚拟点光源对 采样点可见。
8、 根据权利要求 6所述的多光源下的全局光照绘制方法, 其特征在于, 所述将所述子矩阵和几何块从所述外存调入到所述内存中, 包括:
根据所述几何块的所述第一顺序,将判断为需要进行可见性测试的子矩 阵对应的几何块从所述外存调入到所述内存中。
9、 根据权利要求 6所述的多光源下的全局光照绘制方法, 其特征在于, 所述将所述子矩阵和几何块从所述外存调入到所述内存中, 包括:
将所有子矩阵分别与对应的需要进行可见性测试的几何块组合为节点, 以由一个节点到另一个节点需要进行的数据读写量作为连接所述两个节点 的边的权值,将所有节点连接构成一张图,计算能够遍历所述图中所有节点, 并且所述遍历所通过的边的总权值最小的路径,选择所述路径, 并根据所述 路径上各节点的遍历顺序将对应的子矩阵及几何块从所述外存调入到所述 内存中。
10、 一种多光源下的全局光照绘制装置, 其特征在于, 用于对包含若干 个物体的场景进行全局光照绘制, 所述物体由几何面片来描述, 所述方法由 具有内存并耦接至外存的系统来执行, 所述装置包括:
块处理模块,用于对所述场景中的几何面片和虚拟点光源分别基于位置 信息进行处理, 得到第一数量的几何块以及第二数量的光源块;
光传递矩阵建立模块, 用于以所述场景中的所有采样点为行坐标, 以所 有虚拟点光源为列坐标建立光传递矩阵;
子矩阵划分模块, 用于并将所述光传递矩阵划分为所述第二数量的列, 每一列对应一个所述光源块, 将所述光传递矩阵划分为第三数量的行, 每一 行与每一列相交构成为一个子矩阵, 所述第三数量为所述采样点的聚类数 亮度贡献值计算模块,用于将所述子矩阵和几何块从所述外存调入到所 述内存中,根据所述虚拟点光源的材质属性、衰减属性、可见性以及光强度, 计算对应子矩阵中的虚拟点光源对采样点的亮度贡献值;
输出模块,将可见性为可见的所述虚拟点光源对采样点的亮度贡献值累 加到对应的采样点上, 并输出所述采样点的总亮度。
11、根据权利要求 10所述的多光源下的全局光照绘制装置,其特征在于, 所述块处理模块被配置为:
分别计算所述几何面片的重心和所述虚拟点光源的重心在 X轴、 y轴和 z 轴上的位置码, 所述几何面片的重心构成所述几何面片的位置信息, 所述虚 拟点光源的重心构成所述虚拟点光源的位置信息;
根据所述几何面片重心的位置码计算第一莫顿码, 根据所述虚拟点光源 重心的位置码计算第二莫顿码;
根据所述第一莫顿码对所述几何面片进行排序和划分, 得到第一顺序和 第一数量的几何块, 根据所述第二莫顿码对所述虚拟点光源进行排序和划 分, 得到第二顺序和第二数量的光源块。
12、根据权利要求 10所述的多光源下的全局光照绘制装置,其特征在于, 还包括:
空间包围盒建立模块,用于建立第一空间包围盒,将所述子矩阵中的所 有所述虚拟点光源和采样点的连线包含在第一空间包围盒中,每一个子矩阵 对应一个第一空间包围盒,
其中, 所述第一空间包围盒包括两个球体及连接所述两个球体的侧面, 一个球体为包含所述子矩阵中所有采样点的最小球体, 另一个球体为包含所 述子矩阵中所有虚拟点光源的最小球体,通过在所述两个球体上分别截取过 球心并与所述两个球体的球心连线垂直的切面,将所得到的两个切面与所述 两个球体相交的边分别连接构成所述侧面。
13、根据权利要求 12所述的多光源下的全局光照绘制装置,其特征在于, 所述空间包围盒建立模块还用于建立第二空间包围盒,将所述几何块的所有 几何面片包含在第二空间包围盒中, 每一个几何块对应一个第二空间包围 品.,
其中,所述第二空间包围盒由包含所述几何块中所有几何面片的最小轴 对齐长方体构成。
14、根据权利要求 13所述的多光源下的全局光照绘制装置,其特征在于, 还包括:
可见性测试判断模块,用于判断所述第一空间包围盒的中轴到所述第二 空间包围盒的最短距离是否不大于所述第一空间包围盒中较大球体的半径, 是则判断为对应的子矩阵和几何块需要进行可见性测试,否则判断为对应的 子矩阵和几何块不需要进行可见性测试,并将所述子矩阵中的虚拟点光源标 记为对采样点可见。
15、根据权利要求 14所述的多光源下的全局光照绘制装置,其特征在于, 所述亮度贡献值计算模块包括:
调入单元,用于将判断为需要进行可见性测试的子矩阵及几何块从所述 外存调入到所述内存中;
测试单元, 用于对调入的所述子矩阵和几何块进行可见性测试; 计算单元, 用于根据所述子矩阵中虚拟点光源的材质属性、 衰减属性、 可见性以及光强度,计算所述子矩阵中可见性为可见的虚拟点光源对采样点 亮度贡献值,所述可见性为可见的虚拟点光源包括所述可见性测试的结果为 可见的虚拟点光源以及所述标记为可见的虚拟点光源。
16、根据权利要求 15所述的多光源下的全局光照绘制装置,其特征在于, 所述测试单元被配置为:
对于所述子矩阵中的每条虚拟点光源和采样点的连线,分别与所述几何 块中的几何面片进行求交运算, 如果运算结果为相交, 则判断为所述虚拟点 光源对采样点不可见; 如果运算结果为不相交, 则判断为所述虚拟点光源对 采样点可见。
17、根据权利要求 15所述的多光源下的全局光照绘制装置,其特征在于, 所述调入单元被配置为:
根据所述几何块的所述第一顺序,将判断为需要进行可见性测试的子矩 阵对应的几何块从所述外存调入到所述内存中。
18、根据权利要求 15所述的多光源下的全局光照绘制装置,其特征在于, 所述调入单元被配置为: 将所有子矩阵分别与对应的需要进行可见性测试的几何块组合为节点, 以由一个节点到另一个节点需要进行的数据读写量作为连接所述两个节点 的边的权值,将所有节点连接构成一张图,计算能够遍历所述图中所有节点, 并且所述遍历所通过的边的总权值最小的路径,选择所述路径, 并根据所述 路径上各节点的遍历顺序将对应的子矩阵及几何块从所述外存调入到所述 内存中。
PCT/CN2014/080927 2013-11-18 2014-06-27 多光源下的全局光照绘制方法及装置 WO2015070618A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201310577043 2013-11-18
CN201310577043.1 2013-11-18
CN201310632551.5A CN104658033B (zh) 2013-11-18 2013-11-29 多光源下的全局光照绘制方法及装置
CN201310632551.5 2013-11-29

Publications (1)

Publication Number Publication Date
WO2015070618A1 true WO2015070618A1 (zh) 2015-05-21

Family

ID=53056725

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/080927 WO2015070618A1 (zh) 2013-11-18 2014-06-27 多光源下的全局光照绘制方法及装置

Country Status (2)

Country Link
CN (1) CN104658033B (zh)
WO (1) WO2015070618A1 (zh)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2545226A (en) * 2015-12-09 2017-06-14 Samsung Electronics Co Ltd Determining lighting in a 3D virtual scene
CN109493413A (zh) * 2018-11-05 2019-03-19 长春理工大学 基于自适应虚拟点光源采样的三维场景全局光照效果绘制方法
CN110599582A (zh) * 2019-09-11 2019-12-20 河南工业职业技术学院 一种类长方物体包围盒的快速算法
CN112396683A (zh) * 2020-11-30 2021-02-23 腾讯科技(深圳)有限公司 虚拟场景的阴影渲染方法、装置、设备及存储介质
CN112489203A (zh) * 2020-12-08 2021-03-12 网易(杭州)网络有限公司 模型处理方法、模型处理装置、电子设备及存储介质
CN112817308A (zh) * 2020-12-30 2021-05-18 北京航空航天大学 一种在机测量的无碰撞全局路径规划方法及系统
CN112489203B (zh) * 2020-12-08 2024-06-04 网易(杭州)网络有限公司 模型处理方法、模型处理装置、电子设备及存储介质

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103971397B (zh) * 2014-04-16 2016-09-28 浙江大学 基于虚拟点光源和稀疏矩阵还原的全局光照绘制方法
CN106611437B (zh) * 2015-10-23 2019-10-22 华为技术有限公司 为三维场景中的多个物体选择材质的方法和装置
CN105335995B (zh) * 2015-10-28 2018-06-05 华为技术有限公司 一种多光源全局光照绘制方法及装置
CN107180447B (zh) * 2016-03-10 2020-12-04 珠海金山网络游戏科技有限公司 一种获得光照强度的方法及装置
CN116883572B (zh) * 2023-09-06 2023-12-19 腾讯科技(深圳)有限公司 一种渲染方法、装置、设备及计算机可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080018647A1 (en) * 2006-07-24 2008-01-24 Bunnell Michael T System and methods for real-time rendering of deformable geometry with global illumination
CN101982838A (zh) * 2010-11-02 2011-03-02 长春理工大学 一种加速被面光源照射的3d虚拟场景的光线跟踪的方法
CN102314703A (zh) * 2011-06-14 2012-01-11 天津大学 一种蒙特卡罗全局光照的自适应抽样方法
CN103136399A (zh) * 2011-12-01 2013-06-05 北京七十二炫信息技术有限公司 面向室内场景的辐射度并行绘制系统和方法

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8164593B2 (en) * 2006-07-13 2012-04-24 University Of Central Florida Research Foundation, Inc. Systems and methods for graphical rendering

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080018647A1 (en) * 2006-07-24 2008-01-24 Bunnell Michael T System and methods for real-time rendering of deformable geometry with global illumination
CN101982838A (zh) * 2010-11-02 2011-03-02 长春理工大学 一种加速被面光源照射的3d虚拟场景的光线跟踪的方法
CN102314703A (zh) * 2011-06-14 2012-01-11 天津大学 一种蒙特卡罗全局光照的自适应抽样方法
CN103136399A (zh) * 2011-12-01 2013-06-05 北京七十二炫信息技术有限公司 面向室内场景的辐射度并行绘制系统和方法

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
GUO, JIE ET AL.: "Research on Real-time Rendering under Complex Area Lighting", JOURNAL OF SYSTEM SIMULATION, vol. 24, no. 1, 31 January 2012 (2012-01-31) *
WU, WEIHE ET AL.: "Global Illumination Simulation Based on Direct Light", COMPUTER ENGINEERING, vol. 35, no. 9, 31 May 2009 (2009-05-31) *

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2545226A (en) * 2015-12-09 2017-06-14 Samsung Electronics Co Ltd Determining lighting in a 3D virtual scene
CN109493413A (zh) * 2018-11-05 2019-03-19 长春理工大学 基于自适应虚拟点光源采样的三维场景全局光照效果绘制方法
CN109493413B (zh) * 2018-11-05 2022-10-21 长春理工大学 基于自适应虚拟点光源采样的三维场景全局光照效果绘制方法
CN110599582A (zh) * 2019-09-11 2019-12-20 河南工业职业技术学院 一种类长方物体包围盒的快速算法
CN110599582B (zh) * 2019-09-11 2023-03-14 河南工业职业技术学院 一种类长方物体包围盒的快速算法
CN112396683A (zh) * 2020-11-30 2021-02-23 腾讯科技(深圳)有限公司 虚拟场景的阴影渲染方法、装置、设备及存储介质
CN112396683B (zh) * 2020-11-30 2024-06-04 腾讯科技(深圳)有限公司 虚拟场景的阴影渲染方法、装置、设备及存储介质
CN112489203A (zh) * 2020-12-08 2021-03-12 网易(杭州)网络有限公司 模型处理方法、模型处理装置、电子设备及存储介质
CN112489203B (zh) * 2020-12-08 2024-06-04 网易(杭州)网络有限公司 模型处理方法、模型处理装置、电子设备及存储介质
CN112817308A (zh) * 2020-12-30 2021-05-18 北京航空航天大学 一种在机测量的无碰撞全局路径规划方法及系统
CN112817308B (zh) * 2020-12-30 2022-10-11 北京航空航天大学 一种在机测量的无碰撞全局路径规划方法及系统

Also Published As

Publication number Publication date
CN104658033A (zh) 2015-05-27
CN104658033B (zh) 2017-06-20

Similar Documents

Publication Publication Date Title
WO2015070618A1 (zh) 多光源下的全局光照绘制方法及装置
CN109509138B (zh) 针对射线跟踪系统的减小的加速结构
US6952204B2 (en) 3D computer modelling apparatus
TWI546770B (zh) 圖形處理單元中3d加速結構之完全並列原地建構
EP3223244B1 (en) Hierarchy merging
US10417821B2 (en) Method of simplifying a geometry model
US8284188B1 (en) Ray tracing system, method, and computer program product for simultaneously traversing a hierarchy of rays and a hierarchy of objects
JP6336727B2 (ja) 並列パイプラインを用いるグラフィック処理方法及び装置
US11715255B2 (en) Intersection testing in a ray tracing system using ray bundle vectors
US20170236335A1 (en) System and method for manipulating acceleration structures
US9728000B2 (en) Apparatus and method of using acceleration structure in ray tracing
KR101670930B1 (ko) 하드웨어를 이용한 케이디 트리 생성 방법 및 장치
KR101908161B1 (ko) 메시 시퀀스 파일 포맷
US11893677B1 (en) Bounding volume hierarchy (BVH) widening based on node compressibility
EP3933781A1 (en) Intersection testing in a ray tracing system
US11861785B2 (en) Generation of tight world space bounding regions
Chan et al. Particle–mesh coupling in the interaction of fluid and deformable bodies with screen space refraction rendering
CN115374396A (zh) 用于使用稀疏矩阵的分层表示来加速矩阵乘法计算的技术
CN113850897A (zh) 用于光线跟踪系统的分层加速结构
CN113850896A (zh) 用于光线跟踪系统的分层加速结构
CN113850895A (zh) 用于光线跟踪系统的分层加速结构

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14861455

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14861455

Country of ref document: EP

Kind code of ref document: A1