fast transparent windows with Ogre - rough draft

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am

fast transparent windows with Ogre - rough draft

Post by johnhpus » Sun Feb 26, 2012 5:26 am

Hi guys

A while back I was asked to render an Ogre scene into a transparent window, such that the objects in the scene appeared to float above the desktop. I did a thorough search of the forums and looked around the internet for ideas, and I found the common technique used to achieve that effect. That technique was to render the scene to texture, copy the texture from the GPU into system memory, and then blit that texture onto a layered window. The problem with that technique is that it is brutally slow and as far as I could tell at the time, there was no way around those expensive operations.

A few weeks ago I discovered an alternative technique in an article written by a fellow named Tristan Ward. I have adapted his technique for Ogre, and it allows Ogre to render transparently at full speed without any of the downsides of the old approach. I want to share this information with my fellow Ogre users and to that end I have written an article and example project detailing how to implement this new method of transparent rendering. This is just a draft. I wrote it in one sitting and have barely proof read it. When I have finished I'll add it to the Wiki and also make it available on my website.

If anyone does read it please let me know about errors or problems.

Image

article
http://focusgames.net/Transparent_Windo ... raft_1.pdf

source and binaries
http://focusgames.net/OgreTransparentWindow.7z
0 x

Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: fast transparent windows with Ogre - rough draft

Post by Pulas » Sun Feb 26, 2012 8:08 am

Thanks for sharing! I was looking for this kind of solution. It is really interesting!
0 x

User avatar
aguru
Goblin
Posts: 236
Joined: Tue Feb 26, 2008 5:48 pm

Re: fast transparent windows with Ogre - rough draft

Post by aguru » Sun Feb 26, 2012 3:18 pm

Thanks! I think this should be added to the wiki so this information does not get lost?
0 x

User avatar
cybereality
Hobgoblin
Posts: 563
Joined: Wed Jul 12, 2006 5:40 pm

Re: fast transparent windows with Ogre - rough draft

Post by cybereality » Sun Feb 26, 2012 9:06 pm

This looks really interesting. One problem though, when I try this on Windows Vista 32-bit I get a black square (behind the ogre) so it is not transparent for me.
0 x

User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am

Re: fast transparent windows with Ogre - rough draft

Post by johnhpus » Sun Feb 26, 2012 11:11 pm

Oh, darn, I had really hoped it would work on Vista. I'll have to do some experimentation.

And yeah, this can/will definitely go up on the Wiki. I'll try to proof and polish the article over this week and when it's finished I'll toss it on the Wiki.
0 x

User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
Contact:

Re: fast transparent windows with Ogre - rough draft

Post by duststorm » Mon Feb 27, 2012 12:44 am

Interesting.
This technique is specific for windows, but since it works with the OpenGL system I wonder whether it would be possible to use such composite window types on MAC OS and linux too.
0 x
Developer @ MakeHuman.org

User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am

Re: fast transparent windows with Ogre - rough draft

Post by johnhpus » Mon Feb 27, 2012 12:46 am

I've done a little reading about achieving this effect on Mac. It seems like there's a way to do it without much trickery, but I don't have much experience coding for Mac and I haven't done any work on it yet.
0 x

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7144
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 12

Re: fast transparent windows with Ogre - rough draft

Post by Kojack » Mon Feb 27, 2012 4:52 am

This looks really interesting. One problem though, when I try this on Windows Vista 32-bit I get a black square (behind the ogre) so it is not transparent for me.
I had the same thing in windows 7 (a black rectangle behind sinbad). After reading the original article I realised that it was because I use windows classic theme. The technique only works if you have Aero enabled for your desktop. Switching to the default windows 7 theme made it work fine. So it might be your desktop theme settings that are stopping it.
0 x

User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
Contact:

Re: fast transparent windows with Ogre - rough draft

Post by duststorm » Mon Feb 27, 2012 12:01 pm

Could it be possible that this fast transparent window rendering is a new feature in windows 7 developed for the aero themes? This might be why it gets disabled when disabling the aero themes.
0 x
Developer @ MakeHuman.org

User avatar
Zonder
Ogre Magi
Posts: 1102
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 12

Re: fast transparent windows with Ogre - rough draft

Post by Zonder » Mon Feb 27, 2012 1:27 pm

This technique is using the desktop window manager which is only used when aero is enabled. So that is why the black effect when aero disabled as there is no acceleration to the desktop.

It will work on vista as thats when the DWM was created.
0 x
There are 10 types of people in the world: Those who understand binary, and those who don't...
My Blog - http://www.This post is suspected as SPAM! If you feel otherwise contact a moderator.

User avatar
zarlox
Halfling
Posts: 70
Joined: Tue Apr 19, 2011 12:32 am
Location: Canada

Re: fast transparent windows with Ogre - rough draft

Post by zarlox » Mon Feb 27, 2012 10:21 pm

duststorm wrote:Could it be possible that this fast transparent window rendering is a new feature in windows 7 developed for the aero themes? This might be why it gets disabled when disabling the aero themes.
With the aero theme enabled, the DWM is rendering each window to a D3D texture and then composite the final render for the desktop. Only Vista and 7 when aero is enabled, can use this technique. With classic or basic theme or on windows XP, the GDI blit directly on the screen when rendering the application.

So for windows, you should probably detect if the aero theme is enabled by calling the WIN32 function DwmIsCompositionEnabled() (i think thats the one?).
0 x

User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
Contact:

Re: fast transparent windows with Ogre - rough draft

Post by duststorm » Tue Feb 28, 2012 11:45 am

So the new windows DWM works kind of like Compiz on linux, and propably much like the window compositor on MAC OS too.
For this technique to work you thus need a window compositor or manager that already uses 3D rendering.
This would exclude windows XP, but would be possible to get working on all new operating systems given that users have the proper configuration.

On windows you could probably use the aforementioned DwmIsCompositionEnabled API call and do a fallback to a slower technique if it's not supported or enabled (maybe with a warning message so the user knows what's going on)
0 x
Developer @ MakeHuman.org

noorus
Halfling
Posts: 75
Joined: Wed Apr 20, 2011 9:55 pm
Location: Helsinki, Finland

Re: fast transparent windows with Ogre - rough draft

Post by noorus » Fri Mar 02, 2012 5:23 pm

You could fall back on using a layered window if Aero is not available. Layered windows work on every Windows since 2000, and offer a full 8-bit alpha channel as well. They're slower, as they require a move back from video memory to system memory, plus the blit, but you can still achieve hundreds of FPS, although you only need to hit vsync.
0 x
Creator of Nice Input Library, for your advanced input needs.
Image

User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am

Re: fast transparent windows with Ogre - rough draft

Post by johnhpus » Fri Mar 02, 2012 7:48 pm

Yeah, the layered window approach is the original technique I wanted to replace.

Thanks for the tips, insight etc. to everyone who's commented. I will update the article with this information soon, hopefully this weekend.
0 x

Post Reply