Author Topic: Opacity Map Ala 3ds Max?  (Read 9915 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Opacity Map Ala 3ds Max?
« on: October 16, 2009, 03:30:20 am »
As a feature request, could that be implemented? Would be very helpful, including in additive transparency by the software renderer, I imagine (I wrote a little lightsaber test and the software additive transparency barely worked at all, hardware was perfect). I'm thinking it would be particularly useful for hair.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Opacity Map Ala 3ds Max?
« Reply #1 on: October 16, 2009, 09:28:46 am »
Not very likely...it would be pretty slow and with very limited usuage IMHO. Maybe you have a visual example what this would be actually good for? Maybe it can be achieved in a different way.
And what's wrong with the software renderers additive mode? It does exactly the same as the hardware does, it adds the color. Combined with an alpha channel, pretty results should be possible. Here's an example:



This looks exactly the same as it does in hardware...so what's wrong with it... ???

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Opacity Map Ala 3ds Max?
« Reply #2 on: October 16, 2009, 10:19:00 am »
I'll post screenshots of the lightsaber test when I wake up, but it barely combined at all. Far from the somewhat-gaseous look I'd had in mind and which worked with hardware.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Opacity Map Ala 3ds Max?
« Reply #3 on: October 19, 2009, 09:25:09 pm »
Sorry I took this long. Obviously the first one is the hardware one, the second is the software. Exact same code.


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Opacity Map Ala 3ds Max?
« Reply #4 on: October 20, 2009, 08:20:52 am »
What's the value you are using for setTransparency(<int>)?

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Opacity Map Ala 3ds Max?
« Reply #5 on: October 20, 2009, 06:01:47 pm »
100.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Opacity Map Ala 3ds Max?
« Reply #6 on: October 20, 2009, 06:18:57 pm »
100.
That's pretty high. Software and hardware renderer behave different when using higher values for transparency in additive mode. Actually, anything but 0 isn't very reasonable for additive blending in most cases. So please try 0 instead of 100 and tell me if that looks better.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Opacity Map Ala 3ds Max?
« Reply #7 on: October 20, 2009, 06:22:28 pm »
I doubt it. I use 100 for whenever I want to make black areas in a texture transparent. I don't think 0 would do the trick because I could never get transparency to work until Paul suggested I use 100 with black.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Opacity Map Ala 3ds Max?
« Reply #8 on: October 20, 2009, 06:33:08 pm »
But not with additive blending. With 100, you multiply the texture's colors by 100 and add those. That's why everything not black is just blue.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Opacity Map Ala 3ds Max?
« Reply #9 on: October 20, 2009, 08:13:05 pm »
OK, what about hardware? And why not make them behave the exact same way?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Opacity Map Ala 3ds Max?
« Reply #10 on: October 20, 2009, 08:56:29 pm »
OK, what about hardware? And why not make them behave the exact same way?
On hardware, the transparency value shouldn't matter when additive blending is being used. So you should be fine with 0 for both. The results when using 0 should be pretty much the same between the two modes. The software renderer does support a wider internal color range than the hardware one (because of some limitations of the fixed function OGL pipeline that the software renderer doesn't have). That's why the behaviour differs for higher transparency values. The alternative would have been to limit the software renderer artifically to match the hardware renderer and i don't see any reason to do this.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Opacity Map Ala 3ds Max?
« Reply #11 on: October 20, 2009, 09:24:09 pm »
Oh, thank you. For the record, the software transparency is still a little inferior than the hardware, but at least it works very well. The left one is software now:

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Opacity Map Ala 3ds Max?
« Reply #12 on: October 20, 2009, 09:44:44 pm »
I doubt it. I use 100 for whenever I want to make black areas in a texture transparent. I don't think 0 would do the trick because I could never get transparency to work until Paul suggested I use 100 with black.
BTW, the reason I might have suggested using a high number like 100, is because that works well when you want only the black parts of the texture to be transparent but everything else opaque.  For example, I have used this for trees when I wanted the black between the leaves to be transparent, but I didn't want the leaves themselves to be simi-transparent.  However, in your light sabre example, it looks like you want the blade to be simi-transparent.  Using a smaller number like 0 will still make the black parts transparent - the only difference is that the opaque parts will be simi-transparent (which is what you want in this particular case).  I did something like your light sabre in the firefly demo applet I made a while back.  The relevant lines of code:
Code: [Select]
        buttShine.setTransparency( 0 );
        buttShine.setTransparencyMode( Object3D.TRANSPARENCY_MODE_ADD );
        buttShine.setLighting( Object3D.LIGHTING_NO_LIGHTS );
        buttShine.setAdditionalColor( intensityColor );
It uses a texture with alpha information to simulate a glowing effect.  I've also used the above code in several of the special effects in the game I'm currently working on.  The good thing about this method is that you can change the intensity of the "additional color" to create cool things like pulsing engines, for example.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Opacity Map Ala 3ds Max?
« Reply #13 on: October 20, 2009, 10:16:27 pm »
I see. I once asked Egon what exactly 100 did. He gave me three or four answers so I just let it slip. :- )

Offline Ulrick

  • byte
  • *
  • Posts: 18
    • View Profile
Re: Opacity Map Ala 3ds Max?
« Reply #14 on: September 23, 2010, 10:30:19 pm »
Hi there, I'm new in android programming and I'm just playing with JPCT-AE.

I have issues with setTransparency. It actually does'n work. Either I put 0, 3, 100,200 or whatever, it just display the image normally.

I also tried with setTransparencyMode either Add or Default, but nothing change.

Is there anything I should take care on?

How do you set Hardware or Software Render?

Thanks in advance,

Max