From: Maurice L. <mj...@ga...> - 2001-12-15 21:29:10
|
Alan W. Irwin writes: > On Sat, 15 Dec 2001, Maurice LeBrun wrote: > > > When I looked into this last spring (fixing several bugs in the process), I > > concluded we might be better off with a new algorithm. The original algorithm > > only follows lines, not regions. If one endpoint of the line is hidden but > > the other is not, it merely calculates the intersection point and draws from > > that point. Extending this to 2D and getting it right does not look easy to > > me. The existing shade extension is clever but I found the boundary > > conditions too messy to be able to make solid headway without considerable > > effort. > > Maurice, I am having trouble interpreting your words here since the previous > posts in this thread discussed both 2D and 3D shading which have separate > algorithms. I believe (although I am not sure) that part of your paragraph > may refer to a better algorithm for the 2D shading (which might be a good > idea, but there is currently no bug in that case), and part of the paragraph > to 3D shading (which does have a bug). Could you please clarify? I am > particularly interested in whether you think a new 3D shading algorithm is > required to fix the 3D shading bug. If so, I will drop it from the release > wish list. I'm talking about the 3d shading algorithm, which is bolted on top of the 3d perspective (surface) plot. Not the 2d shade-exclusion problem that was fixed previously. These are way different problems. The 3d perspective algorithm follows lines of a constant coordinate. It decides to draw or not-draw based on the condition: is it visible. If it crosses from visible to not-visible or vice versa in one segment, the intersection point is calculated and the segment drawn from there. Once that coordinate line is finished, the next one is started. So you see, the original algorithm has no concept of "regions" at all. The new shading code that is bolted on top of this only worked if the triangle to be shaded is entirely visible. If any of the three vertices is not visible, the triangle is not plotted at all, which gives rise to the visual effects you see in the demo. I was able to work out boundary conditions for some cases and thereby eliminate some of the unshaded areas, but not all. It turns out to be surprisingly complex -- after a few initial successes I had lots of spectacular failures with spiky triangles drawn all over the screen, and had to give up. At that point I concluded it might be simpler to start from scratch with a published 3d shading algorithm. -- Maurice LeBrun mj...@ga... |