2d sprite manager, for Ogre
-
- OGRE Expert User
- Posts: 517
- Joined: Tue Mar 07, 2006 11:22 pm
- Location: Buenos Aires, Argentina
- x 1
I don't understand that image well... but I suppose the problem is that you can't combine the full image blending factor with the alpha values of the image?
H. Hernan Moraldo
Personal website
Personal website
-
- Greenskin
- Posts: 105
- Joined: Tue Jun 26, 2007 12:20 pm
the image shows a blueish background with a cloud image on top.. as you can see there still parts of the rectangle of the image that still is shown when i fade in the texture.. an alpha value change from 0 to 1.0.
the texture is a png.
yes the full image blending looks wrong.. the transparent part of the texture around the cloud still shows up partly which is weird, because it does not happen with OpenGL. it actually works just fine when i set opengl render system
the texture is a png.
yes the full image blending looks wrong.. the transparent part of the texture around the cloud still shows up partly which is weird, because it does not happen with OpenGL. it actually works just fine when i set opengl render system
-
- OGRE Expert User
- Posts: 517
- Joined: Tue Mar 07, 2006 11:22 pm
- Location: Buenos Aires, Argentina
- x 1
As I posted in the other thread: http://www.ogre3d.org/phpBB2/viewtopic. ... 707#253707
I think you can set source2 to LBS_MANUAL, and then alphaArg2 to 0.0... I've been away from Ogre for a while so I don't remember this stuff very well, but I think this should work.
I think you can set source2 to LBS_MANUAL, and then alphaArg2 to 0.0... I've been away from Ogre for a while so I don't remember this stuff very well, but I think this should work.
H. Hernan Moraldo
Personal website
Personal website
-
- Gnoblar
- Posts: 18
- Joined: Thu Jun 21, 2007 4:38 pm
[Newbie question]
I put an app together based on the 2dsprite source and CEGUI, it worked well. I can have a 2d scene in the background and CEGUI menus over the top.
Then I added some standard Ogre particle effects and they work fine in isolation, but disappear if combined with the sprites.
I assume the particle effects are rendering through RENDER_QUEUE_MAIN the default queue. The sprites are rendered through RENDER_QUEUE_BACKGROUND so the particle effects should show up in front.
It seems to be related to the sprite system overriding some render system settings i.e. the world matrix, etc.
Presumably I need to reset everything after the sprite queue renders? Or cache the existing state of everything before making these changes and then putting it back? I can't seem to find any "rs->_get" type functions to do it though.
I put an app together based on the 2dsprite source and CEGUI, it worked well. I can have a 2d scene in the background and CEGUI menus over the top.
Then I added some standard Ogre particle effects and they work fine in isolation, but disappear if combined with the sprites.
Code: Select all
Ogre::SceneManager &sceneMgr = getSceneMgr();
pCamera->setPosition( Ogre::Vector3( 0, 0, 800 ) );
pCamera->lookAt( Ogre::Vector3( 0, 0, 0 ) );
sceneMgr.getRootSceneNode()->createChildSceneNode()->attachObject(
sceneMgr.createParticleSystem("Fireworks", "Examples/Fireworks"));
It seems to be related to the sprite system overriding some render system settings i.e. the world matrix, etc.
Code: Select all
Ogre::RenderSystem* rs=Ogre::Root::getSingleton().getRenderSystem();
rs->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
rs->_setViewMatrix(Ogre::Matrix4::IDENTITY);
rs->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
rs->_setTextureMatrix(0, Ogre::Matrix4::IDENTITY);
rs->_setTextureCoordSet(0, 0);
rs->_setTextureCoordCalculation(0, Ogre::TEXCALC_NONE);
rs->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_POINT);
rs->_disableTextureUnitsFrom(1);
rs->setLightingEnabled(false);
rs->_setFog(Ogre::FOG_NONE);
rs->_setCullingMode(Ogre::CULL_NONE);
rs->_setDepthBufferParams(false, false);
rs->_setColourBufferWriteEnabled(true, true, true, false);
rs->setShadingType(Ogre::SO_GOURAUD);
rs->_setPolygonMode(Ogre::PM_SOLID);
rs->unbindGpuProgram(Ogre::GPT_FRAGMENT_PROGRAM);
rs->unbindGpuProgram(Ogre::GPT_VERTEX_PROGRAM);
-
- Gnoblar
- Posts: 18
- Joined: Thu Jun 21, 2007 4:38 pm
Oops. It's nothing to do with render states. I'd assumed Ogre was updating the view and projection matrices, but it doesn't unless you tell it. If I add this code after the sprites finish rendering then everything seems to work.
Now I can have sprites in the background and particle systems going off in front.
Code: Select all
Ogre::Camera *pCam = sceneMan->getCamera("camera");
Ogre::RenderSystem* rs=Ogre::Root::getSingleton().getRenderSystem();
rs->_setViewMatrix( pCam->getViewMatrix(true) );
rs->_setProjectionMatrix( pCam->getProjectionMatrixRS() );