Plasma drawing impossibly slow?

Monkey Targets Forums/HTML5/Plasma drawing impossibly slow?

frank(Posted 2011) [#1]
I have the following plasma code:

http://pastebin.com/tvjaL6mT

graphically / conceptually it's fine, but it's mindbogglingly slow and CPU intensive; this same code (in c) is fluent on quite ancient computers, but here it just stands still, so I imagine i'm doing something very wrong :)

Anyone can explain what that would be?


Volker(Posted 2011) [#2]
SetColor is incredible slow in html5.


frank(Posted 2011) [#3]
Ah didn't know that, but what can I do about it? Any workarounds?

Hmmm. If I comment SetColor out, it doesn't get much faster.


Volker(Posted 2011) [#4]
No. See first post here: www.monkeycoder.co.nz/Community/posts.php?topic=782#6427


Volker(Posted 2011) [#5]
Sorry, was just a guess. Then I dont know atm.


frank(Posted 2011) [#6]
I'm trying to profile the JS code node :) Not too easy either :) If anyone has an idea... I'll continue trying anyway :)


therevills(Posted 2011) [#7]
Wow that is slow... even in GLFW!

By reducing the size of the FOR loops you can get it to a decent FPS:




impixi(Posted 2011) [#8]
You'll need to directly manipulate the html5 canvas pixels for decent performance. You can use the HTML5 canvas wrapper code from the code archives to do this.

And here's your modified code:



This works very well on my system in Chrome 16 (not so good in IE9).

Don't forget to disable "debug" in monk's build options.


frank(Posted 2011) [#9]
Ah! fantastic, the canvas method is good. That's why I asked for 'direct framebuffer access' in Monkey; is that not possible cross platform? Because it's kind of depressing that this kind of thing doesn't work?

It's not possible? :)


Richard Betson(Posted 2011) [#10]
hmmmm.

I get a blank page after compiling the above example as well as the examples for the HTML5 canvas wrapper. No compile errors.

Monkey .48
Chrome 15.0.874.121 m


impixi(Posted 2011) [#11]
Any browser errors? In Chrome press F12 and select the 'console' tab.


Richard Betson(Posted 2011) [#12]
Indeed there is an error in the browser console. This is the only error it list compiling the text example.

"Uncaught SyntaxError: Unexpected identifier"

It seems to occur in this function: in main.js



I get no errors in Monkey and it all seems to compile fine. I'll try it it FireFox and see what it does there, but yesterday I think it was also a blank page there as well.


EDIT- FireFox give this console error:
[18:29:06.471] missing ; before statement @ http://localhost:53580/main.js:287"
FireFox version 8.0

Which is also in the same function as above.

EDIT- Same error for the plasma example.


impixi(Posted 2011) [#13]
Thanks.

There's a little bug in my JavaScript code. I declared the GCanvas variable inside AND outside the function, probably causing scope confusion. Strange how IE9 and Chrome 16 don't flag the error.

Replace the canvasmods.js file with this one:



Let me know if that fixes the problem.


Richard Betson(Posted 2011) [#14]
Success!

That really is pretty impressive. I will now proceed to making a cool demo.:)

The plasma example was humming on Chrome and FireFox. Your examples all worked on both browsers. The only difference was the textured poly had a red color (the color in the poly) in FireFox and white in Chrome.

But, this really rocks and I am amazed by the speed.:p

Thanks!