Exemple #1
0
//-----------------------------------------------------------------------------
// Purpose: Initializes all view systems
//-----------------------------------------------------------------------------
void CViewRender::Init( void )
{
	memset( &m_PitchDrift, 0, sizeof( m_PitchDrift ) );

	m_bDrawOverlay = false;

	m_pDrawEntities		= cvar->FindVar( "r_drawentities" );
	m_pDrawBrushModels	= cvar->FindVar( "r_drawbrushmodels" );

	beams->InitBeams();
	tempents->Init();

	m_TranslucentSingleColor.Init( "debug/debugtranslucentsinglecolor", TEXTURE_GROUP_OTHER );
	m_ModulateSingleColor.Init( "engine/modulatesinglecolor", TEXTURE_GROUP_OTHER );
	
	extern CMaterialReference g_material_WriteZ;
	g_material_WriteZ.Init( "engine/writez", TEXTURE_GROUP_OTHER );

	// FIXME:  
	QAngle angles;
	engine->GetViewAngles( angles );
	AngleVectors( angles, &m_vecLastFacing );

#if defined( REPLAY_ENABLED )
	m_pReplayScreenshotTaker = NULL;
#endif

#if defined( CSTRIKE_DLL )
	m_flLastFOV = default_fov.GetFloat();
#endif

}
Exemple #2
0
void C_VGuiScreen::OnDataChanged( DataUpdateType_t type )
{
	BaseClass::OnDataChanged( type );

	if ((type == DATA_UPDATE_CREATED) || (m_nPanelName != m_nOldPanelName))
	{
		CreateVguiScreen( PanelName() );
		m_nButtonState = 0;
	}

	// Set up the overlay material
	if (m_nOldOverlayMaterial != m_nOverlayMaterial)
	{
		m_OverlayMaterial.Shutdown();

		const char *pMaterialName = GetMaterialNameFromIndex(m_nOverlayMaterial);
		if (pMaterialName)
		{
			m_OverlayMaterial.Init( pMaterialName, TEXTURE_GROUP_VGUI );
		}
		else
		{
			m_OverlayMaterial.Init( m_WriteZMaterial );
		}
	}
}
Exemple #3
0
//-----------------------------------------------------------------------------
// Purpose: Initializes all view systems
//-----------------------------------------------------------------------------
void CViewRender::Init( void )
{
	memset( &m_PitchDrift, 0, sizeof( m_PitchDrift ) );

	m_bDrawOverlay = false;

	m_pDrawEntities		= cvar->FindVar( "r_drawentities" );
	m_pDrawBrushModels	= cvar->FindVar( "r_drawbrushmodels" );

	beams->InitBeams();
	tempents->Init();

	m_TranslucentSingleColor.Init( "debug/debugtranslucentsinglecolor", TEXTURE_GROUP_OTHER );
	m_ModulateSingleColor.Init( "engine/modulatesinglecolor", TEXTURE_GROUP_OTHER );
	m_WhiteMaterial.Init( "vgui/white", TEXTURE_GROUP_OTHER );
	
	extern CMaterialReference g_material_WriteZ;
	g_material_WriteZ.Init( "engine/writez", TEXTURE_GROUP_OTHER );

	for ( int i = 0; i < MAX_SPLITSCREEN_PLAYERS ; ++i )
	{
		g_vecRenderOrigin[ i ].Init();
		g_vecRenderAngles[ i ].Init();
		g_vecPrevRenderOrigin[ i ].Init();
		g_vecPrevRenderAngles[ i ].Init();
		g_vecVForward[ i ].Init();
		g_vecVRight[ i ].Init();
		g_vecVUp[ i ].Init();
		g_matCamInverse[ i ].Identity();
	}
}
void C_Prop_Hallucination::Spawn( void )
{
	if( !sm_OcclusionProxyMaterial.IsValid() )
	{
		sm_OcclusionProxyMaterial.Init( "engine/occlusionproxy", TEXTURE_GROUP_CLIENT_EFFECTS );
	}

	BaseClass::Spawn();
}
Exemple #5
0
//-----------------------------------------------------------------------------
// Purpose: Initializes all view systems
//-----------------------------------------------------------------------------
void CViewRender::Init( void )
{
	memset( &m_PitchDrift, 0, sizeof( m_PitchDrift ) );

	m_bDrawOverlay = false;

	m_pDrawEntities		= cvar->FindVar( "r_drawentities" );
	m_pDrawBrushModels	= cvar->FindVar( "r_drawbrushmodels" );

	beams->InitBeams();
	tempents->Init();

	m_TranslucentSingleColor.Init( "debug/debugtranslucentsinglecolor", TEXTURE_GROUP_OTHER );
	m_ModulateSingleColor.Init( "engine/modulatesinglecolor", TEXTURE_GROUP_OTHER );
	
	extern CMaterialReference g_material_WriteZ;
	g_material_WriteZ.Init( "engine/writez", TEXTURE_GROUP_OTHER );

	// FIXME:  
	QAngle angles;
	engine->GetViewAngles( angles );
	AngleVectors( angles, &m_vecLastFacing );

#if defined( REPLAY_ENABLED )
	m_pReplayScreenshotTaker = NULL;
#endif

#if defined( CSTRIKE_DLL )
	m_flLastFOV = default_fov.GetFloat();
#endif

	ITexture *depthOld = materials->FindTexture("_rt_FullFrameDepth", TEXTURE_GROUP_RENDER_TARGET);
	static int flags = TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_NOLOD | TEXTUREFLAGS_DEPTHRENDERTARGET;
	if (depthOld)
		flags = depthOld->GetFlags();

	int iW, iH;
	materials->GetBackBufferDimensions(iW, iH);
	materials->BeginRenderTargetAllocation();
	materials->CreateNamedRenderTargetTextureEx(
		"_rt_FullFrameDepth_Alt",
		iW, iH, RT_SIZE_NO_CHANGE,
		IMAGE_FORMAT_A8,
		MATERIAL_RT_DEPTH_NONE,
		flags,
		0);
	materials->EndRenderTargetAllocation();
}
//-----------------------------------------------------------------------------
// Creates, destroys a test material
//-----------------------------------------------------------------------------
void CMaterialSystemTestApp::CreateWireframeMaterial()
{
	KeyValues *pVMTKeyValues = new KeyValues( "Wireframe" );
	pVMTKeyValues->SetInt( "$vertexcolor", 1 );
	pVMTKeyValues->SetInt( "$nocull", 1 );
	pVMTKeyValues->SetInt( "$ignorez", 1 );
	m_pMaterial.Init( "__test", pVMTKeyValues );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_WeaponCombat_ChargeablePlasma::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged( updateType );

	switch( updateType )
	{
	case DATA_UPDATE_CREATED:
		// So we can update our lights
		if ( GetTeamNumber() == 1 )
			m_hMaterial.Init( "sprites/chargeball_team1" );
		else 
			m_hMaterial.Init( "sprites/chargeball_team2" );

		break;								

	case DATA_UPDATE_DATATABLE_CHANGED:
		if ( m_bCharging != m_bLastCharging )
		{
			if ( m_bCharging )
			{
				StartCharging();
			}
			else
			{
				StopCharging();
			}
		}
		break;
	};

	if (WeaponState() == WEAPON_IS_ACTIVE)
	{
		// Start thinking so we can manipulate the light
		SetNextClientThink( CLIENT_THINK_ALWAYS );
	}
	else
	{
		SetNextClientThink( CLIENT_THINK_NEVER );
	}
}
Exemple #8
0
//-----------------------------------------------------------------------------
// Purpose: Initializes all view systems
//-----------------------------------------------------------------------------
void CViewRender::Init( void )
{
    memset( &m_PitchDrift, 0, sizeof( m_PitchDrift ) );

    m_bDrawOverlay = false;

    m_pDrawEntities		= cvar->FindVar( "r_drawentities" );
    m_pDrawBrushModels	= cvar->FindVar( "r_drawbrushmodels" );

    beams->InitBeams();
    tempents->Init();

    m_TranslucentSingleColor.Init( "debug/debugtranslucentsinglecolor", TEXTURE_GROUP_OTHER );
    m_ModulateSingleColor.Init( "engine/modulatesinglecolor", TEXTURE_GROUP_OTHER );

    extern CMaterialReference g_material_WriteZ;
    g_material_WriteZ.Init( "engine/writez", TEXTURE_GROUP_OTHER );

    // FIXME:
    QAngle angles;
    engine->GetViewAngles( angles );
    AngleVectors( angles, &m_vecLastFacing );
}
void CMiniViewportEngineRenderArea::InitSceneMaterials()
{
	if ( m_ScreenBuffer )
		return;

	if ( g_pMaterialSystem->IsTextureLoaded( "_rt_LayoffResult"	) ) 
	{
		ITexture *pTexture = g_pMaterialSystem->FindTexture( "_rt_LayoffResult", TEXTURE_GROUP_RENDER_TARGET );
		m_ScreenBuffer.Init( pTexture );
	}
	else
	{
		// For now, layoff dimensions match aspect of back buffer
		int nBackBufferWidth, nBackBufferHeight;
		g_pMaterialSystem->GetBackBufferDimensions( nBackBufferWidth, nBackBufferHeight );
		float flAspect = nBackBufferWidth / (float)nBackBufferHeight;
		int nPreviewWidth = min( DEFAULT_PREVIEW_WIDTH, nBackBufferWidth );
		int nPreviewHeight = ( int )( nPreviewWidth / flAspect + 0.5f );

		g_pMaterialSystem->BeginRenderTargetAllocation();								// Begin allocating RTs which IFM can scribble into

		// LDR final result of either HDR or LDR rendering
		m_ScreenBuffer.Init( g_pMaterialSystem->CreateNamedRenderTargetTextureEx2(
			"_rt_LayoffResult", nPreviewWidth, nPreviewHeight, RT_SIZE_OFFSCREEN,
			g_pMaterialSystem->GetBackBufferFormat(), MATERIAL_RT_DEPTH_SHARED, TEXTUREFLAGS_BORDER ) );

		g_pMaterialSystem->EndRenderTargetAllocation();									// End allocating RTs which IFM can scribble into
	}

	KeyValues *pVMTKeyValues = NULL;
	pVMTKeyValues= new KeyValues( "UnlitGeneric" );
	pVMTKeyValues->SetString( "$basetexture", m_ScreenBuffer->GetName() );
	pVMTKeyValues->SetInt( "$nofog", 1 );
	m_ScreenMaterial.Init( "MiniViewportEngineRenderAreaSceneMaterial", pVMTKeyValues );
	m_ScreenMaterial->Refresh();
}
int CBulletManager::CBullet::DrawModel( int flags )
{
	if (m_flCurrAlpha < 0)
		return 0;

	if (flags & STUDIO_SHADOWDEPTHTEXTURE)
		return 0;

#ifdef __linux__
	return 0;
#endif

	if (!g_hBulletStreak.IsValid())
		g_hBulletStreak.Init( "effects/tracer1.vmt", TEXTURE_GROUP_OTHER );

	float flAlpha = 150.5f/255.0f * m_flCurrAlpha;

	Vector vecRight = Vector(0, 0, 1).Cross(m_vecDirection).Normalized();
	Vector vecCross1 = (Vector(0, 0, 1) + vecRight).Normalized();
	Vector vecCross2 = (Vector(0, 0, 1) - vecRight).Normalized();

	CMeshBuilder meshBuilder;

	CMatRenderContextPtr pRenderContext( materials );
	pRenderContext->Bind( g_hBulletStreak );
	IMesh* pMesh = pRenderContext->GetDynamicMesh();

	meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );

	DrawCross(meshBuilder, GetRenderOrigin(), vecCross1, m_vecDirection, flAlpha);
	DrawCross(meshBuilder, GetRenderOrigin(), vecCross2, m_vecDirection, flAlpha);

	meshBuilder.End(false, true);

	return 1;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CMiniViewportEngineRenderArea::ShutdownSceneMaterials()
{
	m_ScreenBuffer.Shutdown();
	m_ScreenMaterial.Shutdown();
}
//-----------------------------------------------------------------------------
// Called when the layoff texture needs to be released
//-----------------------------------------------------------------------------
void CMiniViewportEngineRenderArea::ReleaseLayoffTexture()
{
	m_ScreenBuffer.Shutdown();
	m_ScreenMaterial.Shutdown();
}
void CMaterialSystemTestApp::DestroyMaterial()
{
	m_pMaterial.Shutdown();
}
	int CBaseGrenadeProjectile::DrawModel( int flags )
	{
		// During the first half-second of our life, don't draw ourselves if he's
		// still playing his throw animation.
		// (better yet, we could draw ourselves in his hand).
		if ( GetThrower() != C_BasePlayer::GetLocalPlayer() )
		{
			if ( gpGlobals->curtime - m_flSpawnTime < 0.5 )
			{
//Tony; FIXME!
//				C_SDKPlayer *pPlayer = dynamic_cast<C_SDKPlayer*>( GetThrower() );
//				if ( pPlayer && pPlayer->m_PlayerAnimState->IsThrowingGrenade() )
//				{
//					return 0;
//				}
			}
		}

		if (!g_hGrenadeArrow.IsValid())
			g_hGrenadeArrow.Init( "particle/grenadearrow.vmt", TEXTURE_GROUP_OTHER );

		int iReturn = BaseClass::DrawModel(flags);

		C_SDKPlayer* pLocalPlayer = C_SDKPlayer::GetLocalSDKPlayer();
		if (!pLocalPlayer)
			return iReturn;

		if (pLocalPlayer == GetThrower())
			return iReturn;

		float flAppearDistance = 500;
		float flAppearDistanceSqr = flAppearDistance*flAppearDistance;

		if ((pLocalPlayer->GetAbsOrigin() - GetAbsOrigin()).LengthSqr() < flAppearDistanceSqr)
			m_flArrowGoalSize = 20;
		else
			m_flArrowGoalSize = 0;

		float flTime = C_SDKPlayer::GetLocalSDKPlayer()->GetCurrentTime() + m_flArrowSpinOffset;
		float flFrameTime = gpGlobals->frametime * C_SDKPlayer::GetLocalSDKPlayer()->GetSlowMoMultiplier();

		m_flArrowCurSize = Approach(m_flArrowGoalSize, m_flArrowCurSize, flFrameTime*100);

		if (m_flArrowCurSize == 0)
			return iReturn;

		Vector vecViewForward, vecViewRight, vecViewUp;
		pLocalPlayer->EyeVectors(&vecViewForward, &vecViewRight, &vecViewUp);

		float flSin = sin(flTime*4);
		float flCos = cos(flTime*4);

		Vector vecOrigin = GetAbsOrigin();
		Vector vecRight = vecViewRight * flSin + vecViewUp * flCos;
		Vector vecUp = vecViewRight * -flCos + vecViewUp * flSin;

		float flSize = m_flArrowCurSize;

		CMeshBuilder meshBuilder;
		CMatRenderContextPtr pRenderContext( materials );
		IMesh* pMesh = pRenderContext->GetDynamicMesh();

		pRenderContext->Bind( g_hGrenadeArrow );
		meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );

		meshBuilder.Color4f( 1, 1, 1, 1 );
		meshBuilder.TexCoord2f( 0,0, 0 );
		meshBuilder.Position3fv( (vecOrigin + (vecRight * -flSize) + (vecUp * flSize)).Base() );
		meshBuilder.AdvanceVertex();

		meshBuilder.Color4f( 1, 1, 1, 1 );
		meshBuilder.TexCoord2f( 0,1, 0 );
		meshBuilder.Position3fv( (vecOrigin + (vecRight * flSize) + (vecUp * flSize)).Base() );
		meshBuilder.AdvanceVertex();

		meshBuilder.Color4f( 1, 1, 1, 1 );
		meshBuilder.TexCoord2f( 0,1, 1 );
		meshBuilder.Position3fv( (vecOrigin + (vecRight * flSize) + (vecUp * -flSize)).Base() );
		meshBuilder.AdvanceVertex();

		meshBuilder.Color4f( 1, 1, 1, 1 );
		meshBuilder.TexCoord2f( 0,0, 1 );
		meshBuilder.Position3fv( (vecOrigin + (vecRight * -flSize) + (vecUp * -flSize)).Base() );
		meshBuilder.AdvanceVertex();

		meshBuilder.End(false, true);

		return iReturn;
	}
