Mogre Crashes with Compositor

Jo0oker

10-03-2011 21:16:50

Hello,

i tried to convert the C++ Motion Blure code to Mogre:

CompositorPtr comp3 = CompositorManager.Singleton.Create(
"Comp_MotionBlur", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME
);
{
CompositionTechnique t = comp3.CreateTechnique();
{
CompositionTechnique.TextureDefinition_NativePtr def = t.CreateTextureDefinition("scene");
def.width = (uint)myITOgre.Viewport.Width;
def.height = (uint)myITOgre.Viewport.Height;
def.formatList.Add(PixelFormat.PF_R8G8B8);
}
{
CompositionTechnique.TextureDefinition_NativePtr def = t.CreateTextureDefinition("sum");
def.width = (uint)myITOgre.Viewport.Width;
def.height = (uint)myITOgre.Viewport.Height;
def.formatList.Add(PixelFormat.PF_R8G8B8);
}
{
CompositionTechnique.TextureDefinition_NativePtr def = t.CreateTextureDefinition("temp");
def.width = (uint)myITOgre.Viewport.Width;
def.height = (uint)myITOgre.Viewport.Height;
def.formatList.Add(PixelFormat.PF_R8G8B8);
}
/// Render scene
{
CompositionTargetPass tp = t.CreateTargetPass();
tp.SetInputMode(CompositionTargetPass.InputMode.IM_PREVIOUS);
tp.OutputName = ("scene");
}
/// Initialisation pass for sum texture
{
CompositionTargetPass tp = t.CreateTargetPass();
tp.SetInputMode(CompositionTargetPass.InputMode.IM_PREVIOUS);
tp.OutputName = ("sum");
tp.OnlyInitial = (true);
}
/// Do the motion blur
{
CompositionTargetPass tp = t.CreateTargetPass();
tp.SetInputMode(CompositionTargetPass.InputMode.IM_NONE);
tp.OutputName = ("temp");
{
CompositionPass pass = tp.CreatePass();
pass.Type = CompositionPass.PassType.PT_RENDERQUAD;
pass.SetMaterialName("Ogre/Compositor/Combine");
pass.SetInput(0, "scene");
pass.SetInput(1, "sum");
}
}
/// Copy back sum texture
{
CompositionTargetPass tp = t.CreateTargetPass();
tp.SetInputMode(CompositionTargetPass.InputMode.IM_NONE);
tp.OutputName = ("sum");
{
CompositionPass pass = tp.CreatePass();
pass.Type = CompositionPass.PassType.PT_RENDERQUAD;
pass.SetMaterialName("Ogre/Compositor/Copyback");
pass.SetInput(0, "temp");
}
}
/// Display result
{
CompositionTargetPass tp = t.OutputTargetPass;
tp.SetInputMode(CompositionTargetPass.InputMode.IM_NONE);
{
CompositionPass pass = tp.CreatePass();
pass.Type = CompositionPass.PassType.PT_RENDERQUAD;
pass.SetMaterialName("Ogre/Compositor/MotionBlur");
pass.SetInput(0, "sum");
}
}
}

CompositorInstance myInstance = CompositorManager.Singleton.AddCompositor(myITOgre.Viewport, "Comp_MotionBlur");
CompositorManager.Singleton.SetCompositorEnabled(myITOgre.Viewport, "Comp_MotionBlur", false);


But when i call:

CompositorManager.Singleton.SetCompositorEnabled(myITOgre.Viewport, "Comp_MotionBlur", true);


my application crashes, without any error.

There is also no message in the Ogre.log.

Does anyone have an idea?

Greets,
Jo0oker

smiley80

11-03-2011 11:58:10

There's a problem with 'TextureDefinition.formatList', seems you can't add items. It works when you create a new instance:

def.formatList = new PixelFormatList
{
PixelFormat.PF_R8G8B8
};

Also you have to use the actual viewport size or 0:
def.width = 0;
def.height = 0;

Jo0oker

11-03-2011 13:00:51

Thank you, now it works fine:


Thank you!

Greets,
Jo0oker