Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - Open Source Filters

Author
Message
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 12th Dec 2012 04:49 Edited at: 14th Dec 2012 04:56
The following snippet is database which allows programmers to add, share, preview, test and save images of 2d or 3d filters.

It's a framework for filter draw functions that all can contribute without having to write the management code. Just write the name of the filter, etc, and write its code, copy and paste it in and it handles the previewing and browsing for you.

More importantly, filters can be combined to produce other filters, since it is a shared process, you can combine a series of filters together using your own routines. Thus the more you put in the more you get out.

The TGC Open Source Filter Project - For bored programmers... because we want to!!!

* Draw N at location X and Y, at width W and height H with no hassle
* Change properties and colours with no hassle
* Add your own filter to the library with no hassle
* Use my filters or someone elses filters with no hassle
* Apply filters to what ever you like with no hassle
* Browse, search and compare other peoples filters with no hassle
* Animate the filter to create motion effects with no hassle
* Include in your projects, games, products and snippets with no hassle

The concept here is to structure filter based snippets in a searchable sortable system.

Plugin Links
Advanced 2D - Rapid 2D commands for your games
Matrix1 Utilities - Essential DBP Upgrade

Zero Hassle Open Source Filters

If you are feeling bored; feel free to spend a moment to post a filter (hard coded or shader based special effect) according to the source code and template supplied. I am doing the same.

This is a fun activity rather than a serious project.

If you want to share some of your stuff, you should use Advanced2d over traditional 2D functions where possible. Go ahead and use any plugin you like; but if you do use anything other than Advanced2d or Matrix1, please indicate.

As you can see in the source code; we want to be able to select what ever effect we wish, and see it in action in realtime; and would like to save the effect to a bitmap file for what ever purpose desired.

You may use images, sprites and shaders if you like; so as long as the user gets back an image or object she can use via either the screen, 3D space or on a texture.

Prefix your function with FILTER_ followed by your name, nickname or group name. (Place your code in a function as demonstrated). If you need, append a seperate NO HASSLE source file.

Try to prefix local variables larger than 3 characters to avoid conflicts. Eg: tColour as MyType, rather than Colour as MyType.


12/12/12


Attachments

Login to view attachments
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 12th Dec 2012 10:11
I get an error at line 180

Quote: "
"Effect_" + PadLeft$( Str$(i), "0", 5 ) + ".png"
"


Quote: "
Subscript must be Integer or DWORD when referencing an array at line 180.
"


Also, I always ask that Links to any plugins in this board be linked in the first post on here, helps new visitors / users figure out what the various plugins are and where to find them

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 12th Dec 2012 18:34 Edited at: 1st Jan 2013 19:08
Quote: "I get an error at line 180"


People who have not installed Matrix1 still exist?. I should have put in the title that this is NOT FOR NEW PEOPLE.

Quote: "I always ask that Links to any plugins in this board be linked in the first post on here"


Oops I didn't realize you where moderating this board now; I didn't spot any code snippet link posting rule document, my bad.

Quote: "helps new visitors / users figure out what the various plugins are"




True, but this isn't for new people. But for the sake of it, let's do something a little more informative.

New visitors
If any new visitors would like to find a link or any information about any of the plugins used in any snippet; scroll down to the end of the page; there you will see a little white box underneath the heading; 'Thread Subject Search', there you will be able to locate a series of links by clicking the search button which will locate the links for you. Have a nice day

Seriously, I just wanted to spend a relaxing moment posting up little snippet for a change. This post is for casual purposes, as stated; 'for bored programmers'; I can't believe this guy went and did that.

Download 0.11

Attachments

Login to view attachments
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 12th Dec 2012 19:07
I have both installed... 'Sigh' and to think I was trying to be helpful...

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 12th Dec 2012 22:57
Quote: "I have both installed... 'Sigh' and to think I was trying to be helpful..."


I am not being serious MrValentine

However this isn't quite the place for making requests for new visitors. You know I always like to help new people as I'm paying a monthly fee to host a website to help new people get to learn stuff, and I am just about to post links to a new map creation video tutorial. But this thread, just this thread requires experience with the tools; in my other threads I will be far less grumpy.

Regarding your installation of the plugin; PadLeft is a function in the Matrix1 command set; and your compiler is basically saying 'PadLeft$ is an array', therefore Matrix1 has not been installed correctly; or only partially installed. Is the PadLeft$ command highlighted as a keyword? (Is it blue?)

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 12th Dec 2012 23:29
Not to worry buddy

