Trouble with chroma transparency.

Discussion in 'Track Modding' started by blakboks, Jan 16, 2012.

  1. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    29
    Trouble with chroma transparency. (Solved)

    I'm trying to get a chroma transparent texture to work with the new Stamp feature without success. I'm trying to build a 'forest' by scattering a tree over a terrain. So, the whole 'forest' is one object, and each 'tree' should be a stamp. I was able to get the stamping/billboarding to work properly, with the exception of the transparency. I was able to get chroma transparency textures working in rF1. However, it seems that the same settings: Chroma checked, set to the proper color ( (255,0,255) in this case ), and Source/Destination left at One/Zero. I even tried Source/Dest. at SrcAlpha/InvSrcAlpha, but that seemed to make all of the textures additive (becoming a white 'blob' on screen).

    I tried just T1, which made the whole 'forest' disappear. I've also tried 'T1 Stamp Vertex', 'T1 No Shadows Stamp Vertex', and 'T1 Stamp Vertex Alpha Test'; each of which produces the same result (no transparency).

    So, am I missing something someplace? Does the functionality not work? Or might this possibly be another 'bug' with the plugins (using the Max2010 plugins in Max2011)?

    Thanks again in advance for everyone's support!
     
    Last edited by a moderator: Jan 16, 2012
  2. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    29
    Ok, I've now also tried Mianiak's suggestion in the 'REFLECTEDENV' thread of creating a new scene and merging in the objects and exporting again. I was able to get it working, but it does not exactly function as expected.

    First of all, if I set it up like I described above (which is EXACTLY what I did in rF1), then I don't get any transparency whatsoever.
    1.) You need to use the 'T1 Stamp Vertex Alpha Test' shader.
    2.) Source/Dest Blending should be set to: 'Src Alpha'/'Inv Src Alpha'.
    3.) Make sure that "Sorted" is 'checked'.
    In the gTex:
    4.) Leave "Chroma Color" 'unchecked'.

    It all seems very strange to me. I don't know if I just happened to use the right color, or even how it figures out what your choma color is going to be. I can't tell you 'why' it works this way, I just happened to stumble on the right settings, I guess.
     
  3. Luc Van Camp

    Luc Van Camp Track Team Staff Member

    Joined:
    Oct 4, 2010
    Messages:
    1,030
    Likes Received:
    14
    T1 Stamp Vertex, Src/Dest Blend set to One/Zero, enable Chroma RGB(0,0,0) should work. Make sure the texture has an alpha channel, as this does get used by the chroma code AFAIK. Also don't forget to set the vertex alpha to a value other than 100 (we typically use 90).
     
  4. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    29
    Hey Luc, thanks for that.

    Isn't the point of chroma transparency that you don't need an alpha channel? That's how I've understood it, anyway. That way you're storing transparency using only the 24 bits per channel, instead of adding another 8 bits (totaling 32bpc). Cutting down on the texture size by 1/4. I.E. an uncompressed texture using an alpha channel (32-bpc) 1024x1024 is about 4MB, whereas an uncompressed texture using chroma (24-bpc) 1024x1024 is about 3MB. When it comes time to render, it just tests the texture sample color, and if it's whatever you set your color to be--(255,0,255) in this case--then it 'renders' that particular fragment as transparent.

    Like I said--that's the way I've always understood it.

    I'm confused as to how it's actually working in rF2, because, like I said, the settings above (2nd post) actually work even though I don't have an alpha channel on my texture.

    Here is my texture, you can see that it has no alpha channel. View attachment 665
    Here are my settings: View attachment 666 View attachment 667

    It's almost as if the Chroma checkbox is working in the opposite manner that it should (i.e. 'checked' uses alpha, 'unchecked' uses color). But I still can't figure out how it knows what color to actually use.

    Maybe I'm beating a dead horse here, idk... The important thing is that we can get it to work, and get it to work in a consistent manner...
     
  5. Luc Van Camp

    Luc Van Camp Track Team Staff Member

    Joined:
    Oct 4, 2010
    Messages:
    1,030
    Likes Received:
    14
    Chroma transparency is different in rF2. It's received a nice overhaul and I think it's a very good compromise between quality and performance. It doesn't come with the usual drawbacks of alpha transparency, so I recommend using it where you can.

    I've always used an alpha channel in my chroma materials. A big advantage of keying the alpha (using the chroma method rather than the alpha transparency method) is that you can blend the edges in the RGB channels, to prevent unwanted artifacts or dark/coloured edges when it uses the lower mip maps.

    To summarize, my chroma transparency textures are similar in size to alpha transparency, but they are processed faster by the rendering engine.
     
  6. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    756
    Likes Received:
    299
    Would someone post a working GMT and DDS for this, using magenta as the chroma color? I'm having trouble getting mine to work and would like to see a working example.
     
  7. Mario Morais

    Mario Morais Member

    Joined:
    Oct 26, 2010
    Messages:
    1,464
    Likes Received:
    168
  8. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    29
    I've uploaded a .max scene file and .dds to my Google Drive (click to download). You'll probably have to change the paths for wherever you decide to put the .dds file and output.

    I wasn't able to get the traditional "chroma" transparency. However, if you already have images in that format, bring them into Photoshop (GIMP?) and just select the magenta, inverse selection, and save that to the alpha. Then when exporting to .dds, you can select DXT1 with the 1-bit alpha. Your images will still be the same size as a regular DXT1, but you'll have the alpha that the rF2 shaders NEED. Doesn't seem to be any way around it, unfortunately. I REALLY wish ISI would release its shaders (completely). There's so many tweaks I'd love to make.
     
  9. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    756
    Likes Received:
    299
    Thank you for the file. I don't use 3DSMax, so I've asked someone to create the GMT for me.

    Edit: He has the incorrect version of 3DSMax. So, is anyone here willing to do it?
     
    Last edited by a moderator: Nov 27, 2013
  10. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    29
    Try this. I'm pretty sure that's the one I used for testing purposes, so it's not exactly "production quality" by any stretch of the imagination.
     
  11. lordpantsington

    lordpantsington Registered

    Joined:
    Oct 5, 2010
    Messages:
    805
    Likes Received:
    53
    Went to the source and asked LVC a few questions. Thought I'd flip back some of the reply to this thread so others can also learn. This statement:

    Made everything crystal clear.
     
  12. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    29
    Yeah, it makes sense how it works. However, my issue has been continuing, after they changed it, to call it "chroma"--which is quite a bit of a misnomer, since chroma literally means "color". We're not keying a color, we're keying an alpha value, which has no color, it's just a 0-255(if stored as int; otherwise 0-1 if stored as float). I think if they'd called it something more appropriate, there'd be less confusion as to how it works.
     
  13. Luc Van Camp

    Luc Van Camp Track Team Staff Member

    Joined:
    Oct 4, 2010
    Messages:
    1,030
    Likes Received:
    14
    Yep, would have loved to see the confusion had we simply called it ... "Alpha" :) ?
    It's worth a few lines in the expanded documentation. No ETA ...
     
  14. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    29
    How about "Alpha Threshold"? :D

    Since everything above is treated as opaque, and everything below is treated as transparent (with some tolerance for the 'blend' value, of course).
     
  15. wgeuze

    wgeuze Registered

    Joined:
    Oct 1, 2012
    Messages:
    1,608
    Likes Received:
    63
    It's exactly doing what it should though, like in AV it's also called chroma (keying) :)
     
  16. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    29
    Except that it's not. Chroma keying is using a particular color from only the rgb channels. Last time I tried using "chroma transparency" with rF2, you HAD to have an alpha channel in your texture. Maybe I was using a different shader from my above example, but I'm pretty sure I tried several different shaders and blend methods.
     
  17. Luc Van Camp

    Luc Van Camp Track Team Staff Member

    Joined:
    Oct 4, 2010
    Messages:
    1,030
    Likes Received:
    14
    Whatever you do, please try to stay away from blend methods when you work with chroma :) !

    rF2 chroma processes the alpha channel to allow smoother edges when Transparency AA is enabled. It looks much closer to alpha blend, without the performance hit or the sorting issues. That's the only reason why no one is using alpha blend trees (and their drawbacks) anymore. Also, try to imagine how bad RGB chroma would look ... without a negative MIP bias. Remember how people would have pink artifacts around the trees on some tracks in rF1? Some people worked around the sorting issues by cloning the trees (chroma + alpha blend), which would require the use of an alpha channel anyway!

    Is there a specific reason why you want to hang on to old tech? As far as I know, rF2's chroma approach looks better and smoother (less aliasing because it's no longer on/off) and can replace materials that HAD to use alpha blend transparency in rF1 (vegetation) ... it's better in every way, apart from texture memory perhaps. Plus it's easier to use for modders in a way: need something with transparency? Always use an alpha channel.

    Technically, you could call it "Greyscale Chroma Keying", or even "Texture based Chroma Keying" :) .
     
  18. lordpantsington

    lordpantsington Registered

    Joined:
    Oct 5, 2010
    Messages:
    805
    Likes Received:
    53
    This is why I posted to the thread, to get the word out. After you understand how it works, it doesn't matter much what ISI calls this approach to transparency. I will not disagree with you that calling it Chroma makes it difficult to use intuitively.

    Yes, you need to have at least 1 bit alpha in your texture. Source/Dest set to One/Zero, then pick whatever color is transparent in the Alpha for your Chroma color.
     
  19. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    29
    Yes, when I was testing it out, I was using different blend methods (mostly just One/Zero and SrcAlpha/InvSrcAlpha), but no, I'm not using it in "production" at all.

    Pink artifacts were due to improper mip-map creation and/or improper texture creation entirely. When using it, you'd need to have hard edges, no feathering at all. Yes, this looked bad.

    I don't. Over 2 years ago, when I originally started this topic, I did--when I still had chroma textures. :D However, I DO want the tech to work in a predictable manner. See below for what I'm talking about.

    Well, I'm not at ISI, and you guys can call it whatever you'd like. To me, those are still confusing names, though. :D See below for why that is.

    There's actually two problems with this. First, and most importantly, it doesn't even work as you described. The color picker does "bugger all"--as our British friends might say. :p The only thing that affects transparency now with this new system is the 'Chroma Blend' value. See the following attached image. You can see that I varied the 'Chroma Color' and the 'Chroma Blend' values independently. I used a texture with no compression (8.8.8.8 ARGB, no mip-maps) just to be safe as well. (Note: sorry for using such a large image, but I wanted to be sure that the text was legible, and one image is easier to read than 5 images--especially since we're looking at the differences between the images)
    View attachment 12110

    Secondly, instead of thinking of it as "picking" whatever color is transparent, think of it as picking at what point in your alpha channel the blending between completely transparent to completely opaque occurs. Anything below that value is transparent and anything above that value is opaque.

    Maybe that sounds the same to you, but if you still think of it as picking a "color" or "grayscale" or value as a 'key' (similar to chroma key) what that infers is that only that value will be completely transparent. See the attached image for an illustration of the difference. (The illustration assumes no blending pixels or that the difference between colors is greater than the blending region)
    View attachment 12111
     
    Last edited by a moderator: Mar 27, 2014
  20. Luc Van Camp

    Luc Van Camp Track Team Staff Member

    Joined:
    Oct 4, 2010
    Messages:
    1,030
    Likes Received:
    14
    Any shader + Chroma option will work. I see no use for the special Alpha Test shaders.
     

Share This Page