|
|
@ -271,18 +271,11 @@ void CBloomEffect::initTexture(CSmartPtr<ITexture> & tex, bool isMode2D, uint32
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void CBloomEffect::initBloom()
|
|
|
|
void CBloomEffect::initBloom() // clientcfg
|
|
|
|
{
|
|
|
|
|
|
|
|
initBloom(NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CBloomEffect::initBloom(UTexture *renderTarget) // clientcfg
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!((CDriverUser *)_Driver)->getDriver()->supportBloomEffect())
|
|
|
|
if(!((CDriverUser *)_Driver)->getDriver()->supportBloomEffect())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
m_UserRenderTarget = renderTarget ? dynamic_cast<CTextureUser *>(renderTarget)->getITexture() : NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// don't activate bloom when PolygonMode is different from Filled
|
|
|
|
// don't activate bloom when PolygonMode is different from Filled
|
|
|
|
if (_Driver->getPolygonMode() != UDriver::Filled) return;
|
|
|
|
if (_Driver->getPolygonMode() != UDriver::Filled) return;
|
|
|
|
|
|
|
|
|
|
|
@ -356,19 +349,7 @@ void CBloomEffect::initBloom(UTexture *renderTarget) // clientcfg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// For now the user target must be the window size
|
|
|
|
NL3D::CTextureUser txt = (_InitBloomEffect) ? (CTextureUser(_InitText)) : (CTextureUser());
|
|
|
|
// to be compatible with the existing code.
|
|
|
|
|
|
|
|
// TODO: Instead, if user render target is provided,
|
|
|
|
|
|
|
|
// assume the size of the user render target as
|
|
|
|
|
|
|
|
// the screen size to be used.
|
|
|
|
|
|
|
|
if (m_UserRenderTarget.getPtr())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlassert(_WndWidth == m_UserRenderTarget->getWidth());
|
|
|
|
|
|
|
|
nlassert(_WndHeight == m_UserRenderTarget->getHeight());
|
|
|
|
|
|
|
|
_DisplayInitMat.getObjectPtr()->setTexture(0, m_UserRenderTarget);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NL3D::CTextureUser txt = (_InitBloomEffect) ? (CTextureUser(m_UserRenderTarget.getPtr() ? m_UserRenderTarget : _InitText)) : (CTextureUser());
|
|
|
|
|
|
|
|
if(!((CDriverUser *) _Driver)->setRenderTarget(txt, 0, 0, _WndWidth, _WndHeight))
|
|
|
|
if(!((CDriverUser *) _Driver)->setRenderTarget(txt, 0, 0, _WndWidth, _WndHeight))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nlwarning("setRenderTarget return false with initial texture for bloom effect\n");
|
|
|
|
nlwarning("setRenderTarget return false with initial texture for bloom effect\n");
|
|
|
@ -389,7 +370,7 @@ void CBloomEffect::endBloom() // clientcfg
|
|
|
|
if(_Driver->getWindowWidth()==0 || _Driver->getWindowHeight()==0)
|
|
|
|
if(_Driver->getWindowWidth()==0 || _Driver->getWindowHeight()==0)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
CTextureUser txt1 = (_InitBloomEffect) ? (CTextureUser(m_UserRenderTarget.getPtr() ? m_UserRenderTarget : _InitText)) : (CTextureUser());
|
|
|
|
CTextureUser txt1 = (_InitBloomEffect) ? (CTextureUser(_InitText)) : (CTextureUser());
|
|
|
|
CTextureUser txt2(_BlurFinalTex);
|
|
|
|
CTextureUser txt2(_BlurFinalTex);
|
|
|
|
CRect rect1(0, 0, _WndWidth, _WndHeight);
|
|
|
|
CRect rect1(0, 0, _WndWidth, _WndHeight);
|
|
|
|
CRect rect2(0, 0, _BlurWidth, _BlurHeight);
|
|
|
|
CRect rect2(0, 0, _BlurWidth, _BlurHeight);
|
|
|
@ -416,7 +397,7 @@ void CBloomEffect::applyBlur()
|
|
|
|
// in opengl, display in init texture
|
|
|
|
// in opengl, display in init texture
|
|
|
|
if(_InitBloomEffect)
|
|
|
|
if(_InitBloomEffect)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CTextureUser txt(m_UserRenderTarget.getPtr() ? m_UserRenderTarget : _InitText);
|
|
|
|
CTextureUser txt(_InitText);
|
|
|
|
if(!((CDriverUser *) _Driver)->setRenderTarget(txt, 0, 0, _WndWidth, _WndHeight))
|
|
|
|
if(!((CDriverUser *) _Driver)->setRenderTarget(txt, 0, 0, _WndWidth, _WndHeight))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nlwarning("setRenderTarget return false with initial texture for bloom effect\n");
|
|
|
|
nlwarning("setRenderTarget return false with initial texture for bloom effect\n");
|
|
|
@ -478,7 +459,7 @@ void CBloomEffect::endInterfacesDisplayBloom() // clientcfg
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Render from render target to screen if necessary.
|
|
|
|
// Render from render target to screen if necessary.
|
|
|
|
// Don't do this when the blend was done to the screen or when rendering to a user provided rendertarget.
|
|
|
|
// Don't do this when the blend was done to the screen or when rendering to a user provided rendertarget.
|
|
|
|
if (_InitBloomEffect && m_UserRenderTarget.isNull())
|
|
|
|
if (_InitBloomEffect)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!_Driver->supportBloomEffect() || !_Init)
|
|
|
|
if(!_Driver->supportBloomEffect() || !_Init)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -511,15 +492,6 @@ void CBloomEffect::endInterfacesDisplayBloom() // clientcfg
|
|
|
|
_Driver->drawQuad(_DisplayQuad, _DisplayInitMat);
|
|
|
|
_Driver->drawQuad(_DisplayQuad, _DisplayInitMat);
|
|
|
|
_Driver->setMatrixMode3D(pCam);
|
|
|
|
_Driver->setMatrixMode3D(pCam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_UserRenderTarget.getPtr())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_InitBloomEffect)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_DisplayInitMat.getObjectPtr()->setTexture(0, _InitText);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_UserRenderTarget = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|