本文整理汇总了C++中fvf::TL::set方法的典型用法代码示例。如果您正苦于以下问题:C++ TL::set方法的具体用法?C++ TL::set怎么用?C++ TL::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fvf::TL
的用法示例。
在下文中一共展示了TL::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reset_light_marker
void CRenderTarget::reset_light_marker( bool bResetStencil)
{
dwLightMarkerID = 5;
if (bResetStencil)
{
u32 Offset;
float _w = float(Device.dwWidth);
float _h = float(Device.dwHeight);
u32 C = color_rgba (255,255,255,255);
float eps = 0;
float _dw = 0.5f;
float _dh = 0.5f;
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set (-_dw, _h-_dh, eps, 1.f, C, 0, 0);
pv++;
pv->set (-_dw, -_dh, eps, 1.f, C, 0, 0);
pv++;
pv->set (_w-_dw, _h-_dh, eps, 1.f, C, 0, 0);
pv++;
pv->set (_w-_dw, -_dh, eps, 1.f, C, 0, 0);
pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
RCache.set_Element (s_occq->E[2] );
RCache.set_Geometry (g_combine );
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
}
示例2: float
void CRenderTarget::phase_downsamp ()
{
// DON'T DO THIS!!!
//IDirect3DSurface9 *source, *dest;
//rt_Position->pSurface->GetSurfaceLevel(0, &source);
//rt_half_depth->pSurface->GetSurfaceLevel(0, &dest);
//HW.pDevice->StretchRect(source, NULL, dest, NULL, D3DTEXF_POINT);
//Fvector2 p0,p1;
u32 Offset = 0;
u_setrt( rt_half_depth,0,0,0/*HW.pBaseZB*/ );
FLOAT ColorRGBA[4] = {0.0f, 0.0f, 0.0f, 0.0f};
HW.pContext->ClearRenderTargetView(rt_half_depth->pRT, ColorRGBA);
u32 w = Device.dwWidth;
u32 h = Device.dwHeight;
if (RImplementation.o.ssao_half_data)
{
set_viewport(HW.pDevice, Device.dwWidth/2, Device.dwHeight/2);
w /= 2;
h /= 2;
}
RCache.set_Stencil (FALSE);
{
Fmatrix m_v2w; m_v2w.invert (Device.mView );
// Fill VB
float scale_X = float(w) / float(TEX_jitter);
float scale_Y = float(h) / float(TEX_jitter);
// Fill vertex buffer
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set ( -1, 1, 0, 1, 0, 0, scale_Y ); pv++;
pv->set ( -1, -1, 0, 0, 0, 0, 0 ); pv++;
pv->set ( 1, 1, 1, 1, 0, scale_X, scale_Y ); pv++;
pv->set ( 1, -1, 1, 0, 0, scale_X, 0 ); pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
// Draw
RCache.set_Element (s_ssao->E[1] );
RCache.set_Geometry (g_combine );
RCache.set_c ("m_v2w", m_v2w );
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
if (RImplementation.o.ssao_half_data)
set_viewport(HW.pDevice, Device.dwWidth, Device.dwHeight);
}
示例3: DrawPrimitiveTL
void CDrawUtilities::DrawPrimitiveTL(D3DPRIMITIVETYPE pt, u32 pc, FVF::TL* vertices, int vc, BOOL bCull, BOOL bCycle)
{
// fill VB
_VertexStream* Stream = &RCache.Vertex;
u32 vBase, dwNeed=(bCycle)?vc+1:vc;
FVF::TL* pv = (FVF::TL*)Stream->Lock(dwNeed,vs_TL->vb_stride,vBase);
for(int k=0; k<vc; k++,pv++)
pv->set (vertices[k]);
if (bCycle) pv->set(*(pv-vc));
Stream->Unlock(dwNeed,vs_TL->vb_stride);
if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_NONE);
DU_DRAW_DP (pt,vs_TL,vBase,pc);
if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_CCW);
}
示例4: DrawSelectionRect
void CDrawUtilities::DrawSelectionRect(const Ivector2& m_SelStart, const Ivector2& m_SelEnd){
VERIFY( Device.b_is_Ready );
// fill VB
_VertexStream* Stream = &RCache.Vertex;
u32 vBase;
FVF::TL* pv = (FVF::TL*)Stream->Lock(4,vs_TL->vb_stride,vBase);
pv->set(m_SelStart.x*SCREEN_QUALITY, m_SelStart.y*SCREEN_QUALITY, m_SelectionRect,0.f,0.f); pv++;
pv->set(m_SelStart.x*SCREEN_QUALITY, m_SelEnd.y*SCREEN_QUALITY, m_SelectionRect,0.f,0.f); pv++;
pv->set(m_SelEnd.x*SCREEN_QUALITY, m_SelEnd.y*SCREEN_QUALITY, m_SelectionRect,0.f,0.f); pv++;
pv->set(m_SelEnd.x*SCREEN_QUALITY, m_SelStart.y*SCREEN_QUALITY, m_SelectionRect,0.f,0.f); pv++;
Stream->Unlock(4,vs_TL->vb_stride);
// Render it as triangle list
DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_NONE);
DU_DRAW_SH(dxRenderDeviceRender::Instance().m_SelectionShader);
DU_DRAW_DP(D3DPT_TRIANGLEFAN,vs_TL,vBase,2);
DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_CCW);
}
示例5: reset_light_marker
void CRenderTarget::reset_light_marker( bool bResetStencil)
{
dwLightMarkerID = 5;
if (bResetStencil)
{
RCache.set_ColorWriteEnable (FALSE);
u32 Offset;
float _w = float(Device.dwWidth);
float _h = float(Device.dwHeight);
u32 C = color_rgba (255,255,255,255);
float eps = EPS_S;
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set (eps, float(_h+eps), eps, 1.f, C, 0, 0); pv++;
pv->set (eps, eps, eps, 1.f, C, 0, 0); pv++;
pv->set (float(_w+eps), float(_h+eps), eps, 1.f, C, 0, 0); pv++;
pv->set (float(_w+eps), eps, eps, 1.f, C, 0, 0); pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
RCache.set_CullMode (CULL_NONE );
// Clear everything except last bit
RCache.set_Stencil (TRUE,D3DCMP_ALWAYS,dwLightMarkerID,0x00,0xFE, D3DSTENCILOP_ZERO, D3DSTENCILOP_ZERO, D3DSTENCILOP_ZERO);
//RCache.set_Stencil (TRUE,D3DCMP_ALWAYS,dwLightMarkerID,0x00,0xFF, D3DSTENCILOP_ZERO, D3DSTENCILOP_ZERO, D3DSTENCILOP_ZERO);
RCache.set_Element (s_occq->E[1] );
RCache.set_Geometry (g_combine );
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
/*
u32 Offset;
float _w = float(Device.dwWidth);
float _h = float(Device.dwHeight);
u32 C = color_rgba (255,255,255,255);
float eps = 0;
float _dw = 0.5f;
float _dh = 0.5f;
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set (-_dw, _h-_dh, eps, 1.f, C, 0, 0); pv++;
pv->set (-_dw, -_dh, eps, 1.f, C, 0, 0); pv++;
pv->set (_w-_dw, _h-_dh, eps, 1.f, C, 0, 0); pv++;
pv->set (_w-_dw, -_dh, eps, 1.f, C, 0, 0); pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
RCache.set_Element (s_occq->E[2] );
RCache.set_Geometry (g_combine );
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
*/
}
}
示例6: float
void CRenderTarget::u_stencil_optimize (BOOL common_stencil)
{
VERIFY (RImplementation.o.nvstencil);
RCache.set_ColorWriteEnable (FALSE);
u32 Offset;
float _w = float(Device.dwWidth);
float _h = float(Device.dwHeight);
u32 C = color_rgba (255,255,255,255);
float eps = EPS_S;
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set (eps, float(_h+eps), eps, 1.f, C, 0, 0); pv++;
pv->set (eps, eps, eps, 1.f, C, 0, 0); pv++;
pv->set (float(_w+eps), float(_h+eps), eps, 1.f, C, 0, 0); pv++;
pv->set (float(_w+eps), eps, eps, 1.f, C, 0, 0); pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
RCache.set_CullMode (CULL_NONE );
if (common_stencil) RCache.set_Stencil (TRUE,D3DCMP_LESSEQUAL,dwLightMarkerID,0xff,0x00); // keep/keep/keep
RCache.set_Element (s_occq->E[1] );
RCache.set_Geometry (g_combine );
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
示例7: float
void CRenderTarget::phase_smap_spot_tsh (light* L)
{
VERIFY(!"Implement clear of the buffer for tsh!");
VERIFY (RImplementation.o.Tshadows);
RCache.set_ColorWriteEnable ();
if (IRender_Light::OMNIPART == L->flags.type) {
// omni-part
//CHK_DX (HW.pDevice->Clear( 0L, NULL, D3DCLEAR_TARGET, 0xffffffff, 1.0f, 0L));
FLOAT ColorRGBA[4] = {1.0f, 1.0f, 1.0f, 1.0f};
HW.pContext->ClearRenderTargetView(RCache.get_RT(), ColorRGBA);
} else {
// real-spot
// Select color-mask
ref_shader shader = L->s_spot;
if (!shader) shader = s_accum_spot;
RCache.set_Element (shader->E[ SE_L_FILL ] );
// Fill vertex buffer
Fvector2 p0,p1;
u32 Offset;
u32 C = color_rgba (255,255,255,255);
float _w = float(L->X.S.size);
float _h = float(L->X.S.size);
float d_Z = EPS_S;
float d_W = 1.f;
p0.set (.5f/_w, .5f/_h);
p1.set ((_w+.5f)/_w, (_h+.5f)/_h );
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set (EPS, float(_h+EPS), d_Z, d_W, C, p0.x, p1.y); pv++;
pv->set (EPS, EPS, d_Z, d_W, C, p0.x, p0.y); pv++;
pv->set (float(_w+EPS), float(_h+EPS), d_Z, d_W, C, p1.x, p1.y); pv++;
pv->set (float(_w+EPS), EPS, d_Z, d_W, C, p1.x, p0.y); pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
RCache.set_Geometry (g_combine);
// draw
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
}
示例8: float
void CRenderTarget::u_stencil_optimize (eStencilOptimizeMode eSOM)
{
// TODO: DX10: remove half pixel offset?
VERIFY (RImplementation.o.nvstencil);
//RCache.set_ColorWriteEnable (FALSE);
u32 Offset;
float _w = float(Device.dwWidth);
float _h = float(Device.dwHeight);
u32 C = color_rgba (255,255,255,255);
float eps = 0;
float _dw = 0.5f;
float _dh = 0.5f;
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set (-_dw, _h-_dh, eps, 1.f, C, 0, 0);
pv++;
pv->set (-_dw, -_dh, eps, 1.f, C, 0, 0);
pv++;
pv->set (_w-_dw, _h-_dh, eps, 1.f, C, 0, 0);
pv++;
pv->set (_w-_dw, -_dh, eps, 1.f, C, 0, 0);
pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
RCache.set_Element (s_occq->E[1] );
switch(eSOM)
{
case SO_Light:
StateManager.SetStencilRef(dwLightMarkerID);
break;
case SO_Combine:
StateManager.SetStencilRef(0x01);
break;
default:
VERIFY(!"CRenderTarget::u_stencil_optimize. switch no default!");
}
RCache.set_Geometry (g_combine );
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
示例9:
// end
void CRenderTarget::phase_scene_end ()
{
disable_aniso ();
if (!RImplementation.o.albedo_wo) return;
// transfer from "rt_Accumulator" into "rt_Color"
u_setrt ( rt_Color, 0, 0, HW.pBaseZB );
RCache.set_CullMode ( CULL_NONE );
RCache.set_Stencil (TRUE,D3DCMP_LESSEQUAL,0x01,0xff,0x00); // stencil should be >= 1
if (RImplementation.o.nvstencil) u_stencil_optimize (FALSE);
RCache.set_Stencil (TRUE,D3DCMP_LESSEQUAL,0x01,0xff,0x00); // stencil should be >= 1
RCache.set_ColorWriteEnable ();
// common calc for quad-rendering
u32 Offset;
u32 C = color_rgba (255,255,255,255);
float _w = float (Device.dwWidth);
float _h = float (Device.dwHeight);
Fvector2 p0,p1;
p0.set (.5f/_w, .5f/_h);
p1.set ((_w+.5f)/_w, (_h+.5f)/_h );
float d_Z = EPS_S, d_W = 1.f;
// Fill vertex buffer
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set (EPS, float(_h+EPS), d_Z, d_W, C, p0.x, p1.y); pv++;
pv->set (EPS, EPS, d_Z, d_W, C, p0.x, p0.y); pv++;
pv->set (float(_w+EPS), float(_h+EPS), d_Z, d_W, C, p1.x, p1.y); pv++;
pv->set (float(_w+EPS), EPS, d_Z, d_W, C, p1.x, p0.y); pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
// if (stencil>=1 && aref_pass) stencil = light_id
RCache.set_Element (s_accum_mask->E[SE_MASK_ALBEDO]); // masker
RCache.set_Geometry (g_combine);
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
示例10: DrawObjectAxis
void CDrawUtilities::DrawObjectAxis(const Fmatrix& T, float sz, BOOL sel)
{
VERIFY( Device.b_is_Ready );
_VertexStream* Stream = &RCache.Vertex;
Fvector c,r,n,d;
float w = T.c.x*Device.mFullTransform._14 + T.c.y*Device.mFullTransform._24 + T.c.z*Device.mFullTransform._34 + Device.mFullTransform._44;
if (w<0) return; // culling
float s = w*sz;
Device.mFullTransform.transform(c,T.c);
r.mul(T.i,s); r.add(T.c); Device.mFullTransform.transform(r);
n.mul(T.j,s); n.add(T.c); Device.mFullTransform.transform(n);
d.mul(T.k,s); d.add(T.c); Device.mFullTransform.transform(d);
c.x = (float)iFloor(_x2real(c.x)); c.y = (float)iFloor(_y2real(-c.y));
r.x = (float)iFloor(_x2real(r.x)); r.y = (float)iFloor(_y2real(-r.y));
n.x = (float)iFloor(_x2real(n.x)); n.y = (float)iFloor(_y2real(-n.y));
d.x = (float)iFloor(_x2real(d.x)); d.y = (float)iFloor(_y2real(-d.y));
u32 vBase;
FVF::TL* pv = (FVF::TL*)Stream->Lock(6,vs_TL->vb_stride,vBase);
pv->set (c.x,c.y,0,1, 0xFF222222, 0,0); pv++;
pv->set (d.x,d.y,0,1, sel?0xFF0000FF:0xFF000080, 0,0); pv++;
pv->set (c.x,c.y,0,1, 0xFF222222, 0,0); pv++;
pv->set (r.x,r.y,0,1, sel?0xFFFF0000:0xFF800000, 0,0); pv++;
pv->set (c.x,c.y,0,1, 0xFF222222, 0,0); pv++;
pv->set (n.x,n.y,0,1, sel?0xFF00FF00:0xFF008000, 0,0);
Stream->Unlock(6,vs_TL->vb_stride);
// Render it as line list
DU_DRAW_RS (D3DRS_SHADEMODE,D3DSHADE_GOURAUD);
DU_DRAW_SH(dxRenderDeviceRender::Instance().m_WireShader);
DU_DRAW_DP (D3DPT_LINELIST,vs_TL,vBase,3);
DU_DRAW_RS (D3DRS_SHADEMODE,SHADE_MODE);
m_Font->SetColor(sel?0xFF000000:0xFF909090);
m_Font->Out(r.x,r.y,"x");
m_Font->Out(n.x,n.y,"y");
m_Font->Out(d.x,d.y,"z");
m_Font->SetColor(sel?0xFFFFFFFF:0xFF000000);
m_Font->Out(r.x-1,r.y-1,"x");
m_Font->Out(n.x-1,n.y-1,"y");
m_Font->Out(d.x-1,d.y-1,"z");
}
示例11: Render
//.........这里部分代码省略.........
switch(RELATION_REGISTRY().GetRelationType(others_inv_owner, our_inv_owner))
{
case ALife::eRelationTypeEnemy:
C = C_ON_ENEMY; break;
case ALife::eRelationTypeNeutral:
C = C_ON_NEUTRAL; break;
case ALife::eRelationTypeFriend:
C = C_ON_FRIEND; break;
}
if (fuzzyShowInfo>0.5f){
CStringTable strtbl ;
F->SetColor (subst_alpha(C,u8(iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f))));
F->OutNext ("%s", *strtbl.translate(others_inv_owner->Name()) );
F->OutNext ("%s", *strtbl.translate(others_inv_owner->CharacterInfo().Community().id()) );
}
}
fuzzyShowInfo += SHOW_INFO_SPEED*Device.fTimeDelta;
}
else
if (l_pI && our_inv_owner && RQ.range < 2.0f*our_inv_owner->inventory().GetTakeDist())
{
if (fuzzyShowInfo>0.5f){
F->SetColor (subst_alpha(C,u8(iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f))));
F->OutNext ("%s",l_pI->Name/*Complex*/());
}
fuzzyShowInfo += SHOW_INFO_SPEED*Device.fTimeDelta;
}
}
else
{
if (E && (E->GetfHealth()>0))
{
if (pCurEnt && GameID() == GAME_SINGLE){
if (GameID() == GAME_DEATHMATCH) C = C_ON_ENEMY;
else{
if (E->g_Team() != pCurEnt->g_Team()) C = C_ON_ENEMY;
else C = C_ON_FRIEND;
};
if (RQ.range >= recon_mindist() && RQ.range <= recon_maxdist()){
float ddist = (RQ.range - recon_mindist())/(recon_maxdist() - recon_mindist());
float dspeed = recon_minspeed() + (recon_maxspeed() - recon_minspeed())*ddist;
fuzzyShowInfo += Device.fTimeDelta/dspeed;
}else{
if (RQ.range < recon_mindist()) fuzzyShowInfo += recon_minspeed()*Device.fTimeDelta;
else fuzzyShowInfo = 0;
};
if (fuzzyShowInfo>0.5f){
clamp(fuzzyShowInfo,0.f,1.f);
int alpha_C = iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f);
u8 alpha_b = u8(alpha_C & 0x00ff);
F->SetColor (subst_alpha(C,alpha_b));
F->OutNext ("%s",*RQ.O->cName());
}
}
};
};
}else{
fuzzyShowInfo -= HIDE_INFO_SPEED*Device.fTimeDelta;
}
clamp(fuzzyShowInfo,0.f,1.f);
}
//отрендерить кружочек или крестик
if(!m_bShowCrosshair){
// actual rendering
u32 vOffset;
FVF::TL* pv = (FVF::TL*)RCache.Vertex.Lock(4,hGeom.stride(),vOffset);
float size_x = float(Device.dwWidth) * di_size;
float size_y = float(Device.dwHeight) * di_size;
size_y = size_x;
float w_2 = Device.fWidth_2;
float h_2 = Device.fHeight_2;
// Convert to screen coords
float cx = (PT.p.x+1)*w_2;
float cy = (PT.p.y+1)*h_2;
pv->set (cx - size_x, cy + size_y, C, 0, 1); ++pv;
pv->set (cx - size_x, cy - size_y, C, 0, 0); ++pv;
pv->set (cx + size_x, cy + size_y, C, 1, 1); ++pv;
pv->set (cx + size_x, cy - size_y, C, 1, 0); ++pv;
// unlock VB and Render it as triangle LIST
RCache.Vertex.Unlock(4,hGeom.stride());
RCache.set_Shader (hShader);
RCache.set_Geometry (hGeom);
RCache.Render (D3DPT_TRIANGLELIST,vOffset,0,4,0,2);
}else{
//отрендерить прицел
HUDCrosshair.cross_color = C;
HUDCrosshair.OnRender ();
}
}
示例12: tan
void CRenderTarget::phase_ssao ()
{
u32 Offset = 0;
FLOAT ColorRGBA[4] = {0.0f, 0.0f, 0.0f, 0.0f};
HW.pDevice->ClearRenderTargetView(rt_ssao_temp->pRT, ColorRGBA);
// low/hi RTs
if( !RImplementation.o.dx10_msaa )
{
u_setrt ( rt_ssao_temp,0,0,0/*HW.pBaseZB*/ );
}
else
{
u_setrt ( rt_ssao_temp, 0, 0, 0/*RImplementation.Target->rt_MSAADepth->pZRT*/ );
}
RCache.set_Stencil (FALSE);
/*RCache.set_Stencil (TRUE,D3DCMP_LESSEQUAL,0x01,0xff,0x00); // stencil should be >= 1
if (RImplementation.o.nvstencil) {
u_stencil_optimize (CRenderTarget::SO_Combine);
RCache.set_ColorWriteEnable ();
}*/
// Compute params
Fmatrix m_v2w; m_v2w.invert (Device.mView );
float fSSAONoise = 2.0f;
fSSAONoise *= tan(deg2rad(67.5f));
fSSAONoise /= tan(deg2rad(Device.fFOV));
float fSSAOKernelSize = 150.0f;
fSSAOKernelSize *= tan(deg2rad(67.5f));
fSSAOKernelSize /= tan(deg2rad(Device.fFOV));
// Fill VB
float scale_X = float(Device.dwWidth) * 0.5f / float(TEX_jitter);
float scale_Y = float(Device.dwHeight) * 0.5f / float(TEX_jitter);
u32 _w = Device.dwWidth/2;
u32 _h = Device.dwHeight/2;
set_viewport(HW.pDevice, _w, _h);
// Fill vertex buffer
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set ( -1, 1, 0, 1, 0, 0, scale_Y ); pv++;
pv->set ( -1, -1, 0, 0, 0, 0, 0 ); pv++;
pv->set ( 1, 1, 1, 1, 0, scale_X, scale_Y ); pv++;
pv->set ( 1, -1, 1, 0, 0, scale_X, 0 ); pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
// Draw
RCache.set_Element (s_ssao->E[0] );
RCache.set_Geometry (g_combine );
RCache.set_c ("m_v2w", m_v2w );
RCache.set_c ("ssao_noise_tile_factor", fSSAONoise );
RCache.set_c ("ssao_kernel_size", fSSAOKernelSize );
RCache.set_c ("resolution", float(_w), float(_h), 1.0f / float(_w), 1.0f / float(_h) );
if( !RImplementation.o.dx10_msaa )
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
else
{
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
/*RCache.set_Stencil( TRUE, D3DCMP_EQUAL, 0x01, 0x81, 0 );
RCache.Render ( D3DPT_TRIANGLELIST,Offset,0,4,0,2);
if( RImplementation.o.dx10_msaa_opt )
{
RCache.set_Element( s_ssao_msaa[0]->E[0] );
RCache.set_Stencil( TRUE, D3DCMP_EQUAL, 0x81, 0x81, 0 );
RCache.Render ( D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
else
{
for( u32 i = 0; i < RImplementation.o.dx10_msaa_samples; ++i )
{
RCache.set_Element ( s_ssao_msaa[i]->E[0] );
StateManager.SetSampleMask ( u32(1) << i );
RCache.set_Stencil ( TRUE, D3DCMP_EQUAL, 0x81, 0x81, 0 );
RCache.Render ( D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
StateManager.SetSampleMask( 0xffffffff );
}*/
//RCache.set_Stencil( FALSE, D3DCMP_EQUAL, 0x01, 0xff, 0 );
}
set_viewport(HW.pDevice, Device.dwWidth, Device.dwHeight);
RCache.set_Stencil (FALSE);
}
示例13: float
void CRenderTarget::accum_direct_f (u32 sub_phase)
{
// Select target
if (SE_SUN_LUMINANCE==sub_phase) {
accum_direct_lum ();
return ;
}
phase_accumulator ();
u_setrt (rt_Generic_0,NULL,NULL,HW.pBaseZB);
// *** assume accumulator setted up ***
light* fuckingsun = (light*)RImplementation.Lights.sun_adapted._get() ;
// Common calc for quad-rendering
u32 Offset;
u32 C = color_rgba (255,255,255,255);
float _w = float (Device.dwWidth);
float _h = float (Device.dwHeight);
Fvector2 p0,p1;
p0.set (.5f/_w, .5f/_h);
p1.set ((_w+.5f)/_w, (_h+.5f)/_h );
float d_Z = EPS_S, d_W = 1.f;
// Common constants (light-related)
Fvector L_dir,L_clr; float L_spec;
L_clr.set (fuckingsun->color.r,fuckingsun->color.g,fuckingsun->color.b);
L_spec = u_diffuse2s (L_clr);
Device.mView.transform_dir (L_dir,fuckingsun->direction);
L_dir.normalize ();
// Perform masking (only once - on the first/near phase)
RCache.set_CullMode (CULL_NONE );
if (SE_SUN_NEAR==sub_phase) //.
{
// For sun-filter - clear to zero
CHK_DX (HW.pDevice->Clear ( 0L, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0L));
// Fill vertex buffer
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set (EPS, float(_h+EPS), d_Z, d_W, C, p0.x, p1.y); pv++;
pv->set (EPS, EPS, d_Z, d_W, C, p0.x, p0.y); pv++;
pv->set (float(_w+EPS), float(_h+EPS), d_Z, d_W, C, p1.x, p1.y); pv++;
pv->set (float(_w+EPS), EPS, d_Z, d_W, C, p1.x, p0.y); pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
RCache.set_Geometry (g_combine);
// setup
float intensity = 0.3f*fuckingsun->color.r + 0.48f*fuckingsun->color.g + 0.22f*fuckingsun->color.b;
Fvector dir = L_dir;
dir.normalize().mul (- _sqrt(intensity+EPS));
RCache.set_Element (s_accum_mask->E[SE_MASK_DIRECT]); // masker
RCache.set_c ("Ldynamic_dir", dir.x,dir.y,dir.z,0 );
// if (stencil>=1 && aref_pass) stencil = light_id
RCache.set_ColorWriteEnable (FALSE );
RCache.set_Stencil (TRUE,D3DCMP_LESSEQUAL,dwLightMarkerID,0x01,0xff,D3DSTENCILOP_KEEP,D3DSTENCILOP_REPLACE,D3DSTENCILOP_KEEP);
RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
// recalculate d_Z, to perform depth-clipping
Fvector center_pt; center_pt.mad (Device.vCameraPosition,Device.vCameraDirection,ps_r2_sun_near);
Device.mFullTransform.transform(center_pt) ;
d_Z = center_pt.z ;
// nv-stencil recompression
if (RImplementation.o.nvstencil && (SE_SUN_NEAR==sub_phase)) u_stencil_optimize(); //. driver bug?
// Perform lighting
{
u_setrt (rt_Generic_0,NULL,NULL,HW.pBaseZB); // enshure RT setup
RCache.set_CullMode (CULL_NONE );
RCache.set_ColorWriteEnable ();
// texture adjustment matrix
float fTexelOffs = (.5f / float(RImplementation.o.smapsize));
float fRange = (SE_SUN_NEAR==sub_phase)?ps_r2_sun_depth_near_scale:ps_r2_sun_depth_far_scale;
float fBias = (SE_SUN_NEAR==sub_phase)?ps_r2_sun_depth_near_bias:ps_r2_sun_depth_far_bias;
Fmatrix m_TexelAdjust =
{
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, -0.5f, 0.0f, 0.0f,
0.0f, 0.0f, fRange, 0.0f,
0.5f + fTexelOffs, 0.5f + fTexelOffs, fBias, 1.0f
};
// compute xforms
Fmatrix m_shadow;
{
FPU::m64r ();
Fmatrix xf_invview; xf_invview.invert (Device.mView) ;
Fmatrix xf_project; xf_project.mul (m_TexelAdjust,fuckingsun->X.D.combine);
m_shadow.mul (xf_project, xf_invview);
// tsm-bias
if (SE_SUN_FAR == sub_phase)
{
Fvector bias; bias.mul (L_dir,ps_r2_sun_tsm_bias);
Fmatrix bias_t; bias_t.translate(bias);
m_shadow.mulB_44 (bias_t);
}
//.........这里部分代码省略.........
示例14: draw_rain
void CRenderTarget::draw_rain( light &RainSetup )
{
float fRainFactor = g_pGamePersistent->Environment().CurrentEnv->rain_density;
// Common calc for quad-rendering
u32 Offset;
u32 C = color_rgba (255,255,255,255);
float _w = float (Device.dwWidth);
float _h = float (Device.dwHeight);
Fvector2 p0,p1;
p0.set (.5f/_w, .5f/_h);
p1.set ((_w+.5f)/_w, (_h+.5f)/_h );
float d_Z = EPS_S, d_W = 1.f;
// Common constants (light-related)
Fvector L_dir;
Device.mView.transform_dir (L_dir,RainSetup.direction);
L_dir.normalize ();
Fvector W_dirX;
Device.mView.transform_dir (W_dirX,Fvector().set(1.0f, 0.0f, 0.0f));
W_dirX.normalize ();
Fvector W_dirZ;
Device.mView.transform_dir (W_dirZ,Fvector().set(0.0f, 0.0f, 1.0f));
W_dirZ.normalize ();
// Perform masking (only once - on the first/near phase)
//RCache.set_CullMode (CULL_NONE );
//if (SE_SUN_NEAR==sub_phase) //.
{
// Fill vertex buffer
FVF::TL* pv = (FVF::TL*) RCache.Vertex.Lock (4,g_combine->vb_stride,Offset);
pv->set (EPS, float(_h+EPS), d_Z, d_W, C, p0.x, p1.y); pv++;
pv->set (EPS, EPS, d_Z, d_W, C, p0.x, p0.y); pv++;
pv->set (float(_w+EPS), float(_h+EPS), d_Z, d_W, C, p1.x, p1.y); pv++;
pv->set (float(_w+EPS), EPS, d_Z, d_W, C, p1.x, p0.y); pv++;
RCache.Vertex.Unlock (4,g_combine->vb_stride);
RCache.set_Geometry (g_combine);
// setup
// float intensity = 0.3f*fuckingsun->color.r + 0.48f*fuckingsun->color.g + 0.22f*fuckingsun->color.b;
// Fvector dir = L_dir;
// dir.normalize().mul (- _sqrt(intensity+EPS));
// RCache.set_Element (s_accum_mask->E[SE_MASK_DIRECT]); // masker
// RCache.set_c ("Ldynamic_dir", dir.x,dir.y,dir.z,0 );
// if (stencil>=1 && aref_pass) stencil = light_id
// Done in blender!
//RCache.set_ColorWriteEnable (FALSE );
// RCache.set_Stencil (TRUE,D3DCMP_LESSEQUAL,dwLightMarkerID,0x01,0xff,D3DSTENCILOP_KEEP,D3DSTENCILOP_REPLACE,D3DSTENCILOP_KEEP);
// RCache.Render (D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
// recalculate d_Z, to perform depth-clipping
const float fRainFar = ps_r3_dyn_wet_surf_far;
Fvector center_pt; center_pt.mad (Device.vCameraPosition,Device.vCameraDirection,fRainFar);
Device.mFullTransform.transform(center_pt) ;
d_Z = center_pt.z ;
// nv-stencil recompression
//if (RImplementation.o.nvstencil && (SE_SUN_NEAR==sub_phase)) u_stencil_optimize(); //. driver bug?
// Perform lighting
{
// phase_accumulator () ;
// RCache.set_CullMode (CULL_NONE);
// RCache.set_ColorWriteEnable () ;
// texture adjustment matrix
//float fRange = (SE_SUN_NEAR==sub_phase)?ps_r2_sun_depth_near_scale:ps_r2_sun_depth_far_scale;
float fRange = 1;
//float fBias = (SE_SUN_NEAR==sub_phase)?ps_r2_sun_depth_near_bias:ps_r2_sun_depth_far_bias;
//float fBias = 0.00001;
float fBias = -0.0001;
float smapsize = float(RImplementation.o.smapsize);
float fTexelOffs = (.5f / smapsize);
// float view_dimX = float(RainSetup.X.D.maxX-RainSetup.X.D.minX-2)/smapsize;
// float view_dimY = float(RainSetup.X.D.maxX-RainSetup.X.D.minX-2)/smapsize;
// float view_sx = float(RainSetup.X.D.minX+1)/smapsize;
// float view_sy = float(RainSetup.X.D.minY+1)/smapsize;
float view_dimX = float(RainSetup.X.D.maxX-RainSetup.X.D.minX)/smapsize;
float view_dimY = float(RainSetup.X.D.maxX-RainSetup.X.D.minX)/smapsize;
float view_sx = float(RainSetup.X.D.minX)/smapsize;
float view_sy = float(RainSetup.X.D.minY)/smapsize;
Fmatrix m_TexelAdjust =
{
view_dimX/2.f, 0.0f, 0.0f, 0.0f,
0.0f, -view_dimY/2.f, 0.0f, 0.0f,
0.0f, 0.0f, fRange, 0.0f,
view_dimX/2.f + view_sx + fTexelOffs, view_dimY/2.f + view_sy + fTexelOffs, fBias, 1.0f
};
// compute xforms
FPU::m64r ();
Fmatrix xf_invview; xf_invview.invert (Device.mView) ;
// shadow xform
//.........这里部分代码省略.........
示例15: OnRender
void CGameFont::OnRender()
{
VERIFY (g_bRendering);
if (pShader) RCache.set_Shader (pShader);
if (!(uFlags&fsValid)){
CTexture* T = RCache.get_ActiveTexture(0);
vTS.set ((int)T->get_Width(),(int)T->get_Height());
/*
vHalfPixel.set (0.5f/float(vTS.x),0.5f/float(vTS.y));
for (int i=0; i<256; i++){
Fvector& tc = TCMap[i];
tc.x /= float(vTS.x);
tc.y /= float(vTS.y);
tc.z /= float(vTS.x);
}
fTCHeight = fHeight/float(vTS.y);
uFlags |= fsValid;
*/
fTCHeight = fHeight/float(vTS.y);
uFlags |= fsValid;
}
for (u32 i=0; i<strings.size(); ){
// calculate first-fit
int count = 1;
int length = xr_strlen(strings[i].string);
while ((i+count)<strings.size()) {
int L = xr_strlen(strings[i+count].string);
if ((L+length)<MAX_CHARS){
count ++;
length += L;
}
else break;
}
// lock AGP memory
u32 vOffset;
FVF::TL* v = (FVF::TL*)RCache.Vertex.Lock (length*4,pGeom.stride(),vOffset);
FVF::TL* start = v;
// fill vertices
u32 last = i+count;
for (; i<last; i++) {
String &PS = strings[i];
int len = xr_strlen(PS.string);
if (len) {
float X = float(iFloor(PS.x));
float Y = float(iFloor(PS.y));
float S = PS.height*g_current_font_scale.y;
float Y2 = Y+S;
switch(PS.align)
{
case alCenter:
X -= ( iFloor(SizeOf_(PS.string,PS.height)*.5f) ) * g_current_font_scale.x;
break;
case alRight:
X -= iFloor(SizeOf_(PS.string,PS.height));
break;
}
u32 clr,clr2;
clr2 = clr = PS.c;
if (uFlags&fsGradient){
u32 _R = color_get_R (clr)/2;
u32 _G = color_get_G (clr)/2;
u32 _B = color_get_B (clr)/2;
u32 _A = color_get_A (clr);
clr2 = color_rgba (_R,_G,_B,_A);
}
float tu,tv;
for (int j=0; j<len; j++)
{
int c = GetCharRM (PS.string[j]);
Fvector l = GetCharTC (PS.string[j]);
float scw = l.z * g_current_font_scale.x;
//. float scw = vTS.x * l.z * g_current_font_scale.x;
float fTCWidth = l.z/vTS.x;
if ((c>=0)&&!fis_zero(l.z))
{
tu = l.x/vTS.x;//+vHalfPixel.x;
tv = l.y/vTS.y;//+vHalfPixel.y;
v->set (X-0.5f, Y2-0.5f, clr2,tu, tv+fTCHeight); v++;
v->set (X-0.5f, Y-0.5f, clr, tu, tv); v++;
v->set (X+scw-0.5f, Y2-0.5f, clr2,tu+fTCWidth, tv+fTCHeight); v++;
v->set (X+scw-0.5f, Y-0.5f, clr, tu+fTCWidth, tv); v++;
}
X+=scw*vInterval.x;
}
}
}
// Unlock and draw
u32 vCount = (u32)(v-start);
//.........这里部分代码省略.........