Sign in to follow this  
Lonesome Ducky

Using Angelscript for a type of post-processing

Recommended Posts

Lonesome Ducky    122
I've been working on a 2D animator, and I've decided I'm to the point where I want to allow the user to code their own post-process effects. Is it viable to pass a buffer of chars about the size of 1280*720*4 to the script for processing? Are there any things i should be aware of to speed it up?(Note: It most likely will not need to be realtime, and if it will be, I'll scale the screen size down to 1/4 or something so it will have to process less)

Share this post


Link to post
Share on other sites
Sudi    761
Well first question why not use a shader?

Anyway i guess you thought about that and it doesn't make sense in your case....
So do it like the gpu to speed up the process...split the screen into several blocks and process every block on its own in several threads with your script code.

Share this post


Link to post
Share on other sites
Lonesome Ducky    122
Well, I want to be able to store all kinds of variables across multiple frames first of all. Using angelscript, I can easily do that with the global variables. It's also not limited by instruction limits or hardware. You can also do, say, a blur in both directions without having to have an intermediate texture. I could use shaders, but to me there are some key disadvantages and a lot more work to supply the necessary options to achieve the same effect. They might come later if angelscript proves to slow for this though, but angelscript seems like at the very least a good prototype with how simple everything I need can be implemented.

Share this post


Link to post
Share on other sites
WitchLord    4677
AngelScript is definitely capable of doing non-realtime postprocessing. I think you could get some ideas on how to implement the system from my rather old [url="http://www.angelcode.com/texgen/"]texture generator[/url]. It uses an early version of AngelScript to generate the textures, which is really similar to postprocessing in many ways.

However, as you are probably very well aware, scripting is many times slower than native C++ code, so you will want to provide the more common postprocessing functions as native functions to the script (e.g. blur, color transform, emboss, etc), and just leave the more unique processing to the script.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Lonesome Ducky    122
Hmm, I looked at your site just earlier today to download the latest version, but now it's down. Anyway, how would I register a c++ function to the script for it to use the blur and other functions? Would I define it as CScriptArray blur(), and register it as array<int> blur()?

Share this post


Link to post
Share on other sites
WitchLord    4677
I'm not sure what happened, the site is back up now without any intervention from me.

Anyway, I think it would be best for you to deal with the image buffer as an object, rather than an array of pixels. You can then register that object with the engine, and add the blur effect as a method of it.

In the script it might look like this:

[code]
void postProcess(CImage @img)
{
img.blur();
}
[/code]

The object can still expose index operators to access the individual pixels for more unique processing.

Regards,
Andreas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this