Results 1 to 17 of 17

Thread: texture transparency

  1. #1
    Cesco's Avatar Decanus
    Join Date
    Apr 2013
    Location
    Italia
    Posts
    595

    Default texture transparency

    I would like to have some texture portions to be fully transparent, but for some reason I keep experiencing that horrible black outline on the model (see the red circled image).

    Any guess?
    Attached Thumbnails Attached Thumbnails camillan.jpg  
    Huic ab adulescentia bella intestina, caedes, rapinae, discordia civilis grata fuerunt ibique iuventutem suam exercuit

  2. #2

    Default Re: texture transparency

    Are you using only black (0,0,0) and white (255,255,255) in the alpha channel? It looks like a classic case of passing grey-scale through a binary alpha test. In fact, the only thing I can think of that has partial transparency on the battle map is water.

    This thread seems to report the same problem but nobody mentions if they're using grey-scale or binary and there's no solution given.

  3. #3
    Cesco's Avatar Decanus
    Join Date
    Apr 2013
    Location
    Italia
    Posts
    595

    Default Re: texture transparency

    I don't want partial transparency, just total transparency. Some EB units have this feature. How can I use a grey scale alpha channel?
    Huic ab adulescentia bella intestina, caedes, rapinae, discordia civilis grata fuerunt ibique iuventutem suam exercuit

  4. #4

    Default Re: texture transparency

    In the alpha channel, make sure there's only black (0,0,0) and white (255,255,255) and no other colors. Shades of grey are used to produce partial transparency but I don't think partial transparency is supported for units in Medieval II. If partial transparency isn't supported, then the game uses a binary alpha test and there are only three ways to do this:

    1) set everything in the alpha channel that's (0,0,0) to be black and everything else to white
    2) set everything in the alpha channel that's (255,255,255) to be white and everything else to black
    3) pick an arbitrary threshold between 0 and 255 and set everyone on one side of the threshold to black and everything on the other side to white

    I don't know which is used by the game, but if you have shades of grey in your alpha channel, any of these three binary alpha tests will cut off the texture (start making it transparent) at a point that you don't expect and hence produce "jaggies". If you only use black and white in the alpha channel, you will still get jaggies if the texture resolution is low, but at least you'll know precisely where they occur. If you use a high resolution texture, you can make jaggies harder to see but at that point you may as well use geometry which will probably render faster. See here for a graphical representation of what I'm talking about - obviously Medieval II isn't a Source game, but the same principles are used in every game. Below is an image from the Unity engine where a binary alpha test has been applied to a texture with partial transparency. The obvious similarity between this image and your image is why I'm under the impression that the problem is one of partial transparency.

    Spoiler Alert, click show to read: 




    But this is still just an assumption. If the background color on your texture (diffuse channel) isn't even black, then obviously the alpha channel isn't the only cause of this bug. If this is the case, the problem must be one of shaders and rendering in which case it would not surprise me if nobody has found a solution.

  5. #5

    Default Re: texture transparency

    Beware of mip-maps, the textures are based on the .dds file structure with mip-maps, if you have a black outline around the bits of texture you're trying to isolate it will start to bleed into the texture on the lower mip-maps (which are what you see most of the time). Ideally always have the area surrounding the bit of texture you've mapped to in a similar colour to the edges of that section. And/or deliberately create, load and adjust the mip-maps.


    I've discovered recently that at least for strat models (and probably the same for battle models) - if you supply a texture without mip-maps it doesn't actually mean the game doesn't use them. It just generates its own on the fly, which is often a worse option than choosing your own settings...

  6. #6

    Default Re: texture transparency

    It sounded like Banzai! had ruled out mip-maps as the cause of the problem in that thread from 2009. Guess he was wrong.

    Quote Originally Posted by makanyane View Post
    if you supply a texture without mip-maps it doesn't actually mean the game doesn't use them. It just generates its own on the fly, which is often a worse option than choosing your own settings...
    This is very good information. So if we wanted to save a bit of space, we could export to .dds without generating mip-maps, let the game handle it, and hope for the best? Sounds like a trade-off between file size and looks (and possibly performance).

  7. #7
    Cesco's Avatar Decanus
    Join Date
    Apr 2013
    Location
    Italia
    Posts
    595

    Default Re: texture transparency

    Click image for larger version. 

