home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


BananaBread: Porting Cube 2 to the Web

by kripken on 05/04/2012 00:02, 143 messages, last message: 11/10/2016 01:26, 65917 views, last view: 01/29/2022 02:53

Over the last month I've been working to get Sauerbraten running on the web, here is a demo of what I have so far:

http://syntensity.com/static/bb/client.html

Press the "fullscreen" button below the screen, then press "GO!".

That is the Sauerbraten C++ code, compiled to JavaScript and WebGL. It runs at 60fps on my laptop on both Firefox and Chrome, but note that it has not been optimized *at all* yet. I'm posting here because I just got what you see in the demo to work, not because it's finished ;) In particular, the code is not optimized or even minified, and when you press "GO!" it loads an ugly level that I made (I have no artistic talent). So ignore the performance, download time, and artwork. This is just a very very early demo.

Note that you need a very recent browser for the demo to work 100%. Firefox Nightly (15) has fullscreen and pointer lock, for example, but earlier versions don't, the same is true for Chrome. Stable versions of those browsers probably will not work so well, you'll need dev versions (nightly or beta for Firefox, canary or beta for Chrome).

So again this is just a very early demo, but I think this is enough to show the approach can work. Actually we knew this could work already because Mandreel did it,

http://dl.dropbox.com/u/6873971/data/cube2/index.html

But Mandreel is a closed-source compiler that costs money while this demo was made with emscripten, a free open source compiler (that I work on). All the tools and all the code here are open, here is the engine code https://github.com/kripken/BananaBread (hardly any is changed, though) and here is the compiler http://emscripten.org/ So this project will end up with something Sauerbraten and other Cube 2-using projects can use, if they want, unlike Mandreel's tech demo.

Another difference is Mandreel apparently just wanted a tech demo of walking through a small map, that's what they have, whereas the goal in this project is to get all the rest of Sauerbraten working: Rendering other characters, bot AI, weapons, editing (actually a lot of editing already works in the demo!) etc. Basically we aim to get everything working, minus multiplayer since web browsers can't support that yet. But even that should be possible later this year when web browsers get WebRTC support, so we should be able to get the entire game :)

Why is this worth doing? In my opinion, two main reasons:

1. To promote 3D games on the web using open technologies. 3D games are starting to appear on the web, but generally they depend on nonstandard and/or closed source technologies like Flash. This project uses only 100% open and standard technologies, JavaScript and WebGL. We need open technologies to win.

2. To give back to the Sauerbraten community. While running on the web has disadvantages, it does have one huge advantage - all you need is a web browser to run the game. You don't need to download and install an application, which stops most people visiting your game's website from actually playing the game. Imagine if anyone visting the Sauerbraten website could just click and jump right into a game, we could get a lot more people in the community that way!

The current status of this project is that I will continue to work on the rest of the missing features, like model rendering, that are not yet running in the demo. We have permission to use geartrooper's models, and we should be getting some maps from gk, so we should have what we need for some nice results :)

In summary, this is just an early demo, but I think it shows that this can work. There is a lot left to do so help is of course welcome. Btw, this can work for any Cube 2-based project, of course, not just Sauerbraten, so if Red Eclipse, Sandbox etc. want to run on the web as an option we can make that happen too (in fact the porting from C++ to JavaScript is 99% automatic, so almost nothing specific would need to be done), if any project is interested in that then let's work together on it!

- kripken

Go to first 20 messagesGo to previous 20 messages    Board Index   

#125: Re: ..

by JayDoran on 11/27/2012 05:38, refers to #124

Thank you very much for the speedy response.

So there was a translation made of some sorts; That\'s great news even if it is in JS. Can this be found in the source code for Bananabread? I would love to have a look at this and see what I can do with it.

Also, I did take notice of Regal too but it seems far too overly ambitious and, well as you said huge, in my opinion.

reply to this message

#126: ..

by kripken2 on 11/27/2012 22:34

The code is in the compiler, emscripten:

https://github.com/kripken/emscripten/blob/master/src/library_gl.js#L935

Basically that line (935) to the end (not all of it, but most would be relevant to what you want I think).

Translating that to C++ would be pretty straightforward even though the syntax is a little different. The hard part in this conversion is getting the shaders converted, handling all the odd corner cases, etc., and the code has all of that done for you already. And it converts to WebGL which is a subset of OpenGL ES 2.0, so that should be perfect.

I'd be interested to see this in C++ btw, to compare performance to the JS version. If you decide to work on it then I'd like to help.

reply to this message

#127: ..

by kripken2 on 01/19/2013 06:43

We're working on multiplayer for this now, it's basically functional at this point. Here is a video,

http://vimeo.com/57658941

reply to this message

#128: 2.0, Multiplayer release

by kripkenstein on 03/30/2013 18:43

Multiplayer now works and there are a few new levels, we just launched BananaBread 2.0,

https://developer.mozilla.org/demos/detail/bananabread

Note though that multiplayer requires WebRTC binary data channels, which are only present in Firefox Nightly. But over the next few months they should appear in other browsers and in beta and stable releases.

reply to this message

#129: ..

by kripkenstein on 03/30/2013 18:44

https link is not clicky, here is a better one,

http://developer.mozilla.org/demos/detail/bananabread

reply to this message

#130: ..

by TheLove on 03/31/2013 22:22

really nice good job and good luck!

reply to this message

#131: BananaBread: Porting Cube 2 to the Web

by cdxbow on 06/11/2013 03:09

This is fantastic. It's really come along. Well done.

