CN105513122A - Shadow volume establishing method and device - Google Patents

Shadow volume establishing method and device Download PDF

Info

Publication number
CN105513122A
CN105513122A CN201410495842.9A CN201410495842A CN105513122A CN 105513122 A CN105513122 A CN 105513122A CN 201410495842 A CN201410495842 A CN 201410495842A CN 105513122 A CN105513122 A CN 105513122A
Authority
CN
China
Prior art keywords
limit
data
hash
depth map
silhouette
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201410495842.9A
Other languages
Chinese (zh)
Other versions
CN105513122B (en
Inventor
刘明
樊增智
贾霞
方晓鑫
董振江
盛斌
王睿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN201410495842.9A priority Critical patent/CN105513122B/en
Priority to PCT/CN2015/072334 priority patent/WO2016045298A1/en
Publication of CN105513122A publication Critical patent/CN105513122A/en
Application granted granted Critical
Publication of CN105513122B publication Critical patent/CN105513122B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a shadow volume establishing method and device. The establishing method comprises that in a depth map of an object in which shadow is to be drafted, the non-contour side of the object is rejected from the depth map according to a Hash algorithm, and the depth map is searched for all contour sides of the object; and a shadow volume of the object is established according to all the contour sides. According to the technical scheme provided by the invention, the problem that the GPU load is greatly increased in shadow volume establishment in the prior art is solved, the contour sides are detected accurately under the condition that the GPU load is not increased, and the efficiency is greatly improved.

Description

The method for building up of umbra volume and device
Technical field
The present invention relates to computer graphical and play up field, more particularly, relate to a kind of method for building up and device of umbra volume.
Background technology
Shade refers to the certain area that the light in space has been blocked.Hatching effect can help the Distance geometry relative position of people better between perceptual object, helps people to obtain the information such as the geometric configuration of shade shelter and shade receiving body simultaneously.
In correlation technique, up to the present also there is no the dynamic shadow Rendering of standard.In order to render dynamic shadow effect true to nature, related researcher has made a lot of trial, it is also proposed many sense of reality Shading Rendering algorithms.In the algorithm that these are different, shadow volume algorithm is a kind of high-efficiency dynamic shadow algorithm of main flow.
The efficiency of shadow volume algorithm all the time limit by two crucial steps: one is the detection of silhouette edge, and another is playing up of umbra volume.Because previous step will affect the workload of a rear step to a great extent, therefore improving silhouette edge detection efficiency is the key point improving total algorithm efficiency.Usually do not carry out the detection of silhouette edge in existing algorithm in order to save cpu resource, but all limits being in front are used for building umbra volume.Do the burden really decreasing CPU like this, but the limit of bulk redundancy is for constructing umbra volume, greatly adds the burden of GPU.
Significantly increase the burden problem of GPU for the technical scheme building umbra volume in correlation technique, not yet propose effective solution at present.
Summary of the invention
The invention provides a kind of method for drafting and device of shade, at least to solve the problem.
According to an aspect of the present invention, provide a kind of method for building up of umbra volume, comprise: in the depth map of the object of pending shade drafting, reject according to the non-silhouette edge of hash algorithm by object described in described depth map, and find all silhouette edges of object described in described depth map; The umbra volume of described object is set up according to described all silhouette edges;
Preferably, reject according to the non-silhouette edge of hash algorithm by object in described depth map, and before finding all silhouette edges of object described in described depth map, also comprise: create and be used for the vertical array of all limits data in the object front of preserving described object corresponding light source.
Preferably, find all silhouette edges of object described in described depth map according to hash algorithm, comprising: travel through all limits data in described vertical array; For the every one side data in the data of described all limits, calculate the key assignments of described limit data, and in the Hash table set up in advance, search position corresponding to described limit data according to described key assignments; When described position does not find repetition limit, determine that limit corresponding to described limit data is silhouette edge, wherein, the first Hash tabular value corresponding to described repetition limit is identical with the second Hash tabular value, described Hash tabular value is determined according to described key assignments, wherein, the Hash tabular value on described second Hash tabular value limit indicated by the data of described limit.。
Preferably, reject according to the non-silhouette edge of hash algorithm by object in described depth map, comprising: when finding to repeat limit in described position, judge that whether the index value on two summits of described limit data is equal; If so, then the limit that described limit data are corresponding is rejected.
Preferably, all silhouette edges of object described in described depth map are found according to hash algorithm, comprise: when the index value on two summits of described limit data is unequal, the key assignments of described limit data is added 2N-1, wherein, described N is the number of times of collision loop, and adds the value after 2N-1 according to described key assignments search position corresponding to limit data in the described Hash table set up in advance.
Preferably, the key assignments KEY of limit data according to following formulae discovery: wherein, V aand V bfor the index value that described two summits are corresponding respectively, MAX is the size of described Hash table.
According to another aspect of the present invention, additionally provide a kind of apparatus for establishing of umbra volume, comprising: reject module, in the depth map of the object of pending shade drafting, reject according to the non-silhouette edge of hash algorithm by object described in described depth map; Search module, for finding all silhouette edges of object described in described depth map according to hash algorithm; Set up module, for setting up the umbra volume of described object according to described all silhouette edges.
Preferably, described device, also comprises: creation module, for creating the vertical array of all limits data in the object front for preserving described object corresponding light source.
Preferably, described in search module, comprising: Traversal Unit, for traveling through all limits data in described vertical array; Computing unit, for for the every data in the data of described all limits, calculates the key assignments of described limit data; Search unit, for searching position corresponding to described limit data according to described key assignments in the Hash table set up in advance; Determining unit, for when described position does not find repetition limit, determine that limit corresponding to described limit data is silhouette edge, wherein, the first Hash tabular value corresponding to described repetition limit is identical with the second Hash tabular value, described Hash tabular value is determined according to described key assignments, wherein, and the Hash tabular value on described second Hash tabular value limit indicated by the data of described limit.。
Preferably, described rejecting module, comprising: judging unit, during for finding to repeat limit in described position, judges that whether the index value on two summits of described limit data is equal; Culling unit, for when the index value on described two summits is equal, rejects the limit that described limit data are corresponding.
Pass through the present invention, adopt and search silhouette edge based on hash algorithm, and based on the technical scheme of silhouette edge determination umbra volume, solve in correlation technique the burden problem that the technical scheme building umbra volume significantly increases GPU, achieve when not increasing CPU burden, accurately detected silhouette edge, greatly improve efficiency.
Accompanying drawing explanation
Accompanying drawing described herein is used to provide a further understanding of the present invention, and form a application's part, schematic description and description of the present invention, for explaining the present invention, does not form inappropriate limitation of the present invention.In the accompanying drawings:
Fig. 1 is the process flow diagram of the method for building up of umbra volume according to the embodiment of the present invention;
Fig. 2 is the schematic diagram adding new limit in Hash table according to the embodiment of the present invention;
Fig. 3 is the general flow chart playing up shade according to the embodiment of the present invention;
Fig. 4 is the structured flowchart of the apparatus for establishing of umbra volume according to the embodiment of the present invention;
Fig. 5 is a structured flowchart again of the apparatus for establishing of umbra volume according to the embodiment of the present invention;
Fig. 6 is the shadow algorithm schematic diagram according to the embodiment of the present invention;
Fig. 7 is the Z-pass detection method schematic diagram according to the embodiment of the present invention.
Embodiment
Hereinafter also describe the present invention in detail with reference to accompanying drawing in conjunction with the embodiments.It should be noted that, when not conflicting, the embodiment in the application and the feature in embodiment can combine mutually.
Other features and advantages of the present invention will be set forth in the following description, and, partly become apparent from instructions, or understand by implementing the present invention.Object of the present invention and other advantages realize by structure specifically noted in write instructions, claims and accompanying drawing and obtain.
The present invention program is understood better in order to make those skilled in the art person, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the embodiment of a part of the present invention, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, should belong to the scope of protection of the invention.
In order to solve the problems of the technologies described above, embodiments provide a kind of method for building up of umbra volume, Fig. 1 is the process flow diagram of the method for building up of umbra volume according to the embodiment of the present invention, and as shown in Figure 1, the method comprises the steps:
Step S102: in the depth map of the object of pending shade drafting, rejects according to the non-silhouette edge of hash algorithm by object above-mentioned in above-mentioned depth map, and finds all silhouette edges of above-mentioned object in above-mentioned depth map;
Step S104: the umbra volume setting up above-mentioned object according to above-mentioned all silhouette edges.
By each step above-mentioned, employing can find fast based on hash algorithm and set up umbra volume silhouette edge used, and based on the technical scheme of silhouette edge determination umbra volume, solve in correlation technique the burden problem that the technical scheme building umbra volume significantly increases GPU, achieve when not increasing CPU burden, quick and precisely detected silhouette edge, greatly improve efficiency.
Alternatively, reject according to the non-silhouette edge of hash algorithm by object in above-mentioned depth map, and before finding all silhouette edges of above-mentioned object in above-mentioned depth map before, also comprise: create and be used for the vertical array of all limits data in the object front of preserving above-mentioned object corresponding light source.
In embodiments of the present invention, find all silhouette edges of above-mentioned object in above-mentioned depth map according to hash algorithm, comprising: travel through all limits data in above-mentioned vertical array; For the every one side data in the data of above-mentioned all limits, calculate the key assignments of above-mentioned limit data, and in the Hash table set up in advance, search position corresponding to above-mentioned limit data according to above-mentioned key assignments; When above-mentioned position does not find repetition limit, determine that limit corresponding to above-mentioned limit data is silhouette edge, wherein, the first Hash tabular value corresponding to above-mentioned repetition limit is identical with the second Hash tabular value, above-mentioned Hash tabular value is determined according to above-mentioned key assignments, wherein, the Hash tabular value on above-mentioned second Hash tabular value limit indicated by the data of above-mentioned limit.In specific implementation process, the key assignments KEY according to following formulae discovery above-mentioned limit data: wherein, V aand V bfor the index value that above-mentioned two summits are corresponding respectively, MAX is the size of above-mentioned Hash table.
In an embodiment of the embodiment of the present invention, when above-mentioned position has found repetition limit, judge that whether the index value on two summits of above-mentioned limit data is equal; If so, then the limit that above-mentioned limit data are corresponding is rejected; If not, then continue the process performing above-mentioned " searching all silhouette edges of above-mentioned object in above-mentioned depth map ": namely the key assignments of above-mentioned limit data adds 2N-1, wherein, above-mentioned N is the number of times of collision loop, and in the Hash table set up in advance, searches position corresponding to limit data according to above-mentioned key assignments.
Wherein, be that silhouette edge corresponding to genuine above-mentioned limit data sets up silhouette edge array by above-mentioned placeholder, wherein, above-mentioned silhouette edge array is used for playing up process to above-mentioned umbra volume.
The further improvement of the embodiment of the present invention to technique scheme is, according to Z-pass algorithm, template test is carried out to the shadow region of above-mentioned umbra volume, wherein, when Z-pass algorithm depth test is carried out in shadow region corresponding to the object front of carrying out above-mentioned object corresponding light source, if above-mentioned depth test passes through, then the stencil buffers value of above-mentioned shadow region subtracts one, if do not passed through, then above-mentioned stencil buffers value is constant; When Z-pass algorithm depth test is carried out in shadow region corresponding to the object back side of carrying out above-mentioned object corresponding light source, if above-mentioned depth test passes through, then the stencil buffers value of above-mentioned shadow region adds one, if do not passed through, then above-mentioned stencil buffers value is constant.
It is more difficult for efficiently playing up real-time shadow effect.Existing algorithm is all not enough to satisfy the demands on robustness and efficiency of algorithm.Existing shadow volume algorithm is a lot of cpu resource because needs expend, and is difficult to obtain smooth real-time shadow effect therefore.In addition particularly mobile platform graphic hardware supports imperfection for bottom standard at present, causes the algorithm depending on hardware to be difficult to play due effect.The embodiment of the present invention has explored a kind of new real-time rendering algorithm, under the prerequisite keeping low CPU to consume, substantially increases the rendering efficiency of shade, decreases hardware-dependent simultaneously, enable to widely use on each platform comprising mobile platform.
In order to better understand the flow process of the method for drafting of above-mentioned shade, be described below in conjunction with preferred embodiment, but do not limit the present invention:
Step 1, builds umbra volume.Reading in comprising document scene, the storage of vertex data, the rejecting etc. of non-silhouette edge.Obtain umbra volume limit array to be drawn after this step, wherein, carry out according to hash algorithm the main contents that " rejecting of non-silhouette edge " stress for the embodiment of the present invention.
Step 2, utilizes umbra volume to judge shadow region.Comprise playing up of umbra volume, utilize evaluation algorithm to carry out update mark etc. to shadow region.The shadow region marked with stencil buffer is obtained after this step.
Step 3, draws the shadow region marked.Comprise the setting of stencil buffers method of testing and draw operation etc.After this step, screen obtains the final shade of completing.
In specific implementation process
Step 1 specifically comprises: first open depth buffered write operation (being a setting command in openGL), read in the vertex information of whole document scene, then adopt openGL order to be loaded into vertex information to draw, play up whole scene, first pass obtains the depth map of all objects after playing up, this depth map is using the true viewpoint of user as reference.Then use hash algorithm, the silhouette edge of object is processed, reject non-silhouette edge.After rejecting, silhouette edge saves as an array.Then for each silhouette edge, projected at a distance, added all limits in object front, built umbra volume.The limit of whole umbra volume saves as an array, waits for Rendering operations.Below the detailed introduction of hash algorithm being rejected to non-silhouette edge:
The non-silhouette edge occluding technique of umbra volume based on Hash table, is intended to the detection efficiency improving silhouette edge, first, supposes to use pointolite and the model file with index.According to the relative position of light source and shelter, all dough sheets on shelter model all need test to determine anterior dough sheet and back dough sheet, i.e. facing light sources position, and front or the back side are facing to the dough sheet of light source.Technically, utilize light source to the dot product of the normal vector of the vector (direction sensing light source) of dough sheet and dough sheet to judge pros and cons.When two vector dot are greater than zero, be anterior dough sheet, otherwise be back dough sheet.Then for all anterior dough sheets, all limits need detected to determine silhouette edge.To all silhouette edges, extend to infinite point along light source to the direction of every bar limit line and build umbra volume.The side of the umbra volume of formation is referred to shadow polygon.Searching silhouette edge is a very time-consuming process, and therefore the search efficiency of silhouette edge will determine the efficiency of whole algorithm to a great extent.Shadow volume algorithm based on Hash table is for whole object creation umbra volume, namely to the silhouette edge searching object, utilizes silhouette edge to set up umbra volume, instead of sets up umbra volume to all tri patchs that object is in front.This greatly can reduce the pressure of graphic hardware, does not increase a large amount of calculating simultaneously.In the method, Hash table is for improving silhouette edge search efficiency.By utilizing the characteristic of Hash table, ensure after all limits being positioned at object front have been traversed one time, all non-silhouette edges can both be disallowable.
In traditional algorithm, the front dough sheet of the shelter seen from light-source angle all can for generation of umbra volume.This algorithm is consuming time very serious, and the requirement in actual applications for hardware is very high.The more important thing is, along with the raising of shelter model complexity, the efficiency of silhouette edge detection algorithm declines clearly.Be O (n) to the algorithm complex of each limit S.The total complexity of algorithm reaches O (n 2).
In order to reduce the algorithm complex that silhouette edge detects, Hash table is used to improve the efficiency of detection.Hash table is the data structure directly conducted interviews according to key value.It visits the data of storage by key value being mapped in table a position, can accelerate the speed of searching.This mapping function is called hash function, and the array of put is called Hash table.In practice, hash algorithm greatly can increase inquiry velocity.The setting being at all hash function of hash algorithm, and the disposal route after conflict.In the setting and conflict processing method of hash function, the embodiment of the present invention designs for the rejecting of silhouette edge, ensures inerrably to complete this process fast.
Suppose to use the model file with index value, each summit is with an index value.For silhouette edge array to be selected, in fact only store the index value of each end points.Whenever an increase limit, no longer need to travel through whole array and search and whether have the limit of redundancy to exist.Hash table provides the characteristic of fast finding.Add new limit at every turn, the existence on redundancy limit can be known whether within O (1) time.Because identical limit is always mapped to the same position in Hash table.Each Hash element in Hash table stores a signless integer for storing key assignments; Two integers are for storing the index value of end points; A Boolean is for storing placeholder.Suppose that MAX represents the size of Hash table, VA, VB represent the index value of two end points, so provide a kind of method of fast and effectively calculation key: KEY = ( V A 2 + V B 2 ) mod MAX .
Utilize this computing method, the limit that can ensure same endpoints can be mapped to the same position in Hash table all the time.When needing to add a new limit, first calculation key, then checks relevant position in Hash table.If this position does not have occupied, so store the index value of end points, and to change placeholder be true.If occupied, check that whether the index value of two end points on two limits is completely equal.If completely equal, prove to have found redundancy limit, change placeholder is false.If the index value of end points is not exclusively completely equal, then there occurs conflict.The key assignments on new limit is added 2N-1, and wherein N represents the number of times of collision loop.Such as first time runs into conflict, and key assignments adds 1, reexamines relevant position, if still conflicted, then adds 3, and so circulation is until find unappropriated position.Fig. 2 is the schematic diagram adding new limit in Hash table according to the embodiment of the present invention.
When all limits all join after in Hash table, all placeholders are that genuine position stores silhouette edge.Traveling through whole Hash table once, generating final silhouette edge array, for playing up umbra volume.
In the implementation, use Z-pass algorithm to carry out template test, when position for video camera is when umbra volume is inner, Z-fail algorithm is used for template test to obtain correct result.Below the false code utilizing Hash table to detect silhouette edge algorithm:
In step 2: close depth buffered write operation, open the write operation of stencil buffers, input umbra volume limit array, plays up umbra volume.Application Z-Pass algorithm is tested: to the front of umbra volume, i.e. this one side of relative viewpoint, if depth test passes through, so corresponding with respective pixel stencil buffers value adds one, if depth test does not pass through, then stencil buffers value is constant; For the back side of umbra volume, namely away from the side of viewpoint, if depth test does not pass through, then stencil buffers value remains unchanged, if depth test passes through, then stencil buffers value subtracts one.After shadow region is completed, stencil buffer non-zero region is labeled as shadow region.
In step 3: the shadow region marked for stencil buffer, what arrange template test is non-zero by condition, then draws one and cover the echo of whole screen, this echo only by the region of template test drawn go out, complete final shade drafting.
Fig. 3 is the general flow chart playing up shade according to the embodiment of the present invention.
Adopt the technique scheme that the embodiment of the present invention provides, owing to have employed the thought for whole object creation umbra volume, namely build umbra volume according to each object, instead of for each triangle, the tri patch quantity building umbra volume falls sharply, and does not increase a large amount of computing simultaneously.Thus umbra volume needs the tri patch quantity played up to reduce in a large number, greatly alleviates the pressure of graphic hardware, saves a large amount of render time simultaneously.Final rendering speed improves a lot, and when playing up complex scene, picture fluency significantly improves.And the algorithm of the embodiment of the present invention is when processing the model of different complexity, rendering efficiency is close linearly with the relation of model complexity.This allows this algorithm can process different complexity situations, improves the robustness of algorithm.Meanwhile, algorithm make use of the ability of fast finding that Hash table can provide and deletion, does not significantly increase the utilization rate of CPU, greatly improve the efficiency of Shading Rendering when fast finding rejects non-silhouette edge.
Additionally provide a kind of apparatus for establishing of umbra volume in the present embodiment, for realizing above-described embodiment and preferred implementation, having carried out repeating no more of explanation, and below the module related in this device being described.As used below, term " module " can realize the software of predetermined function and/or the combination of hardware.Although the device described by following examples preferably realizes with software, hardware, or the realization of the combination of software and hardware also may and conceived.Fig. 4 is the structured flowchart of the drawing apparatus of shade according to the embodiment of the present invention.As shown in Figure 4, this device comprises:
Reject module 40, in the depth map of the object of pending shade drafting, reject according to the non-silhouette edge of hash algorithm by object above-mentioned in above-mentioned depth map;
Search module 42, be connected, for finding all silhouette edges of above-mentioned object in above-mentioned depth map according to hash algorithm with rejecting module 40;
Set up module 44, and search module 42 and be connected, for setting up the umbra volume of above-mentioned object according to above-mentioned all silhouette edges.
By the combined action of above-mentioned modules, adopt based on hash algorithm fast finding silhouette edge, and based on the technical scheme of silhouette edge determination umbra volume, solve in correlation technique the burden problem that the technical scheme building umbra volume significantly increases GPU, achieve when not increasing CPU burden, accurately detected silhouette edge, greatly improve efficiency.
Alternatively, as shown in Figure 5, said apparatus also comprises: creation module 46, for creating the vertical array of all limits data in the object front for preserving above-mentioned object corresponding light source.
Wherein, search module 42, comprising: Traversal Unit 420, for traveling through all limits data in above-mentioned vertical array; Computing unit 422, is connected with Traversal Unit 420, for for the every data in the data of above-mentioned all limits, calculates the key assignments of above-mentioned limit data; Search unit 424, be connected with computing unit 422, for searching position corresponding to above-mentioned limit data according to above-mentioned key assignments in the Hash table set up in advance; Determining unit 426, and searches unit 424 and is connected, and for when above-mentioned position is unoccupied, determines that limit corresponding to above-mentioned limit data is silhouette edge.
In embodiments of the present invention, reject module 40, comprising: judging unit 400, for when above-mentioned position is occupied, judge that whether the index value on two summits of above-mentioned limit data is equal;
Culling unit 402, is connected with judging unit 400, for when the index value on top, above-mentioned two tops is equal, rejects the limit that above-mentioned limit data are corresponding.In specific implementation process, the concrete grammar drawing a shade is:
Step 1, obtains the depth map of all objects after the model under first pass rendering contexts light, this depth map is using the true viewpoint of user as reference.Open the write operation switch of depth buffer, play up whole scene, according to model, obtain all vertex information of model, these vertex information can be kept in a vertical array.And corresponding, also have an array of indexes to preserve the index information on summit.So-called array of indexes, what be exactly that content in array of indexes preserves is index number in vertical array.Also can obtain the current location of light source simultaneously.
Step 2, after all acquisition of informations are good, creates umbra volume.Each tri patch on traversal model.First whether it is detected in the front relative to light.If in the front of light, then this tri patch is joined in the vertical array to be rendered of umbra volume.Continuous print three vertex representations tri patch in vertical array.In each leg-of-mutton process of traversal, create another vertical array, be used for being kept at all limits data in light source front.Continuous print two vertex representations limit.Then utilize Hash to reject algorithm, reject non-silhouette edge, preserve silhouette edge as the limit set creating umbra volume.Travel through the limit that each is in front, add Hash table, first calculation key, then in Hash table, check relevant position.If this position does not have occupied, so store the index value of end points, and to change placeholder be true.If occupied, check that whether the index value of two end points on two limits is completely equal.If completely equal, prove to have found redundancy limit, change placeholder is false.If the index value of end points is not exclusively completely equal, then there occurs conflict.The key assignments on new limit is added 2N-1, and wherein N represents the number of times of collision loop.Such as first time runs into conflict, and key assignments adds 1, reexamines relevant position, if still conflicted, then adds 3, and so circulation is until find unappropriated position.When all limits all join after in Hash table, all placeholders are that genuine position stores silhouette edge.We travel through whole Hash table once, generate final silhouette edge array, for playing up umbra volume.
Step 3, after generating the array of silhouette edge, travels through this array.Each limit is made up of two summits.And each summit projects " infinity " place generates two other summit.These four summits constitute a quadrilateral.Each limit projects away, all can generate a quadrilateral.These quadrilaterals are exactly the side of umbra volume.Whole umbra volume is just defined together with front and rear covers.Each quadrilateral partition is two triangles, joins in the vertical array to be rendered of umbra volume.So, save all vertex information about umbra volume in the array to be rendered of umbra volume.Find the silhouette edge of object facing light sources, namely by limit that object separates relative to light source front and rear.Fig. 6 explains the principle of umbra volume.The object of drafting umbra volume is the test as drawing shade, and therefore this umbra volume can not finally appear on screen, otherwise just there will be unnecessary umbra volume region.
Step 4, arranges the type of depth test for being less than or equal to reference value.And turn off depth buffered write operation.The type of template test is set to always pass through.The result of depth test is only depended on when test.The buffer value of template test is set as 0.
Step 5, plays up umbra volume at twice.Template test is utilized in render process.Template test effectively can utilize the hardware acceleration capability of GPU, detects shadow region fast.In this patent, what the algorithm of template test adopted is Z-Pass algorithm, for specifically testing which region in the middle of shade.Explain the ultimate principle of Z-Pass algorithm in the figure 7.Draw a ray from the vision point of user to object, be called sight line.When sight line enters umbra volume time, when namely traversing to inside face from the exterior face of umbra volume, stencil buffers value adds one, and when sight line passes umbra volume time, when namely traversing to exterior face from the inside face of umbra volume, stencil buffers value subtracts one.According to Z-Pass algorithm, when the stencil buffers value in certain region is zero, represent that the number of times entering and leave umbra volume is equal, so this region is not just in the middle of shade.And when stencil buffers value is non-vanishing, just represent that this region is in the middle of shade.First time plays up and rejects the back side, if depth test passes through, then respective regions stencil buffers value adds one, otherwise remains unchanged.
The back side is rejected with determined by fate setting of glCullFace (GL_BACK) in openGL, then order glStencilOp (GL_KEEP is used, GL_KEEP, incr) if arrange depth test by; respective regions stencil buffers value add one, otherwise remains unchanged.Then call rendering command to play up.Second time is played up and is rejected front, if depth test passes through, then respective regions stencil buffers value subtracts one, otherwise constant.Face, front is rejected with determined by fate setting of glCullFace (GL_FRONT) in openGL, then order glStencilOp (GL_KEEP is used, GL_KEEP, decr) if arrange depth test by; respective regions stencil buffers value subtract one, otherwise remains unchanged.Then call rendering command to play up.In this step, also can play up for the first time and reject front, second time is played up and is rejected the back side.Corresponding operating answers exchange sequence, can obtain same effect, belongs to identically to play up flow process.
The reason done like this is, before drafting umbra volume, has depicted other model.Therefore the actual in store real depth value needing the object of display inside depth buffer.So when first time plays up umbra volume front, be less than or equal to due to the type of depth test is set to, that is, the depth value of umbra volume is less than the depth value of actual object (illustrating that the front of umbra volume has covered object), and at this moment the stencil buffers value of respective regions adds one.Same situation, if when the back side of umbra volume, depth test have passed, and stencil buffers value subtracts one.It should be noted that when playing up umbra volume, the write operation in color buffer district be shut.Because do not need real umbra volume to be plotted on screen, just obtain depth information, to draw shade by drawing umbra volume.
Step 6, obtains a stencil buffers figure about all regions in previous step.Then directly draw the echo that covers whole screen, paint color in the place that stencil buffers value is non-vanishing, complete the drafting of shade.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, also can be that the independent physics of unit exists, also can two or more unit in a unit integrated.Above-mentioned integrated unit both can adopt the form of hardware to realize, and the form of SFU software functional unit also can be adopted to realize.
It should be noted that, term " first ", " second " etc. in instructions of the present invention and claims and above-mentioned accompanying drawing are for distinguishing similar object, and need not be used for describing specific order or precedence.Should be appreciated that the object used like this can exchange in the appropriate case, so as embodiments of the invention described herein can with except here diagram or describe those except order implement.In addition, term " comprises " and " having " and their any distortion, intention is to cover not exclusive comprising, such as, contain those steps or unit that the process of series of steps or unit, method, system, product or equipment is not necessarily limited to clearly list, but can comprise clearly do not list or for intrinsic other step of these processes, method, product or equipment or unit.
To sum up above-mentioned, the embodiment of the present invention achieves following beneficial effect: solve in correlation technique the burden problem that the technical scheme building umbra volume significantly increases GPU, achieving when not increasing CPU burden, accurately detected silhouette edge, greatly improve efficiency.
Obviously, those skilled in the art should be understood that, above-mentioned of the present invention each module or each step can realize with general calculation element, they can concentrate on single calculation element, or be distributed on network that multiple calculation element forms, alternatively, they can realize with the executable program code of calculation element, thus, they can be stored and be performed by calculation element in the storage device, and in some cases, step shown or described by can performing with the order be different from herein, or they are made into each integrated circuit modules respectively, or the multiple module in them or step are made into single integrated circuit module to realize.Like this, the present invention is not restricted to any specific hardware and software combination.
These are only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (10)

1. a method for building up for umbra volume, is characterized in that, comprising:
In the depth map of the object of pending shade drafting, reject according to the non-silhouette edge of hash algorithm by object described in described depth map, and find all silhouette edges of object described in described depth map;
The umbra volume of described object is set up according to described all silhouette edges.
2. method according to claim 1, is characterized in that, rejects, and before finding all silhouette edges of object described in described depth map, also comprise according to the non-silhouette edge of hash algorithm by object in described depth map:
Create and be used for the vertical array of all limits data in the object front of preserving described object corresponding light source.
3. method according to claim 2, is characterized in that, finds all silhouette edges of object described in described depth map, comprising according to hash algorithm:
Travel through all limits data in described vertical array;
For the every one side data in the data of described all limits, calculate the key assignments of described limit data, and in the Hash table set up in advance, search position corresponding to described limit data according to described key assignments;
When described position does not find repetition limit, determine that limit corresponding to described limit data is silhouette edge, wherein, the first Hash tabular value corresponding to described repetition limit is identical with the second Hash tabular value, described Hash tabular value is determined according to described key assignments, wherein, the Hash tabular value on described second Hash tabular value limit indicated by the data of described limit.
4. method according to claim 3, is characterized in that, rejects, comprising according to the non-silhouette edge of hash algorithm by object in described depth map:
When finding to repeat limit in described position, judge that whether the index value on two summits of described limit data is equal;
If so, then the limit that described limit data are corresponding is rejected.
5. method according to claim 4, is characterized in that, finds all silhouette edges of object described in described depth map, comprising according to hash algorithm:
When the index value on two summits of described limit data is unequal, the key assignments of described limit data is added 2N-1, wherein, described N is the number of times of collision loop, and adds the value after 2N-1 according to described key assignments search position corresponding to limit data in the described Hash table set up in advance.
6. the method according to any one of claim 3 to 5, is characterized in that, the key assignments KEY of limit data according to following formulae discovery:
wherein, V aand V bfor the index value that described two summits are corresponding respectively, MAX is the size of described Hash table.
7. an apparatus for establishing for umbra volume, is characterized in that, comprising:
Reject module, in the depth map of the object of pending shade drafting, reject according to the non-silhouette edge of hash algorithm by object described in described depth map;
Search module, for finding all silhouette edges of object described in described depth map according to hash algorithm;
Set up module, for setting up the umbra volume of described object according to described all silhouette edges.
8. device according to claim 7, is characterized in that, described device, also comprises:
Creation module, for creating the vertical array of all limits data in the object front for preserving described object corresponding light source.
9. device according to claim 8, is characterized in that, described in search module, comprising:
Traversal Unit, for traveling through all limits data in described vertical array;
Computing unit, for for the every data in the data of described all limits, calculates the key assignments of described limit data;
Search unit, for searching position corresponding to described limit data according to described key assignments in the Hash table set up in advance;
Determining unit, for when described position does not find repetition limit, determine that limit corresponding to described limit data is silhouette edge, the first Hash tabular value corresponding to described repetition limit is identical with the second Hash tabular value, described Hash tabular value is determined according to described key assignments, wherein, the Hash tabular value on described second Hash tabular value limit indicated by the data of described limit.
10. device according to claim 9, is characterized in that, described rejecting module, comprising:
Judging unit, during for finding to repeat limit in described position, judges that whether the index value on two summits of described limit data is equal;
Culling unit, for when the index value on described two summits is equal, rejects the limit that described limit data are corresponding.
CN201410495842.9A 2014-09-24 2014-09-24 The method for building up and device of umbra volume Active CN105513122B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201410495842.9A CN105513122B (en) 2014-09-24 2014-09-24 The method for building up and device of umbra volume
PCT/CN2015/072334 WO2016045298A1 (en) 2014-09-24 2015-02-05 Establishment method and device for shadow volume

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410495842.9A CN105513122B (en) 2014-09-24 2014-09-24 The method for building up and device of umbra volume

Publications (2)

Publication Number Publication Date
CN105513122A true CN105513122A (en) 2016-04-20
CN105513122B CN105513122B (en) 2019-01-25

Family

ID=55580209

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410495842.9A Active CN105513122B (en) 2014-09-24 2014-09-24 The method for building up and device of umbra volume

Country Status (2)

Country Link
CN (1) CN105513122B (en)
WO (1) WO2016045298A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107481314A (en) * 2017-06-30 2017-12-15 浙江科澜信息技术有限公司 A kind of umbra volume optimization method based on KD trees

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101127127A (en) * 2007-09-29 2008-02-20 腾讯科技(深圳)有限公司 Shade drafting method and rendering device
CN101145246A (en) * 2006-09-14 2008-03-19 腾讯科技(深圳)有限公司 Method and system for producing volume shade
US20080278489A1 (en) * 2005-11-02 2008-11-13 Koninklijke Philips Electronics, N.V. Image Processing System and Method for Silhouette Rendering and Display of Images During Interventional Procedures
CN101601048A (en) * 2006-10-25 2009-12-09 诺伯特·林克 Be used to monitor the method and apparatus and the scaling method of spatial volume
CN101799937A (en) * 2010-03-23 2010-08-11 南京大学 Method for creating three-dimensional model by using sketch

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6690372B2 (en) * 2000-05-31 2004-02-10 Nvidia Corporation System, method and article of manufacture for shadow mapping
JP4181430B2 (en) * 2003-03-10 2008-11-12 シャープ株式会社 Graphic processing apparatus, graphic processing method, graphic processing program, and program recording medium
CN102135417B (en) * 2010-12-26 2013-05-22 北京航空航天大学 Full-automatic three-dimension characteristic extracting method
CN102968814B (en) * 2012-11-22 2015-11-25 华为技术有限公司 A kind of method and apparatus of image rendering

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080278489A1 (en) * 2005-11-02 2008-11-13 Koninklijke Philips Electronics, N.V. Image Processing System and Method for Silhouette Rendering and Display of Images During Interventional Procedures
CN101145246A (en) * 2006-09-14 2008-03-19 腾讯科技(深圳)有限公司 Method and system for producing volume shade
CN101601048A (en) * 2006-10-25 2009-12-09 诺伯特·林克 Be used to monitor the method and apparatus and the scaling method of spatial volume
CN101127127A (en) * 2007-09-29 2008-02-20 腾讯科技(深圳)有限公司 Shade drafting method and rendering device
CN101799937A (en) * 2010-03-23 2010-08-11 南京大学 Method for creating three-dimensional model by using sketch

Non-Patent Citations (7)

* Cited by examiner, † Cited by third party
Title
《中国优秀博士学位论文全文数据库 信息科技辑》 *
《中国优秀硕士学位论文全文数据库 信息科技辑》 *
LEE MARKOSIAN 等: "Real-Time Nonphotorealistic Rendering", 《COMPUTER GRAPHICS AND INTERACTIVE TECHNIQUES》 *
任政: "基于GPU的非真实感图形学水墨渲染", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
周思远: "3D图形引擎的研究与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
张桂梅,章毅: "基于路径轮廓的三维目标识别", 《计算机应用研究》 *
梅世冬: "实时阴影绘制方法研究及GPU加速", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107481314A (en) * 2017-06-30 2017-12-15 浙江科澜信息技术有限公司 A kind of umbra volume optimization method based on KD trees

Also Published As

Publication number Publication date
WO2016045298A1 (en) 2016-03-31
CN105513122B (en) 2019-01-25

Similar Documents

Publication Publication Date Title
JP4621617B2 (en) Graphic drawing apparatus, graphic drawing method, and program
KR102193684B1 (en) Apparatus and method for processing ray tracing
CN111127623B (en) Model rendering method and device, storage medium and terminal
US20100164955A1 (en) Image forming techniques
US20090046098A1 (en) Primitive binning method for tile-based rendering
CN108090947A (en) A kind of ray tracing optimization method towards 3D scenes
US9959685B2 (en) Method and system for selectively blending buildings to improve route visibility in a 3D navigation system
TW201033937A (en) Discarding of vertex points during two-dimensional graphics rendering using three-dimensional graphics hardware
CN104899563A (en) Two-dimensional face key feature point positioning method and system
US9672642B2 (en) Apparatus and method of performing tile binning of bezier curve
WO2023066121A1 (en) Rendering of three-dimensional model
US11113878B2 (en) Screen tile pair-based binocular rendering pipeline process and method
CN104850847A (en) Image optimization system and method with automatic face thinning function
CN103700134A (en) Three-dimensional vector model real-time shadow deferred shading method based on controllable texture baking
CN101930367A (en) Implementation method of switching images and mobile terminal
CN104318605A (en) Parallel lamination rendering method of vector solid line and three-dimensional terrain
CN111127603B (en) Animation generation method and device, electronic equipment and computer readable storage medium
US8525843B2 (en) Graphic system comprising a fragment graphic module and relative rendering method
CN110930492B (en) Model rendering method, device, computer readable medium and electronic equipment
CN110910308B (en) Image processing method, device, equipment and medium
KR102166426B1 (en) Rendering system and rendering method thereof
CN106204703A (en) Three-dimensional scene models rendering intent and device
US20140347355A1 (en) Ray tracing core and method for processing ray tracing
CN102831632B (en) Mirror image texture generating method and device
CN105513122A (en) Shadow volume establishing method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant