DigitalEro Offline

Adding Ambient Occlusion To a Model

Thu, 12 Jun 2014 05:26:59


I'm pretty confused by this. When porting some bedroom furniture props, I realized that they never had ambient occlusion on them. So, I googled how to do it, baked an AO map with Blender, made a new layer on my diffuse layer, and changed the blending mode to "Multiply". Then, I remade my vtf file to use the new tga file I just created. And... it didn't work. Here's my vmt:
"VertexlitGeneric" { $basetexture "models/bedprops/FBed/fbedmat" $ambientocclusion "1" $phong "1" $phongexponent "100" $phongboost "4" $phongfresnelranges "[.5 .7 1]" $halflambert "0" }
And by "it didn't work", I mean there's no grain effect. Changing any of the SSAO settings from a scene camera doesn't affect anything. And AO is on in SFM. I've tried looking at other files that do have AO on them, but I can't really see what they do, that I don't. So someone, please help me out on this. Been killin' me for hours.
Thu, 12 Jun 2014 05:38:29


There is only a few requirements for AO to work on a model. The most important one is thatyour material needs a bumpmap. You don't have to bake AO maps by yourself because SFM's AO is generated on the fly. Also, a few words about phong shading: You have $phong parameters in your VMT, but Phong shading will not render in SFM without a bumpmap. Your phong effect will sometimes show in the model viewer by default, but never as detailed as with a bump map. (make sure you tick the "normal mapping" box in HLVM) If you feel there's not enough detail on your mesh to bake a bumpmap, a small 64x64 substitute will suffice. Just create an image in Photoshop or the GIMP, set the red and green channels to 50% and the blue channel to maximum. Save as a VTF and include it in your VMT. Sample VMT file:
	$basetexture "models/bedprops/FBed/fbedmat"
	$bumpmap "models/bedprops/FBed/fbedmat_bump"

	$phong "1"
	$phongexponent "100"
	$phongboost "4"	
	$phongfresnelranges	"[.5 .7 1]"
Thu, 12 Jun 2014 05:53:21


"Ganonmaster" said ...
Thank you! I can't believe I didn't think of creating normal maps.
Thu, 12 Jun 2014 08:22:15


Another thing or 2 to consider about AO: - tf2 models have an AO bake in the diffuse but that's just their style. - many models that compile with $mostlyopaque in the qc will get the AO treatment in SFM. - Transparency and AO sometimes don't mix (in my experiences)