Depth of field (working version)


27-12-2011 13:56:47


I want to share my (from c++ to net) converted version of this dof implemention.

Note: I only converted this code. I used a modified version by polygon9

There is now a wiki page:

How to use it:

There are three classes:
DepthOfField - This is the class which controls the dof shader and the underlying compositor script.
Lens - This is a class which makes it easier to control the DeathOfField class (makes it more natural)
dofmanager - This class combines both other classes to an automatic dof shader: create a new instance and set mode=automatic and everything runs out of the box

1. Copy the folder "dof" and its files (in to your media folder
2. Add a reference of the folder "dof" either in code or in the resource file
3. create a dofmanager instance (and set the values you need) or do it by hand with DeathOfField [and Lens]

These are some pictures from the original thread.
The original source is here.

Thanks to:


29-12-2011 09:45:26

great! it's very useful


15-01-2012 17:21:28

Nice would be to create a wiki page related your code.
So people have a better chance to find you useful work - even after month and years.


15-01-2012 19:52:15

Ok, it's on my todo list.

Just one question: Where should it be? In the snippet section?


16-01-2012 02:33:05

Good question.
... And good idea.

I would suggest to add it as child to:
Libraries » Alternative Languages » MOGRE » Mogre HOWTO's and Snippets

The page you can create with easy by "add page" from here: ... d+Snippets


16-01-2012 09:31:29

Nice work! But no need to kill the poor field, as it's actually "depth of field" instead of death. :wink:


16-01-2012 17:51:13

Nice work! But no need to kill the poor field, as it's actually "depth of field" instead of death. :wink:

Edit: (my first) Wiki page created: (Section: Shaders)


17-01-2012 00:05:02

Great work - it's looking really well.
Thank you very much. :D

Additionally it's nice to see that you added both, C# and VS.


08-11-2016 18:17:07


I'm trying to implement DOF with Mogre 1.7.4, but when I try to Render my Scene, I receive this error message:

"The native class that implements Ogre::Renderable isn't a subclass of CLRObject. Cannot create the CLR wrapper object."

Anyone has a sugestion?

More information:
- When I implemented DepthOfFieldEffect class, I can't declare RenderTargetListener RenderTargetListener and CompositorInstance.Listener Listener, because I have a compilation error: Cannot declare a variable of static class.
But these 2 variables are not used in this class, so I commented these 2 lines.

- I'm using DX9

- The Ogre.log does not show any error. All shaders are compiling well

Thank you