Any likely improvements in performance in the near future?

reply to this message

#133: ..

by kripkenstein on 07/27/2013 23:08

Performance improvements have been happening all the time. Most important is that the current release of Firefox contains optimizations for asm.js, the subset of JS generated here, and Chrome is working on that too. With those, speed should be pretty close to native.

More specifically, CPU speed is about half of native, GPU speed is the same as native, so overall should be good.

reply to this message

#135: Multiplayer

by hypernova on 10/08/2016 04:25

Hey all,
Is there currently a multiplayer version being hosted anywhere? If not, I'll build it and host somewhere :)

reply to this message

#136: Re: Multiplayer

by hypernova on 10/08/2016 04:34, refers to #135

Btw this page is cool, might help anyone who is interested in playing BananaBread multiplayer: http://iswebrtcreadyyet.com/

PS: Huge thanks to Kripten for his work on Emscripten and BananaBread. This is one of the most noteworthy contributions I've seen in this community :)

reply to this message

#137: Re: Multiplayer

by hypernova on 10/08/2016 04:35, refers to #135

Btw - this page is cool, might help anyone who is interested in playing BananaBread multiplayer: http://iswebrtcreadyyet.com/

PS: Huge thanks to Kripten for his work on Emscripten and BananaBread. This is one of the most noteworthy contributions I've seen in this community :)

reply to this message

#138: Re: Multiplayer

by hypernova on 10/08/2016 04:37, refers to #137

Lol sorry for the triple post, I meant to write "Kripken" :D

reply to this message

#139: ..

by chasester on 10/08/2016 08:52

you need to fix your config files. Defaultmap file is a mess it should just load in all the base textures so you can edit the map, and set the default skymap to be something that actually exists :)

reply to this message

#140: Re: ..

by hypernova on 10/08/2016 16:00, refers to #139

There's two demos which I know of:
https://kripken.github.io/BananaBread/wasm-demo/index.html
and
http://people.mozilla.org/~vladimir/misc/bench-new/

The first one is linked from the BananaBread github page https://github.com/kripken/BananaBread, and the second one is hosted by Mozilla.
The first one works fine for me, but the second one has completely messed up content (this may be the configuration problems you were mentioning?)
However I don't know how to setup multiplayer on either of them :D
I pulled the github repo and it appears to be the second demo.

reply to this message

#141: Re: ..

by hypernova on 10/08/2016 16:01, refers to #139

There's two demos which I know of:
https://kripken.github.io/BananaBread/wasm-demo/index.html
and
http://people.mozilla.org/~vladimir/misc/bench-new/

The first one is linked from the BananaBread github page https://github.com/kripken/BananaBread, and the second one is hosted by Mozilla.
The first one works fine for me, but the second one has completely messed up content (this may be the configuration problems you were mentioning?)
However I don't know how to setup multiplayer on either of them :D
I pulled the github repo and it appears to be the second demo.

PS. I didn't realize I somehow made a double post previously, can admin please delete it? Thanks.

reply to this message

#142: ..

by chasester on 10/09/2016 06:52

i had issues as well it just takes a really long time to load and it seems to help switch in and out of windows. for me about 5 mins or so at least, tho my internet at this point was subpar so it could be that as well. Tho when I did load it (on high res), map one (the one i picked) seem to have various shader errors (i presume). Colors that should be defined seem to have random red and green over tones that where obviously not correct. Also the Blue flag over the door was stretched. probably due to an invaid look up on the model, forcing the verticies to stretch to positive infinity.

I loaded the second map and got the same shader error. It seemed to flixer around in editmode cuzing the material draw bounds to show the same problems that the model from the previous one was having. This looks very reminicant to a shader erros. Further more the hudguns are not lining up and the animations will not render (this happens when you have sever shader errors). Also when in thirdperson everthing disappears and you are stuck with just the fadded glow overlay on the map (if you turned on glow). I saw some issues with the lighting so I tried to fix with a light calc, but some how it just locked the entire browers and nv recovered. I eventually got the window closed and it seemed to save the rest of my pages. Last side note is that all the water disapeared and was not showing any form of reflection. My guess is you have some major shader issues you need to fix.

Note: I am using chrome but i tried this also on firefox and got the same errors. Also A small side note. This flag error the is on the arena map seems to go away after the first bot is added. This again sounds like shaders and maybe just copy old shaders that where working properly back in.

chasester


reply to this message

#143: Re: ..

by hypernova on 10/12/2016 01:04, refers to #142

Ok thanks for the info. I doubt I'll get time to work on this, but if I do, I'll host it somewhere and let everyone know..

reply to this message

#144: Re: ..

by Catalin Stan on 11/07/2016 09:34, refers to #142

Hi chasester,

maybe you could try the android port. There should no glsl errors and glsl translation layer is not needed.

http://github.com/realuptime/sauerbraten_android/

This backgammon game is based on sauerbraten framework and works great on any platform, including web.
The networking is TCP and I have no issues.

reply to this message

#145: Re: ..

by Catalin Stan on 11/07/2016 09:35, refers to #144

forgot the link:

http://catalinux.eu/bg/em3d

reply to this message

#146: ..

by chasester on 11/10/2016 01:26

very nice tho it needs a load screen I thought it didnt work ;P

reply to this message

Go to first 20 messagesGo to previous 20 messages    Board Index   


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2022
website by SleepwalkR © 2001-2022
43022621 visitors requested 58808707 pages
page created in 0.070 seconds using 10 queries
hosted by Boost Digital