Author Topic: Transparency in the engine  (Read 8606 times)

0 Members and 1 Guest are viewing this topic.

Offline newman

  • 211
Transparency in the engine
Hi all, I've recently spoken with The_E on irc about this issue and he suggested I post it here.
Before I begin, I'd just like to say that I'm an artist for Diaspora, and know very little about coding - so I have no idea whether or not what I'm suggesting is even possible, or how complicated it is. I thought I'd throw the issue out there and see if a better way of handling transparency can be found. Warning: lots of text ahead :)
 
As the thread title suggests, this is about transparency and the way engine handles it in the game. Right now, the alpha channel on the diffuse (color) map is used to determine transparency: black is transparent, white is opaque, and say 50% gray is 50% transparent. That part's fine. The complication comes from the fact that anything you want to see through the transparent object on a ship needs to be set up in the pof as below that object in hierarchy - the transparent object itself (the one that has the alpha map applied) needs to be higher in the hierarchy than the stuff you see through it. This in itself isn't a problem on simpler setups where you only have, say, a cockpit canopy on a fighter - you set up your canopy is as detail0 and slave everything to that, problem solved (FUBAR's been testing this stuff and he actually tells me that your transparent object has to be detail0 to work properly - so you can't have say, the fighter main hull as detail0, then slaved to that the canopy, and below the canopy the cockpit interior - and this causes complications in some examples).
The problems begin on ships that need more, larger surfaces transparent or semi transparent. Since I'm a Diaspora member I'll be using ships from the BSG universe as an example of why this way of doing things causes us problems.

Let's begin with the ringship:


Once this one is built for Diaspora, we definitely want to have the interior of the ring actually modeled out, with transparent glass over it. Ideally, we'll also want to be able to see the inside of the glass as well from certain angles (right now means having two glass objects, one with polygon normals pointing outwards and the other with poly normals pointing inwards).
The problems on this one will arise mainly from the fact that the glass object(s) need to be detail-0, but they also need to spin (the entire ring section including the arms and parts of the main hull rotates). You can rotate sub-objects, but not sure about detail-0..
If the glass can work with not being detail-0 you can still get issues of not seeing some hull parts through it from certain angles (say, you park your fighter so you should be able to see the bridge through the glass, or the connecting arms). We did do some testing on this and the problem is more complex than one might imagine; even if everything is set up seemingly correctly, there's always some ship part you can't see through the glass.

Here's another example:



Not exactly the most accurate depiction of the botanical cruiser, but it'll do. The problems are, of course, the domes. With a single dome, it's not a problem at all. Set up the dome as detail0 and everything else below that. With multiple ones, you have a problem if you want to see other domes through other domes. Say you park you fighter in front of it, you should be able to see several domes right through each other. In parts where the transparent parts intersect you should see less and less transparent surfaces, the more glass objects you're looking through at once.

And finally, on to the actual request part:
We've been thinking of ways to get around these issues, but the best thing would be if the need for hierarchy for transparent objects was eliminated. I'm not sure if it's even possible, but if it is the best thing would be that everything that happens to be behind a transparent object (relative to the player) is visible through that object, no matter if it's another ship part which may or may not be higher in hierarchy, or another ship for that matter.

I hope you lot can make sense of what I wrote. If anybody would like to tackle this, I'd of course be willing to do any test models or textures to test it on - while this would be extremely useful to Diaspora, I'm sure there are other projects which could benefit from this as well. If it can't be done, well, thanks for listening and all your great work so far :)
You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here! - Jayne Cobb

 

Offline DaBrain

  • Screensniper
  • 212
    • Shadows of Lylat board
Re: Transparency in the engine
I see three issues here:

1. The lack of support for two-sided materials. This one is probably the easiest to fix. Maybe The E can allow that in his material file.

2. Rendering order/sorting issues. Very hard to fix. Sorting issues are a common problem. You can even create content that is impossible to sort correctly.
There is a DX11 feature that allows rendering order independant transparency, but I doubt FSO will support that.
Also, I've never seen it being used by any game yet. I imagine it might be very costly.

http://www.yakiimo3d.com/2010/07/19/dx11-order-independent-transparency/
http://www.youtube.com/watch?v=zANEUhyT2y8


