Procedural generated 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
Zeckurbo
Gnoblar
Posts: 9
Joined: Wed Nov 11, 2020 6:13 pm

Procedural generated textures

Post by Zeckurbo »

I was about to play around with some procedural textures.

I came across ogre procedural, but it seemed like a plugin to me. Is this correct?
https://ogrecave.github.io/ogre-procedu ... tures.html

Is it possible to use procedural textures in vanilla ogre 1.12 and maybe also generate some?

Thanks for helping

User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 169
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 39

Re: Procedural generated textures

Post by sercero »

Hello,

As far as I know you cannot generate procedural textures in vanilla OGRE.

I have not used OGRE procedural but it seems to be a library not a plugin.

So you should compile it separately and use it from withing your OGRE app.

Check out the wiki page and the forum to get more information:
http://wiki.ogre3d.org/Ogre+Procedural+Geometry+Library

User avatar
Zeckurbo
Gnoblar
Posts: 9
Joined: Wed Nov 11, 2020 6:13 pm

Re: Procedural generated textures

Post by Zeckurbo »

Thank you for your answer.

Do you know if vanilla Ogre can display a procedural texture in any kind of way?

paroj
OGRE Team Member
OGRE Team Member
Posts: 1400
Joined: Sun Mar 30, 2014 2:51 pm
x 610
Contact:

Re: Procedural generated textures

Post by paroj »

well, ogre-procedural displays procedural textures using ogre, so it must be possible somehow..

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7154
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 525

Re: Procedural generated textures

Post by Kojack »

If you mean generating textures by code, it's fairly easy in Ogre 1.x.
Here's a quick hack demo of bare texture generation (been a few years since I've done this, so not sure if there's currently a better way).

Code: Select all

		Ogre::Entity* ent = scnMgr->createEntity("Sinbad.mesh");
		Ogre::SceneNode* node = scnMgr->getRootSceneNode()->createChildSceneNode();
		node->attachObject(ent);

		auto tex = Ogre::TextureManager::getSingleton().createManual("brick", "General", Ogre::TextureType::TEX_TYPE_2D, 256, 256, 1, Ogre::PixelFormat::PF_B8G8R8A8);
		auto hpb = tex->getBuffer();
		auto pb = hpb->lock(Ogre::Box(0, 0, 255, 255), Ogre::HardwareBuffer::LockOptions::HBL_DISCARD);
		for (int y = 0; y < 256; ++y)
		{
			for (int x = 0; x < 256; ++x)
			{
				Ogre::ColourValue c(1, 1, 1, 1);
				if (y % 8 == 0)
					c = Ogre::ColourValue(0, 0, 0, 1);
				if((x+((y/8)%2)*8)%16==0)
					c = Ogre::ColourValue(0, 0, 0, 1);
				pb.setColourAt(c, x, y, 0);
			}
		}
		hpb->unlock();

		auto mat = ent->getSubEntity(1)->getMaterial();
		mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTexture(tex);
This generates a procedural brick texture.

Image

If you want something higher level like Ogre Procedural does (cells, gradients, noise, etc) that's not in Ogre, you'd have to write those effects yourself.

Post Reply