Loading ...
Sorry, an error occurred while loading the content.

Transparency in Antiprism

Expand Messages
  • Adrian Rossiter
    Hi All I have pretty much finished adding transparency to Antiprism. I have taken the opportunity to change the way I hold the colours in memory. I previously
    Message 1 of 8 , Mar 2, 2007
    View Source
    • 0 Attachment
      Hi All

      I have pretty much finished adding transparency to
      Antiprism.

      I have taken the opportunity to change the way I hold
      the colours in memory. I previously held them in an
      inefficient but convenient format which took 24 bytes
      per colour. If I extended this for the alpha value
      that would be 32 bytes. I now store them as one byte
      per value, with an integer for index values, which
      comes to a much more reasonable 8 bytes per colour.

      Because this change affects the core of Antiprism,
      I have decided that it was best to do it straight
      away, just after the release. Then I will have most
      time to uncover bugs before the next release. I will
      make a snapshot release available in case anyone else
      would like to run the code.

      The core changes were quite involved. The changes
      to the rest of the code to use the new colour
      format were fairly minor, and mostly simplified
      the code.

      Adding transparency to antiview was effectively
      done in three lines (and including a file of stipple
      patterns that I found). The "screen door" transparency
      looks better than I thought it would. If I try the
      "depth peeling" approach it would probably be just
      for interest.

      Adding transparency to off2pov was equally
      straightforward. My default element-transparency POV
      variables no longer have a purpose, but I might change
      them to transparency (opacity!) factors used to multiply
      all the alpha values, then they can still be used to make
      solid faces transparent just like they do now.

      I will have a look at adding some transparency options
      to off_color today, and then make a snapshot.

      Adrian.
      --
      Adrian Rossiter
      adrian@...
      Home: http://antiprism.com/adrian
    • Adrian Rossiter
      ... Here is the snapshot, which includes Windows binaries (3.3Mb) http://www.freewebtown.com/adrian/tmp/anti_32.zip It is work in progress! Here is an example
      Message 2 of 8 , Mar 2, 2007
      View Source
      • 0 Attachment
        On Fri, 2 Mar 2007, Adrian Rossiter wrote:
        > I will have a look at adding some transparency options
        > to off_color today, and then make a snapshot.

        Here is the snapshot, which includes Windows binaries (3.3Mb)

        http://www.freewebtown.com/adrian/tmp/anti_32.zip

        It is work in progress!

        Here is an example command

        geodesic 2 | off_color -f CHA -A 0.3,1 | antiview

        In antiview, pressing 't' will toggle between transparency
        and solid (bug: also 'v', but that has been fixed!)

        Now I have played around with the transparency in antiview
        a bit more I can see that there could be some value in
        improving on it. But it is not terrible, and certainly
        worth the ten minutes it took to add it!

        Here are some images

        geodesic 2 | off_color -v CHA -A 0.3,1 | antiview -x ef -v b
        http://www.freewebtown.com/adrian/tmp/trans_test01.jpg

        geodesic 2 | off_color -v CHA -A 0.3,1 | off2pov -x ef -v b
        http://www.freewebtown.com/adrian/tmp/trans_test01.jpg

        It would be nice to match the transparency between the two
        programs.

        I didn't say before but antiview has 17 levels for the alpha
        value. It might be better to have less, and just use the least
        speckled stipple patterns.

        Adrian
        --
        Adrian Rossiter
        adrian@...
        Home: http://antiprism.com/adrian
      • Adrian Rossiter
        ... Even if it does appear to match quite well in the images above! The second image (POV-Ray) should be http://www.freewebtown.com/adrian/tmp/trans_test02.jpg
        Message 3 of 8 , Mar 2, 2007
        View Source
        • 0 Attachment
          On Fri, 2 Mar 2007, Adrian Rossiter wrote:
          > geodesic 2 | off_color -v CHA -A 0.3,1 | antiview -x ef -v b
          > http://www.freewebtown.com/adrian/tmp/trans_test01.jpg
          >
          > geodesic 2 | off_color -v CHA -A 0.3,1 | off2pov -x ef -v b
          > http://www.freewebtown.com/adrian/tmp/trans_test01.jpg
          >
          > It would be nice to match the transparency between the two
          > programs.

          Even if it does appear to match quite well in the images above!

          The second image (POV-Ray) should be

          http://www.freewebtown.com/adrian/tmp/trans_test02.jpg

          Adrian.
          --
          Adrian Rossiter
          adrian@...
          Home: http://antiprism.com/adrian
        • Adrian Rossiter
          ... Another problem with the method is that the stipple pattern is placed relative to the window, so if two objects have the same stipple pattern then the back
          Message 4 of 8 , Mar 2, 2007
          View Source
          • 0 Attachment
            On Fri, 2 Mar 2007, Adrian Rossiter wrote:
            > Now I have played around with the transparency in antiview
            > a bit more I can see that there could be some value in
            > improving on it. But it is not terrible, and certainly
            > worth the ten minutes it took to add it!
            ...
            > I didn't say before but antiview has 17 levels for the alpha
            > value. It might be better to have less, and just use the least
            > speckled stipple patterns.
            ...
            > http://www.freewebtown.com/adrian/tmp/trans_test01.jpg

            Another problem with the method is that the stipple pattern
            is placed relative to the window, so if two objects have the
            same stipple pattern then the back one can't be seen through
            the front one, because its coloured pixels lie exactly behind
            those of the front one.

            Adrian.
            --
            Adrian Rossiter
            adrian@...
            Home: http://antiprism.com/adrian
          • vortexswirling
            Adrian, Very good! I downloaded the interim release and everything compiled. I see you no longer have col.get_ivals (which I started using) but that line was
            Message 5 of 8 , Mar 2, 2007
            View Source
            • 0 Attachment
              Adrian,

              Very good! I downloaded the interim release and everything compiled. I
              see you no longer have col.get_ivals (which I started using) but that
              line was easy to replace. (just multipling col by 255, I only have to
              do it in one place. f2i is private).

              I read the depth peeling paper and you are right, it is a whole
              different way of doing it. If you ever decide try it there might be
              some source code somewhere to get started. Otherwise I wouldn't let it
              keep you from all the other good stuff!

              Also it was wise to make the change for transparency now before it gets
              too hard to change in the future. I don't think there is anything left
              to add to the OFF file format now.

              Roger
            • Adrian Rossiter
              Hi Roger ... I replaced col.get_ivals with col[], e.g the 0-255 red value is col[0]. ... That was what I was thinking too, and it is nice that Antiprism
              Message 6 of 8 , Mar 3, 2007
              View Source
              • 0 Attachment
                Hi Roger

                On Fri, 2 Mar 2007, vortexswirling wrote:
                > Very good! I downloaded the interim release and everything compiled. I
                > see you no longer have col.get_ivals (which I started using) but that
                > line was easy to replace. (just multipling col by 255, I only have to
                > do it in one place. f2i is private).

                I replaced col.get_ivals with col[], e.g the 0-255 red value
                is col[0].


                > Also it was wise to make the change for transparency now before it gets
                > too hard to change in the future. I don't think there is anything left
                > to add to the OFF file format now.

                That was what I was thinking too, and it is nice that
                Antiprism completely supports the OFF format now. Your
                feedback has been a great help with this.

                Adrian.
                --
                Adrian Rossiter
                adrian@...
                Home: http://antiprism.com/adrian
              • vortexswirling
                ... That is why when I multiplied by 255 it wasn t working! Also I noticed that printf( %d ,col[0]) always prints 0. But printf( %d ,(int)col[0]) prints the
                Message 7 of 8 , Mar 3, 2007
                View Source
                • 0 Attachment
                  > I replaced col.get_ivals with col[], e.g the 0-255 red value
                  > is col[0].

                  That is why when I multiplied by 255 it wasn't working! Also I noticed
                  that printf("%d",col[0]) always prints 0. But printf("%d",(int)col[0])
                  prints the correct value.

                  > Your
                  > feedback has been a great help with this.

                  Glad to help!

                  Roger
                • Adrian Rossiter
                  Hi Roger ... Good find. I have fixed it, and this exposed an error introduced into off2m with the changes. The colour text function should be string
                  Message 8 of 8 , Mar 3, 2007
                  View Source
                  • 0 Attachment
                    Hi Roger

                    On Sat, 3 Mar 2007, vortexswirling wrote:
                    >> I replaced col.get_ivals with col[], e.g the 0-255 red value
                    >> is col[0].
                    >
                    > That is why when I multiplied by 255 it wasn't working! Also I noticed
                    > that printf("%d",col[0]) always prints 0. But printf("%d",(int)col[0])
                    > prints the correct value.

                    Good find. I have fixed it, and this exposed an error introduced
                    into off2m with the changes. The colour text function should be

                    string RGBtxt(col_val col)
                    {
                    char buf[128];
                    vec3d cv = col.get_vec3d();
                    snprintf(buf, 128, "RGBColor[%g, %g, %g]", cv[0], cv[1], cv[2]);
                    return buf;
                    }


                    Adrian.
                    --
                    Adrian Rossiter
                    adrian@...
                    Home: http://antiprism.com/adrian
                  Your message has been successfully submitted and would be delivered to recipients shortly.