Antialiasing to Transparency in DAZ Studio?

Boingo the ClownBoingo the Clown Posts: 97
edited December 1969 in Technical Help (nuts n bolts)

I have been using DAZ Studio to render out some sprites for a game project I have been working on.

Until now I thought DS antialiased the figure(s) in a render with no background to transparency because renders saved to PNGs had transparent backgrounds. At the coarse resolution of the game I have discovered this is not true. The figures are in fact antialiased to the background colour used by the editor. As a result, all of my sprites have thin but noticeable outlines in that colour around their edges.

Is there a setting that will allow DS to antialias my sprites to transparency, thereby eliminating these outlines and making them look better in my game?

Comments

  • SzarkSzark Posts: 10,634
    edited December 1969

    NO is the simple answer.

    You will need either a MASK maker We did have Surface Mask Creator for DS3 and up to a point is still works in DS4.6 http://www.daz3d.com/forums/discussion/8743/. Adam is working on a new one but no tme frame to when that will be available. Or if using Photoshop use Defringe to get rid of the outline or make the background a similar colour to what you are overlaying the Sprites on to.

  • millighostmillighost Posts: 261
    edited December 1969

    I have been using DAZ Studio to render out some sprites for a game project I have been working on.

    Until now I thought DS antialiased the figure(s) in a render with no background to transparency because renders saved to PNGs had transparent backgrounds. At the coarse resolution of the game I have discovered this is not true. The figures are in fact antialiased to the background colour used by the editor. As a result, all of my sprites have thin but noticeable outlines in that colour around their edges.

    Is there a setting that will allow DS to antialias my sprites to transparency, thereby eliminating these outlines and making them look better in my game?

    Yes, simply set the background to black.
    Note, that when saving images in PNG format, you will get a premultiplied alpha channel. If you do not want that, you can save as TIFF, DS will reverse the premultiplication then, but it only works for a Gamma of 1 (because of a bug); probably you would use Gamma=1 anyway in your application (if you do not understand this last sentence, just save as TIFF).

  • SzarkSzark Posts: 10,634
    edited December 1969

    You will still get a Black edge when setting the background to black and saving as PNG or TIFF unless things have changed recently and I haven't noticed it which is possible with not using DS4.6 much.. ;)

  • millighostmillighost Posts: 261
    edited December 1969

    Szark said:
    You will still get a Black edge when setting the background to black and saving as PNG or TIFF unless things have changed recently and I haven't noticed it which is possible with not using DS4.6 much.. ;)

    No, i will not. Alhough i can understand what probably makes you think i would. When saving as PNG, i will get a premultiplied alpha channel. In order to use it i will either need to unpremultiply it (or predivide or whatever it is called), or use an appropriate blending mode to put it onto a background. What will NOT work, is to simply load it into GIMP (or photoshop, same thing) as a layer, leave the default layer mode at "Normal" and hope for the best. That will indeed leave a dark border around the object. But this is probably what 90% of the Photoshop users do, understandably, because Photoshop is a very complicated program and nobody wants to spend hours reading to find out how it works; and that is probably the main reason it can be seen in so many renders on the internet. In this case saving as TIFF could help; TIFF and PNG are different in this regard (at least in DS4.6), not by definition, just for a matter of fact. Works only within limits, though, because of some issues with the exposure settings and some small errors because of the limited bit-depth. But there is no real reason why Boingo the Clown should run into the same same problems, after all he is making a game, not using Photoshop, when in fact the dark borders stem from Photoshop, not from the renderer. Of course, there should be something in the documentation of the game engine if it accepts straight alpha (-> TIFF) or premultiplied alpha (->PNG) images as input.
  • SzarkSzark Posts: 10,634
    edited December 1969

    Granted if you use say the Screen blend mode in Photoshop and use black as the background colour for the render you will lose the edge. This ok if you are not intending to use it as an overlay on top of another image but yes if it just a sprite then it will work.

    But I was just taking about how the render comes out, as standard, out of Daz Studio and not using any other program.

    I would be very interested in seeing/reading the info on that it is not the rneder that has the edge but when taken in to Photoshop. This is news to me and I would like to see if for myself. Can you provide me the link please.

  • Boingo the ClownBoingo the Clown Posts: 97
    edited July 2013


    Yes, simply set the background to black.

    I have a dumb question.

    How do I set the background to black?

    When I go to Edit > Backdrop it does not give me the option to change the colour. It asks for a bitmap instead.

    Am I missing something?

    Post edited by Boingo the Clown on
  • SzarkSzark Posts: 10,634
    edited December 1969

    hope that helps

    background_colour.jpg
    1232 x 704 - 314K
  • JaderailJaderail Posts: 0
    edited December 1969

    The Black Background is the best way, as the Alpha channel will then see the Anti A as mostly Alpha also. Not Perfect but workable.

  • PendraiaPendraia Posts: 3,598
    edited December 1969

    Szark said:
    You will still get a Black edge when setting the background to black and saving as PNG or TIFF unless things have changed recently and I haven't noticed it which is possible with not using DS4.6 much.. ;)

    No, i will not. Alhough i can understand what probably makes you think i would. When saving as PNG, i will get a premultiplied alpha channel. In order to use it i will either need to unpremultiply it (or predivide or whatever it is called), or use an appropriate blending mode to put it onto a background. What will NOT work, is to simply load it into GIMP (or photoshop, same thing) as a layer, leave the default layer mode at "Normal" and hope for the best. That will indeed leave a dark border around the object. But this is probably what 90% of the Photoshop users do, understandably, because Photoshop is a very complicated program and nobody wants to spend hours reading to find out how it works; and that is probably the main reason it can be seen in so many renders on the internet. In this case saving as TIFF could help; TIFF and PNG are different in this regard (at least in DS4.6), not by definition, just for a matter of fact. Works only within limits, though, because of some issues with the exposure settings and some small errors because of the limited bit-depth. But there is no real reason why Boingo the Clown should run into the same same problems, after all he is making a game, not using Photoshop, when in fact the dark borders stem from Photoshop, not from the renderer. Of course, there should be something in the documentation of the game engine if it accepts straight alpha (-> TIFF) or premultiplied alpha (->PNG) images as input.
    Thanks for the info...

    I vaguely remember but I think it was psp not photoshop that there used to be an option to defringe?? Sorry early in the morning here and I can't remember exactly the option but think it was defringe and you had the choice of black or white.

  • SzarkSzark Posts: 10,634
    edited December 1969

    In CS2 the Defringe is here

    defringe.jpg
    653 x 938 - 304K
  • PendraiaPendraia Posts: 3,598
    edited December 1969

    Szark said:
    In CS2 the Defringe is here
    Yeah...now that I'm more awake I remember there was an option in both programs. I used to use it to remove the black left from a background years ago. I haven't touched it in a long time.
  • Boingo the ClownBoingo the Clown Posts: 97
    edited December 1969

    Thanks Szark. :-)

    I was really getting tired of that powder blue background DS 4 starts off with. I was able to change the background colour in DS 1, 2, and 3, but couldn't figure it out in DS 4.

    I will trymmillighosts suggestion and see if it works.

  • SzarkSzark Posts: 10,634
    edited December 1969

    That always gets me confused...certain aspect of DS4/4.5+ haven't changed since DS2. Anyways you found it now and that's what matters.

    Good luck

  • Boingo the ClownBoingo the Clown Posts: 97
    edited December 1969

    millighost's technique seems to be working. There still appears to be a slight outline, but it is certainly not as severe.

    Of course this means I am going to have to go back and redo a whole bunch of sprites I did earlier, but at least it is going to be for a good reason.

  • millighostmillighost Posts: 261
    edited December 1969

    Szark said:
    Granted if you use say the Screen blend mode in Photoshop and use black as the background colour for the render you will lose the edge. This ok if you are not intending to use it as an overlay on top of another image but yes if it just a sprite then it will work.

    But I was just taking about how the render comes out, as standard, out of Daz Studio and not using any other program.

    I would be very interested in seeing/reading the info on that it is not the rneder that has the edge but when taken in to Photoshop. This is news to me and I would like to see if for myself. Can you provide me the link please.

    Here is an illustration showing the difference between the TIFF and PNG output of DS. I rendered a cube on a plane against a black background and saved the render to TIFF as well as to PNG. Separating the alpha and color channels in GIMP it can be seen that the alpha channels of the two formats are the same, but the color channels are not. PNG has those antialiased-looking smooth edges, whereas TIFF contains basically only the color in the border pixels (i.e. not the background). So there is no real "standard how the render comes out of DAZ Studio"; there are actually two standards. Of course the two different color channels give different results when put on a background in GIMP with a layer mode "Normal". The PNG results in the border pixels being too dark. But the TIFF output works.
    The reason for this is that the "Normal" layer mode calculates foreground_color * alpha + background_color * (1 - alpha), but it can only calculate this if there is a foreground_color. In the PNG image the pixels contain a mixture between foreground and background, so this does not work. In fact, the color channel in the PNG image contains alpha * foreground + (1 - alpha) * background, but because the background is black (value zero), it effectively contains only alpha * foreground (hence the term premultiplied).
    So, since the PNG color channels already contain alpha * foreground, but what is needed is alpha*foreground + (1-alpha)*background, all that is needed is to add the (1-alpha)*background part. In GIMP i create an additional layer containing the inverted alpha channel (the (1-alpha)-part), multiply with the background (creating (1-alpha)*background) and add it to the render, which gives the same result as in the TIFF-case, no defringe or something like that needed.
    Of course, this is slightly more complicated than just a single "Normal"-layer because it requires an additional layer. But on the other hand the premultiplied alpha is the de-facto-standard for renderers (that 3delight outputs an unpremultiplied color channel for TIFF images is the exception rather than the norm), and other applications than GIMP (or photoshop) which are more geared towards compositing renders support it out of the box anyway. In OpenGL, for instance, it simply means to use a different parameter for glBlendFunc().

    3dl-alpha.png
    1332 x 1115 - 341K
  • Boingo the ClownBoingo the Clown Posts: 97
    edited December 1969

    I'm convinced.

  • SzarkSzark Posts: 10,634
    edited December 1969

    Yeah thanks for that. Things have definately changed then as I tested this a few years back and Tiff and PNG aplha were the exact same. Whereas as you pointed out the TIFF comes with a seperate mask/alpha layer.

Sign In or Register to comment.