terra+sky compositor, shader param

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
Posts: 192
Joined: Thu Jun 10, 2004 4:19 am
x 11

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(
		Ogre::Pass* pass = mat->getTechnique(0)->getPass(0);

		Ogre::GpuProgramParametersSharedPtr psParams = pass->getFragmentProgramParameters();
		psParams->setNamedConstant("colors", Ogre::Vector4(static_cast<Ogre::Real>(0),
			1, 1));
			//each frame
				psParams->setNamedConstant("colors", Ogre::Vector4(static_cast<Ogre::Real>(a/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
OGRE Team Member
OGRE Team Member
Posts: 4501
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 936

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.

Post Reply