//------------------------------------------------------------------------------
// CExampleEffect shutdown
//------------------------------------------------------------------------------
void CExampleEffect::Shutdown( )
{
	m_Material.Shutdown();
}
void ShaderEditorInterface::OnUpdateSkymask( bool bCombineMode, int x, int y, int w, int h )
{
	SetFramebufferCopyTexOverride( NULL );

	if ( !IsSkymaskAvailable() )
		return;

	//UpdateFramebufferTexture( true );

	ITexture *pSkyMask = GetSkymaskTex();

	if ( IsErrorTexture( pSkyMask ) )
		return;

	static CMaterialReference pMatSkyDraw = NULL;
	static CMaterialReference pMatScreenRestore = NULL;
	static CMaterialReference pMatCombineMasks = NULL;
#ifdef SHADER_EDITOR_DLL_2006
	pMatSkyDraw = materials->FindMaterial( "postprocessing/skymask_fill_0", TEXTURE_GROUP_OTHER );
	pMatCombineMasks = materials->FindMaterial( "postprocessing/skymask_fill_1", TEXTURE_GROUP_OTHER );
	pMatScreenRestore = materials->FindMaterial( "postprocessing/fb_restore", TEXTURE_GROUP_OTHER );
#else
	if ( !pMatSkyDraw )
	{
		pSkyMats[ 0 ] = new KeyValues( "FILL_SKYMASK" );
		pSkyMats[ 0 ]->SetInt( "$COMBINEMODE", 0 );
		pMatSkyDraw.Init( "__sedit_skyfill", TEXTURE_GROUP_CLIENT_EFFECTS, pSkyMats[ 0 ] );
		//pMatSkyDraw->Refresh();
		//pKV->Clear();
		Assert( pMatSkyDraw );
	}
	if ( !pMatScreenRestore )
	{
		pSkyMats[ 1 ] = new KeyValues( "FULLSCREENQUAD_WRITEA" );
		pSkyMats[ 1 ]->SetString( "$BASETEXTURE", GetFBTex()->GetName() );
		pSkyMats[ 1 ]->SetInt( "$COMBINEMODE", 0 );
		pMatScreenRestore.Init( "__sedit_fbrestore", TEXTURE_GROUP_CLIENT_EFFECTS, pSkyMats[ 1 ] );
		//pMatScreenRestore->Refresh();
		//pKV->Clear();
		Assert( pMatScreenRestore );
	}
	if ( !pMatCombineMasks )
	{
		const char *skymaskname = pSkyMask->GetName();
		pSkyMats[ 2 ] = new KeyValues( "FILL_SKYMASK" );
		pSkyMats[ 2 ]->SetString( "$BASETEXTURE", skymaskname );
		pSkyMats[ 2 ]->SetInt( "$COMBINEMODE", 1 );
		pMatCombineMasks.Init( "__sedit_skyfill", TEXTURE_GROUP_CLIENT_EFFECTS, pSkyMats[ 2 ] );
		//pMatCombineMasks->Refresh();
		//pKV->Clear();
		Assert( pMatCombineMasks );
	}
#endif

	// _rt_SEdit_Skymask
	CMatRenderContextPtr pRenderContext( materials );

	IMaterial *pOperation = pMatSkyDraw;
	if ( bCombineMode )
		pOperation = pMatCombineMasks;

	int dest_width = w;
	int dest_height = h;
	float src_x1 = w - 1;
	float src_y1 = h - 1;

#ifdef SHADER_EDITOR_DLL_2006
	Frustum frustum;
	CViewSetup setup;
	setup.angles = _MainView.angles;
	setup.origin = _MainView.origin;
	setup.x = _MainView.x;
	setup.y = _MainView.y;
	setup.width = _MainView.width;
	setup.height = _MainView.height;
	setup.fov = _MainView.fov;
	setup.context = 0;
	setup.m_bOrtho = false;
	setup.m_flAspectRatio = _MainView.m_flAspectRatio;
	setup.m_vUnreflectedOrigin = setup.origin;
	render->Push3DView( setup, 0, false, NULL, frustum );
#endif

	pRenderContext->PushRenderTargetAndViewport( NULL );
	//pRenderContext->Viewport( x, y, w, h );
	//pRenderContext->DepthRange( 0, 1 );
	//MaterialHeightClipMode_t hClipLast = pRenderContext->GetHeightClipMode();
	//pRenderContext->SetHeightClipMode( MATERIAL_HEIGHTCLIPMODE_DISABLE );
	//const bool bEnableClipping = pRenderContext->EnableClipping( false );

#ifndef SHADER_EDITOR_DLL_2006
	UpdateScreenEffectTexture( GetFBTex(), x, y, w, h );
	//pRenderContext->CopyRenderTargetToTexture( GetFBTex() );
#endif

	// do ops
	pRenderContext->DrawScreenSpaceRectangle( pOperation,
		x, y, dest_width, dest_height,
		x, y, src_x1, src_y1,
		w, h );

	// store to mask
	UpdateScreenEffectTexture( pSkyMask, x, y, w, h, true );
	//pRenderContext->CopyRenderTargetToTexture( pSkyMask );

	// restore fb
#ifndef SHADER_EDITOR_DLL_2006
	pRenderContext->DrawScreenSpaceRectangle( pMatScreenRestore,
		x, y, w, h,
		x, y, w - 1, h - 1,
		w, h );
#endif

	//pRenderContext->EnableClipping( bEnableClipping );
	//pRenderContext->SetHeightClipMode( hClipLast );
	pRenderContext->PopRenderTargetAndViewport();

#ifdef SHADER_EDITOR_DLL_2006
	render->PopView( frustum );
#endif
}