void CHLSL_Solver_Subtract::Render( Preview2DContext &c )
{
	int type0 = GetSourceVar(0)->GetType();
	int type1 = GetSourceVar(1)->GetType();

	SetUVParamBySourceVar( NPSOP_CALC_SUBTRACT, 0, 0 );
	SetUVParamBySourceVar( NPSOP_CALC_SUBTRACT, 1, 1 );

	IMaterialVar *var_2 = pEditorRoot->GetUVTargetParam( NPSOP_CALC_SUBTRACT, 2 );
	IMaterialVar *var_3 = pEditorRoot->GetUVTargetParam( NPSOP_CALC_SUBTRACT, 3 );
	var_2->SetVecValue( 0, 0, 0, 0 );
	var_3->SetVecValue( 0, 0, 0, 0 );

	if ( type0 != type1 )
	{
		int maxSlots = ::GetSlotsFromTypeFlag( max( type0, type1 ) );
		Assert( maxSlots > 1 );
		bool target_is_0 = ( type0 < type1 );

		IMaterialVar *var_target = target_is_0 ? var_2 : var_3;
		var_target->SetVecValue( maxSlots >= 2, maxSlots >= 3, maxSlots >= 4, 0 );
	}

	CNodeView::RenderSingleSolver( c, pEditorRoot->GetOperatorMaterial( NPSOP_CALC_SUBTRACT ) );
	UpdateTargetVarToReflectMapIndex( 0 );
}
void CHLSL_Solver_VCompression::OnWriteFXC( bool bIsPixelShader, WriteContext_FXC &context )
{
	char tmp[MAXTARGC];
	for ( int i = 0; i < this->GetNumTargetVars(); i++ )
		GetTargetVar(i)->DeclareMe( context, true );

	const bool bUseTangent = m_iType == CNodeVCompression::COMPRESSION_MODE_NORMAL_TANGENT;

	CHLSL_Var *pVar_Normal = GetSourceVar( 0 );
	CHLSL_Var *pVar_Tangent = bUseTangent ? GetSourceVar( 1 ) : NULL;

	switch ( m_iType )
	{
	default:
		AssertMsg( 0, "unimplemented compression type in solver" );
	case CNodeVCompression::COMPRESSION_MODE_NORMAL:
		Q_snprintf( tmp, MAXTARGC, "DecompressVertex_Normal( %s, %s );\n",
			pVar_Normal->GetName(), GetTargetVar(0)->GetName() );
		break;
	case CNodeVCompression::COMPRESSION_MODE_NORMAL_TANGENT:
		Q_snprintf( tmp, MAXTARGC, "DecompressVertex_NormalTangent( %s, %s, %s, %s );\n",
			pVar_Normal->GetName(), pVar_Tangent->GetName(),
			GetTargetVar(0)->GetName(), GetTargetVar(1)->GetName() );
		break;
	}

	context.buf_code.PutString( tmp );
}
void CHLSL_Solver_Subtract::OnWriteFXC( bool bIsPixelShader, WriteContext_FXC &context )
{
	CHLSL_Var *tg = GetTargetVar( 0 );
	tg->DeclareMe(context);
	CHLSL_Var *src1 = GetSourceVar( 0 );
	CHLSL_Var *src2 = GetSourceVar( 1 );

	char tmp[MAXTARGC];
	Q_snprintf( tmp, MAXTARGC, "%s = %s - %s;\n",
		tg->GetName(),src1->GetName(),src2->GetName() );
	context.buf_code.PutString( tmp );
}
void CHLSL_Solver_Array::OnVarInit_PostStep()
{
    CHLSL_Var *src_0 = GetSourceVar( 0 );
    CHLSL_Var *src_1 = (m_iSize_y > 1) ? GetSourceVar( 1 ) : NULL;

    CHLSL_Var *target = GetTargetVar( 0 );
    char tmp[MAXTARGC];
    Q_snprintf( tmp, sizeof( tmp ), "g_cArray_%i[%s]", GetData().iNodeIndex, src_0->GetName() );
    if ( src_1 != NULL )
    {
        char szAppend[MAX_PATH];
        Q_snprintf( szAppend, sizeof( szAppend ), "[%s]", src_1->GetName() );
        Q_strcat( tmp, szAppend, sizeof( tmp ) );
    }
    //Q_strcat( tmp, "", sizeof( tmp ) );
    target->SetName( tmp, true );
}
void CHLSL_Solver_Clip::OnWriteFXC( bool bIsPixelShader, WriteContext_FXC &context )
{
	CHLSL_Var *pvar = GetSourceVar( 0 );

	char tmp[MAXTARGC];
	Q_snprintf( tmp, sizeof( tmp ), "clip( %s );\n", pvar->GetName() );

	context.buf_code.PutString( tmp );
}