Meshing Question How to create tranparent textures?

anemazoso

Addon Developer
Addon Developer
Joined
May 23, 2008
Messages
442
Reaction score
0
Points
0
Location
Las Vegas, NV
Hello all,
Once upon a time I new how to create transparent textures using an alpha channel but I do not recall and have not been able to find the procedure for creating transparent .dds textures. Can anyone clue me in? I appreciate any help. :)
 

francisdrake

Addon Developer
Addon Developer
Joined
Mar 23, 2008
Messages
1,096
Reaction score
930
Points
128
Website
francisdrakex.deviantart.com
Normally you would define a mesh-object transparent in your 3D-modelling program by setting its 'opacity' to 0. This is a simple method to define a window.
Just keep in mind that the window must be a separate mesh (object), as Orbiter does not support multi-texturing within one mesh.

Transparent textures:
I think (being not quite sure about it) that the color Red 255, Green 0, Blue 255 (= kind of pink) is interpreted as transparent by the Orbiter renderer.

If you want to make 'see-through' holes in your texture, painting these areas with this special color should work.
 

anemazoso

Addon Developer
Addon Developer
Joined
May 23, 2008
Messages
442
Reaction score
0
Points
0
Location
Las Vegas, NV
I thought there was a method for creating a texture with transparent areas on it which involves combining an alpha (using black for the area that is not seen) and a color version?

I just tried using the color you suggested francisdrake but it didn't work. Not sure what I'm doing wrong. Is there some function of DxTex I'm forgeting?

Does it matter if the texture is being used as a surface tile?
Thanks,
 

Spike Spiegel

New member
Joined
Feb 12, 2009
Messages
168
Reaction score
2
Points
0
Check out this add-on: [ame="http://www.orbithangar.com/searchid.php?ID=2437"]Brighton beach surface tiles v2 for orbiter 060504[/ame]

Mcwgogs uses an alpha channel in the surface tile images.
 

francisdrake

Addon Developer
Addon Developer
Joined
Mar 23, 2008
Messages
1,096
Reaction score
930
Points
128
Website
francisdrakex.deviantart.com
Ah, I forgot the method using the alpha channel!

First you draw the color bmp-picture.
Then you make a copy of it, convert this into b/w-bmp and paint black what later shall become transparent.

In the DxTex tool first open the color bmp-image, then (the menu is epanded now) use the menu-item "Open as alpha channel". Convert the loaded picture it into a dxt format and save it. This should do it.
 

Notebook

Addon Developer
Addon Developer
News Reporter
Donator
Joined
Nov 20, 2007
Messages
11,819
Reaction score
641
Points
188
A very useful tool for working with .dds files is "DXTbmp". You can get it here.

http://fly.to/mwgfx/

It can let you open the Alpha channel in your "paint" program, and you can preview the resulsts. Good for messing about with .dds files in general.

As francisdrake says, you have the choice of making the material opaque in the mesh itself.
You can use the Alpha channel, but you may get unexpected results.
Have a look at #126 here:
http://www.orbiter-forum.com/showthread.php?t=8698&page=7


Because I wanted the Black and White "Z", I couldn't find a way to use the Alpha channel to let the Grey be transparent, and keep the tank material "underneath".

Might be a way, but I left it as a straight map for the moment.

N.
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
You can use the Alpha channel, but you may get unexpected results.
Have a look at #126 here:
http://www.orbiter-forum.com/showthread.php?t=8698&page=7

Because I wanted the Black and White "Z", I couldn't find a way to use the Alpha channel to let the Grey be transparent, and keep the tank material "underneath".
This visual artefact is caused by the fact that z-buffering (the method DirectX and other 3D renderers use to remove hidden surfaces) is not compatible with transparent objects.

This is how z-buffering works:

  • Each pixel that the renderer paints on the screen also records its depth (distance from the camera) in a corresponding z-buffer pixel.
  • If another object in the 3D scene projects a point onto the same pixel, the renderer first performs a z-test: it checks whether the distance of the new object pixel is smaller or larger than the one already drawn. If it is closer, then the new pixel overwrites the old one, and the z-value is updated. If it is further away, then it is hidden by the object already rendered, and neither the colour nor the depth pixel are updated.
This works well with opaque surfaces, but not with (semi-)transparent ones. The reason is this:

  • When drawing a semi-transparent surface pixel, the corresponding z-buffer pixel is still updated. This means that the pixel obscures everything behind it. Any objects further away will be skipped, although they should really be visible through the transparent surface. There is no way to record semi-transparency in the z-buffer.
  • Note that for fully transparent pixels this should not be a problem, because the renderer could obviously just skip them altoghether. Whether this is done may depend on the graphics driver or hardware implementation. For semitransparent pixels however, z-buffering just doesn't work.
The only solution is applying the "painter's method": You draw the objects ordered according to depth, starting from the furthest. This ensures that by the time the transparent texture is drawn, the scene behind it is already fully built, and transparency is applied correctly.
Orbiter only provides limited support for depth-sorting (since you would have to re-sort the mesh faces for every frame. z-buffering is far more efficient). The only way to do it for vessel meshes is by re-arranging the mesh groups. Orbiter draws the groups in the order they appear in the mesh. So if the furthest groups appear first, they are drawn correctly. Of course, "furthest" may depend on the view direction, so there may not be a single group order working for all camera positions. In your particular problem however, it may work, by just putting the transparent group after the group containing the underlying object.

Edit: Generally, putting transparent mesh groups at the end of the mesh file, after all opaque mesh groups, is probably a good strategy. Only if you have multiple layers of transparent surfaces, the order may become a bit trickier to work out.

Sorry for the long-winded explanation, but this problem seems to surface occasionally, so may be of general interest. If there is a rendering howto or similar collection anywhere on the forum, maybe it could be copied there.
 

anemazoso

Addon Developer
Addon Developer
Joined
May 23, 2008
Messages
442
Reaction score
0
Points
0
Location
Las Vegas, NV
Thank you to everyone that responded.

I have a working transparent texture for a mesh but that same texture when tested as a surface tile does not work.

Is there a separate method for creating working transparent textures for surface tiles?
 

marcogavazzeni

Addon Developer
Addon Developer
Joined
Jan 5, 2009
Messages
219
Reaction score
0
Points
16
Location
Near Verona
Website
orbiteritalia.forumotion.com
If you can help, I use this program to make transparent or semi-transparent textures in DDS format, http://www.gimp.org/ is designed for Linux but also works well with Window XP in my add-on using GIMP, I managed to recreate various shades of light that can be seen well when the medium passes into the dark side of the planet
[ame="http://www.orbithangar.com/searchid.php?ID=3796"]SSD Executor revisted[/ame]
 

Wraith

New member
Joined
Oct 7, 2008
Messages
59
Reaction score
0
Points
0
Location
Moscow
The only solution is applying the "painter's method": You draw the objects ordered according to depth, starting from the furthest. This ensures that by the time the transparent texture is drawn, the scene behind it is already fully built, and transparency is applied correctly.
Orbiter only provides limited support for depth-sorting (since you would have to re-sort the mesh faces for every frame. z-buffering is far more efficient). The only way to do it for vessel meshes is by re-arranging the mesh groups.
Actually, there's another way, simple and inexpensive: drawing transparent faces (without depth-sorting) in a separate pass after non-transparent and with Z-writing disabled. This yields a worse quality in case of multiple transparent faces overlapping, but is still acceptable in many cases.
Obviously, that would require changes to be made to the renderer.
 

anemazoso

Addon Developer
Addon Developer
Joined
May 23, 2008
Messages
442
Reaction score
0
Points
0
Location
Las Vegas, NV
This is all good and useful information but no one has answered my original and most pressing question. How do you create one for a surface tile?