Name:	canali alfa.jpg 
Views:	11 
Size:	406.8 KB 
ID:	363218
    These are the alpha channels of the diff. and the normal map.

    I can't spot the problem, here: they seem the same alpha channles from others Europa Barbarorum 2's textures...
    Huic ab adulescentia bella intestina, caedes, rapinae, discordia civilis grata fuerunt ibique iuventutem suam exercuit

  8. #8

    Default Re: texture transparency

    Can you post the .texture files you're using here so we can check the transparency and mip maps?

    You can also post the .texture files for something from EBII that you says is working correctly by contrast.

  9. #9
    Cesco's Avatar Decanus
    Join Date
    Apr 2013
    Location
    Italia
    Posts
    595

    Default Re: texture transparency

    Huic ab adulescentia bella intestina, caedes, rapinae, discordia civilis grata fuerunt ibique iuventutem suam exercuit

  10. #10

    Default Re: texture transparency

    It's not clear which of these is the original from EBII and which is your edited file. But they both contain partial transparency (grey in the alpha channel). The file eb_principes_camillan has only ~1 pixel-width of grey on the element in the bottom-right. The file france_eb_principes_camillan has a lot of the transparent features from eb_principes_camillan but they've been made partially transparent with lots of grey around the edges (see comparison below).

    Spoiler Alert, click show to read: 




    When you look at the alpha channel of the mip maps, these transparent sections turn into this:

    Spoiler Alert, click show to read: 




    My guess is that the binary alpha test is still being applied to these mip maps and only black (0,0,0) is being defined as transparent while every other shade of grey is being defined as not transparent. Hence, if any level of mip map is being used, these holes on your texture very quickly fill in with the black background color from the diffuse channel.

  11. #11
    AnthoniusII's Avatar Μέγαc Δομέστικοc
    Join Date
    Feb 2007
    Location
    Thessalonike Greece
    Posts
    19,058

    Default Re: texture transparency

    Remember one basic rule.
    In the real texture transparency comes with total black on the alpha chanel.
    Take a close look in this guy's chain head hood.

    The hood its self is a solid 3d item. The eye wholes are a result of the black color in their place in the texture's aplha chanel.
    But i found something interesting when i applied this trick to horse head gear eye wholes.
    The texture ussualy has a comon background color. The texture pieces have theor colors of their own. Lets supose that in my texture the background is black but i deside (in order to know where exactly the eye wholes are) to paint them grey on the hood's chain texture. Automaticaly i will have eye wholes with black square spikes in the eye wholes edges.
    So when you creat a texture make sure that all parts are in the same background color and if and ONLY IF transparency requires then add black color ONLY in those places without harming the original texture.
    In the normal map the total black alpha chanel works as a default color.
    I explain.If i want something shining there are two ways to acomplish.
    Lets supose i want this guy's helmet more shiny. In the normal map texture instead of total black i use values of grey untill the shine i want is accomplished. My way though is he second choice.
    When i add the helmet texture is the main texture i "play" with its shine in the Photoshop until i am sutisfied. Then is easier to have a total black alpha chanel in my normal map texture.
    That black alpha chanel in normal map texture ensures that the colors and the shine you have chosen will remain unchanged.
    TGC in order to continue its development seak one or more desicated scripters to put our campaign scripts mess to an order plus to create new events and create the finall missing factions recruitment system. In return TGC will give permision to those that will help to use its material stepe by step. The result will be a fully released TGC plus many mods that will benefit TGC's material.
    Despite the mod is dead does not mean that anyone can use its material
    read this to avoid misunderstandings.

    IWTE tool master and world txt one like this, needed inorder to release TGC 1.0 official to help TWC to survive.
    Adding MARKA HORSES in your mod and create new varietions of them. Tutorial RESTORED.


  12. #12
    Cesco's Avatar Decanus
    Join Date
    Apr 2013
    Location
    Italia
    Posts
    595

    Default Re: texture transparency

    So, first of all thanks to both of you for your suggestions, I really appreciate that.


    Quote Originally Posted by Callistonian View Post
    My guess is that the binary alpha test is still being applied to these mip maps and only black (0,0,0) is being defined as transparent while every other shade of grey is being defined as not transparent. Hence, if any level of mip map is being used, these holes on your texture very quickly fill in with the black background color from the diffuse channel.
    I eliminated the partial transparency from the diff. texture, but that didn't solve the problem.

    Anthonius, Are you saying I should have a black alpha channel in the diff. texture where I want the transparency to be in game? Isn't black the default color of the diff. alpha channel?
    Huic ab adulescentia bella intestina, caedes, rapinae, discordia civilis grata fuerunt ibique iuventutem suam exercuit

  13. #13
    AnthoniusII's Avatar Μέγαc Δομέστικοc
    Join Date
    Feb 2007
    Location
    Thessalonike Greece
    Posts
    19,058

    Default Re: texture transparency

    Quote Originally Posted by Cesco View Post
    So, first of all thanks to both of you for your suggestions, I really appreciate that.




    I eliminated the partial transparency from the diff. texture, but that didn't solve the problem.

    Anthonius, Are you saying I should have a black alpha channel in the diff. texture where I want the transparency to be in game? Isn't black the default color of the diff. alpha channel?
    Lets use my MARKA horse texture as example.

    As you can see the parts of the groups are in black background but they could be easy in every color.
    Lets focus on that image.
    Each model group has UV MAPs. If by accident a vertex live goes in that black background when the ingame model will be loaded there will be a thin black line on its edges.
    In this case the black edges line is a matter of proper UV map placing.
    Now..When that PSD file converted to .DDS one automaticaly created an alpha chanel that is totaly white.
    Now watch carefullly the four armor parts of the horses . All four require eyes wholes inorder to be able to see the horse eyes in battle.
    The three armors in the eye wholes use either a grey color or the black background color.
    The white though has no visible eye whole.
    In all cases to achieve the trasparency of the eye wholes we go to the white alpha chanel and paint the eye wholes (only them) black.
    In the three cases the result may cause black spikes in the inned edges of the eye wholes. In the white texture though the round black in the alpha chanel will create a smooth eye whole.
    Now the texture requires a norman map texture as well.
    By default its DDS format has white color but if you load it in game the texture will be silver! By feeling the normal map texture's alpha chanel as black you make sure that all the colors will be same as the main texture.
    TGC in order to continue its development seak one or more desicated scripters to put our campaign scripts mess to an order plus to create new events and create the finall missing factions recruitment system. In return TGC will give permision to those that will help to use its material stepe by step. The result will be a fully released TGC plus many mods that will benefit TGC's material.
    Despite the mod is dead does not mean that anyone can use its material
    read this to avoid misunderstandings.

    IWTE tool master and world txt one like this, needed inorder to release TGC 1.0 official to help TWC to survive.
    Adding MARKA HORSES in your mod and create new varietions of them. Tutorial RESTORED.


  14. #14
    Cesco's Avatar Decanus
    Join Date
    Apr 2013
    Location
    Italia
    Posts
    595

    Default Re: texture transparency

    Click image for larger version. 

Name:	canali alfa.jpg 
Views:	7 
Size:	90.5 KB 
ID:	363232
    This is the alpha channel of my diff. texture (I'm using GIMP). It seems like black is its default colour. I'm clearly missing something...
    Huic ab adulescentia bella intestina, caedes, rapinae, discordia civilis grata fuerunt ibique iuventutem suam exercuit

  15. #15
    AnthoniusII's Avatar Μέγαc Δομέστικοc
    Join Date
    Feb 2007
    Location
    Thessalonike Greece
    Posts
    19,058

    Default Re: texture transparency

    I know nothing about GIMP. The best you can do is to create a freash empty texture, cut the textures part and past them in to the new one.
    Merge all levels to create the DDS file with mini.maps including. Place each gmodel's group UV maps in the textures edges and save. Make the texture's aplha chanel white and when you create its normal map make its aplha chanel black.
    TGC in order to continue its development seak one or more desicated scripters to put our campaign scripts mess to an order plus to create new events and create the finall missing factions recruitment system. In return TGC will give permision to those that will help to use its material stepe by step. The result will be a fully released TGC plus many mods that will benefit TGC's material.
    Despite the mod is dead does not mean that anyone can use its material
    read this to avoid misunderstandings.

    IWTE tool master and world txt one like this, needed inorder to release TGC 1.0 official to help TWC to survive.
    Adding MARKA HORSES in your mod and create new varietions of them. Tutorial RESTORED.


  16. #16
    Cesco's Avatar Decanus
    Join Date
    Apr 2013
    Location
    Italia
    Posts
    595

    Default Re: texture transparency

    I managed to do so but the problem persists, mybe it really depends on GIMP. It's a pity, because the models were coming along pretty well.
    Huic ab adulescentia bella intestina, caedes, rapinae, discordia civilis grata fuerunt ibique iuventutem suam exercuit

  17. #17
    AnthoniusII's Avatar Μέγαc Δομέστικοc
    Join Date
    Feb 2007
    Location
    Thessalonike Greece
    Posts
    19,058

    Default Re: texture transparency

    Remember the diff texture must have totaly white alpha chanel. Unless you need wholes womewhere.
    TGC in order to continue its development seak one or more desicated scripters to put our campaign scripts mess to an order plus to create new events and create the finall missing factions recruitment system. In return TGC will give permision to those that will help to use its material stepe by step. The result will be a fully released TGC plus many mods that will benefit TGC's material.
    Despite the mod is dead does not mean that anyone can use its material
    read this to avoid misunderstandings.

    IWTE tool master and world txt one like this, needed inorder to release TGC 1.0 official to help TWC to survive.
    Adding MARKA HORSES in your mod and create new varietions of them. Tutorial RESTORED.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •