Hi,
I've finished render the 3d scene to GUI(StaticImage here),the problem I encountered is that I just want to render my player to the StaticImage, but what I get is that my player and black background altogher are rendered to the StaticImage, which lead to a black square(the dimension of StaticImage) who takes the player.What I want is just a player rendered at the StaticImage area, the remain pixel of the StaticImage is transparent, from this we can see the background image.
My Layout likes follow:
////////////////////////////////////////////////////////////////
//....................................................................................//
//....................................................................................//
//....................................................................................//
//....................................................................................//
//..........Background Image occupy the full game area......................//
//....................................................................................//
//....................................................................................//
//...///StaticImage/////........................................................//
//...//...................//........................................................//
//...//..Player..........//........................................................//
//...//...................//........................................................//
//...//...................//........................................................//
//...//////////////////........................................................//
////////////////////////////////////////////////////////////////
Player shouldn't occupy all of the StaticImage area, the other pixels of StaitcImage should be Background Image
Render To Texture
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Render To Texture
Did you disable the StaticImage background by setting the "BackgroundEnabled" property to "False"? If so the background is coming from the texture you're using as the source of the image. Make sure you clear the alpha values on that texture to 0 before you render
CE.
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Render To Texture
I've disabled "FrameEnabled" and "BackgroundEnabled" property, code I used to render to texture is from the ogre's tutorial, I don't know how and where to clear the alpha component of the source image.
My Code Here:
Thanks Eddie
My Code Here:
Code: Select all
// Setup Render To Texture for preview window
TexturePtr rttTex = TextureManager::getSingleton().createManual(m_RttTexName,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D,
512, 512, 1, 0, PF_R8G8B8A8, TU_RENDERTARGET);
{
if (!m_pCamera)
{
m_randerCamera = TRUE;
m_pCamera = m_SceneMgr->createCamera(m_CamName);
SceneNode* camNode =
m_SceneMgr->getRootSceneNode()->createChildSceneNode(m_CamSceneNodeName);
camNode->attachObject(m_pCamera);
m_pCamera->setPosition(0,0,200);
m_pCamera->setFarClipDistance(100);
m_pCamera->setNearClipDistance(0.51);
//m_pCamera->setVisible(true);
Viewport *v = rttTex->getBuffer()->getRenderTarget()->addViewport( m_pCamera );
v->setOverlaysEnabled(false);
v->setClearEveryFrame( true );
v->setBackgroundColour( ColourValue::Black );
//v->
m_pCamera->setAspectRatio(0.4/0.6);
}
else
{
Viewport *v = rttTex->getBuffer()->getRenderTarget()->addViewport( m_pCamera );
v->setOverlaysEnabled(false);
v->setClearEveryFrame( true );
v->setBackgroundColour( ColourValue::Black );
}
}
// Retrieve CEGUI texture for the RTT
m_rttTexture = m_GUIRenderer->createTexture((CEGUI::utf8*)m_RttTexName.c_str(), (CEGUI::utf8*)"General");
CEGUI::Imageset* rttImageSet =
CEGUI::ImagesetManager::getSingleton().createImageset(
(CEGUI::utf8*)m_RttImagesetName.c_str(), m_rttTexture);
rttImageSet->defineImage((CEGUI::utf8*)m_RttImageName.c_str(),
CEGUI::Point(0.0f, 0.0f),
CEGUI::Size(m_rttTexture->getWidth(), m_rttTexture->getHeight()),
CEGUI::Point(0.0f,0.0f));
//use it,these line of codes is not in the same function as that above
CEGUI::Imageset* rttImageSet =
CEGUI::ImagesetManager::getSingleton().getImageset(
(CEGUI::utf8*)m_RttImagesetName.c_str());
si->setProperty("Image", CEGUI::PropertyHelper::imageToString(
&rttImageSet->getImage((CEGUI::utf8*)m_RttImageName.c_str())));
Thanks Eddie
Re: Render To Texture
My 3d scene's environment is black, and only a player stand there, I just want my player placed on the StaticImage, not the black environment, but now the black background is also rendered to the StaticImage, where the black pixel should be the UI's background(StaticImage, too)
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Render To Texture
In order to clear the alpha on the texture, you'll have to specify that explicitly in the clear / background value. For example, instead of:
do:
Depending upon where the blackness in your main environment comes from, the above change may be enough to get what you want (if the blackness comes from geometry, it will not be though. For that I guess you'll have to find a means of not drawing that on the RTT pass; I do not know enough about Ogre to advise on that aspect).
HTH
CE.
Code: Select all
v->setBackgroundColour( ColourValue::Black );
do:
Code: Select all
v->setBackgroundColour( ColourValue(0, 0, 0, 0) );
Depending upon where the blackness in your main environment comes from, the above change may be enough to get what you want (if the blackness comes from geometry, it will not be though. For that I guess you'll have to find a means of not drawing that on the RTT pass; I do not know enough about Ogre to advise on that aspect).
HTH
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Render To Texture
Thank you very much!Yeah, it works!aha!
Re: Render To Texture
Hi!
But my question is similar and I have dared to post here.
How can I bind my Direct3D render-target and StaticImage?
Based on this code,
I desided that the texture and the render-target have bound by name (RttTexName). But the author used Ogre, I use Direct3D9Renderer.
Thanks in advance.
But my question is similar and I have dared to post here.
How can I bind my Direct3D render-target and StaticImage?
Based on this code,
Code: Select all
TexturePtr rttTex = TextureManager::getSingleton().createManual(m_RttTexName,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D,
512, 512, 1, 0, PF_R8G8B8A8, TU_RENDERTARGET);
...
m_rttTexture = m_GUIRenderer->createTexture((CEGUI::utf8*)m_RttTexName.c_str(), (CEGUI::utf8*)"General");
I desided that the texture and the render-target have bound by name (RttTexName). But the author used Ogre, I use Direct3D9Renderer.
Thanks in advance.
Return to “Offtopic Discussion”
Who is online
Users browsing this forum: No registered users and 12 guests