📄 38856
字号:
Newsgroups: comp.graphicsPath: cantaloupe.srv.cs.cmu.edu!magnesium.club.cc.cmu.edu!news.sei.cmu.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!ira.uka.de!math.fu-berlin.de!aa.cad.slb.com!aa.cad.slb.com!gorgenFrom: gorgen@ann-arbor.applicon.slb.com (David Gorgen)Subject: Need help: Z-buffering lines & areas togetherOrganization: Applicon, Inc.; Ann Arbor, MI (USA)Date: Tue, 27 Apr 1993 22:37:51 GMTKeywords: Z-buffer, roundoff, lines, areasMessage-ID: <gorgen.735950271@aa.cad.slb.com>Lines: 84I'm asking for help on a sticky problem involving unreasonably lowapparent precision in Z-buffering, that I've encountered in 2 differentPEX implementations. I can't find any discussion of this problem in anyresources I can lay hands on (e.g. the comp.windows.x.pex FAQ, Gaskins's_PEXlib_Programming_Manual_, vendors' documentation).I'm posting this article by itself on comp.graphics, and virtually thesame article with a test program demonstrating the problem oncomp.windows.x.pex. The problem is hard to describe without pictures,hence this article is longish. If you can run PEXlib 5.x programs andare interested, I encourage you to build and run the test program incomp.windows.x.pex to see the effect yourself and play with my approachto dealing with it. (It depends on the utility code from the aboveGaskins book; instructions for fetching it via anonymous FTP are given.)The problem to be solved is to eliminate or minimize "stitching"artifacts resulting from the use of Z-buffering with polylines that arecoplanar with filled areas. The interpolated Z values along a line willdiffer slightly, due to roundoff error, from the interpolated Z valuesacross an area, even when the endpoints of the line are coincident withvertices of the area. Because of this, it's a tossup whether theZ-buffer will allow the line pixels or the area pixels to be displayed.Visually, the result tends to be a dashed-line effect even though theline is supposed to be solid.Using the PEXlib API, my approach to a solution is to use two slightlydifferent PEX view mapping transforms, in two view table entries, onefor the areas and one for the lines. The PEX structures or immediate-mode output must be organized so that one view table index is always ineffect for areas, and the other is always in effect for lines. Theresult is a slight shift in NPC Z coordinates for the lines, so as toattempt to bias the tossup situations in favor of the lines.This shift is effected by moving the front and back clipping planes usedin the PEXlib view table entry for lines just a hair "backwards" (i.e.smaller VRC Z coordinates), compared to their positions in the viewtable entry used for areas. This means that when a point is transformedto NPC, its Z value will be slightly bigger if it comes from a line thanif it comes from an area, thus accomplishing the desired bias.I would expect the Z roundoff errors which cause the problem to amountto a few units at most, out of the entire dynamic range of the Z-buffer,typically from 0 to 65535 if not 16777215 (i.e. 16 or 24 bit Z-buffers).Therefore, it seems that a tiny fraction of the range of Z in VRCbetween the front and back clip planes ought to suffice to reliably fixthe stitching.But in fact, experience shows that the shift has to be as much as 0.003to 0.006 of the range. (Empirically, it's worst when the NPC Zcomponent of the slope of the surface is high, i.e. when it appears moreor less edge-on to the viewer.) It's as if only 8 or 9 bits of theZ-buffer have any dependable meaning! This amount is so great that oneproblem is replaced by another: sometimes the polylines "show through"areas which they are supposed to lie behind.I've observed the problem on both Hewlett-Packard and Digitalworkstation PEX servers, to approximately the same degree. The testprogram demonstrates the problem on an MIT PEXlib 5.x implementation;this version is known to compile and run on an HP-UX system with PEX5.1.Open questions: (1) Why does this happen? -- Am I configuring the PEX view table wrongly? -- Is there a systematic difference in Z interpolation for lines as opposed to areas (e.g. pixel centers versus corners) which could be corrected for? -- Are PEX implementors wantonly discarding Z precision in their interpolators? -- Something else? (2) What to do about it? -- Can I fix my use of the view table to allow better precision in Z-buffered HLHSR? -- Is there another approach I can take to remove the stitching artifacts? -- Am I just out of luck?Any help would be immensely appreciated!-- ===============================================================================Dave Gorgen Internet: gorgen@ann-arbor.applicon.slb.comApplicon Inc. gorgen@aaaca1.sinet.slb.comAnn Arbor, Michigan (USA) UUCP: ...!uunet!sharkey!applga!gorgen
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -