<!--
===========================================================================
Copyright 2015 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.
===========================================================================
-->

<fragment uiName="floatMath" name="floatMath" type="plumbing" class="ShadeFragment" version="1.0">
	<description><![CDATA[Float math shade fragment]]></description>
	<properties>
		<float name="floatA" />
		<float name="floatB" />
		<int name="operation" />
	</properties>
	<values>
		<float name="floatA" value="1.0" />
		<float name="floatB" value="0.0" />
		<int name="operation" value="1" />
	</values>
	<outputs>
		<float  name="outFloat" />
	</outputs>
	<implementation>
	<implementation render="OGSRenderer" language="Cg" lang_version="2.1">
		<function_name val="floatMath" />
		<source>
		<![CDATA[
float floatMath(float floatA, float floatB, int operation)
{
	float resultFloat = floatA;

	if (operation==0)
	{
		resultFloat += floatB ;
	}
	else if (operation==1)
	{
		resultFloat -= floatB ;
	}
	else if (operation==2)
	{
		resultFloat *= floatB ;
	}
	else if (operation==3)
	{
		resultFloat = floatB != 0.0 ? (floatA/floatB) : 0.0;
	}
	else if (operation==4)
	{
		if ( floatA > floatB )
		{
			resultFloat = floatB;
		}
	}
	else if (operation==5)
	{
		if ( floatA < floatB )
		{
			resultFloat = floatB;
		}
	}
	else if (operation==6)
	{
		resultFloat = pow( floatA, floatB );
	}

	return resultFloat;
}
		]]>
		</source>
	</implementation>
	<implementation render="OGSRenderer" language="HLSL" lang_version="11.0">
		<function_name val="floatMath" />
		<source>
		<![CDATA[
float floatMath(float floatA, float floatB, int operation)
{
	float resultFloat = floatA;

	if (operation==0)
	{
		resultFloat += floatB ;
	}
	else if (operation==1)
	{
		resultFloat -= floatB ;
	}
	else if (operation==2)
	{
		resultFloat *= floatB ;
	}
	else if (operation==3)
	{
		resultFloat = floatB != 0.0 ? (floatA/floatB) : 0.0;
	}
	else if (operation==4)
	{
		if ( floatA > floatB )
		{
			resultFloat = floatB;
		}
	}
	else if (operation==5)
	{
		if ( floatA < floatB )
		{
			resultFloat = floatB;
		}
	}
	else if (operation==6)
	{
		resultFloat = pow( floatA, floatB );
	}

	return resultFloat;
}
		]]>
		</source>
		</implementation>
		<implementation render="OGSRenderer" language="GLSL" lang_version="3.0">
			<function_name val="floatMath" />
			<source>
				<![CDATA[
float floatMath(float floatA, float floatB, int operation)
{
	float resultFloat = floatA;

	if (operation==0)
	{
		resultFloat += floatB ;
	}
	else if (operation==1)
	{
		resultFloat -= floatB ;
	}
	else if (operation==2)
	{
		resultFloat *= floatB ;
	}
	else if (operation==3)
	{
		resultFloat = floatB != 0.0 ? (floatA/floatB) : 0.0;
	}
	else if (operation==4)
	{
		if ( floatA > floatB )
		{
			resultFloat = floatB;
		}
	}
	else if (operation==5)
	{
		if ( floatA < floatB )
		{
			resultFloat = floatB;
		}
	}
	else if (operation==6)
	{
		resultFloat = pow( floatA, floatB );
	}

	return resultFloat;
}
		]]>
		</source>
	</implementation>
	</implementation>
</fragment>
