Page 1 of 1

pluginless web browser ogre embedding through emscripten

Posted: Wed Jun 20, 2012 8:34 am
by kkimlabs
I recently discovered emscripten, and I think it's really cool. Maybe ogre3d can benefit from it.

https://github.com/kripken/emscripten/wiki
"Emscripten is an LLVM-to-JavaScript compiler. It takes LLVM bitcode (which can be generated from C/C++ using Clang, or any other language that can be converted into LLVM bitcode) and compiles that into JavaScript, which can be run on the web (or anywhere else JavaScript can run).

Using Emscripten, you can:
*Compile C and C++ code into JavaScript and run that on the web
*Run code in languages like Python as well, by compiling CPython from C to JavaScript and interpreting code in that on the web"

the most relevant demo(bullet+webgl) : http://www.syntensity.com/static/ammo.html


Cons:
web standard(unlike NaCl which is not likely to be supported other than the chromium browser family)
pluginless
incorporates LLVM; thus less modification is required.

Pros:
possibly slow speed (the bullet+webgl demo shows 60 fps on my machine but not sure for more complex scene)
needs webgl porting.

Re: pluginless web browser ogre embedding through emscripten

Posted: Mon Jul 02, 2012 7:18 pm
by kripken
Hi, I'm an Emscripten dev. We've ported entire game engines, for example Cube 2/Sauerbraten,

http://www.syntensity.com/static/night8/ (warning: needs a development build of Firefox or Chrome)

so Ogre would definitely be possible. If someone is interested in doing this I would be happy to help on the Emscripten side.

Re: pluginless web browser ogre embedding through emscripten

Posted: Tue May 07, 2013 9:09 pm
by jj
Hi!

Any progress on this? It would just be amazing to be able to run Ogre on a browser without a plugin installation.... Would be the way to keep up with Three.js and the like engines.

Thanks!
jj

Re: pluginless web browser ogre embedding through emscripten

Posted: Wed May 08, 2013 8:23 am
by TheSHEEEP
jj wrote:Would be the way to keep up with Three.js and the like engines.
"Keep up" is definitely the wrong phrase here ;)

WebGL & JavaScript is by far not as grown up as many people claim it to be. Networking, audio, videos, etc. are still a pita (and there are many more shortcomings).
Give 'em some more years and we will see where they are then :)

Re: pluginless web browser ogre embedding through emscripten

Posted: Wed May 08, 2013 3:37 pm
by kripken
I would say that full 3D on the web is pretty mature, as shown by Unreal Engine 3 being able to run in JS+WebGL,

http://www.unrealengine.com/html5/

Would be great if we could get Ogre there too.

Re: pluginless web browser ogre embedding through emscripten

Posted: Wed May 08, 2013 3:57 pm
by jj
"Keep up" is definitely the wrong phrase here
Totally right :) was not my intention to be rough. The reason why I say that is cause there is so much movement now towards graphics engines running on browsers plugin-less (the recent example that kripken put is the most amazing case) that I think Ogre3d should have an eye on it, specially with possibilities like Emscripten which make it seem like a viable option. It would be a solid reason to keep using and pushing Ogre in IMHO. But don't take me wrong, I love Ogre (and we're using it on this framework about to be released, where web support would be amazing next step but it is dependent on Ogre supporting it).

Re: pluginless web browser ogre embedding through emscripten

Posted: Thu May 09, 2013 3:16 am
by kripken
The great thing with Ogre is that it's both powerful and open source. Things like Unreal Engine and others are now running on the web or soon will, but are closed source of course. three.js and other JS WebGL engines are open source and quite good in some ways, but not powerful like Ogre is.

The WebGL space is going to become very large very soon, especially now that apparently even Internet Explorer (11) will support WebGL. So it would be great if Ogre ran on the web too and there was a really solid open source option.

My offer still stands to help on the Emscripten side if the Ogre community is interested in doing this.

Re: pluginless web browser ogre embedding through emscripten

Posted: Fri May 10, 2013 3:59 am
by Marc
Ogre working with emscripten would be awesome! :)

I'm not sure about the size of the generated html though. Might get huge.

Re: pluginless web browser ogre embedding through emscripten

Posted: Fri May 10, 2013 10:43 am
by TheSHEEEP
Well, all JavaScript stuff is typically obfuscated (All variables having only a length of 1 character, no spaces, etc.).
So the size of the engine itself shouldn't be too big.

Assets are a much bigger problem in the browser.

I'm generally for everything that pushes OpenGL, and webGL does, so you have a +1 from me if you want to try your hand at Ogre + emscripten :D

Re: pluginless web browser ogre embedding through emscripten

Posted: Fri May 10, 2013 10:38 pm
by Marc
emscripten generated big html files. the data, you'll always have when you bring 3d to the web no matter what you do. with emscripten, a natively compiled code that becomes 500kb is 2mb in emscripted generated html. Ogremain.dll has 6mb natively for me. So that alone might become 24mb in emscripten generated html/js ...

But still, maybe we can host it at a central location and browsers could cache it.

Re: pluginless web browser ogre embedding through emscripten

