Relief Macro

This macro has two modes. One is to add shading to an image with an alpha mask. For example, add shading to a Text operator. To do this, use only one input, and keep the mode on Shading. The second mode is to turn is to turn mode to Relief, and add a second background image. The first image will create highlights and shading on the background image.

 

image Relief(image Input, image BG,
		int method,
		float depth,
		float lightDirection,
		float lightHeight=30.064,
		float detail,
		float sharpness,
		float mix,
)
{
Bytes1 = Bytes(Input, 2);
DetailControl = Blur(Bytes1, detail, xPixels, 1, "gauss", "gauss", "rgba");
Emboss1 = Emboss(DetailControl, depth, lightDirection, lightHeight);
SharpnessControl = Blur(Emboss1, sharpness, xPixels, 1, "gauss", "gauss", "rgba");
Bytes2 = Bytes(SharpnessControl, 4);
Brightness1 = Brightness(Bytes2, 2);
IMult1 = IMult(Input, Brightness1, 1, mix, 0);
IMult2 = IMult(BG, Brightness1, 0, mix, 0);
Bytes3 = Bytes(IMult1, Input.bytes);
Bytes4 = Bytes(IMult2, BG.bytes);
SwitchMatte1 = SwitchMatte(Bytes3, Input, 0, "a", 0, 0);
SwitchMatte2 = SwitchMatte(Bytes4, BG, 0, "a", 0, 0);
Select1 = Select(method+1, SwitchMatte1, SwitchMatte2, 0, 0);
}