:cheers:
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Same way. I don't know why it doesn't work for you. The stock Canaveral tiles mostly contain transparency (DXT1 with binary alpha channel). Do those work for you?
 

Notebook

Addon Developer
Addon Developer
News Reporter
Donator
Joined
Nov 20, 2007
Messages
11,819
Reaction score
641
Points
188
Here is how I made transparent surface tiles for my Newcastle Airport base.
This is the tile, it has a coastline and a river, so a good choice for some transparency.
http://i89.photobucket.com/albums/k207/Notebook_04/09093008-44-26Deltaglider.jpg
This is another view of the tile
http://i89.photobucket.com/albums/k207/Notebook_04/09093009-21-04Deltaglider.jpg
This is the same shot, with the tile commented out in the .cfg file, to show the size and shape of the tile..
http://i89.photobucket.com/albums/k207/Notebook_04/09093009-21-42Deltaglider.jpg


This tile has a .dds file name "Earth_3_w0016_n0624.dds", and the entry in the .cfg file is
BEGIN_SURFTILELIST
3 -16 624 1
END_SURFTILELIST
These are Orbiter names, and hard (for me) to relate to the geography. So I made a grid based on the position of the base, and the level of the tile, then the position North/South_East/West.

Using Ar81's SurfaceTileCalculator (STC)
http://i89.photobucket.com/albums/k207/Notebook_04/STW.jpg
So, this tile is Two South, Four East, from the base tile at Level Three.
In my naming scheme this is "NewcastleVOR_L3_S2_E4"
This is the .jpg screen grab from Google Earth with corner co-ordinates taken from STC and marked in yellow. At this latitude the tiles are tall and narrow, so its rotated 90 degrees in Google Earth to get the maximum screen area. Its then rotated -90 in Paint.NET to get the original orienatation.

http://i89.photobucket.com/albums/k207/Notebook_04/NewcastleVOR_L3_S2_E4.jpg
In Paint.Net, this is trimmed to the yellow markers, resized, rotated -90 and saved as a .bmp to be suitablefor DxTex.
This is the .bmp
http://i89.photobucket.com/albums/k207/Notebook_04/NewcastleVOR_L3_S2_E4-2.jpg
(It says .jpg, but it went into Photobucket as a .bmp., honest)

DxTex needs the .bmp file to be powers of two, for this latitude, the aspect ratio looks to be about 2:1, so 512x1024 pixel was a suitable size. Needed to experiment with these numbers, so other latitudes will be
different.
DxTex can load this, and save it as a .dds file.
http://i89.photobucket.com/albums/k207/Notebook_04/DxTex.jpg
To convert this to a .dds file type 1.
Select the "Format" menu, then "Change Image Format" then "DXT1(1-bit alpha)
Save this as "Earth_3_w0016_n0624.dds". STC gives the .dds file name.
http://i89.photobucket.com/albums/k207/Notebook_04/dxtbmp6.jpg
Now compare this with the early shots

http://i89.photobucket.com/albums/k207/Notebook_04/09093010-17-14Deltaglider.jpg
The tile is back, but it has lost its transparency, finally getting to your question...


The bmp was converted to a type 1 .dds file, this has "binary" transparency, anything Black in the alpha map is transparent, anything White is opaque.
So, the alpha map in this .dds file is completely White, so there is no transparency. We have to make the alpha map Black in the areas you want transparent, that is the Sea, the river, and the docks.


I use DXTbmp to alter alpha maps.
Openeing the Earth_3_w0016_n0624.dds gives you this
http://i89.photobucket.com/albums/k207/Notebook_04/dxtbmp1.jpg
As you can see. the Alpha Channel (top right) is completely White.

What I normally do is select "Create Alpha Template" from the Alpha menu, this gives a starting point.
http://i89.photobucket.com/albums/k207/Notebook_04/dxtbmp2.jpg
Double click on the Alpha Channel image at the top right, and it will open in your paint program:
http://i89.photobucket.com/albums/k207/Notebook_04/dxtbmp3.jpg


