forums | blogs | polls | tutorials | downloads | rules | help

The variable "b hasalpha" and other stuff

Messing around with elfhair and am wondering about the hasalpha variable in the gas-files, e.g.

[t:tsd,n:b_c_gah_ef_hair_sol77_01_01]
{
  b dither = false;
  b hasalpha = false;
	layer1texture1 = b_c_gah_ef_hair_sol77_01_01;
  i texturedetail = 0;
}
This is the gas-file that obviously goes with b_c_gah_ef_hair_sol77_01_01.dds.

How exactly does this work? It is apparent that the image b_c_gah_ef_hair_alpha_sol77_01_01.dds, with it's alpha channel will be placed over b_c_gah_ef_hair_sol77_01_01.dds. I guess my question is why the variable "hasalpha", and what can I do with it?

Could I use it to give a character a bald spot?

Will setting dither to "true" or changing the level of texturedetail have any real effect?

volkan's picture

The alpha channel determines what aspects of the mesh are visible. This is the texture .gas for Chaos Grips in DS2.

[t:tsd,n:b_w_ces_chaos]
{
	b alphaformat = true;
	i numlayers = 2;
	i texturedetail = 1;

	layer1alphaarg1 = texture;
	layer1alphaarg2 = diffuse;
	layer1alphaop = modulate;
	layer1colorarg1 = texture;
	layer1colorarg2 = diffuse;
	layer1colorop = modulate;
	layer1numframes = 1;
	layer1uwrap = true;
	layer1vwrap = true;
	layer1texture1 = b_w_ces_chaos;

	layer2alphaarg1 = texture;
	layer2alphaarg2 = current;
	layer2alphaop = arg1;
	layer2colorarg1 = texture;
	layer2colorarg2 = current;
	layer2colorop = blendcurrentalpha;
	layer2numframes = 1;
	layer2uwrap = true;
	layer2vshiftpersecond = 0.2;
	layer2vwrap = true;
	layer2texture1 = b_w_hmr_foecrusher-flames;
}
This is how I was able to make animated armors, (thanks to Duvante/Wylac) Wink he is the one that taught me how to edit alpha channel and how to edit the .gas file.

Thanks for your reply Volkan.

I know what an alpha channel is though, I just don't get how the variable works.
The engine seems to be looking for a [texture name]_alpha_[headmesh]_[hairversion] to go with each
[texture name]_[headmesh]_[hairversion], i.e. b_c_gah_ef_hair_alpha_01_01 and b_c_gah_ef_hair_alpha_01_01. And it seems to be using that second texture as an alpha channel.
Fine, that is one way to do it and it seems pretty flexible.

But b_c_gah_ef_hair_alpha_01_01 has it's own alpha channel and even though hasalpha is set to false, that channel is still being used.

As I see it either the engine doesn't need the alpha channel when applying a texture to a mesh like hair, why it work like that I don't know, and therefore hasalpha tells the engine not to use it. Or the hasalpha variable tells the engine to look for a second texture that will be used as an alpha channel. In which case the second texture is never used in this case.

Guess a little testing is in order. Will probably summon Wyvante just in case though. ^^

volkan's picture

OK, I'm not sure but assuming hasalpha is referring to the actual mesh. Some meshes are able to incorporate the alpha to use different textures. (Like the type90/Mac Daddy Cap in LOA) The type90 mesh is used to create the Alloy Crown/Bone Crown/Woven Headband etc.

Edit: Maybe the hair is a texture that goes onto the head mesh, and only meshes use the alpha channel so hasalpha = false for hair?

Setting it to true had no effect, that I could see. Removing the files that are used as the alpha channel had an apparent effect though so the engine uses them whenever it can find them.

You could be right, I actually have no idea.

I'm not sure it makes no sense to have true and false. GPG isn't even consistent about it either. I guess if you have an alpha channel set it to true and if not set it to false. I don't think it makes a difference though.

Edit: It may be used to override the mesh's default texture but I have no idea.

Dither may make the image look like it has more depth. I guess it adds noise.

Site Owner of Siegecore a new Dungeon Siege 1 & 2 fansite.

I discovered that the texture's alpha does not work unless the mesh it is applied to also has a bit set to allow alpha-bearing textures. I think that was done so that bodies wouldn't be transparent. My guess would be that the hair is missing its "allow alpha on texture": bit. Most built-in hair already has it, but I've had to hex-edit the ASP files to set it before now. I don't remember which bit it was, but I had to compare meshes where it worked with ones where it didn't to track it down.

Abstraction site
Dungeon Raider

volkan's picture

I found that some meshes will not allow the animated textures so the "allow alpha on texture": bit seems to hold true, but I have no clue as to what that is or how to hex-edit it. One of these days I have to start messing around with gmax and meshes and learn all this stuff.

This page may help picture what's happening with the hair textures. You could do a bald spot that way. The alpha on the hair map lets the face map show through when they are combined. If you can see a face, the alpha is working! Most NPC characters have the hair and head combined on a single texture map to save load time, but the playables use two to let you pick the hair color. The alpha channels are only used to do this overlay of textures in DS1.

On some of the DS2 heads, there are uses of alpha channels to make the edges of the hair transparent so that you get the effect of more polys than are really there. This is the use that needs the alpha setting on the mesh. IIRC they also use multiple materials (the hair is on a separate map from the head) but the UV mapping is the same so the same texture can be applied to both materials. The alpha channels all have the same "holes" where the edges of the hair are removed, so even after hair and head are overlayed, there are still some transparent areas. You can put holes in the head instead of just bald spots!

Abstraction site
Dungeon Raider

Thanks for all that information ghastley. I will read through it a couple of times to make sure I get it.