Efectul este activ doar cand treci cu mouse-ul peste NPC
*Poze / Video (obligatoriu):
*Link download:
*Link scanare VirusTotal (obligatoriu):
Ultima oară modificat 16 Mai 2026, 15:33 de către SCOOB, modificat 1 dată în total.
Motiv: Adaugat virustotal + backup link
ModelInstance.h :
void CGraphicThingInstance::RenderWithoutTexture(float fScale)
{
//assert(m_bUpdated);
if (!m_bUpdated)
return;
CGrannyLODController::FRenderWithoutTexture render;
render.fScale = fScale;
std::for_each(m_LODControllerVector.begin(), m_LODControllerVector.end(), render);
}
Fixed. the client must call BeginModelOutlineFrame() / EndModelOutlineFrame() around the actor render loop and ReleaseModelOutlineResources() before DirectX reset.Shahin Zareey scrie: ↑ I found a serious issue in the outline resource: the version we received creates a fullscreen render-target in D3DPOOL_DEFAULT, doesn't handle it on device reset, and performs multiple fullscreen renders for each NPC being processed. This can block DirectX reset and produces exactly the kind of leak/performance spike that needs to be avoided.
// Go at the bottom and add this :
#if defined(ENABLE_MODEL_OUTLINE_EFFECT)
protected:
BOOL m_isModelOutline;
BOOL m_isTargetRing;
D3DXCOLOR m_ModelOutlineColor;
public:
void SetModelOutline(BOOL isEnable);
void SetTargetRing(BOOL isEnable);
void RenderModelOutline();
void RenderTargetRing();
static void BeginModelOutlineFrame();
static void EndModelOutlineFrame();
static void ReleaseModelOutlineResources();
#endif
// Before this :
};
// Add this after includes
#if defined(ENABLE_MODEL_OUTLINE_EFFECT)
static DWORD MakeTargetRingColor(float fAlpha, BYTE byRed, BYTE byGreen, BYTE byBlue);
class CModelOutlineMaskTarget : public CGraphicBase
{
public:
CModelOutlineMaskTarget()
{
m_uWidth = 0;
m_uHeight = 0;
m_lpTexture = NULL;
m_lpSurface = NULL;
m_lpOldRenderTarget = NULL;
m_lpOldDepthSurface = NULL;
m_isFrameOpen = false;
m_isMaskDirty = false;
m_isStencilCleared = false;
}
~CModelOutlineMaskTarget()
{
Release();
}
void BeginFrame()
{
m_isFrameOpen = true;
m_isMaskDirty = false;
m_isStencilCleared = false;
}
void EndFrame()
{
if (m_isFrameOpen && m_isMaskDirty)
RenderGlow();
if (m_isStencilCleared)
ms_lpd3dDevice->Clear(0L, NULL, D3DCLEAR_STENCIL, 0, 1.0f, 0);
m_isFrameOpen = false;
m_isMaskDirty = false;
m_isStencilCleared = false;
}
void ReleaseResources()
{
Release();
}
bool BeginMask()
{
if (!m_isFrameOpen)
return false;
if (!Ensure())
return false;
if (FAILED(ms_lpd3dDevice->GetRenderTarget(0, &m_lpOldRenderTarget)))
return false;
if (FAILED(ms_lpd3dDevice->GetDepthStencilSurface(&m_lpOldDepthSurface)))
{
safe_release(m_lpOldRenderTarget);
return false;
}
if (FAILED(ms_lpd3dDevice->SetRenderTarget(0, m_lpSurface)))
{
ResetBackBuffer();
return false;
}
if (FAILED(ms_lpd3dDevice->SetDepthStencilSurface(m_lpOldDepthSurface)))
{
ResetBackBuffer();
return false;
}
if (!m_isMaskDirty)
ms_lpd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
return true;
}
void EndMask()
{
ResetBackBuffer();
m_isMaskDirty = true;
}
bool PrepareStencil()
{
if (!m_isStencilCleared)
{
if (FAILED(ms_lpd3dDevice->Clear(0L, NULL, D3DCLEAR_STENCIL, 0, 1.0f, 0)))
return false;
m_isStencilCleared = true;
}
return true;
}
void DiscardFrame()
{
m_isMaskDirty = false;
}
private:
void RenderOffset(float fOffsetX, float fOffsetY, DWORD dwColor)
{
if (!m_lpTexture)
return;
TPDTVertex vertices[4];
vertices[0].position = TPosition(fOffsetX - 0.5f, fOffsetY - 0.5f, 0.0f);
vertices[0].texCoord = TTextureCoordinate(0.0f, 0.0f);
vertices[0].diffuse = dwColor;
vertices[1].position = TPosition(float(m_uWidth) + fOffsetX - 0.5f, fOffsetY - 0.5f, 0.0f);
vertices[1].texCoord = TTextureCoordinate(1.0f, 0.0f);
vertices[1].diffuse = dwColor;
vertices[2].position = TPosition(fOffsetX - 0.5f, float(m_uHeight) + fOffsetY - 0.5f, 0.0f);
vertices[2].texCoord = TTextureCoordinate(0.0f, 1.0f);
vertices[2].diffuse = dwColor;
vertices[3].position = TPosition(float(m_uWidth) + fOffsetX - 0.5f, float(m_uHeight) + fOffsetY - 0.5f, 0.0f);
vertices[3].texCoord = TTextureCoordinate(1.0f, 1.0f);
vertices[3].diffuse = dwColor;
if (SetPDTStream(vertices, 4))
{
SetDefaultIndexBuffer(DEFAULT_IB_FILL_RECT);
STATEMANAGER.SetTexture(0, m_lpTexture);
STATEMANAGER.SetTexture(1, NULL);
STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE);
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
}
}
UINT GetWidth() const { return m_uWidth; }
UINT GetHeight() const { return m_uHeight; }
void RenderGlow()
{
STATEMANAGER.SaveTexture(0, NULL);
STATEMANAGER.SaveTexture(1, NULL);
STATEMANAGER.SaveRenderState(D3DRS_TEXTUREFACTOR, 0xffffffff);
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_ZWRITEENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_LIGHTING, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_FOGENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
STATEMANAGER.SaveRenderState(D3DRS_COLORWRITEENABLE, 0x0000000f);
STATEMANAGER.SaveRenderState(D3DRS_STENCILENABLE, TRUE);
STATEMANAGER.SaveRenderState(D3DRS_STENCILFUNC, D3DCMP_NOTEQUAL);
STATEMANAGER.SaveRenderState(D3DRS_STENCILREF, 1);
STATEMANAGER.SaveRenderState(D3DRS_STENCILMASK, 0xffffffff);
STATEMANAGER.SaveRenderState(D3DRS_STENCILWRITEMASK, 0xffffffff);
STATEMANAGER.SaveRenderState(D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
STATEMANAGER.SaveRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
STATEMANAGER.SaveRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
STATEMANAGER.SaveVertexShader(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
STATEMANAGER.SaveTransform(D3DTS_WORLD, &ms_matIdentity);
STATEMANAGER.SaveTransform(D3DTS_VIEW, &ms_matIdentity);
D3DXMATRIX matProjection;
D3DXMatrixOrthoOffCenterRH(&matProjection, 0.0f, float(GetWidth()), float(GetHeight()), 0.0f, -1.0f, 1.0f);
STATEMANAGER.SaveTransform(D3DTS_PROJECTION, &matProjection);
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
static const float s_afLargeOffsets[][2] =
{
{ -6.0f, 0.0f }, { 6.0f, 0.0f }, { 0.0f, -6.0f }, { 0.0f, 6.0f },
{ -4.5f, -4.5f }, { 4.5f, -4.5f }, { -4.5f, 4.5f }, { 4.5f, 4.5f }
};
static const float s_afMidOffsets[][2] =
{
{ -3.5f, 0.0f }, { 3.5f, 0.0f }, { 0.0f, -3.5f }, { 0.0f, 3.5f },
{ -2.5f, -2.5f }, { 2.5f, -2.5f }, { -2.5f, 2.5f }, { 2.5f, 2.5f }
};
static const float s_afCoreOffsets[][2] =
{
{ -1.6f, 0.0f }, { 1.6f, 0.0f }, { 0.0f, -1.6f }, { 0.0f, 1.6f },
{ -1.1f, -1.1f }, { 1.1f, -1.1f }, { -1.1f, 1.1f }, { 1.1f, 1.1f }
};
const DWORD dwOuterGlow = MakeTargetRingColor(0.08f, 185, 255, 8);
const DWORD dwMidGlow = MakeTargetRingColor(0.16f, 220, 255, 24);
const DWORD dwCoreGlow = MakeTargetRingColor(0.46f, 255, 244, 64);
for (int i = 0; i < sizeof(s_afLargeOffsets) / sizeof(s_afLargeOffsets[0]); ++i)
RenderOffset(s_afLargeOffsets[i][0], s_afLargeOffsets[i][1], dwOuterGlow);
for (int i = 0; i < sizeof(s_afMidOffsets) / sizeof(s_afMidOffsets[0]); ++i)
RenderOffset(s_afMidOffsets[i][0], s_afMidOffsets[i][1], dwMidGlow);
for (int i = 0; i < sizeof(s_afCoreOffsets) / sizeof(s_afCoreOffsets[0]); ++i)
RenderOffset(s_afCoreOffsets[i][0], s_afCoreOffsets[i][1], dwCoreGlow);
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MIPFILTER);
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MAGFILTER);
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MINFILTER);
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSV);
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSU);
STATEMANAGER.RestoreTransform(D3DTS_PROJECTION);
STATEMANAGER.RestoreTransform(D3DTS_VIEW);
STATEMANAGER.RestoreTransform(D3DTS_WORLD);
STATEMANAGER.RestoreVertexShader();
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ALPHAOP);
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_COLOROP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG2);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG1);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG2);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILPASS);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILZFAIL);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILFAIL);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILWRITEMASK);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILMASK);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILREF);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILFUNC);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_COLORWRITEENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
STATEMANAGER.RestoreRenderState(D3DRS_FOGENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_LIGHTING);
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_TEXTUREFACTOR);
STATEMANAGER.RestoreTexture(1);
STATEMANAGER.RestoreTexture(0);
}
bool Ensure()
{
const UINT uWidth = ms_Viewport.Width;
const UINT uHeight = ms_Viewport.Height;
if (uWidth == 0 || uHeight == 0)
return false;
if (m_lpTexture && m_lpSurface && m_uWidth == uWidth && m_uHeight == uHeight)
return true;
Release();
// Render targets must be DEFAULT-pool in D3D9; release this before device Reset.
if (FAILED(ms_lpd3dDevice->CreateTexture(uWidth, uHeight, 1, D3DUSAGE_RENDERTARGET,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_lpTexture, NULL)))
{
Release();
return false;
}
if (FAILED(m_lpTexture->GetSurfaceLevel(0, &m_lpSurface)))
{
Release();
return false;
}
m_uWidth = uWidth;
m_uHeight = uHeight;
return true;
}
void ResetBackBuffer()
{
if (m_lpOldRenderTarget)
ms_lpd3dDevice->SetRenderTarget(0, m_lpOldRenderTarget);
if (m_lpOldDepthSurface)
ms_lpd3dDevice->SetDepthStencilSurface(m_lpOldDepthSurface);
safe_release(m_lpOldRenderTarget);
safe_release(m_lpOldDepthSurface);
}
void Release()
{
safe_release(m_lpSurface);
safe_release(m_lpTexture);
safe_release(m_lpOldRenderTarget);
safe_release(m_lpOldDepthSurface);
m_uWidth = 0;
m_uHeight = 0;
m_isFrameOpen = false;
m_isMaskDirty = false;
m_isStencilCleared = false;
}
private:
UINT m_uWidth;
UINT m_uHeight;
LPDIRECT3DTEXTURE9 m_lpTexture;
LPDIRECT3DSURFACE9 m_lpSurface;
LPDIRECT3DSURFACE9 m_lpOldRenderTarget;
LPDIRECT3DSURFACE9 m_lpOldDepthSurface;
bool m_isFrameOpen;
bool m_isMaskDirty;
bool m_isStencilCleared;
};
static CModelOutlineMaskTarget s_kModelOutlineMaskTarget;
// Add this around the actor render loop:
// CActorInstance::BeginModelOutlineFrame();
// ... render actors ...
// CActorInstance::EndModelOutlineFrame();
//
// Add this before IDirect3DDevice9::Reset or in the engine lost-device callback:
// CActorInstance::ReleaseModelOutlineResources();
#endif
// Search in here:
void CActorInstance::OnRender()
{
// And after this :
kMtrl.Diffuse=D3DXCOLOR(m_dwMtrlColor);
STATEMANAGER.SetMaterial(&kMtrl);
// Add this
#if defined(ENABLE_MODEL_OUTLINE_EFFECT)
if (m_isTargetRing)
RenderTargetRing();
#endif
// In the same function after this :
case RENDER_MODE_MODULATE:
BeginModulateRender();
RenderWithOneTexture();
BlendRenderWithOneTexture();
EndModulateRender();
break;
}
// Add this :
#if defined(ENABLE_MODEL_OUTLINE_EFFECT)
if (m_isModelOutline)
RenderModelOutline();
#endif
// Add anywhere this :
#if defined(ENABLE_MODEL_OUTLINE_EFFECT)
void CActorInstance::SetModelOutline(BOOL isEnable)
{
if (m_pkHorse)
m_pkHorse->SetModelOutline(isEnable);
m_isModelOutline = isEnable;
}
void CActorInstance::SetTargetRing(BOOL isEnable)
{
if (m_pkHorse)
{
m_pkHorse->SetTargetRing(isEnable);
m_isTargetRing = FALSE;
return;
}
m_isTargetRing = isEnable;
}
void CActorInstance::BeginModelOutlineFrame()
{
s_kModelOutlineMaskTarget.BeginFrame();
}
void CActorInstance::EndModelOutlineFrame()
{
s_kModelOutlineMaskTarget.EndFrame();
}
void CActorInstance::ReleaseModelOutlineResources()
{
s_kModelOutlineMaskTarget.ReleaseResources();
}
static DWORD MakeTargetRingColor(float fAlpha, BYTE byRed, BYTE byGreen, BYTE byBlue)
{
if (fAlpha < 0.0f)
fAlpha = 0.0f;
else if (fAlpha > 1.0f)
fAlpha = 1.0f;
const DWORD dwAlpha = DWORD(fAlpha * 255.0f);
return (dwAlpha << 24) | (DWORD(byRed) << 16) | (DWORD(byGreen) << 8) | DWORD(byBlue);
}
static void RenderTargetRingSegment(float fX, float fY, float fZ,
float fInnerRadius, float fOuterRadius,
float fStartAngle, float fAngleLength,
DWORD dwInnerColor, DWORD dwOuterColor,
int iStepCount)
{
if (fOuterRadius <= fInnerRadius || iStepCount < 2)
return;
if (iStepCount > 96)
iStepCount = 96;
SPDTVertexRaw vertices[(96 + 1) * 2];
int iVertexCount = 0;
for (int i = 0; i <= iStepCount; ++i)
{
const float fRatio = float(i) / float(iStepCount);
const float fAngle = fStartAngle + fAngleLength * fRatio;
const float fCos = cosf(fAngle);
const float fSin = sinf(fAngle);
vertices[iVertexCount].px = fX + fCos * fOuterRadius;
vertices[iVertexCount].py = fY + fSin * fOuterRadius;
vertices[iVertexCount].pz = fZ;
vertices[iVertexCount].diffuse = dwOuterColor;
vertices[iVertexCount].u = 0.0f;
vertices[iVertexCount].v = 0.0f;
++iVertexCount;
vertices[iVertexCount].px = fX + fCos * fInnerRadius;
vertices[iVertexCount].py = fY + fSin * fInnerRadius;
vertices[iVertexCount].pz = fZ;
vertices[iVertexCount].diffuse = dwInnerColor;
vertices[iVertexCount].u = 0.0f;
vertices[iVertexCount].v = 0.0f;
++iVertexCount;
}
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, UINT(iVertexCount - 2), vertices, sizeof(SPDTVertexRaw));
}
static void RenderTargetRingSpark(float fX, float fY, float fZ,
float fAngle, float fRadius, float fSize,
DWORD dwColor)
{
const float fCos = cosf(fAngle);
const float fSin = sinf(fAngle);
const float fTangentX = -fSin;
const float fTangentY = fCos;
const float fSparkX = fX + fCos * fRadius;
const float fSparkY = fY + fSin * fRadius;
SPDTVertexRaw vertices[4] =
{
{ fSparkX + fCos * fSize, fSparkY + fSin * fSize, fZ, dwColor, 0.0f, 0.0f },
{ fSparkX + fTangentX * fSize, fSparkY + fTangentY * fSize, fZ, dwColor, 0.0f, 0.0f },
{ fSparkX - fTangentX * fSize, fSparkY - fTangentY * fSize, fZ, dwColor, 0.0f, 0.0f },
{ fSparkX - fCos * fSize, fSparkY - fSin * fSize, fZ, dwColor, 0.0f, 0.0f },
};
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertices, sizeof(SPDTVertexRaw));
}
void CActorInstance::RenderTargetRing()
{
D3DXVECTOR3 v3Center;
float fBoundRadius = 0.0f;
if (!GetBoundingSphere(v3Center, fBoundRadius))
fBoundRadius = 100.0f;
float fRingRadius = fBoundRadius * 0.55f;
if (fRingRadius < 52.0f)
fRingRadius = 52.0f;
else if (fRingRadius > 92.0f)
fRingRadius = 92.0f;
const float fTime = GetLocalTime();
const float fPhase = fTime * 0.22f;
const float fPulse = 0.5f + 0.5f * sinf(fTime * 0.90f);
const float fBreath = 0.5f + 0.5f * sinf(fTime * 0.58f);
const float fZ = m_z + 1.0f;
D3DXMATRIX matIdentity;
D3DXMatrixIdentity(&matIdentity);
STATEMANAGER.SaveTransform(D3DTS_WORLD, &matIdentity);
STATEMANAGER.SaveTexture(0, NULL);
STATEMANAGER.SaveTexture(1, NULL);
STATEMANAGER.SaveVertexShader(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, TRUE);
STATEMANAGER.SaveRenderState(D3DRS_ZWRITEENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_LIGHTING, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_FOGENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
STATEMANAGER.SaveRenderState(D3DRS_COLORWRITEENABLE, 0x0000000f);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
const DWORD dwAuraCenter = MakeTargetRingColor(0.08f + 0.03f * fBreath, 255, 214, 92);
const DWORD dwAuraEdge = MakeTargetRingColor(0.0f, 255, 188, 44);
const DWORD dwSoftGold = MakeTargetRingColor(0.13f + 0.04f * fBreath, 255, 190, 46);
const DWORD dwRingGold = MakeTargetRingColor(0.36f + 0.07f * fPulse, 255, 220, 82);
const DWORD dwHotGold = MakeTargetRingColor(0.58f + 0.08f * fPulse, 255, 238, 116);
const DWORD dwFadeGold = MakeTargetRingColor(0.05f, 190, 132, 28);
RenderTargetRingSegment(m_x, m_y, fZ, 0.0f, fRingRadius * 0.78f,
0.0f, D3DX_PI * 2.0f, dwAuraCenter, dwAuraEdge, 96);
RenderTargetRingSegment(m_x, m_y, fZ, fRingRadius - 2.2f, fRingRadius + 2.2f,
0.0f, D3DX_PI * 2.0f, dwRingGold, dwSoftGold, 96);
for (int i = 0; i < 5; ++i)
{
const float fDrift = sinf(fTime * 0.19f + float(i) * 1.37f) * 0.10f;
const float fStart = fPhase + (D3DX_PI * 2.0f / 5.0f) * float(i) + fDrift;
const float fArcLength = D3DX_PI * (0.18f + 0.04f * sinf(fTime * 0.27f + float(i) * 2.11f));
const float fRadiusOffset = sinf(fTime * 0.33f + float(i) * 0.91f) * 1.4f;
RenderTargetRingSegment(m_x, m_y, fZ, fRingRadius - 4.0f + fRadiusOffset, fRingRadius + 2.8f + fRadiusOffset,
fStart, fArcLength, dwHotGold, dwFadeGold, 14);
}
for (int i = 0; i < 3; ++i)
{
const float fStart = -fPhase * 0.65f + (D3DX_PI * 2.0f / 3.0f) * float(i);
RenderTargetRingSegment(m_x, m_y, fZ, fRingRadius * 0.68f - 1.2f, fRingRadius * 0.68f + 1.2f,
fStart, D3DX_PI * 0.22f, dwSoftGold, MakeTargetRingColor(0.0f, 255, 188, 44), 10);
}
for (int i = 0; i < 8; ++i)
{
const float fSparkPulse = 0.5f + 0.5f * sinf(fTime * 0.72f + float(i) * 1.73f);
const float fSparkPhase = fPhase * 0.38f + float(i) * (D3DX_PI * 2.0f / 8.0f) + sinf(fTime * 0.21f + float(i)) * 0.08f;
const float fSparkRadius = fRingRadius * (0.82f + 0.12f * sinf(fTime * 0.24f + float(i) * 0.87f));
RenderTargetRingSpark(m_x, m_y, fZ + 0.35f, fSparkPhase, fSparkRadius,
0.8f + fSparkPulse * 0.9f, MakeTargetRingColor(0.08f + fSparkPulse * 0.14f, 255, 220, 88));
}
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ALPHAOP);
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_COLOROP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG1);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
STATEMANAGER.RestoreRenderState(D3DRS_COLORWRITEENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
STATEMANAGER.RestoreRenderState(D3DRS_FOGENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_LIGHTING);
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_ZFUNC);
STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
STATEMANAGER.RestoreVertexShader();
STATEMANAGER.RestoreTexture(1);
STATEMANAGER.RestoreTexture(0);
STATEMANAGER.RestoreTransform(D3DTS_WORLD);
}
void CActorInstance::RenderModelOutline()
{
D3DMATERIAL9 kMtrl;
STATEMANAGER.GetMaterial(&kMtrl);
if (!s_kModelOutlineMaskTarget.BeginMask())
return;
D3DMATERIAL9 kMaskMtrl = kMtrl;
kMaskMtrl.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
kMaskMtrl.Ambient = kMaskMtrl.Diffuse;
kMaskMtrl.Emissive = kMaskMtrl.Diffuse;
STATEMANAGER.SaveTexture(0, NULL);
STATEMANAGER.SaveTexture(1, NULL);
STATEMANAGER.SaveRenderState(D3DRS_TEXTUREFACTOR, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f));
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, TRUE);
STATEMANAGER.SaveRenderState(D3DRS_ZWRITEENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_LIGHTING, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_FOGENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_COLORWRITEENABLE, 0x0000000f);
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
STATEMANAGER.SetMaterial(&kMaskMtrl);
RenderWithoutTexture(1.0f);
STATEMANAGER.SetMaterial(&kMtrl);
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ALPHAOP);
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_COLOROP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG2);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG1);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG2);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
STATEMANAGER.RestoreRenderState(D3DRS_COLORWRITEENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_FOGENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_LIGHTING);
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_ZFUNC);
STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_TEXTUREFACTOR);
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
STATEMANAGER.RestoreTexture(1);
STATEMANAGER.RestoreTexture(0);
s_kModelOutlineMaskTarget.EndMask();
if (!s_kModelOutlineMaskTarget.PrepareStencil())
{
s_kModelOutlineMaskTarget.DiscardFrame();
return;
}
STATEMANAGER.SaveTexture(0, NULL);
STATEMANAGER.SaveTexture(1, NULL);
STATEMANAGER.SaveRenderState(D3DRS_TEXTUREFACTOR, m_ModelOutlineColor);
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_ZWRITEENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_LIGHTING, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_FOGENABLE, FALSE);
STATEMANAGER.SaveRenderState(D3DRS_COLORWRITEENABLE, 0);
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
STATEMANAGER.SaveRenderState(D3DRS_STENCILENABLE, TRUE);
STATEMANAGER.SaveRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
STATEMANAGER.SaveRenderState(D3DRS_STENCILREF, 1);
STATEMANAGER.SaveRenderState(D3DRS_STENCILMASK, 0xffffffff);
STATEMANAGER.SaveRenderState(D3DRS_STENCILWRITEMASK, 0xffffffff);
STATEMANAGER.SaveRenderState(D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
STATEMANAGER.SaveRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
STATEMANAGER.SaveRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
STATEMANAGER.SetRenderState(D3DRS_COLORWRITEENABLE, 0);
STATEMANAGER.SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
STATEMANAGER.SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE);
RenderWithoutTexture(1.0f);
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ALPHAOP);
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_COLOROP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG2);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG1);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG2);
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILPASS);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILZFAIL);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILFAIL);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILWRITEMASK);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILMASK);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILREF);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILFUNC);
STATEMANAGER.RestoreRenderState(D3DRS_STENCILENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_COLORWRITEENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
STATEMANAGER.RestoreRenderState(D3DRS_FOGENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_LIGHTING);
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
STATEMANAGER.RestoreRenderState(D3DRS_TEXTUREFACTOR);
STATEMANAGER.RestoreTexture(1);
STATEMANAGER.RestoreTexture(0);
STATEMANAGER.SetMaterial(&kMtrl);
}
#endif
Trebuie să fii membru pentru a răspunde
Membrii pot crea subiecte noi și pot descărca resurse Metin2 Gratuit!
Te poți înregistra sau conecta rapid utilizând contul tău de Discord, Github sau Google.
Utilizatori ce navighează pe acest forum: cabesas_papi, Ciocanito, ensedev, ionutvlc, manu_z5, nonsoc, whitehat1632 și 2 vizitatori