How to “trap” my surface patches to prevent the background from bleeding through the cracks?

后端 未结 1 807
半阙折子戏
半阙折子戏 2021-01-29 04:33

In response to a challenge in comp.lang.postscript, I\'m working-up my 3D chops trying to render a cylinder as projected rectangular patches. But I\'m still seeing the wire-fram

相关标签:
1条回答
  • 2021-01-29 05:00

    Alright, I've come up with something that sits a little easier in the gut.

    6% fudging just feels to horrible to bear.

    But Ken suggested that rounding could be involved. That means taking control of the rounding should gain one some measure of control over the problem. And it looks like it's true.

    So I tried prepending all moveto and lineto calls with a call to prep:

    /prep {
        transform
        %2 {
        %    exch
            %floor
            round
            %ceiling
            %2 mul cvi 2 div %round
        %} repeat
        itransform
    } def
    

    The comments show the various pieces I tried. Rounding on both device coordinates eliminated all horizontal bleed-lines and leaves very thin vertical bleeds. This seems to make sense assuming Ghostscript rasterizes by horizontal scanlines: it has an easier time with the horizontal ones with just a little help, but near-verticals are tougher.

    But then I combined this with fudging. And I found that rounding just the device-y 'ordinate and fudging the patch dimensions by 2% eliminates all bleeds. It really lit up this batcave.

    2% is an acceptable level of fudging, I think. (?)


    Unfortunately, all the above requires tweaking when you adjust the value of N (the number of slices). The simplest fix to cover the whole surface is to stroke the edges in the same color as the fill. The only difficult point here is making sure the linewidth is appropriate for the scale. And the easy way to do that is to set them both together. For very high resolutions, this should probably be adjusted in some way to account for N.

    1 70 dup dup scale div setlinewidth
    

    Here's one of the images generated by the final program, a Steinmetz solid with coordinate axes and random colors, in a slightly skewed perspective (its right foot sticks out a little).

    Steinmetz solid in skewed perspective

    0 讨论(0)
提交回复
热议问题