Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: Herra Tohtori on March 17, 2007, 12:01:53 am

Title: Transparency issues and how to solve them?
Post by: Herra Tohtori on March 17, 2007, 12:01:53 am
Okay, here's a question.

I've been trying to make a model planet and it's rings to appear in FS2_Open. The planet part is no biggie, obviously it's just a big sphere with texture on it. But the rings (like the ones on Saturn) seem to be a bit problematic. When I slap a transparent texture on them, the rings themselves become transparent all right. The problem here is that everything else behind them also becomes transparent. That is, where the rings are over the planet, you can see the background through the planet when you should be seeing the planet's surface instead.

This is quite possibly related (or even the same) to the issue with "show ship" flag when the cockpit texture has a transparent HUD screen on it, it creates all kinds of wacky stuff that causes you to partially see through your ship's nose... or floor, if you're on external camera. I don't know if it's a bug or a feature, but I know that it is possible the have correctly transparent parts in models - the cockpit glasses are perfect examples of that. I just don't know how it is done, and search wouldn't find a tree in a forest. So... what do I have to do to make the rings of the planet transparent so that other models are still visible behind them?

I've tried different modle hierarchies - subobjects and stuff. I even created separate planet and ring models, but with exact same results. So I'm guessing I need to do something to the surface of the model itself. Closest bet would be that the polygons would need to be inverted or something like that... but wouldn't it make the whole ring invisible, or rather only visible to the inside of it? The ring model itself is a flat torus instead of flat rim, by the way.

Another question I have is related to PCS and TS 3.2 and where the hell is that lottery machine that decides how many normals a model uses...

Thanks for answers.
Title: Re: Transparency issues and how to solve them?
Post by: taylor on March 17, 2007, 12:17:33 am
I'm sure that someone else will have an idea or two as well (and probably betters ones), but one thing that you could try is to use a non-transparent texture (no alpha) and name it properly so that the game renders it with additive blending like it does for effects and what not.  Basically, just change "texture.dds" to "texture-trans.dds", and change the reference in the model to "texture-trans" and then it should be transparent.  This isn't a fool-proof solution though, since it can sometimes create other rendering issues.

The other course of action is probably just to get your model hierachy in the correct order so that you are sure that the rings are rendered last.  That way it can properly deal with the blending with alpha from the texture.  I think what you would want to do (I'm not the expert on this though) is set the planet itself as a subobject, and the rings as what would be considered the main hull.  Since subobjects are drawn first, that will draw the planet, then the rings, which should allow the blending to work properly.  Someone else might correct me on this though, but you could probably test it for yourself in the meantime.
Title: Re: Transparency issues and how to solve them?
Post by: Herra Tohtori on March 17, 2007, 12:22:34 am
Will do, thanks for suggestions. :)

EDIT: That hierarchy seems to have done the trick. Thanks.
Title: Re: Transparency issues and how to solve them?
Post by: Getter Robo G on March 17, 2007, 11:19:47 pm
Can we see a screenie? :D
Title: Re: Transparency issues and how to solve them?
Post by: Herra Tohtori on March 18, 2007, 01:30:44 pm
Can we see a screenie? :D

Here you go... :drevil:

(http://img238.imageshack.us/img238/9273/hulahulaplanetpf7.th.jpg) (http://img238.imageshack.us/img238/9273/hulahulaplanetpf7.jpg)
Title: Re: Transparency issues and how to solve them?
Post by: Huggybaby on March 18, 2007, 06:09:57 pm
Those rings look very cool!  :)
Title: Re: Transparency issues and how to solve them?
Post by: aldo_14 on March 20, 2007, 05:47:51 am
Sweet!

