project reality header
Go Back   Project Reality Forums > PR:BF2 Mod Forums > PR:BF2 Community Modding > Modding Tutorials
21 Sep 2024, 00:00:00 (PRT)
Register Developer Blogs Members List Search Quick Links
Modding Tutorials Information and tutorials related to modding BF2.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 2016-01-05, 19:34   #1
Rhino
Retired PR Developer
Supporting Member

Rhino's Avatar
Lightbulb BF2 BundleMesh Transparency

Really quick little info guide since some fellow devs are asking me about how and which way is best to do transparency

I'm only going to go into BundleMeshes for now since StaticMeshes is another story which I might go into another time but for now will just over complicate things.


Types of Transparency
Firstly there are two types of Transparency in BF2, "Alpha Blend" & "Alpha Test".


Alpha Blend
Alpha Blend is the most common type of transparency seen on Bundle Meshes and it allows for not only fully opaque or fully transparent, but also anything in between, which is what you need for things like dirt glass windows, that you can mostly see though, but isn't totally clear, like the rear passenger window on the Technical, where the driver window and windscreen are smashed but still bits of semi-transparent glass remain in them.

Alpha Test
Alpha Test is not that commonly seen on BundleMeshes but this is mainly because its not so known about, but also because it only allows for either fully opaque or fully transparent, transparency, and nothing in-between, so you can't do semi-transplant things like glass. On the plus side thou this can be what you want on some things like a wire mesh where you only want your texture to be fully opaque where the wire is, and fully transplant in-between the wire, like for example on this SideNet Radar:

In theroy it is also easier for GPUs to render this type of transparency (so better performance) than it is for "Alpha Blend", but I've got no solid evidence to support that.


Transparency Shader Techniques

"Shader Techniques" determine how the Shader will use the textures its being asked to load for each material, for example in which texture, and which channel of that texture, it needs to look for the opacity map and then how it will use that opacity map and so on. I'm only going to give examples/info of Shader Techniques related to Transparency here since there are lots of different combinations of Shader Technique and each behaves slightly differently.


Alpha Blend Shader Techniques
All the following Shader Techniques use the "Alpha Blend" type of opacity, meaning they are capable of having semi-transplant materials. Read the "Types of Transparency" segment above for more details.

Alpha
This is the most basic "Alpha Blend" Shader Technique and it loads the Opacity (Transparency) map from the "*_c.dds" alpha channel, and the Specularity (Spec) map from the "*_b.dds" alpha channel, if a "*_b.dds" texture is loaded and if not, no spec is used.
Spoiler for Examples:
Best examples would be firstly the 1st Person Chinook Series Windows that use this Shader Technique:

Next best example would be pretty much all of PR's first person scopes have an inner shadow to them which has its opacity map in its "scopeinner_blackgradient.dds" ("*_c.dds") texture but it dose not load a normal map, so has no spec/shine.
AlphaEnvMap
This Shader Technique is basically the same as the "Alpha" technique above, with the slight exception that it also allows for an ENV Reflection on it, which is really good to have on many types of glass as it makes it look more life like and many types of vehicle and scope glass textures use this material as a result.
Spoiler for Examples:
The Best example again are the Chinook Windows, although its the 3rd person windows (outside) ones that use this rather than the first person which only use the "Alpha" Shader Technique. Overdone example in BFMeshView to show the reflections more clearly, ingame they are much more subtle and don't have the glowing edges:



Alpha Test Shader Techniques
All the following Shader Techniques use the "Alpha Test" type of opacity, meaning they are NOT capable of having semi-transplant materials and can only be fully transparent, or fully opaque. Read the "Types of Transparency" segment above for more details.

Alpha_Test
This Shader Technique loads the Opacity Map from the "*_c.dds" Texture's Alpha Channel and if a "*_b.dds" texture is loaded, it loads the Spec Map from the "*_b.dds" Texture's Alpha Channel.
Spoiler for Examples:
The Best example here is the SideNet Radar again as this has it set up with all Diffuse, Opacity, Normal and Spec maps, although it should be noted that the texture setup isn't very optimized and really the transparent radar should really be on its own sheet since 3/4 of the opacity map is wasted memory from the rest of the texture not needing one.



Alpha_TestColorMapGloss
This is a really interesting Shader Technique since depending on what textures are loaded, it can behave very differently, so I'm going to split this one into two parts; with and without "*_b.dds".

Alpha_TestColorMapGloss - WITH "*_b.dds"
This Shader Technique, with it loading a "*_b.dds" Normal Map, loads its Opacity Map from the "*_b.dds" Normal Map's Alpha channel, and the Spec map from the "*_c.dds"
Spoiler for Examples:
Best example would be the Scimitar/Scorpion's Exhaust Guard which loads its opacity for the holes in the guard from its "*_b.dds" Normal Map's Alpha Channel, and loads it's Spec map from its "*_c.dds" Alpha Channel.



On a slight note, the Scimitar/Scorpion would probably be better off with the "Alpha_TestColorMapGloss - withOUT "*_b.dds"" setup since it would save more texture memory and wouldn't loose anything, in fact it would have better quality holes since the "*_c.dds" texture is saved at a higher resolution.
Alpha_TestColorMapGloss - withOUT "*_b.dds"
This Shader Technique, withOUT it loading a "*_b.dds" Normal Map, loads its opacity from the RGB channels of the "*_c.dds" texture. To be more specific, it looks for any areas on the texture that is on the faces of the material that have this material applied to it, for any 100% black areas and anything that is 100% black (or close to it), becomes fully transplant, where anything that has any other colour on it, is fully opaque. At the same time it loads the Spec Map from the "*_c.dds" Alpha channel. This material is really good for saving on texture memory since you do not need any specialised Opacity Map and its simply just integrated into the main Diffuse/Colour texture. On the down side however, you naturally can't have any Normal maps but that might not be so much of a big deal to have this material simply not load them even if the rest of your model loads a DXT1 normal map.
Spoiler for Examples:
One simple example of this would be the Lee Enfield No.4 Rifle's Ammo Clip which has this type of material applied to it, to make the holes on its sides transparent, while saving it from having to potentially double its texture memory usage if it was to have its own specialised Opaque map, just for a few tiny holes.



Exporting with Transparent Materials
This section is really (mostly) covered in my "Working With Multi/Sub-Object Materials" Tutorial under the "Part 1. Multi/Sub-Object Material Setup" & "Part 3. Transparent Materials" section and it also only fully works if you totally use the Multi/Sub-Object Materials since only then can you name more than one (sub) material with the same name, if they are in the same Multi/Sub-Object Material so while you can do the rest of it outside of a Multi/Sub-Object Material, you can only have one material named "AlphaEnvMap" for example.
More info here: https://www.realitymod.com/forum/f18...materials.html

Rhino is offline
Last edited by [R-DEV]Rhino; 2016-01-07 at 17:03..
Reply With Quote
 


Tags
bf2, bundlemesh, transparency, trasnaprancy

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 15:28.