Now the work starts, you have to make the land White, the river/Sea, Black. Using Fill Tool, and brushes,
and Fill Rectangle, you will get something like this:

http://i89.photobucket.com/albums/k207/Notebook_04/dxtbmp7.jpg
Save the Alpha map in the paint program and go back to Dxtbmp and select "Refresh after Edit in the Alpha Channel window.

You can use the Transparency Preview from the menu bar or the spyglass icon in the Alpha Channel window.

Save now as a DDS Texture, type DDS DXT1, overwriting the old file.
You should have something like this:
http://i89.photobucket.com/albums/k207/Notebook_04/09093011-12-52Deltaglider.jpg

Hope this helps, N.
 

anemazoso

Addon Developer
Addon Developer
Joined
May 23, 2008
Messages
442
Reaction score
0
Points
0
Location
Las Vegas, NV
Thanks Martin and Notebook!

@ Martin

Yes the stock Canaveral surface tiles work for me as well as wehaveaproblem's Wide Awake Island. This is very confusing :p

I have tried several times to create the texture using the method described above. Specifically I created a color version, an alpha channel with the area to be opaque white and the area to be transparent black. I then opened the color version with DxTex, coverted it to a DXT1 and oped the alpha as "Open as Alpha". I then saved, assigned the proper name for the surface tile and got the following results.

Island_alpha_attempt.jpg


Here are the two textures I used. Feel free to try with them if you like.

Overton_island_flat2.jpg

and the alpha
Overton_island_flat_alpha.jpg


---------- Post added at 09:11 AM ---------- Previous post was at 08:24 AM ----------

Here is a screen shot of the same texture applied to a flat rectangular plate mesh. Works with the mesh but not the surface tile.

Islandonmesh.jpg
 

fort

Active member
Joined
Mar 19, 2008
Messages
1,018
Reaction score
20
Points
38
I'm not quite sure I understand this whole conversation, and family events I have just removed me the last few weeks of my activities on surftiles with whom I worked hard in recent months, but in the solutions given by each, here, it seems to me that something is missing in the puzzle (sorry if I'm wrong or if my memory is wrong ...).

To have the transparency of a surftile as you've built it with an alpha chanel ( black and white or gray scaled - and maybe in dxt5 for a grey scaled surftile...do not exactly remember ), you must declare it in the "surftiles begin / end surftiles" list with a reference to a 3 number and not a 1.

An example ( in canaveral.cfg ):
3 -920 323 3

Not:
3 -920 323 1

This for standard surftiles.

The transparency works also for a dds with an alpha chanel on a mesh in this form:
BEGIN_OBJECTLIST
MESH
FILE MYMESH
TEX Mytexture
END

I do not know ( versus remember...) if it works with:
BEGIN_OBJECTLIST
MESH
FILE MYMESH
TEX Ownmaterial
END

( but certainly with the good numbers at the end of the meshe refering to opacity ).
 
Last edited:

anemazoso

Addon Developer
Addon Developer
Joined
May 23, 2008
Messages
442
Reaction score
0
Points
0
Location
Las Vegas, NV
Thats it!! That did it, I changed the 1 to a 3 and presto! Now all I need to do is make a better blend on the edges. Thanks to everyone!!! It's so nice to be able to get on the forum and have a question answered by the pros.

Cheers :cheers:

working_alpha.jpg
 

fort

Active member
Joined
Mar 19, 2008
Messages
1,018
Reaction score
20
Points
38
In fact, I can not remember exactly in what circumstances that number 3 should be used. I just did a test with a transparent texture ( surftile ) and an alpha channel (black and white) in DXT1 with the number 1 and the transparency is made. I have a few topics on the use of that 3 number somewhere on my hard drive but right now I do not need it, so.
 
Top