ToonMaterial/toon_fragment.cg

ToonMaterial/toon_fragment.cg
//**************************************************************************/
// Copyright (c) 2008 Autodesk, Inc.
// All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//**************************************************************************/
// DESCRIPTION:
// CREATED: October 2008
//**************************************************************************/
// This is C9E4f_toonShading from "The Cg Tutorial" (Addison-Wesley, ISBN
// 0321194969) by Randima Fernando and Mark J. Kilgard. See page 248.
void main(float diffuseLight : TEXCOORD0,
float specularLight: TEXCOORD1,
float edge : TEXCOORD2,
out float4 color : COLOR,
uniform float4 Kd,
uniform float4 Ks,
uniform sampler1D diffuseRamp,
uniform sampler1D specularRamp,
uniform sampler1D edgeRamp)
{
// Apply step functions
diffuseLight = tex1D(diffuseRamp, diffuseLight).x;
specularLight = tex1D(specularRamp,specularLight).x;
edge = tex1D(edgeRamp, edge).x;
// Compute the final color
color = edge * (Kd * diffuseLight +
Ks * specularLight);
}