3. Hierachy... well it can be painful to set up, but at least you have the complete control. It would be frustrating if the engine rendered your model wrong and you had no way to fix it.
--------------------------------------------------
SoL is looking for a sound effect artist
Please PM me in case you want to apply
---------------------------------
Shadows of Lylat - A Freespace 2 total conversion
(hosted by Game-Warden)
----------------------------------

  

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Transparency in the engine
this kinda thing is one of those big annoyances ive always had with the engine. it has a really hard time with transparency. subobjects all get rendered first, so if they are in front of detail 0 they will be covered up. also i think rendering order of subobjects is somewhat fixed by the submodel number, with no depth sorting at all, so transparency between subobjects is not considered and whatever gets rendered last is usually what you see. since this game engine was never really meant to deal with transparency it is somewhat fundamentally flawed when you try to implement it. there are methods to make small parts of of ships transparent, but it takes some rather complicated modding techniques. i dont think there is really any way around it, its something that would have to be handled properly in the code.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline newman

  • 211
Re: Transparency in the engine
Well, like I said, I have no idea if this is fixable at all, but at least this way I know I've tried :) I would encourage a brainstorming session on this here if there's more than a snowball's chance in hell of the transparency code getting improved, though. I wish I knew more about code, this way all I can do is ask and hope someone has an idea.
You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here! - Jayne Cobb

 

Offline Sushi

  • Art Critic
  • 211
Re: Transparency in the engine
Yeah, trying to deal with multiple overlapping transparent textures is a "hard problem" in 3d rendering in general, so it's not surprising that FSO chokes on it.

 

Offline DaBrain

  • Screensniper
  • 212
    • Shadows of Lylat board
Re: Transparency in the engine
FS2 only used additive rendering for textures back then. There is no need to sort additive effects. No matter in which order you render them, the result will always be the same.


Alpha blended materials made the sorting more apparent. I think taylor already improved the sorting a lot.
--------------------------------------------------
SoL is looking for a sound effect artist
Please PM me in case you want to apply
---------------------------------
Shadows of Lylat - A Freespace 2 total conversion
(hosted by Game-Warden)
----------------------------------

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Transparency in the engine
There is another issue Newman forgot to mention.  While other objects can be seen through a transparency they can't be if they are inside a transparency.  Say you took and docked something inside of one of those domes.  It can't be seen. 

As for the issue with not having the transparency on detailx what happens there is you open a hole through the entire ship.  You can see the star field on the other side.  This happens even if there is a solid object behind the transparency with normals facing the direction you are looking from. 

One other note is that a lot of these items show up fine in PCS2 but not in game. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline Galemp

  • Actual father of Samus
  • 212
  • Ask me about GORT!
    • Steam
    • User page on the FreeSpace Wiki
Re: Transparency in the engine
I ran into this issue with the high-poly PVF Anubis, which has two glass cockpits. Fortunately the Blender-to-DAE-to-POF workflow lets you create transparent polies on a detached subobject, which then gets merged into the main geometry in the proper rendering order. You might want to make some test POFs (the botanical cruiser is an excellent example) to try it out.
"Anyone can do any amount of work, provided it isn't the work he's supposed to be doing at that moment." -- Robert Benchley

Members I've personally met: RedStreblo, Goober5000, Sandwich, Splinter, Su-tehp, Hippo, CP5670, Terran Emperor, Karajorma, Dekker, McCall, Admiral Wolf, mxlm, RedSniper, Stealth, Black Wolf...

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: Transparency in the engine
Is that possible that while we're at it, somebody could look into the problem with cockpit glass being visible from inside the cockpit?
This bug is a real problem for anybody who wants to use cockpit view.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Transparency in the engine
Dragon, that's a model issue more than anything. Namely, that the cockpit glass is apparently double sided. The current shaders only render polygons facing your way.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: Transparency in the engine
I have to check again, but I'm sure it occured on Mediavps models like Herc II, which worked fine in 3.6.9 (this started to appear in 3.6.10, the first notable case was Steve-O's fighters suddenly getting inside of their opaque glass rendered).

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Transparency in the engine
It's still a model issue. Only the front sides of polygons are rendered. If you are seeing it, it means it's facing your way.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Transparency in the engine
i kind of have an issue on one ship where the cockpit glass that is meant to be visible from the outside only, can be seen from the cockpit model. but only until you fire your weapons for abit, then it goes away. though i think this has been fixed in recent builds.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline newman

  • 211
