Motion Blur in ogre for iphone

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Ananditha Roy
Kobold
Posts: 30
Joined: Wed Mar 14, 2012 2:25 pm

Motion Blur in ogre for iphone

Post by Ananditha Roy »

Hi ,

Code: Select all

 Ogre::CompositorPtr comp3 = Ogre::CompositorManager::getSingleton().create(
                                                                               "Motion Blur", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
                                                                               );
	{
		Ogre::CompositionTechnique *t = comp3->createTechnique();
		{
			Ogre::CompositionTechnique::TextureDefinition *def = t->createTextureDefinition("scene");
			def->width = 0;
			def->height = 0;
			def->formatList.push_back(Ogre::PF_B8G8R8);
		}
		{
			Ogre::CompositionTechnique::TextureDefinition *def = t->createTextureDefinition("sum");
			def->width = 0;
			def->height = 0;
			def->formatList.push_back(Ogre::PF_B8G8R8);
		}
		{
			Ogre::CompositionTechnique::TextureDefinition *def = t->createTextureDefinition("temp");
			def->width = 0;
			def->height = 0;
			def->formatList.push_back(Ogre::PF_B8G8R8);
		}
		/// Render scene
		{
			Ogre::CompositionTargetPass *tp = t->createTargetPass();
			tp->setInputMode(Ogre::CompositionTargetPass::IM_PREVIOUS);
			tp->setOutputName("scene");
		}
		/// Initialisation pass for sum texture
		{
			Ogre::CompositionTargetPass *tp = t->createTargetPass();
			tp->setInputMode(Ogre::CompositionTargetPass::IM_PREVIOUS);
			tp->setOutputName("sum");
			tp->setOnlyInitial(true);
		}
		/// Do the motion blur
		{
			Ogre::CompositionTargetPass *tp = t->createTargetPass();
			tp->setInputMode(Ogre::CompositionTargetPass::IM_NONE);
			tp->setOutputName("temp");
			{ Ogre::CompositionPass *pass = tp->createPass();
                pass->setType(Ogre::CompositionPass::PT_RENDERQUAD);
                pass->setMaterialName("Ogre/Compositor/Combine");
                pass->setInput(0, "scene");
                pass->setInput(1, "sum");
			}
		}
		/// Copy back sum texture
		{
			Ogre::CompositionTargetPass *tp = t->createTargetPass();
			tp->setInputMode(Ogre::CompositionTargetPass::IM_NONE);
			tp->setOutputName("sum");
			{ Ogre::CompositionPass *pass = tp->createPass();
                pass->setType(Ogre::CompositionPass::PT_RENDERQUAD);
                pass->setMaterialName("Ogre/Compositor/Copyback");
                pass->setInput(0, "temp");
			}
		}
		/// Display result
		{
			Ogre::CompositionTargetPass *tp = t->getOutputTargetPass();
			tp->setInputMode(Ogre::CompositionTargetPass::IM_NONE);
			{ Ogre::CompositionPass *pass = tp->createPass();
                pass->setType(Ogre::CompositionPass::PT_RENDERQUAD);
                pass->setMaterialName("Ogre/Compositor/MotionBlur");
                pass->setInput(0, "sum");
			}
		}
	}
    
    
and i have the MotionBlur.material as below

Code: Select all

fragment_program Ogre/Compositor/Combine_fp cg
{
	source Combine_fp.cg
	profiles ps_2_0 arbfp1
	entry_point Combine_fp

	default_params
	{
		param_named blur float 0.8
	}
}

material Ogre/Compositor/Combine
{
	technique
	{
		pass
		{
			depth_check off

			fragment_program_ref Ogre/Compositor/Combine_fp
			{
			}

			vertex_program_ref Ogre/Compositor/StdQuad_Cg_vp
			{
			}

			texture_unit RT
			{
				tex_address_mode clamp
				filtering linear linear none
                tex_coord_set 0
			}

			texture_unit SUM
			{
				tex_address_mode clamp
				filtering linear linear none
                tex_coord_set 0
			}
		}
	}
}

material Ogre/Compositor/Copyback
{
	technique
	{
		pass
		{
			lighting off
			depth_check off

			texture_unit Temp
			{
				tex_address_mode clamp
				filtering linear linear none
				colour_op replace
                tex_coord_set 0
			}
		}
	}
}

material Ogre/Compositor/MotionBlur
{
	technique
	{
		pass
		{
			lighting off
			depth_check off

			texture_unit Sum
			{
				tex_address_mode clamp
				filtering linear linear none
				colour_op replace
                tex_coord_set 0
			}

		}
	}
}
in the example.compositor

Code: Select all

compositor "MotionBlur"
{
technique
{
// Temporary textures
texture scene target_width target_height PF_A8R8G8B8
texture sum target_width target_height PF_A8R8G8B8
texture temp target_width target_height PF_A8R8G8B8

target scene
{
// Render output from previous compositor (or original scene)
input previous
}
target sum
{
// Render this target pass only initially, on the first frame that
// this effect was enabled. This makes sure the sum texture
// does not start with randomness.
only_initial on

input previous
}
target temp
{
// Start with clear texture
input none
// Combine scene and sum texture
pass render_quad
{
// Renders a fullscreen quad with a material
material Ogre/Compositor/Combine
input 0 scene
input 1 sum
}
}
target sum
{
// Start with clear texture
input none
// Copy temporary back to sum
pass render_quad
{
// Renders a fullscreen quad with a material
material Ogre/Compositor/Copyback
input 0 temp
}
}
target_output
{
// Start with clear output
input none
// Draw a fullscreen quad with the blur
pass render_quad
{
// Renders a fullscreen quad with a material
material Ogre/Compositor/MotionBlur
input 0 sum
}
}
}
} 
i did anything wrong in the above steps ,, do i need to add any plugins for this . plz help me
I am getting this warning

material Ogre/Compositor/Combine has no supportable Techniques and will be blank. Explanation:
Pass 0: Vertex program Ogre/Compositor/StdQuad_Cg_vp cannot be used - not supported.

WARNING: material Ogre/Compositor/Combine has no supportable Techniques and will be blank. Explanation:
Pass 0: Vertex program Ogre/Compositor/StdQuad_Cg_vp cannot be used - not supported.

CompositorChain: Compositor MotionBlur has no supported techniques.