Tutorials

Refracting Textures



The Source engine has a lot of amazing looking shaders, and my personal favourite is the refraction shader. So without further ado, here is a simple tutorial on creating refracting materials in Source.

Create your texture in Photoshop or another paint application. I created this blue glass texture by using the Render Clouds filter and a Glass filter on top. I then used the Offset filter to make it tile properly. Once finished save it into the targa format as bglass.tga.

news post image


Create your normal map with the Nvidia normal map tool. Try to bring out the areas that you wish to be more bumped by playing with the colour settings in the plugin. Once complete, save it into the tga format as bglass_normal.tga.

news post image

Next step is to create your Du/Dv map. This part is essential to making your texture refract properly. Make sure you use the settings illustrated below in my example screenshot, improper Du/Dv settings can make for an ugly looking texture. Save this file into tga as bglass_dudv.tga

news post image

Drag and drop the files onto VTEX and compile them as you would normally. When it comes time to create the VMT, use these settings illustrated below.

news post image

Especially important is the REFRACTTINTTEXTURE line, without that, your texture will not show through and you will see only the refraction and normal, no colour. Instead of REFRACTTINTTEXTURE you can use REFRACTTINT and choose a colour to tint the transparent refraction instead if you wish. Also you can add this following code:

"Proxies"
	{
		"TextureScroll"
		{
			"texturescrollvar" "$bumptransform"
			"texturescrollrate" 3
			"texturescrollangle" -90
		}
	}


after the REFRACTINTTEXTURE line to make your texture scroll, which is useful if you are making a waterfall texture. Once your VMT is ready to go load up Hammer.

In Hammer texture whatever you want with your new material and tie the brush to a func_brush or func_breakable. Under Render Mode set it to Additive. This is optional, some textures look better without changing the Render Mode. Place a cubemap nearby and build your map! Make sure once you are ingame to buildcubemaps or else your texture may look purple or have purple checkers.

news post image

This concludes my tutorial on refracting textures, hope you learned something.
-longshanks

View comments ( 47 )

Back to top