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 );
}
void CHLSL_Solver_ReadSemantics::OnVarInit( const WriteContext_FXC &context )
{
	const ResourceType_t &type = GetResourceType();
	const char *varname = GetResourceTypeName( type );
	CHLSL_Var *target = GetTargetVar( 0 );
	char tmp[MAXTARGC];
	Q_snprintf( tmp, MAXTARGC, "In.%s", varname );
	target->SetName( tmp, true );
}
void CHLSL_Solver_Callback::OnVarInit( const WriteContext_FXC &context )
{
	CHLSL_Var *target = GetTargetVar( 0 );
	char tmp[MAXTARGC];

	Q_snprintf( tmp, MAXTARGC, "g_cData_%s", szName );

	target->SetName( tmp, true );
}
void CHLSL_Solver_Invert::OnWriteFXC( bool bIsPixelShader, WriteContext_FXC &context )
{
	CHLSL_Var *tg = GetTargetVar( 0 );
	tg->DeclareMe(context);
	CHLSL_Var *src1 = GetSourceVar( 0 );

	char tmp[MAXTARGC];
	Q_snprintf( tmp, MAXTARGC, "%s = 1.0f - %s;\n",
		tg->GetName(),src1->GetName() );
	context.buf_code.PutString( tmp );
}
void CHLSL_Solver_VectorRefract::OnWriteFXC( bool bIsPixelShader, WriteContext_FXC &context )
{
	CHLSL_Var *tg = GetTargetVar( 0 );
	tg->DeclareMe(context);
	CHLSL_Var *src1 = GetSourceVar( 0 );
	CHLSL_Var *src2 = GetSourceVar( 1 );
	CHLSL_Var *src3 = GetSourceVar( 2 );

	char tmp[MAXTARGC];
	Q_snprintf( tmp, MAXTARGC, "%s = refract( %s, %s, %s );\n",
		tg->GetName(),src1->GetName(),src2->GetName(),src3->GetName() );
	context.buf_code.PutString( tmp );
}
void CHLSL_Solver_PP_RT::OnExecuteCode( const RunCodeContext &context )
{
	CHLSL_Var *pT = GetTargetVar(0);

	if ( IsErrorTexture( pT->GetTexture() ) )
		pT->SetTexture( materials->FindTexture( m_szRTName, TEXTURE_GROUP_OTHER ) );

	if ( context.IsUsingPreview() )
	{
		context.pRenderContext->PushRenderTargetAndViewport( pT->GetTexture() );
		BlitRTRect( context );
		context.pRenderContext->PopRenderTargetAndViewport();
	}
}
bool CNodeRandom::CreateSolvers(GenericShaderData *ShaderData)
{
	CJack *pJ_Out = GetJack_Out( 0 );
	const int res = pJ_Out->GetResourceType();

	CHLSL_Var *tg = pJ_Out->AllocateVarFromSmartType();
	tg->MakeConstantOnly();

	CHLSL_Solver_Random *solver = new CHLSL_Solver_Random( GetUniqueIndex() );
	solver->SetResourceType( res );
	solver->AddTargetVar( tg );
	solver->SetState( m_iNumComponents, m_flValue_Min, m_flValue_Max );
	AddSolver( solver );

	return true;
}
bool CNodeLightscale::CreateSolvers(GenericShaderData *ShaderData)
{
    CJack *pJ_Out = GetJack_Out( 0 );
    const int res = pJ_Out->GetResourceType();

    SetAllocating( false );
    CHLSL_Var *tg = pJ_Out->AllocateVarFromSmartType();
    tg->MakeConstantOnly();

    CHLSL_Solver_Lightscale *solver = new CHLSL_Solver_Lightscale( GetUniqueIndex() );
    solver->SetResourceType( res );
    solver->AddTargetVar( tg );
    solver->SetState( m_iLightScale );
    AddSolver( solver );
    return true;
}
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 );
}
bool CNodeConstant::CreateSolvers(GenericShaderData *ShaderData)
{
	CJack *pJ_Out = GetJack_Out( 0 );

	const int res = pJ_Out->GetResourceType();

	CHLSL_Var *tg = pJ_Out->AllocateVarFromSmartType();
	tg->MakeConstantOnly();

	CHLSL_Solver_Constant *solver = new CHLSL_Solver_Constant( GetUniqueIndex() );
	solver->SetResourceType( res );
	solver->AddTargetVar( tg );
	solver->SetComponentInfo( m_iChannelInfo );
	AddSolver( solver );

	return true;
}
Пример #11
0
bool CNodeVSInput::CreateSolvers(GenericShaderData *ShaderData)
{
	for ( int i = 0; i < GetNumJacks_Out(); i++ )
	{
		CJack *pJ = GetJack_Out( i );
		if ( !pJ->GetNumBridgesConnected() )
			continue;

		const int res = pJ->GetResourceType();
		CHLSL_Var *var = pJ->AllocateVarFromSmartType();
		var->MakeConstantOnly();

		CHLSL_Solver_ReadSemantics *solver = new CHLSL_Solver_ReadSemantics( GetUniqueIndex() );
		solver->SendVSSetup( curSetup );
		solver->SetResourceType( res );
		solver->AddTargetVar( var );
		AddSolver( solver );
	}

	SmartCreateDummySolver();
	return true;
}
bool CNodeUtility_Assign::CreateSolvers(GenericShaderData *ShaderData)
{
	if ( GetNumJacks_In_Connected() < 2 )
		return false;

	CJack *pJ1 = GetJack_In( 0 );
	CJack *pJ2 = GetJack_In( 1 );
	CJack *pJ_Out = GetJack_Out( 0 );
	if ( !pJ1->GetTemporaryVarTarget_End()->CanBeOverwritten() )
	{
		SetOutputsUndefined();
		OnShowSolverErrored();
		return false;
	}


	const int res = pJ_Out->GetResourceType();

	CHLSL_Var *tg = pJ1->GetTemporaryVarTarget_End_Smart( pJ1->GetSmartType(), true );
	Assert( tg );
	if ( !tg->CanBeOverwritten() )
		tg = NULL;
	if ( !( tg->GetType() & pJ1->GetSmartType() ) )
		tg = NULL;

	SetAllocating( !tg );
	if ( !tg )
		tg = pJ_Out->AllocateVarFromSmartType();
	pJ_Out->SetTemporaryVarTarget( tg );

	CHLSL_Solver_Utility_Assign *solver = new CHLSL_Solver_Utility_Assign( GetUniqueIndex() );
	solver->SetResourceType( res );
	solver->AddSourceVar( pJ1->GetTemporaryVarTarget_End() );
	solver->AddSourceVar( pJ2->GetTemporaryVarTarget_End() );
	solver->AddTargetVar( tg );
	AddSolver( solver );

	return true;
}
bool CNodeBumpBasis::CreateSolvers(GenericShaderData *ShaderData)
{
	for ( int i = 0; i < GetNumJacks_Out(); i++ )
	{
		CJack *pJCur = GetJack_Out(i);
		if ( !pJCur->GetNumBridgesConnected() && i != 0 )
			continue;

		const int res = pJCur->GetResourceType();

		CHLSL_Var *tg = pJCur->AllocateVarFromSmartType();
		tg->MakeConstantOnly();

		CHLSL_Solver_BumpBasis *solver = new CHLSL_Solver_BumpBasis( GetUniqueIndex() );
		solver->SetResourceType( res );
		solver->AddTargetVar( tg );
		solver->SetState( i );
		AddSolver( solver );
	}

	return !!GetNumSolvers();
}
Пример #14
0
bool CNodeCallback::CreateSolvers(GenericShaderData *ShaderData)
{
	if ( !szCallbackName || !Q_strlen( szCallbackName ) || !iNumComponents )
		return false;
	int target = shaderEdit->FindCallback( szCallbackName );
	if ( target < 0 )
		return false;

	CJack *pJ_Out = GetJack_Out( 0 );

	const int res = pJ_Out->GetResourceType();

	SetAllocating( true );
	CHLSL_Var *tg = pJ_Out->AllocateVarFromSmartType();
	tg->MakeConstantOnly();

	CHLSL_Solver_Callback *solver = new CHLSL_Solver_Callback( GetUniqueIndex() );
	solver->SetState( target, szCallbackName, iNumComponents );
	solver->SetResourceType( res );
	solver->AddTargetVar( tg );
	AddSolver( solver );

	return true;
}
void CHLSL_Solver_Array::OnVarInit( const WriteContext_FXC &context )
{
    CHLSL_Var *target = GetTargetVar( 0 );
    target->SetName( "NOT_VALIDATED_YET", true );
}