Cleanup is going to take awhile, so the site is back up but editing has been disabled.

Custom Breakable Glass

From HalfLife 2 Knowledge Base

Jump to: navigation, search

By KillerMonkey PM me with specific questions


Contents


Disclaimer

Holy crap, this is a very rough draft of my custom breakable glass, I believe I spent 20 minutes on this lol, well here is how I did it!


Custom Glass

I decompiled the VTF's of glasswindow018a.vtf, glasswindow018a_mask.vtf, glasswindow018b.vtf, and glasswindow018b_mask.vtf which are located in the Glass folder of the "SourceMaterials.gcf"


I then merged that with my existing window texture that I was planning on making a breakable window:
My Old Texture
Enlarge
My Old Texture
Then with some photoshop magic I just interjected the decompiled TGA files into the background of my sweet window texture.

Unbroken Glass Broken Glass


All them files
Enlarge
All them files

Don't forget to make the masks for the two images too, this tells where the reflective parts of the glass are!! Although not necessary, make sure you don't include them in your VMT later if you decide you don't want them. Now compile all your new textures as you can see I have layed them out neatly in my folder :)


Okay now we have all our TGA's setup now compile them with VTEX and they should be located in your proper mod folder's materials section! Now lets make our VMT's


Making the VMT's

This is the most important part of this whole tutorial because this is where the beef of the custom breakable glass is! You can basically just COPY these VMT's and change the names, and your glass will break perfectly!


This is the VMT for the unbroken glass
"LightmappedGeneric" { "$basetexture" "Glass/window_quad_glassa" "$envmap" "env_cubemap" "$surfaceprop" "glass" // See those masks are useful! "$envmapmask" "glass/window_quad_glassa_mask" "$translucent" 1 "$multipass" 1 "$nocull" 1 // This is where you tell the engine what texture to use as the broken glass "$crackmaterial" "glass/window_quad_glassb" "LightmappedGeneric_dx6" { // This takes into account the alpha channel of the basetexture // which we can't modulate against under dx7 since envmap // happens in a separate pass "$envmaptint" "[0.5 0.5 0.5]" } }


This is for the broken glass texture
"ShatteredGlass" { "$basetexture" "Glass/window_quad_glassb" "$detail" "Glass/window_quad_glassb" "$envmap" "env_cubemap" "$surfaceprop" "glass" "$envmapmask" "glass/window_quad_glassb_mask" "$translucent" 1 "$unlitfactor" 0.0 "ShatteredGlass_DX8" { "$unlitfactor" 0.3 // This is roughly equal to the average value of envmapmask of the unbroken texture "$envmaptint" "{201 201 201}" } // On the low end, envmaptint + lightmap tint both use the average alpha value "ShatteredGlass_DX7" { // This is roughly equal to the average value of alpha channel of the unbroken basetexture "$lightmaptint" "{128 128 128}" // This is roughly equal to the average value of envmapmask of the unbroken texture // times the average value of the alpha value of the unbroken base texture "$envmaptint" "{100 100 100}" } "$nocull" 1 "Proxies" { "BreakableSurface" { } } }


Now throw those babies in with your compiles textures, make your shattered glass as normal in Hammer except use your custom unbroken texture. Now here is the result!!!


Unbroken InGame Shot

Broken InGame Shot

Totally Broken InGame Shot

Personal tools