Projective textures

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
NeoPain
Halfling
Posts: 42
Joined: Fri Mar 18, 2005 9:24 pm
Location: Ukraine, Uzhgorod
Contact:

Projective textures

Post by NeoPain »

The feature why is chose OGRE is projected texture. I read http://www.ogre3d.org/phpBB2/viewtopic.php?t=5824. And it seem there are a lot of problems with using that. Is there some demo on Projective Textures?

User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 148
Contact:

Post by spookyboo »

Do you mean the fact that the projection is displayed in front and at the back of the frustum? This is normal with projective texture mapping.

User avatar
NeoPain
Halfling
Posts: 42
Joined: Fri Mar 18, 2005 9:24 pm
Location: Ukraine, Uzhgorod
Contact:

Post by NeoPain »

Yes, i ment that. So is there a demo?

User avatar
Kencho
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4011
Joined: Fri Sep 19, 2003 6:28 pm
Location: Burgos, Spain
x 2
Contact:

Post by Kencho »

Render to texture demo does that:

Code: Select all

        RenderTexture* rttTex = mRoot->getRenderSystem()->createRenderTexture( "RttTex", 512, 512, TEX_TYPE_2D, PF_R8G8B8 );
        {
            mReflectCam = mSceneMgr->createCamera("ReflectCam");
            mReflectCam->setNearClipDistance(mCamera->getNearClipDistance());
            mReflectCam->setFarClipDistance(mCamera->getFarClipDistance());
            mReflectCam->setAspectRatio(
                (Real)mWindow->getViewport(0)->getActualWidth() / 
                (Real)mWindow->getViewport(0)->getActualHeight());

            Viewport *v = rttTex->addViewport( mReflectCam );
            v->setClearEveryFrame( true );
            v->setBackgroundColour( ColourValue::Black );

            MaterialPtr mat = MaterialManager::getSingleton().create("RttMat",
                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
            TextureUnitState* t = mat->getTechnique(0)->getPass(0)->createTextureUnitState("RustedMetal.jpg");
            t = mat->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex");
            // Blend with base texture
            t->setColourOperationEx(LBX_BLEND_MANUAL, LBS_TEXTURE, LBS_CURRENT, ColourValue::White, 
                ColourValue::White, 0.25);
            t->setProjectiveTexturing(true, mReflectCam);
            rttTex->addListener(this);

            // set up linked reflection
            mReflectCam->enableReflection(mPlane);
            // Also clip
            mReflectCam->enableCustomNearClipPlane(mPlane);
        }
Just above "rttTex->addListener(this);" ;)
Image

User avatar
NeoPain
Halfling
Posts: 42
Joined: Fri Mar 18, 2005 9:24 pm
Location: Ukraine, Uzhgorod
Contact:

Post by NeoPain »

It seems that projective textures can be projected only on plane, righ?

User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 148
Contact:

Post by spookyboo »

No, I have projection on a billboard.

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Projective textures can apply to any surface / mesh.

User avatar
NeoPain
Halfling
Posts: 42
Joined: Fri Mar 18, 2005 9:24 pm
Location: Ukraine, Uzhgorod
Contact:

Post by NeoPain »

OK. Is a texture in REnderToTexture demo projected down to plane? I also created terrain there an texture wasnt projected on it...Thats maybe i dont undesrtand full process on setting up projective textures... Can anyone explain more detailed please? Previously thank you.

User avatar
NeoPain
Halfling
Posts: 42
Joined: Fri Mar 18, 2005 9:24 pm
Location: Ukraine, Uzhgorod
Contact:

Post by NeoPain »

wow...aswear me Hello!!! :roll: :)

User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 148
Contact:

Post by spookyboo »

What exactly isn't clear?
The idea of a projective textures is that you use a frustum (i.e. camera) that projects a texture on a surface, just like a movie. The texture in the code example is created by means of a camera, which is continuesly updated.

It's not exaclty clear to me what you want to do with the terrain though, but you can assign a material to the terrain with a texure that is rendered the same way as the example.

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

If you want to know more technical details about projective textures, use Google, there are lots and lots of articles about it (it's been around for decades).

User avatar
NeoPain
Halfling
Posts: 42
Joined: Fri Mar 18, 2005 9:24 pm
Location: Ukraine, Uzhgorod
Contact:

Post by NeoPain »

OK Thanks. We need to assign material which has a techinque with SetProjectiveTexturing right? I'll try.

Post Reply