Re: Transparency in the engine
I ran into this issue with the high-poly PVF Anubis, which has two glass cockpits. Fortunately the Blender-to-DAE-to-POF workflow lets you create transparent polies on a detached subobject, which then gets merged into the main geometry in the proper rendering order. You might want to make some test POFs (the botanical cruiser is an excellent example) to try it out.

Could you expand a bit on your method of doing this? Are you actually saying you can create polygons that will always be transparent (well, semi transparent) independently of the texture applied?
At any rate, what you're suggesting sounds interesting, I'd love to hear more specifics :)
You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here! - Jayne Cobb

 

Offline Galemp

  • Actual father of Samus
  • 212
  • Ask me about GORT!
    • Steam
    • User page on the FreeSpace Wiki
Re: Transparency in the engine
Could you expand a bit on your method of doing this? Are you actually saying you can create polygons that will always be transparent (well, semi transparent) independently of the texture applied?

You still need a texture with transparency, of course; this method simply builds the mesh in such a way that the drawing order is arranged correctly. The relevant step is on this Wiki page but I'll quote:

Quote
Transparent objects are handled quite badly by FSO at the time of writing, and so the following technique is basically a hack to get around that.

If you have anything that requires transparency as a part of the hull or any subobject, you must:

   1. Select all faces that will need to be transparent. (For cockpits this means all the polies that would be the glass, and for nameplates it means just the floating nameplate rectangle polies)
   2. Detach these faces from the mesh they're a part of so they form their own mesh.
   3. Assign them the texture if necessary. (For cockpit glass just give it any old image called 'glass' and for nameplates give it any old image called 'nameplate'. Both these textures exist in the 3.6.10 MediaVPs and so will be used on your model with no further worry about it. If you need some other form of transparency you'll have to make your own transparent texture and use that.)
   4. Name the object in the form of '<Object the transparent polies came from>-trans'. So for example, the glass or nameplate would be called 'detail0-trans', because they were pulled off the main hull.
   5. Parent the transparent polies object to whatever object they originally came from. (Select the transparent object, then the parent object and press Ctrl+P->'Make Parent' ) For glass or a nameplate this would of course be detail0.

What basically happens is that PCS2 will re-attach the transparent polies to their parent object last in the list, which lets Freespace draw them last of all and so correctly transparent.

I haven't tried anything as complex as the botanical cruiser but for two glass domes it's worked perfectly.
"Anyone can do any amount of work, provided it isn't the work he's supposed to be doing at that moment." -- Robert Benchley

Members I've personally met: RedStreblo, Goober5000, Sandwich, Splinter, Su-tehp, Hippo, CP5670, Terran Emperor, Karajorma, Dekker, McCall, Admiral Wolf, mxlm, RedSniper, Stealth, Black Wolf...

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Transparency in the engine
I've tried it and it doesn't work for sub objects just for detail0.  Using it on subobjects results in the see clear through the ship issue I described above. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline newman

  • 211
Re: Transparency in the engine
Aw, shucks. Knew about that. Thought you had a magical solution to the problem. Still, thanks :)
You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here! - Jayne Cobb

 

Offline Spicious

  • Master Chief John-158
  • 210
Re: Transparency in the engine
That only applies with respect polygon order within an individual subobject. Getting around this would require moving the opaque geometry into a subobject.

If you need to be able to view a set of transparent things in multiple orderings, you're doomed.

 

Offline Galemp

  • Actual father of Samus
  • 212
  • Ask me about GORT!
    • Steam
    • User page on the FreeSpace Wiki
Re: Transparency in the engine
If you need to be able to view a set of transparent things in multiple orderings, you're domed.

Fixed that for you...
"Anyone can do any amount of work, provided it isn't the work he's supposed to be doing at that moment." -- Robert Benchley

Members I've personally met: RedStreblo, Goober5000, Sandwich, Splinter, Su-tehp, Hippo, CP5670, Terran Emperor, Karajorma, Dekker, McCall, Admiral Wolf, mxlm, RedSniper, Stealth, Black Wolf...

 

Offline Sushi

  • Art Critic
  • 211
Re: Transparency in the engine
If you need to be able to view a set of transparent things in multiple orderings, you're domed.

Fixed that for you...

 :lol: