Transparent texture problem

Hi all

I am trying to make a TF2 hat with a transparent texture, however, although the alpha map works, in the sense that the bits I want to be transparent, are, it does not seem to display correctly in HLMV or in TF2 itself.

Below is a screenshot of the hat in HLMV. It is relatively simple - a UFO with a beam coming down.

http://www.adamwestmagic.com/ufoscr1.png

The parts that are transparent are as follows: the beam, becoming more transparent nearer the bottom, and also with striped transparency throughout (fairly obvious from the image). Also the blue ‘dome’ at the top is semi transparent (mid grey on the alpha channel of the .vtf).

The problem is that the beam, for some bizarre reason shows through the rest of the hat, despite for example the UFO being completely non-transparent (white on the alpha channel).

A similar issue can be seen when viewing from below:

http://www.adamwestmagic.com/ufoscr2.png

As you can see, the little green man that is inside the dome can be seen through the rest of the UFO. Interestingly this problem can be somewhat alleviated by making this little green man semi-transparent himself. This however, seems a bit of a fudge, as really the occlusion should work correctly.

I include for reference my .vmt and .qc code:

.qc


$cd "C:\Users\Magic\Desktop\ufohat\output"
$modelname "player\items\scout\milkhat.mdl"
$model "Body" "ufohat.smd"
$cdmaterials "\models\player\items\scout\"
$hboxset "default"
$hbox 0 "bip_head" -4.436  -8.926  -6.394  4.336  0.000  5.105
// Model uses material "models/player/items/scout/milkhat.vmt"
$surfaceprop "cloth"
$sequence idle "ufohat" loop fps 30.00
$collisionmodel "ufohat.smd" {

	$mass 5.0
	$inertia 1.00
	$damping 0.00
	$rotdamping 0.00
}


.vmt


"VertexlitGeneric"
{
	"$baseTexture" "models\player\items\scout/ufohat"

	"$bumpmap" "models\effects\flat_normal" 
	"$detail" "effects/tiledfire/fireLayeredSlowTiled512.vtf"	
	"$detailscale" "5"
	"$detailblendfactor" .01
	"$detailblendmode" 6
	"$yellow" "0"

	"$translucent" "1"
	"$phong" "0"
	"$phongexponent" "25"
	"$phongboost" "1"
	"$lightwarptexture" "models/player/pyro/pyro_lightwarp"
	"$phongfresnelranges"	"[.25 1 4]"
	"$basemapalphaphongmask" "1"

	"$rimlight" "1"
	"$rimlightexponent" "4"
	"$rimlightboost" ".65"
	// Cloaking
	"$cloakPassEnabled" "1"
	"Proxies"
	{
		"weapon_invis"
		{
		}
		"AnimatedTexture"
		{
			"animatedtexturevar" "$detail"
			"animatedtextureframenumvar" "$detailframe"
			"animatedtextureframerate" 30
		}
		"BurnLevel"
		{
			"resultVar" "$detailblendfactor"
		}
		"YellowLevel"
		{
			"resultVar" "$yellow"
		}
		"Equals"
		{
			"srcVar1"  "$yellow"
			"resultVar" "$color2"
		}

	}
}


As a sidenote, when trying to get the transparency to work, I found I had to set “$phong” to “0” to do so.

Any help with this issue (or indeed any other general advice/suggestions) is greatly appreciated.

Cheers

Try using “$alphatest” “1” instead of “$translucent” “1”
The latter can be quite fussy when it comes to actually working right

Thanks for the suggestion one free man. I actually circumvented the problem by using separate .vmt’s and .vtf’s for transparent/non-transparent parts.

I will take a look at how it behaves with translucent as well though for future reference.

Finished article for anyone interested: http://steamcommunity.com/sharedfiles/filedetails/?id=123598742&tscn=1359599576

Thanks.

compile with $opaque or $mostlyopaque in the qc

it helps with most z-order issues.