<?xml version="1.0" encoding="iso-8859-1"?>
<xsi_file type="ShaderCompound" name="Gain" category="Image Processing" author="Joey Ponthieux" formatversion="1.1" compoundversion="1.2" color="10991252">
	<description><![CDATA["Gain" Shader Compound v1.2

Author: Joey Ponthieux
Version: 1.2
Date: 08-23-08
Email: joey.p@cox.net


The purpose of this compound is to provide advanced Level/Gain control for any 
Color (RGBA) parameter. 


BASIC CONTROLS
Input will take any RGB/RGBA color or texture parameter.

Color Gain is a multiplication factor which affects the INPUT RGB value.

Alpha Gain is a multiplication factor which affects the INPUT Alpha value.

Alpha_State provides multiple methods for  Alpha Gain modification.

Output wil pass a combined RGBA Color/Texture value which will be "modified" 
by the Color Gain/Alpha Gain factors.


CONTROL SPECIFICS

GENERAL
All Gain values are on a scale of 0-1. Ex. 0 = 0% Gain, 1 = 100% Gain.

Color(RGB) is unified and driven as a single Color Gain level. 

Alpha is driven as a single Gain level.

Color Gain and Alpha Gain factors can be driven by separate input. 

Color and Alpha output are re-combined for typical input to any RGBA Parameter.

Default values for Color Gain and Alpha Gain are 1,1. When set to default values,
no changes will be made to any gain level. However, different alpha state methods
may still affect the alpha appearance regardless whether gain is set to the default
of 1. This is however an interpretation change and not a level change, usually the 
result of inversion. 


COLOR GAIN
Acceptable values are within the range of 0-1. 0=0%, 1=100%.

100% Color Gain sets the INPUT Gain to the equivalant of 100% Color. 

0% Color Gain reduces the INPUT Gain to a 0 value, or Black.

Color Gain processing is the same regardless what Alpha State is used


ALPHA GAIN
Acceptable values are within the range of 0-1. 0=0%, 1=100%.

Alpha Gain values are directly relative to the active Alpha State.


ALPHA STATE
The Alpha State is used to manipulate Alpha Gain in different ways depending
on the nature of the shader structure being passed to Gain.

Due to the inherent legacy issues present in XSI, Alpha is intepreted differently
in some cases, depending on what the Alpha is being used to manipulate.  In 
general Alpha is considered 1.0 Positive in a scalar range of 0-1. That is, Alpha
at 1 is white or opaque and it's corresponding RGB values are visible. Alpha at 0
is black or transparent and it's corresponding RGB values are invisible. Any Alpha 
value greater than 0 means that some or all of the corresponding RGB value 
relative to the non-zero Alpha is visible, but transparent. 

However, in XSI, Transparency as a Shader parameter, and not a definition, is 
just the opposite, a 1.0 Transparency value is opaque white, which means that 
the corresponding RGB values are invisible. Therefore when using Alpha to 
drive Transparency one must be aware that positive Alpha values result in
negative Transparency. The two are 180 degrees out of phase, but this is a 
legacy issue inhertied directly from Softimage 3D. This can cause unusual
problems, at least with the user's interpetation of what is a positive alpha 
composite and what is not. With time this is typically learned and overcome 
via experience.

The purpose of this Gain shader is to provide an intermediary means of altering
the Alpha to suit different interpretations. The Alpha State options are intended 
to simplify how the user inteprets Alpha Gain within the Gain shader. It provides 
5 different methods for changing the way Alpha is intepreted/processed, thus
modifying the Alpha to be used in different ways upon output. The 5 Alpha States 
are described as follows:


SI_Standard(Default)
This works using the same model as the standard Softimage shading model. If 
you are familiar with the Alpha to Tranparency behavior within XSI, this will adhere
to all of the standard rules you are familiar with. Further, if your intent is to affect 
Color and not to affect the Alpha in any way, you should use this option with Alpha
Gain set to 1. 

If Alpha Gain is set to 1 with this option, it will basically act as a pass through. 
Whatever Alpha is fed to Gain will remain as is. 

If the Alpha input to Gain is 0, modifying the Alpha Gain will have no affect. 
This is due to the fact that Alpha input is non-existant, or 0, therefore providing 
no input alpha level to be altered.

If the Alpha input is 1, then Alpha Gain of 0 will cause the Alpha to be reduced to
0, or nothing.

If the Alpha input is less than 1 or greater than 0, the effect of Alpha Gain will be 
to change the value from whatever the standing input value is, to 0. That is, if the 
input Alpha is 0.5, then Alpha Gain of 0 to 1 will change the Alpha from 0 to 0.5 
respectively, or:
	Alpha Gain	Alpha Value
	0	=	0
	1	=	0.5


SI_Inverted
This behaves the same as SI_Standard, except that it inverts the Alpha. 

If Alpha Gain is set to 0 with this option, it will basically act as a pass through. 
Whatever Alpha is fed to Gain will remain as is. 

If the Alpha input to Gain is 0, modifying the Alpha Gain will have no affect. 

If the Alpha input is 1, then Apha Gain of 1 will cause the Alpha to be decreased.

If the Alpha input is less than 1 or greater than 0, the effect of Alpha Gain will be 
to change the value from whatever the standing input value is, to 0. That is, if the 
input Alpha is 0.5, then Alpha Gain of 0 to 1 will change the Alpha from 0.5 to 0 
respectively, or:
	Alpha Gain	Alpha Value
	0	=	0.5
	1	=	0


Normalized
This behaves more as one would expect Alpha to be modified, attempting to 
maintain a 1:1 relationship between Alpha Input, Alpha Gain, Alpha Output, and 
any visual expectation of how Alpha may affect Transparency.

Normalization accomplishes two things. First it attempts to apply the proper 
inversions to accomplish a 1:1 Alpha to Transparency ratio, if using Alpha to
drive Transparency. Second, it attemps to clamp the input values so that 
modifying the Alpha Gain from 1 to 0, in that direction, results in the input values,
whatever their origination levels are, to gradually increase to an output of 1 
within the 1-0 gain range.

If Alpha Gain is set to 0 with this option, no matter what the Input Alpha is, it will 
be set to 1.

If the Alpha input to Gain is 0, modifying the Alpha Gain will have no affect. 

If the Alpha input to Gain is 1, then Apha Gain of 0 will cause the Alpha to be 
increased to 1, similar to that of SI_Inverted.

If the Alpha input is less than 1 or greater than 0, the effect of Alpha Gain will be to
change the value from whatever the standing input value is, to 1. This is opposite 
the behavior of SI_Standard or SI_Inverted. That is, if the input Alpha is 0.5, then 
Alpha Gain of 0 to 1 will change the Alpha from 1 to .5 respectively, or:
	Alpha Gain	Alpha Value
	0	=	1
	1	=	.5


Replace Standard
This replaces whatever the input Alpha is with the Alpha Gain value as defined. It 
will not modify input, it simply strips it out and replaces it with new values as set 
by the user. This version uses the same Alpha polarity as SI_Standard.
	Alpha Gain	Alpha Value
	0	=	0
	1	=	1

Replace Inverted
This replaces whatever the input Alpha is with the Alpha Gain value as defined. It 
will not modify input, it simply strips it out and replaces it with new values as set 
by the user. This version uses the same Alpha polarity as SI_Inverted.
	Alpha Gain	Alpha Value
	0	=	1
	1	=	0




WARNING: Use at own risk! No guarantees and no warranties, explicit or 
otherwise, will be provided with the use of this shader.

 
NOTES
This shader appears to handle RGBA->RGB just as any other shader does, There
appears to be no adverse affects of providing an RGBA channel to an RGB
channel which possesses no Alpha.]]></description>
	<definition>
		<nodes>
			<node type="shader" progid="Softimage.sib_color_math_basic.1" index="0">
				<param name="Name" type="31" ><![CDATA[Color_Math_Basic]]></param>
				<param name="input1.red" type="4" value="1.000000"></param>
				<param name="input1.green" type="4" value="1.000000"></param>
				<param name="input1.blue" type="4" value="1.000000"></param>
				<param name="input1.alpha" type="4" value="1.000000"></param>
				<param name="input2.red" type="4" value="1.000000"></param>
				<param name="input2.green" type="4" value="1.000000"></param>
				<param name="input2.blue" type="4" value="1.000000"></param>
				<param name="input2.alpha" type="4" value="0.000000"></param>
				<param name="op" type="3" value="2"></param>
				<param name="alpha" type="11" value="true"></param>
				<datablob category="ui_infos">
					<prop name="posx">860</prop>
					<prop name="posy">-45</prop>
					<prop name="state">ConnectedOnly</prop>
				</datablob>
			</node>
			<node type="shader" progid="Softimage.sib_color_combine.1" index="1">
				<param name="Name" type="31" ><![CDATA[RGBA_combine]]></param>
				<param name="red" type="4" value="1.000000"></param>
				<param name="green" type="4" value="1.000000"></param>
				<param name="blue" type="4" value="1.000000"></param>
				<param name="alpha" type="4" value="1.000000"></param>
				<datablob category="ui_infos">
					<prop name="posx">610</prop>
					<prop name="posy">23</prop>
					<prop name="state">ConnectedOnly</prop>
				</datablob>
			</node>
			<node type="shader" progid="Softimage.sib_color_multi_switch.1" index="2">
				<param name="Name" type="31" ><![CDATA[Color_Multi_Switch]]></param>
				<param name="default.red" type="4" value="0.000000"></param>
				<param name="default.green" type="4" value="0.000000"></param>
				<param name="default.blue" type="4" value="0.000000"></param>
				<param name="default.alpha" type="4" value="0.000000"></param>
				<param name="switch" type="3" value="0"></param>
				<param name="value0" type="3" value="0"></param>
				<param name="input0.red" type="4" value="0.000000"></param>
				<param name="input0.green" type="4" value="0.000000"></param>
				<param name="input0.blue" type="4" value="0.000000"></param>
				<param name="input0.alpha" type="4" value="0.000000"></param>
				<param name="value1" type="3" value="1"></param>
				<param name="input1.red" type="4" value="0.000000"></param>
				<param name="input1.green" type="4" value="0.000000"></param>
				<param name="input1.blue" type="4" value="0.000000"></param>
				<param name="input1.alpha" type="4" value="0.000000"></param>
				<param name="value2" type="3" value="2"></param>
				<param name="input2.red" type="4" value="0.000000"></param>
				<param name="input2.green" type="4" value="0.000000"></param>
				<param name="input2.blue" type="4" value="0.000000"></param>
				<param name="input2.alpha" type="4" value="0.000000"></param>
				<param name="value3" type="3" value="3"></param>
				<param name="input3.red" type="4" value="0.000000"></param>
				<param name="input3.green" type="4" value="0.000000"></param>
				<param name="input3.blue" type="4" value="0.000000"></param>
				<param name="input3.alpha" type="4" value="0.000000"></param>
				<param name="value4" type="3" value="4"></param>
				<param name="input4.red" type="4" value="0.000000"></param>
				<param name="input4.green" type="4" value="0.000000"></param>
				<param name="input4.blue" type="4" value="0.000000"></param>
				<param name="input4.alpha" type="4" value="0.000000"></param>
				<param name="value5" type="3" value="5"></param>
				<param name="input5.red" type="4" value="0.000000"></param>
				<param name="input5.green" type="4" value="0.000000"></param>
				<param name="input5.blue" type="4" value="0.000000"></param>
				<param name="input5.alpha" type="4" value="0.000000"></param>
				<param name="value6" type="3" value="6"></param>
				<param name="input6.red" type="4" value="0.000000"></param>
				<param name="input6.green" type="4" value="0.000000"></param>
				<param name="input6.blue" type="4" value="0.000000"></param>
				<param name="input6.alpha" type="4" value="0.000000"></param>
				<param name="value7" type="3" value="7"></param>
				<param name="input7.red" type="4" value="0.000000"></param>
				<param name="input7.green" type="4" value="0.000000"></param>
				<param name="input7.blue" type="4" value="0.000000"></param>
				<param name="input7.alpha" type="4" value="0.000000"></param>
				<datablob category="ui_infos">
					<prop name="portgroupconnectedonlystates">21,0;24,0;27,0;30,0;33,0;</prop>
					<prop name="posx">1168</prop>
					<prop name="posy">-117</prop>
					<prop name="state">ConnectedOnly</prop>
				</datablob>
				<comment type="node" state="maximized" wordwrap="true" autoresize="true" background="0" background_alpha="0.000000" title="14876671" title_text="0" offsetx="2" offsety="142" sizex="868" sizey="45"><![CDATA[This functions as the master switch separating "alpha gain modification" from "alpha gain replacement".  Cases 0 & 1 are modifier processes, cases 2-4 are replacement processes.

NOTE:  All Color Gain methods are identical, only Alpha Gain is processed differently.]]></comment>
			</node>
			<node type="shader" progid="Softimage.sib_interp_linear.1" index="3">
				<param name="Name" type="31" ><![CDATA[Change_range]]></param>
				<param name="input" type="4" value="1.000000"></param>
				<param name="oldrange_min" type="4" value="0.000000"></param>
				<param name="oldrange_max" type="4" value="1.000000"></param>
				<param name="newrange_min" type="4" value="1.000000"></param>
				<param name="newrange_max" type="4" value="0.562000"></param>
				<datablob category="ui_infos">
					<prop name="posx">103</prop>
					<prop name="posy">212</prop>
					<prop name="state">ConnectedOnly</prop>
				</datablob>
				<comment type="node" state="maximized" wordwrap="true" autoresize="true" background="0" background_alpha="0.000000" title="14876671" title_text="0" offsetx="1" offsety="68" sizex="707" sizey="19"><![CDATA[This node takes the Alpha input and uses it as a threshold reference. It then uses the Alpha Gain to drive the input alpha value from "input" to 1.]]></comment>
			</node>
			<node type="shader" progid="Softimage.sib_color_invert.1" index="4">
				<param name="Name" type="31" ><![CDATA[Invert]]></param>
				<param name="input.red" type="4" value="1.000000"></param>
				<param name="input.green" type="4" value="1.000000"></param>
				<param name="input.blue" type="4" value="1.000000"></param>
				<param name="input.alpha" type="4" value="1.000000"></param>
				<param name="alpha" type="11" value="true"></param>
				<datablob category="ui_infos">
					<prop name="posx">-225</prop>
					<prop name="posy">243</prop>
					<prop name="state">Collapsed</prop>
				</datablob>
			</node>
			<node type="shader" progid="Softimage.sib_color_split.1" index="5">
				<param name="Name" type="31" ><![CDATA[RGBA_Split1]]></param>
				<param name="input.red" type="4" value="1.000000"></param>
				<param name="input.green" type="4" value="1.000000"></param>
				<param name="input.blue" type="4" value="1.000000"></param>
				<param name="input.alpha" type="4" value="1.000000"></param>
				<datablob category="ui_infos">
					<prop name="posx">-61</prop>
					<prop name="posy">333</prop>
					<prop name="state">ConnectedOnly</prop>
				</datablob>
			</node>
			<node type="shader" progid="Softimage.sib_color_math_basic.1" index="6">
				<param name="Name" type="31" ><![CDATA[Color_Math_Basic2]]></param>
				<param name="input1.red" type="4" value="0.000000"></param>
				<param name="input1.green" type="4" value="0.000000"></param>
				<param name="input1.blue" type="4" value="0.000000"></param>
				<param name="input1.alpha" type="4" value="0.000000"></param>
				<param name="input2.red" type="4" value="1.000000"></param>
				<param name="input2.green" type="4" value="1.000000"></param>
				<param name="input2.blue" type="4" value="1.000000"></param>
				<param name="input2.alpha" type="4" value="1.000000"></param>
				<param name="op" type="3" value="2"></param>
				<param name="alpha" type="11" value="false"></param>
				<datablob category="ui_infos">
					<prop name="portgroupnormalstates">4,0;</prop>
					<prop name="posx">859</prop>
					<prop name="posy">54</prop>
					<prop name="state">ConnectedOnly</prop>
				</datablob>
				<comment type="node" state="maximized" wordwrap="true" autoresize="true" background="0" background_alpha="0.000000" title="14876671" title_text="0" offsetx="0" offsety="72" sizex="1018" sizey="32"><![CDATA[Unlike SI_Standard and SI_Inverted, this compositing multiplier requiers the input Color to be channeled to Input 2. Apply to Alpha is turned off in this node and it allows for the Alpha to be relpaced rather than modified, by inheriting the modified Alpha via Input 1.]]></comment>
			</node>
			<node type="shader" progid="Softimage.sib_scalar_multi_switch.1" index="7">
				<param name="Name" type="31" ><![CDATA[Scalar_Multi_Switch]]></param>
				<param name="default" type="4" value="0.000000"></param>
				<param name="switch" type="3" value="0"></param>
				<param name="value0" type="3" value="0"></param>
				<param name="input0" type="4" value="1.000000"></param>
				<param name="value1" type="3" value="1"></param>
				<param name="input1" type="4" value="0.000000"></param>
				<param name="value2" type="3" value="2"></param>
				<param name="input2" type="4" value="0.000000"></param>
				<param name="value3" type="3" value="3"></param>
				<param name="input3" type="4" value="1.000000"></param>
				<param name="value4" type="3" value="4"></param>
				<param name="input4" type="4" value="0.000000"></param>
				<param name="value5" type="3" value="5"></param>
				<param name="input5" type="4" value="0.000000"></param>
				<param name="value6" type="3" value="6"></param>
				<param name="input6" type="4" value="0.000000"></param>
				<param name="value7" type="3" value="7"></param>
				<param name="input7" type="4" value="0.000000"></param>
				<datablob category="ui_infos">
					<prop name="portgroupconnectedonlystates">24,0;27,0;30,0;33,0;</prop>
					<prop name="posx">339</prop>
					<prop name="posy">89</prop>
					<prop name="state">ConnectedOnly</prop>
				</datablob>
				<comment type="node" state="maximized" wordwrap="true" autoresize="true" background="0" background_alpha="0.000000" title="14876671" title_text="0" offsetx="1" offsety="137" sizex="1554" sizey="19"><![CDATA[This serves as the core alpha pre-processing switch and defines the basic nature of each Case's processing paradigm. Cases 0 & 3 adhere to standard methods of alpha interpretation, Cases 1 & 4 adhere to inverted methods of alpha interpretation, and Case 3 adheres to the "normalized"  method of alpha interpretation.]]></comment>
			</node>
			<node type="shader" progid="Softimage.sib_scalar_invert.1" index="8">
				<param name="Name" type="31" ><![CDATA[Scalar_Invert]]></param>
				<param name="input" type="4" value="1.000000"></param>
				<datablob category="ui_infos">
					<prop name="posx">-229</prop>
					<prop name="posy">118</prop>
					<prop name="state">ConnectedOnly</prop>
				</datablob>
			</node>
			<node type="shader" progid="Softimage.sib_color_to_scalars.1" index="9">
				<param name="Name" type="31" ><![CDATA[Color_to_Scalars]]></param>
				<param name="input.red" type="4" value="1.000000"></param>
				<param name="input.green" type="4" value="1.000000"></param>
				<param name="input.blue" type="4" value="1.000000"></param>
				<param name="input.alpha" type="4" value="1.000000"></param>
				<datablob category="ui_infos">
					<prop name="posx">-96</prop>
					<prop name="posy">246</prop>
					<prop name="state">Collapsed</prop>
				</datablob>
			</node>
		</nodes>
		<exposed_ports>
			<port index="0" portname="input1" username="input" displayname="input">
				<secondaryport index="4" portname="input"></secondaryport>
				<secondaryport index="6" portname="input2"></secondaryport>
			</port>
			<port index="1" portname="red" username="color_gain" displayname="color gain">
				<secondaryport index="1" portname="green"></secondaryport>
				<secondaryport index="1" portname="blue"></secondaryport>
			</port>
			<port index="7" portname="input0" username="alpha_gain" displayname="alpha gain">
				<secondaryport index="8" portname="input"></secondaryport>
				<secondaryport index="7" portname="input3"></secondaryport>
				<secondaryport index="3" portname="input"></secondaryport>
			</port>
			<port index="2" portname="switch" username="alpha_state" displayname="alpha state">
				<secondaryport index="7" portname="switch"></secondaryport>
			</port>
			<port index="2" portname="" username="out" displayname="out"></port>
		</exposed_ports>
		<connections>
			<cnx from_node="0" from_port="" to_node="2" to_port="input0"> </cnx>
			<cnx from_node="0" from_port="" to_node="2" to_port="input1"> </cnx>
			<cnx from_node="1" from_port="" to_node="0" to_port="input2"> </cnx>
			<cnx from_node="1" from_port="" to_node="6" to_port="input1"> </cnx>
			<cnx from_node="3" from_port="" to_node="7" to_port="input2"> </cnx>
			<cnx from_node="4" from_port="" to_node="5" to_port="input"> </cnx>
			<cnx from_node="4" from_port="" to_node="9" to_port="input"> </cnx>
			<cnx from_node="6" from_port="" to_node="2" to_port="input3"> </cnx>
			<cnx from_node="6" from_port="" to_node="2" to_port="input4"> </cnx>
			<cnx from_node="6" from_port="" to_node="2" to_port="input2"> </cnx>
			<cnx from_node="7" from_port="" to_node="1" to_port="alpha"> </cnx>
			<cnx from_node="8" from_port="" to_node="7" to_port="input1"> </cnx>
			<cnx from_node="8" from_port="" to_node="7" to_port="input4"> </cnx>
			<cnx from_node="9" from_port="a" to_node="3" to_port="newrange_max"> </cnx>
		</connections>
		<layout>
			<item type="input" name="input" ppgvis="1" portvis="1"> </item>
			<item type="input" name="color_gain" min="0" max="1" ppgvis="1" portvis="1"> </item>
			<item type="input" name="alpha_gain" min="0" max="1" ppgvis="1" portvis="1"> </item>
			<item type="input" name="alpha_state" min="0" max="4" ppgvis="1" portvis="1">
				<enum string="SI Standard" value="0"> </enum>
				<enum string="SI Inverted" value="1"> </enum>
				<enum string="Normalized" value="2"> </enum>
				<enum string="Replace Standard" value="3"> </enum>
				<enum string="Replace Inverted" value="4"> </enum>
			</item>
			<item type="output" name="out" ppgvis="1" portvis="0"> </item>
		</layout>
		<ppglogic lang=""><![CDATA[]]></ppglogic>
	</definition>
</xsi_file>