Posted: Fri May 10, 2013 10:51 pm
by TheSHEEEP
Marc wrote:emscripten generated big html files. the data, you'll always have when you bring 3d to the web no matter what you do. with emscripten, a natively compiled code that becomes 200kb is 2mb in emscripted generated html. Ogremain.dll has 6mb natively for me. So that alone might become 60mb in emscripten generated html/js ...
Mhh... nope.
I mean, yes, if you are talking about unoptimized JS. Have a look at that developer post about file size: here.
That shows a 10x increase in size compared to object files, yes. But that is mainly because all the function and variable names remain unchanged.
But as any distributed JS code should be obfuscated and stripped of anything unnecessary anyway, it is more or less a non-issue. After that stripping down is done (in that post this is done with "Closure"), the file size is only around 2x bigger than the original object file.
That's pretty good if you take into account it is not in binary format.

Also, I don't know what HTML you are talking about. emscripten afaik creates only JS files. Besides creating a "test" HTML page for embedding the JS files, that is.

Re: pluginless web browser ogre embedding through emscripten

Posted: Fri May 10, 2013 11:05 pm
by PhilipLB
Just have a look at http://flohofwoe.blogspot.de/ , where major parts of the Nebula 3 engine are compiled via Emscripten.

Re: pluginless web browser ogre embedding through emscripten

Posted: Fri May 10, 2013 11:36 pm
by saejox
Unreal is 52mb of uncompressed js code.
Three.js is 0.9mb of uncompressed js.

Three.js compressed is 100kb. I couldn't compile unreal code. Closure finds lots of errors in it.
Assuming it's 5mb. That's still 50x more than hand written webgl code.

Unreal code is at this link: http://www.unrealengine.com/html5/UDKGa ... hipping.js

Not to devalue emscripten, i think it's awesome.
However, if i wanted to create a web game i wouldn't chose a C++ engine and port it to html.

Re: pluginless web browser ogre embedding through emscripten

Posted: Sat May 11, 2013 2:21 pm
by Marc
The values I posted are from my own experience just this week. And yes I enabled the optimizations. Emscripten does generate a html file with the generated js in it.

However, I assume that if ogre worked with emscripten, a lot of people will be interested in it. If several projects use it and we set up a central location to host it, download size wouldn't matter that much. It's like the unity web plugin then - without having to actually install it. Instead, it will run from the browser's cache once it is loaded.

Re: pluginless web browser ogre embedding through emscripten

Posted: Sun May 12, 2013 8:22 am
by TheSHEEEP
Plus, you can always have a loading bar ;)

Re: pluginless web browser ogre embedding through emscripten

Posted: Wed May 15, 2013 10:03 pm
by Mikachu
kripken wrote:I would say that full 3D on the web is pretty mature, as shown by Unreal Engine 3 being able to run in JS+WebGL,

http://www.unrealengine.com/html5/
This demo has a big "only runs in firefox" sign at the moment... so it's not what I would call mature.
I guess it must use asm.js, which is firefox only atm (even if it may change in the near future), which is as good as NaCl being chrome only...
Yes, it will probably become good in the future, but I wouldn't call it ready for production right now.
In fact, I would much prefer an officially supported Ogre browser plugin rather than an slower/hacky conversion to javascript. :roll:

Just my two cents, of course :)

Re: pluginless web browser ogre embedding through emscripten

Posted: Fri May 17, 2013 12:21 am
by Marc
Mikachu wrote:
kripken wrote:I would say that full 3D on the web is pretty mature, as shown by Unreal Engine 3 being able to run in JS+WebGL,

http://www.unrealengine.com/html5/
This demo has a big "only runs in firefox" sign at the moment... so it's not what I would call mature.
I guess it must use asm.js, which is firefox only atm (even if it may change in the near future), which is as good as NaCl being chrome only...
Yes, it will probably become good in the future, but I wouldn't call it ready for production right now.
In fact, I would much prefer an officially supported Ogre browser plugin rather than an slower/hacky conversion to javascript. :roll:

Just my two cents, of course :)
I'm not sure about this but afaik is asm.js just a subset of javascript. Therefore, all asm.js stuff runs on all browsers that can run js. There is a special optimization implemented in firefox that makes asm.js compliant javascript code run faster. However, this is not yet in the normal stable build but only in the nightly build. So for now, that unreal demo should run approximately equally well in ff and chrome.

There is also a port of cube2 to the browser. Including networking. Runs surprisingly well: https://developer.cdn.mozilla.net/media ... index.html

Re: pluginless web browser ogre embedding through emscripten

Posted: Fri May 17, 2013 9:47 am
by Mikachu
Marc wrote:There is a special optimization implemented in firefox that makes asm.js compliant javascript code run faster. However, this is not yet in the normal stable build but only in the nightly build.
That's what I meant about not being mature :wink:

But it's true that at least, it's cross-browser...

Re: pluginless web browser ogre embedding through emscripten

Posted: Mon Jun 03, 2013 1:41 pm
by Dernise
It would really be awesome if ogre3D was ported to emscripten. :)

Re: pluginless web browser ogre embedding through emscripten

Posted: Wed Jan 22, 2014 1:15 pm
by joeyye
I made ogre work on emscripten, and it can support plugin. detail information visit
https://github.com/mview/summary/wiki/Summary

There is still a lot of work need be improved, I really appreciate if anyone can help me.