New wiki article - easy material managment

bharling

10-01-2009 16:18:53

Just thought i'd let everyone know I've posted an article on the wiki concerning a little-documented but extremely useful ogre feature to quickly change all materials in a scene, for example to render a depth buffer image. This method avoids having to modify any material scripts or loop over any objects to change materials, and it runs quite fast too. I found it on the way to implementing Depth of Field for a project I'm working on, and thought it might be useful ( it certainly was to me ). AFAIK, its not fully documented anywhere else on the OGRE site.

Enjoy:

http://wiki.python-ogre.org/index.php/CodeSnippits_Easy_RTT_Materials_Management

skorpio

10-01-2009 16:35:12

Hello,

Thanks for your article is very informative. I have tried to implement Depth of Field unsuccessfully.
I'll give your code a try.

Best Regards,
Skorpio

bharling

11-01-2009 15:49:34

Thanks ;)

I've updated it a bit in the last few minutes, to fix a problem I encountered when adding compositors to the scene.

Basically, it turns out that you shouldn't use MaterialManager.Listener all the time, rather it should only be attached when you need it ie: when rendering to the depth target. To this end I added a rendertarget listener class that enables and disables the MaterialManager.Listener as the target is rendered. That way the compositor Quad doesn't get caught in the material listener ( I was getting really weird stuff going on with the whole screen quad or overlays being rendered using the depth or normal material - really hard to work out what was going on! )

anyway, I'd suggest using the new code to avoid the hair pulling I went through - also properly formatted for the wiki now as well.

cheers,