Illustrative/Cartoon Shader Team Fortress Style

Hey there guys (especially Aras),

Could some of you tell me if it’s possible to reproduce the shader used on the characters in Team Fortress 2? I have posted this question over at my Unity Artist forum but haven’t gotten too many replies since we are mostly “artists” over there.

http://www.theunityartist.com/forum/index.php?topic=139.0

There is a PDF you can download which describes the shader in detail. I’d really like to know if that can be reproduced with Unity’s shader lab.

Thomas

+1
I would also like someone with more technical knowledge to take a look at this.

This is actually not that different from the skin shader I wrote on the Wiki.

I’d think you should be able to get something a bit like this if you tweak the various falloff ramps there.

Anyone reproduced something like this yet?

You can make a ramp shader quite simply by using a look up texture in your lighting function to ‘change’ the lighting based on the ‘brightness’ of the light at a point. If you modify the lighting function to be like this (this example uses the light prepass renderer):

sampler2D _LightingRamp;
			inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
			{
				float lum = Luminance( light.rgb );
				float newIllumination = tex2D(_LightingRamp, float2( lum, 0)).r;
				half3 spec = light.a * s.Gloss;
				half4 c;
				c.rgb = (s.Albedo * newIllumination + newIllumination * spec);
				c.a = s.Alpha + Luminance(spec);
				return c;
			}

This is a pretty simple example where it only supports white resultant light. What it does it is calculates the luminosity of the light at each pixel, samples from a texture lookup at this value of illumination (this will be your ramp texture for the light gradient). Then uses this remapped lighting for the surface illumination. You could remultiply the ramp by some normalized light color if you want coloured lighting.

Here is how the result looks on a simple sphere with a simple ramp:

495161--17438--$Screen shot 2011-02-10 at 5.59.05 PM.png