Hard Light Productions Forums

Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: zookeeper on March 04, 2011, 11:44:53 am

Title: Texture transparency and RTT
Post by: zookeeper on March 04, 2011, 11:44:53 am
I'm using RTT to draw stuff on a ship's texture. However, I'd need the parts I haven't drawn on to remain transparent, instead of showing up as black (or garbage-coloured if I don't clear it to black), but this seems impossible to do. If I could make the ship be drawn using additive blending then that'd work too, but apparently that's not possible either.

Am I missing something? If it's indeed impossible to 1) make some pixels transparent using RTT and 2) clear the whole texture to be entirely transparent and also 3) to make a whole ship get drawn using additive blending, then would one of those would be easy to add?

Things I've tried (and which didn't work):

- Trying to paint transparency by first setting a transparent colour with gr.setColor().
- Setting gr.CurrentOpacityType = ALPHABLEND_FILTER in an $On Object Render hook made for that ship.
Title: Re: Texture transparency and RTT
Post by: Nuke on March 04, 2011, 12:28:46 pm
i once tried to trick the game into rendering the hud to a texture, it didnt quite work. and the main issue was that there is no way to draw to the alpha channel. i suspect its something to do with the internal texture format of the rtt texture (i doubt it even has an alpha channel).
Title: Re: Texture transparency and RTT
Post by: zookeeper on March 12, 2011, 03:54:56 am
Due to my discovery of how to use -trans textures (http://www.hard-light.net/forums/index.php?topic=75016.0), being able to directly paint alpha on an rtt texture isn't really necessary anymore for me. Whether it'd have a use for other folks I leave up to them.
Title: Re: Texture transparency and RTT
Post by: Nuke on March 12, 2011, 03:27:36 pm
isn't that kind of deprecated?

i still kind of want this sort of thing. would probably be better if we just make it so you can specify the pixel format when creating a dynamic texture. it seems to be rgb888, but i kinda want rgba8888, might also want some other formats available like a8 or rgb565.
Title: Re: Texture transparency and RTT
Post by: zookeeper on March 12, 2011, 04:32:09 pm
isn't that kind of deprecated?

Maybe, but it's not removed. It also seems like the only way to have any kind of rtt transparency, so I guess it shouldn't be too hard to keep it from getting removed either.
Title: Re: Texture transparency and RTT
Post by: Reprobator on March 31, 2011, 02:48:07 am
Does the problem with alpha channel pointed here only concern the rtt texture?
Because i wonder if it would be possible to render a fixed image with alpha that would simulate the helmet view like this :
(http://i.ytimg.com/vi/XzBsa_n8ZMo/0.jpg)
it would have to follow your view
Title: Re: Texture transparency and RTT
Post by: zookeeper on March 31, 2011, 03:24:08 am
Does the problem with alpha channel pointed here only concern the rtt texture?

Yes, I'm pretty sure it does. It would be easy to test to make sure though, and maybe I'll remember to do that later today.
Title: Re: Texture transparency and RTT
Post by: Nuke on March 31, 2011, 08:51:18 am
that kinda thing has nothing to do with rtt. thats merely taking a texture and drawing it on top of the scene. you dont need to create a texture on the fly for that. you would just need to create a large high resolution texture, with alpha, and scale it to fit the screen and (in freespace context) draw it right before the hud gets drawn. obviously when you do this, its hard to make a texture that works well for all available resolutions and aspect ratios, and it may get stretched in an undesired or ugly way (such as getting warped or blockey). you can get around this a few ways, make a few textures and use the one that closest matches your res and/or aspect ratio, you can apply a blur shader or other to it, you can also do both.

a lot of people seem to misunderstand what rtt is for. rtt is used when you need to do one of these:
render the scene to a texture for use on a model in the game (like a gun/missile/turret camera display on a panel, or a security camera monitor in an fps game).
make the content of a texture interactive (like the control panels in doom3)
simple procedural animations based on events in the game (like radar and other cockpit panel elements, or hud glass)

of course this doesnt mean you cant find some other uses for it. however render to texture is a very expensive operation and should be avoided if there is a better method for doing something.
Title: Re: Texture transparency and RTT
Post by: Reprobator on March 31, 2011, 09:44:47 am
Nuke  : i knew for the rtt i was asking about alpha channel in other cas than rtt.
Title: Re: Texture transparency and RTT
Post by: Nuke on March 31, 2011, 11:30:39 am
Nuke  : i knew for the rtt i was asking about alpha channel in other cas than rtt.

i think all the image draw functions can work with alpha channels. the problem with rtt and transparency is most likely the internal pixel format of the texture simply does not support alpha data. of course use textures with alpha in texture formats that support it (8888, dxt5) and you should have no problem doing something like in the image you posted.