Must be conflicting with STYX or something... yes it highlights

Grasmann
15
Years of Service
User Offline
Joined: 1st Sep 2008
Location:
Posted: 14th Dec 2012 00:16 Edited at: 14th Dec 2012 00:45
Well, obviously everything can be done with no hassle.
But I don't really get what this snippet basically does. XD

BTW:
I see you are using "CALL FUNCTION NAME".

If you want this to be as performant as possible, I would probably replace this with "CALL FUNCTION PTR" and get the needed function pointers for each effect within "AddFilter".

It should be much faster to call a function pointer instead of evaluating a string everytime.

EDIT:

I played around with this a bit now.

Actually the snippet is nice, but with sync rate 0 this only runs with ~64 FPS on my machine, so there is a big bottleneck somewhere.
( well, it seems to be programed to run with constant 30 FPS anyways )

I tried the idea with the function pointers.
Parts I changed:

In Type FilterType:


In DrawFilter:


In AddFilter:


But those changes didn't improve the performance at all, so I guess the 2d-commands are simply very slow. XD
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Dec 2012 02:38 Edited at: 14th Dec 2012 02:53
Quote: "If you want this to be as performant as possible, I would probably replace this with "CALL FUNCTION PTR" and get the needed function pointers for each effect within "AddFilter"."


I agree with you 100%.

I chose to use function name because it is less intimidating for new users to understand, thus increasing the chances of them contributing. (Edit: Then again they wouldn't need to look at the addfilter function )

I will implement your suggestion.

The Call Function Name is only a little bit slower than PTRs, I've run a test, but don't have the source code evidence near me.

The Advanced2D commands should be quite fast, especially with batch processing properly used. I'll look into tweaking the performance later.



I am sure you see where I am going with this. It is light at the moment because I have other priorities, but in future I will add some UI, search box, line based filters and more practicle filters, and more importantly others can contribute quite easily.

Quote: "well, it seems to be programed to run with constant 30 FPS anyways "


Just a random choice for FPS. I was more interested in getting it functioning at the time.

@MrValentine
Quote: "Must be conflicting with STYX or something... yes it highlights"


Could be. I believe you need to decide which string functions you prefer, then simply move the unwanted string dll to an external folder safely. Infact I think it is the core dll within Styx. That's what I did to use Styx with Matrix1, although I intend to quit using Styx.

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Dec 2012 02:54
Someone mind explaining what this code is suppose to do? The bullet points at the top don't really offer any insight. I can only guess and say "image filters"?

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Dec 2012 04:30 Edited at: 14th Dec 2012 04:38
This is a filter library (Not limited to images). Something to organize filters shared by the community. The filters have animation features.

It's a framework for filter draw functions that all can contribute without having to write the management code. Just write the name of the filter, etc, and write its code, copy and paste it in and it handles the previewing and browsing for you.

It's a small database currently allowing you to test, browse, save results and share hard coded filters. The bullet points indicate what you can do; EG: 'Draw N at X, Y' therefore demonstrates that N is the filter number, which is drawn at X, Y etc ...

The relatively small snippet itself at this moment in time contains a 'shared' draw function that draws or applys a given filter at a screen location and size; using opacity settings, intensity, sourceimage and other optional properties. This program uses the draw function to preview filters. You would then use the draw command directly in your program or simply save your image (or result depending on the type of filter)

More importantly, filters can be combined to produce other filters, since it is a shared process, you can combine a series of filters together using your own routines. Thus the more you put in the more you get out.

Infact, the whole point is to not limit the explanation of the draw function in a single way based on images; since the function is to be shared by all filters using optional parameters; so, what it actually does is up to the programmer who creates the filter. For example; one filter I added animates grass, another animates text; but these are generators; I could have created a blur filter, since the shared function has an optional source image parameter.

As was the case with Grasmann, it's easiest to understand by reading and compiling the code, as it is small and easy to read, and runs like a wizard program.

I will add features, windows UI, more filters and other facilities and screenshots at a later time.

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 1st Jan 2013 19:05
Minor update: v0.11

Added ability to load filter settings from XML based format, FML
Added continuous blur filter. (ImageKit required)
Added filter which paints an image with text (requires supplied FML file)
Added default image for filter tests which loads automatically.
Corrected issue with 2D line generators

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-03-29 00:36:57
Your offset time is: 2024-03-29 00:36:57