terra+sky compositor, shader param

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Nickak2003
Goblin
Posts: 272
Joined: Thu Jun 10, 2004 4:19 am
x 26

terra+sky compositor, shader param

Post by Nickak2003 »

Ok, I added the sky post-processing compositor_node into the terra compositor, and it works to draw the sky. So now, I want to be able to alter the sky based on shader params, and I've done a lot of research and stuff I think, but I ended up doing the following:

Code: Select all

		Ogre::MaterialPtr mat= Ogre::MaterialManager::getSingleton().load(
			"SkyPostprocess",
			Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME).
			staticCast<Ogre::Material>();
		Ogre::Pass* pass = mat->getTechnique(0)->getPass(0);

		Ogre::GpuProgramParametersSharedPtr psParams = pass->getFragmentProgramParameters();
		psParams->setNamedConstant("colors", Ogre::Vector4(static_cast<Ogre::Real>(0),
			static_cast<Ogre::Real>(1),
			1, 1));
			
			//each frame
				psParams->setNamedConstant("colors", Ogre::Vector4(static_cast<Ogre::Real>(a/100.0f),
					static_cast<Ogre::Real>(b/100.0f),
					1, 1));
This is different from all the stuff I was reading about modifying hlms or listeners for say, fog parameters, is what I have done correct or is there a better method?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5505
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1372

Re: terra+sky compositor, shader param

Post by dark_sylinc »

I'm not sure what the question is... but everything looks correct.

Given that the sky is implemented as a compositor effect using the older material system; it uses a different interface (the 1.x one).
Btw you don't need to set it every frame if the values don't change.