Opacity Map Ala 3ds Max?

Started by AGP, October 16, 2009, 03:30:20 AM

Previous topic - Next topic

AGP

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.

EgonOlsen

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... ???

AGP

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.

AGP

Sorry I took this long. Obviously the first one is the hardware one, the second is the software. Exact same code.


EgonOlsen

What's the value you are using for setTransparency(<int>)?


EgonOlsen

Quote from: AGP on October 20, 2009, 06:01:47 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.

AGP

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.

EgonOlsen

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.

AGP

OK, what about hardware? And why not make them behave the exact same way?

EgonOlsen

Quote from: AGP on October 20, 2009, 08:13:05 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.

AGP

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:

paulscode

Quote from: AGP 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.
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:
        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.

AGP

I see. I once asked Egon what exactly 100 did. He gave me three or four answers so I just let it slip. :- )

Ulrick

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