Need help with generating of single color material from code. Topic is solved

Problems building or running the engine, queries about how to use features etc.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 107
Joined: Fri May 23, 2025 5:04 pm
x 4

Need help with generating of single color material from code.

Post by slapin »

Hi, all!
I'd appreciate example of creation of single color unlit materials from code. It is needed for a debug tool
and manual creation gets messy... Also that will get me started with other things.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 107
Joined: Fri May 23, 2025 5:04 pm
x 4

Re: Need help with generating of single color material from code.

Post by slapin »

Code: Select all

		Ogre::MaterialPtr mat =
			Ogre::static_pointer_cast<Ogre::Material>(
				Ogre::MaterialManager::getSingleton()
					.createOrRetrieve("Debug/Red2",
							  "General")
					.first);
		mat->removeAllTechniques();
		Ogre::Technique *tech = mat->createTechnique();
		tech->setDiffuse(Ogre::ColourValue(1, 0, 0, 1));
		tech->setName("Debug/S");
		tech->setDepthCheckEnabled(false);
		tech->setLightingEnabled(false);

This is what I try to do and it silently doesn't work...

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 107
Joined: Fri May 23, 2025 5:04 pm
x 4

Re: Need help with generating of single color material from code.

Post by slapin »

The problem is still actual. Is it even possible to create single-color materials with diffuse-only without textures?

paroj
OGRE Team Member
OGRE Team Member
Posts: 2189
Joined: Sun Mar 30, 2014 2:51 pm
x 1179

Re: Need help with generating of single color material from code.

Post by paroj »

there is no "unlit", only ffp. Enable lighting and set emissive.