Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Plugins

Getting started with plugins: rendering.

ShiVa Plugin Development

Getting started with plugins: rendering.

Postby flippout » 27 Oct 2011, 01:13

So I'm finally starting to do some experiments with plugins.

I thought a good starting point would be to implement this task that I described awhile back - rendering the app screen to video:
http://www.stonetrip.com/developer/forum/viewtopic.php?f=13&t=23009&p=32729&hilit=render+plugin#p32729

It seemed like it'd be a generally useful plugin to have...

So my first question is: What would be the best place to call glReadPixels()? Should I set this up as a plugin api function and call it each frame from one of my AI's startEnterFrame() script functions?
Or is there some way to hook into the engine's per-frame drawing code to catch the frame buffer directly after the frame has been drawn?
flippout
Gold Boarder
Gold Boarder
 
Posts: 279

Re: Getting started with plugins: rendering.

Postby NiCoX » 27 Oct 2011, 08:58

So my first question is: What would be the best place to call glReadPixels()? Should I set this up as a plugin api function and call it each frame from one of my AI's startEnterFrame() script functions?
Or is there some way to hook into the engine's per-frame drawing code to catch the frame buffer directly after the frame has been drawn?


Starting from 1.9.1.beta2 (that will be available really soon), plug-ins will receive special event from the engine. This is the preferred way to handle init/update/shutdown tasks. But waiting for the beta, you can just do an update function as a POC.
User avatar
NiCoX
Platinum Boarder
Platinum Boarder
 
Posts: 5644
Location: France

Re: Getting started with plugins: rendering.

Postby flippout » 27 Oct 2011, 16:00

Excellent news that there'll be special events!

Sorry for my ignorance, what's a POC?
flippout
Gold Boarder
Gold Boarder
 
Posts: 279

Re: Getting started with plugins: rendering.

Postby NiCoX » 27 Oct 2011, 16:17

POC = Proof Of Concept ;)
User avatar
NiCoX
Platinum Boarder
Platinum Boarder
 
Posts: 5644
Location: France

Re: Getting started with plugins: rendering.

Postby flippout » 28 Oct 2011, 18:22

Ok not exactly related, but let me just say - I'm really impressed with plugins so far!

I'm loving the direct access to the engine api from the native code, and the workflow seems pretty slick - I like how it automatically updates the native files when you add new plugin api functions, and being able to quickly recompile and then see the results right away in the editor is really handy. So far I've only worked with the windows version of the plugin, but it's cool that the .sln includes the code for all the platforms for easy viewing.

Definitely much nicer than the Windows->XCode workflow I've been using for native code.

As far as the glReadPixels(), I'm having some issues, but that's for another thread :)
flippout
Gold Boarder
Gold Boarder
 
Posts: 279

Re: Getting started with plugins: rendering.

Postby flippout » 02 Nov 2011, 14:48

So I'm happy to report that glReadPixels() is working as expected from my per-frame update function. My next step is capturing audio (this is going to use some custom code since we're using our own custom audio engine.)

I also noticed that my app is insanely fast on Windows, which is awesome - like 500 fps. I almost wonder if it isn't a measurement error.

My plan is to set the frame time factor to something really high, but clamp the per-frame delta to 25 fps. I'm hoping to use this to do faster-than-realtime video recording of song playback for Monkey Drum, on a remote Linux server. Of course this means I'll have to do my own audio mixing to compensate for the speed difference, but I'm up for a challenge.

I'd love to share the code and our process when I get it all working if people are interested. Could be useful for people wanting to make promo videos, or as in our case - render video directly from your app for sharing on Facebook etc.
flippout
Gold Boarder
Gold Boarder
 
Posts: 279

Re: Getting started with plugins: rendering.

Postby NiCoX » 02 Nov 2011, 17:16

I also noticed that my app is insanely fast on Windows, which is awesome - like 500 fps. I almost wonder if it isn't a measurement error.


To clap at 30Hz, use:

Code: Select all
application.setOption ( application.kOptionSwapInterval, 2 )


;)
User avatar
NiCoX
Platinum Boarder
Platinum Boarder
 
Posts: 5644
Location: France

Re: Getting started with plugins: rendering.

Postby flippout » 02 Nov 2011, 17:51

Cool,thanks, I hadn't noticed that option before.
I just did a test in my windows build for video rendering as well - it's pretty un-optimized (I'm writing out video frames to disk each frame) but I can record raw video in real-time without any problems, at least at 640x480. With a combination of setting the frame time factor to a high value (trying 5 for now) and clamping the min/max frame time to 25, I'm able to record at pretty blazing fast speeds.

Last big technical question we have to tackle: Will this all work on a headless Linux server rendering in software mode? We shall find out soon :)
flippout
Gold Boarder
Gold Boarder
 
Posts: 279


Return to Plugins