Insofar as transparency goes, it's sometimes a wee bit tricky; for cockpits it's a case of keeping the canopy 'glass' part of the main hull (with a different texture) and the cockpit as a submodel IIRC (actually, it occurs to me the latter bit might not be strictly necessary, so I'll need to check that out for myself), which works fine provided the glass faces don't have low point (vertice) ids as the vertice order seems to determine rendering and transparency order.

The trickiest bit, in my experience, is getting the ship hull to show through the glass, not the cockpit.  One thing you'll want to look out for is to check the smoothing on the planet 'body' is ok, subobjects tend to have very funky smoothing going by modelview.
Title: Re: Transparency issues and how to solve them?
Post by: Raven2001 on March 20, 2007, 05:52:08 am
You dont need them o be separat subobjects... make them all a single object, then detach the ring from the rest of the planet, and then re-attach it to the planet (keep in mind the planet body has to be the "parent" object of teh attach)... that should make the ring faces to be rendered last (due to face numbers).

Atleast that works for Max
Title: Re: Transparency issues and how to solve them?
Post by: Herra Tohtori on March 20, 2007, 06:25:14 am
Well, no Max here, I have to deal with TurdSpace 3.2 but I guess it's better than nothing. And as it works at the moment without any performance loss that I notice on my PC, I can't bother to change it at least at the moment. The rendering order definitely explains why problems arise when the HUD screen of the cockpit model has transparent texture - it's part of the cockpit subobject so it renders transparent last, making everything else behind it also transparent. Also probably because of vertice/face ID numbers, in some ships only part of the HUD makes the ship behind it disappear.

As far as smoothing goes, it looks good enough... Though I wonder where you can actually set the smoothing - under which tool group is that setting hidden in TS3.2's outerface (calling it an interface insults all proper ones...)? I once got smoothing setting visible by accident, it came up when I did something, but then it disappeared and I can't find it again. :mad:

And does it affect how PCS converts the object into a POF?

Considering other planets... is there some way to make a shine map that only affects the specular lighting and not the environmental mapping? Because it's a pain to make water reflect sunlight but not the backgrounds. Or is the only option to turn env mapping off?
Title: Re: Transparency issues and how to solve them?
Post by: aldo_14 on March 20, 2007, 07:19:28 am
Well, no Max here, I have to deal with TurdSpace 3.2 but I guess it's better than nothing. And as it works at the moment without any performance loss that I notice on my PC, I can't bother to change it at least at the moment. The rendering order definitely explains why problems arise when the HUD screen of the cockpit model has transparent texture - it's part of the cockpit subobject so it renders transparent last, making everything else behind it also transparent. Also probably because of vertice/face ID numbers, in some ships only part of the HUD makes the ship behind it disappear.

As far as smoothing goes, it looks good enough... Though I wonder where you can actually set the smoothing - under which tool group is that setting hidden in TS3.2's outerface (calling it an interface insults all proper ones...)? I once got smoothing setting visible by accident, it came up when I did something, but then it disappeared and I can't find it again. :mad:

And does it affect how PCS converts the object into a POF?

Considering other planets... is there some way to make a shine map that only affects the specular lighting and not the environmental mapping? Because it's a pain to make water reflect sunlight but not the backgrounds. Or is the only option to turn env mapping off?

I think so; I believe you can control the env mapping using alpha channels on shine-maps, but I've never really used env (never had much of a desire for it) mapping so I can't give any specific details.
Title: Re: Transparency issues and how to solve them?
Post by: Herra Tohtori on March 29, 2007, 01:28:29 am
Okay, I've got another thing to complain about.

Now the model and transparent ring textures work all right in itself. But, if the model is not centered enough, and if there's another model behind the rings... the transparent rings turn the other model behind them transparent, for those parts where it's covered by the transparent rings of the first model. :wtf:

Mind you, this does not occur if the ringed planet is in the center of the view. But if I turn my craft so that the view doesn't have the ringed planet close enough to the center, then the parts of another model behind the ring suddenly turn transparent. The actual angle in which the transition occurs I don't know, but there's pretty sharp limit on it.


I think it's caused because for some reason, the game alternates the order in which it draws polygons, based on the attitude of the craft. :nervous:

Dunno why, but couldn't it be simply changed by making the models in view render in order of proximity, if they don't already do so? Or, assign rendering priority to each craft - perhaps even use distance as one?

If transparent parts must be drawn first and parts behind them after that, wouldn't that take care of the problems regarding separate models obscuring each other with their transparent subobjects?
Title: Re: Transparency issues and how to solve them?
Post by: Nuke on March 29, 2007, 05:28:07 am
that ring isnt one big polygon is it? if it is then thats probably your problem. you could try using a higher poly grid instead so that the sections are being rendered in the proper z order. if you have one big polygon and its center is too far from the area infront of another object, it could seriously screw up the render order.

one thing ive come to realize about freespace's rendering order is that its greatly antiquated.  though it has been modified to take basic advantage of htl, it still hasnt been brought up modern standards. most modern game engines i have seen have almost zero limitations to the use of transparency. if theres one more feature id like out of the freespace engine, it would be a much more robust render list.

ive been able to do a couple ships with cockpits while using only one texture with alpha for the whole ship, but its not something you can do every time without glitches. id like to be able to do more with transparency.
Title: Re: Transparency issues and how to solve them?
Post by: Herra Tohtori on March 29, 2007, 07:50:27 am
(http://img123.imageshack.us/img123/9903/planetsamplejd6.gif)

It has plenty enough polygons... Probably too many to be optimized, but it looks good and doesn't really hit performance in a way I would notice it. :nervous: So that can't be the issue.

It's more likely that the order of rendering does some quirk that causes the problem to occur. I'm curious... does this happen with everything transparent, like Ship cockpits? I may have to stage some field tests to find out if cockpits obscure other models behind them... :blah:
Title: Re: Transparency issues and how to solve them?
Post by: Snail on March 29, 2007, 07:52:59 am
Don't think it happens with everything or you'd be able to see through the Orion, Demon, Typhon and Lucifer... I guess.
Title: Re: Transparency issues and how to solve them?
Post by: Herra Tohtori on March 29, 2007, 07:55:37 am
What do you mean by that? :nervous:
Title: Re: Transparency issues and how to solve them?
Post by: Snail on March 29, 2007, 08:38:57 am
The Orion, Typhon, Demon and Lucy have transparent textures, don't they?
Title: Re: Transparency issues and how to solve them?
Post by: Herra Tohtori on March 29, 2007, 08:45:44 am
Do they?

...anyhow, now I'm not talking about transparent parts making the same model transparent.

I'm talking about transparent part in one model obscuring another model behind it, and making the other model partially see-through... which is quite clearly something that I would classify as "bug" or at least poorly managed way to render things, because it's triggered by changing your ship's attitude...
Title: Re: Transparency issues and how to solve them?
Post by: Nuke on March 31, 2007, 03:49:34 am
i do get a glitch like that when using weapon models with transparency. usually the weapon will black out the backgrounds. ive always attributed that to freespace's funky transparency handeling.

are you implementing the planet as a skybox or as a ship? you might try one or the other and see if that helps. also try making the planet a child of the ring too. that might do it.
Title: Re: Transparency issues and how to solve them?
Post by: Shadow0000 on March 31, 2007, 04:48:27 am
If I would know all this stuff about transparencies was available...:

http://i29.photobucket.com/albums/c254/Shadow0000/Eartht_Hi_Poly_0001.png
http://i29.photobucket.com/albums/c254/Shadow0000/Eartht_Hi_Poly_0002.png
http://i29.photobucket.com/albums/c254/Shadow0000/Eartht_Hi_Poly_0003.png
http://i29.photobucket.com/albums/c254/Shadow0000/Eartht_Hi_Poly_0004.png
http://i29.photobucket.com/albums/c254/Shadow0000/Eartht_Hi_Poly_0005.png
http://i29.photobucket.com/albums/c254/Shadow0000/Eartht_Hi_Poly_0006.png

Well this is pretty easy to do, basically one Sphere for the Earth (Terrain), one for the Clouds, notice the clouds rotate at different ratio than the terrain sphere, though is only noticeable when the game is at fast forward speed.

The Atmosphere is not done as it should, it is actually set at a 3rd Sphere, which is using a texture with RGBA 0, 0, 128, 128. It seems this effect is either done as a mask or as an outer glow nowadays. The Hierarchy is set like this:

+Clouds
    +Atmosphere
         +Terrain

That way the transparent clouds are always rendered on top, while the Atmosphere will always be rendered behind both Clouds and Terrain, you will only see the outer edges and it will not add the 128 transparent blue to the rest of the clouds and terrain.

That detail is at 7200 polys with medium to high size textures, though there is a problem with the spheres if the planet is too big (real scale). Still, I think the ocean has an Specular Level map which can't be implemented in game (not too sure), and bumpmapping could improve it in the future...
Title: Re: Transparency issues and how to solve them?
Post by: Snail on March 31, 2007, 05:18:18 am
BTW, Shadow, for that model, could you shinemap the water? It looks cool and realistic, no?
Title: Re: Transparency issues and how to solve them?
Post by: Shadow0000 on March 31, 2007, 05:37:26 am
That's what I meant with the Specular Level, the water reflects more than the rest of the earth's surface, or I am confusing Specular Map with Specular Level, well anyways, this is what I meant...

http://celestiamotherlode.net/catalog/earthbumpspec.php

The atmosphere is well... much better than nothing, but it's still noticeable it's a sphere. As for the night and night lights Map I remember trying before but didn't really get good results.



Title: Re: Transparency issues and how to solve them?
Post by: Herra Tohtori on March 31, 2007, 06:03:04 am
are you implementing the planet as a skybox or as a ship? you might try one or the other and see if that helps. also try making the planet a child of the ring too. that might do it.

It's a "ship", yeah.

And currently the sphere is a child of the rings object. The thing is that the model itself works all right now, but it affects the way other models behind it are rendered...