3dickulus
|
|
« on: July 01, 2015, 10:55:14 AM » |
|
here is what I have so far... in a command shell I type... ./Fragmentarium-1.0.8 -s test.fqs test.fqs is a text file that looks like this... // Fragmentarium qscript // 3Dickulus 06/30/15
app.loadFragFile("./My_Params/new-Mandelbulb-anim.frag"); app.setAnimationLength( 10 ); app.setTileWidth(64); app.setTileHeight(36); app.setTileMax(10); app.setSubFrames(10); app.setOutputBaseFileName("./test.png"); app.setFps(25); app.setStartframe(0); app.setEndframe(24); app.setPreview(false); app.setAnimation(true); // begin rendering app.tileBasedRender();
and that automatically renders all of the frames for a 10 second animation at 25 fps you can omit the first line in the script file and run it with the frag file on the commandline like... ./Fragmentarium-1.0.8 -s test.fqs ./My_Params/new-Mandelbulb-anim.frag and it does the same thing. I have basically exposed the parts of the hires/animation dialogue required for rendering a frame or a range of frames from any frag file. Given that this works quite well I think it will be easy to do in server/client mode too. The scripting language spec is here, http://www.ecma-international.org/ecma-262/6.0/index.html, java uses the same base spec I think. EDIT: ECMAScript is based on several originating technologies, the most well-known being JavaScript (Netscape) and JScript (Microsoft). The language was invented by Brendan Eich at Netscape and first appeared in that company’s Navigator 2.0 browser. It has appeared in all subsequent browsers from Netscape and in all browsers from Microsoft starting with Internet Explorer 3.0.
Errors with fqscript line numbers are reported in the log window done with less than 50 lines of code added to Fragmentaium sources I would like to get some input from the community before I go any further.
|
|
« Last Edit: July 01, 2015, 08:37:48 PM by 3dickulus, Reason: assumtion »
|
Logged
|
|
|
|
|
3dickulus
|
|
« Reply #2 on: July 01, 2015, 08:17:52 PM » |
|
Yes, very simple to do (I think), this is just the start originating from a request by Patryk for all of those functions on the commandline, I felt it would be more productive to just have one commandline option... a script file Should it be compile/execute as you type like evaldraw/shadertoy or a compose/save/execute scenario ? What other functions() should be exposed ?
|
|
|
Logged
|
|
|
|
Syntopia
|
|
« Reply #3 on: July 01, 2015, 09:36:09 PM » |
|
Nice! I did essentially the same with Structure Synth, also using the QScriptEngine: http://blog.hvidtfeldts.net/index.php/2010/11/scripting-in-structure-synth/I imagine that you'd want to make it possible to script the uniforms somehow. Either by making it possible to render one frame at time, and then change some uniforms and repeat in a for-loop (that was the approach I used in Structure Synth), or by making it possible to provide a JavaScript callback function that updates the uniforms before each frame is rendered.
|
|
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #4 on: July 01, 2015, 11:24:06 PM » |
|
I'm not sure how far I will take this, as it is right now it only takes one line of code to expose a function for script use and technically it is possible right now to render one frame at a time while making adjustments in a for(){} loop, (see link in first post re:language spec) just allow access to... variableEditor->setSettings( settings ); ...where settings is a list of variables and values just like in a parameters file or preset and then call tileRender() for a single frame (start == finish). I tried using the QJScript class, it works but it segfaults on exit every time, QScript does not seem to have this problem.
|
|
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #5 on: July 02, 2015, 01:53:10 AM » |
|
added a few functions... // sets current time to 0 app.rewind(); // starts animating if keyframes and/or easing curves or time var in GLSL are present and length is something app.play(); // duh ;) app.stop();
// sets multiple parameters where String follows the format of a parameters file app.setParameters(String);
// sets a 1,2,3,4 component parameter app.setParameter1("RotAngle", 120.31622); app.setParameter2("SpotLightDir", 0.63626,0.5); app.setParameter3("Target", -5.2432,4.25801,-0.607125); app.setParameter4("SpotLight", 1.0,1.0,1.0,1.0);
haven't tested extensively but seems to work EDIT: two modes seem apparent 1> animating is controlled by the keyframes and easing curves in the loaded frag file 2> everything is controlled in the script, this would mean always rendering at frame/time 0 with "Animation = false" and modifying the output filename and parameters as needed before calling app.tileBasedRender(); I don't know if the script control will present a conflict with time tick incrementing :ENDEDIT QScript can also load QtDesigner ui files and exploit the signal/slot mechanism in Qt, this could be used for developing very specialized control interface plugins.
|
|
« Last Edit: July 02, 2015, 05:41:39 AM by 3dickulus, Reason: modes »
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #6 on: July 02, 2015, 03:17:02 PM » |
|
as requeseted EDIT: on err cursor jumps to line in editor v1.0.8 source code is available on my website.
|
|
« Last Edit: July 03, 2015, 07:21:24 AM by 3dickulus »
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #7 on: July 04, 2015, 01:19:11 AM » |
|
This is working very well, I should have done it a long time ago. @Syntopia, I swiped the pad() function so my test script looks like this now... // Fragmentarium qscript // 3Dickulus 07/04/15
// pad function from http://blog.hvidtfeldts.net/index.php/2010/11/scripting-in-structure-synth/ function pad(number) { number = number + ''; // convert to string while (number.length < 4) { number = "0" + number; } return number; }
// frame specs function setFrameSpec(w,h,m,s) {
// set the tile buffer size app.setTileWidth(w); app.setTileHeight(h); // set tile multiplier app.setTileMax(m);
// how many frames to accumulate app.setSubFrames(s); }
// starting point function init(){
// uncomment to load a frag file, this will open a new tab in Fragmentarium // app.loadFragFile("./My_Params/new-Mandelbulb-anim.frag");
// used to calculate range frames and/or total frames app.setFps(25); // this number should be => EasingCurve max frame / fps app.setAnimationLength( 10 );
// false = save images // true = open a preview window for EACH image (be careful) app.setPreview(false);
// true = animation gets control from frag // false = animation gets control from cmd script app.setAnimation(false);
// setting both to 0 tells Fragmentarium to not adjust the output filename app.setStartframe(0); app.setEndframe(0); }
// call our startup function init(); // set how many frames (seconds x fps) max = 10; // just a few for testing
for (i = 0; i <= max; i+=1) { // what kind of tiled/frame to render setFrameSpec(64,36,10,100); // adjust parameter(s) app.setParameter("RotAngle", i*18); // we need to adjust the filename for each frame app.setOutputBaseFileName("./test." + pad(i) + ".png"); // render an image app.tileBasedRender(); }
I am amazed a t how easy this was to implement , thank you (again!) Syntopia what it means is that all variables available in a preset are also available to cmd script, I'm not a java programmer but I think some of you folks will be very happy with this latest hack. I'm sure it could go deeper. Currently only available as source code but I'll try to get the win/mac executables asap bermarte?
|
|
« Last Edit: July 05, 2015, 12:24:55 AM by 3dickulus, Reason: script update with comments »
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #8 on: July 05, 2015, 10:23:35 AM » |
|
Ok had some time to play with it and I have some promising results... Test 0: cmd script control only Script: test0.fqsResult: test.0.mp4Test 1: frag animation control only Script: test1.fqsResult: test.1.mp4Test 2: cmd script control together with frag animation control Script: test2.fqsResult: test.2.mp4...so keyframes and parameter morphing play nice together with script control Edit: parameter setting functions in app object void setParameter(name, bool) void setParameter(name, int) void setParameter(name, float) void setParameter(name, float, float ) void setParameter(name, float, float , float) void setParameter(name, float, float , float, float)
|
|
« Last Edit: July 07, 2015, 03:06:29 AM by 3dickulus, Reason: app object »
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #9 on: July 08, 2015, 06:50:09 AM » |
|
Had a bug, webserver/conscience issue, the Fragmentarium-1.0.8 packages are now available Sorry for the inconvenience The Command Script editor now has a Stop button but there is one caveat... When called from the cmdline in a console window as "Fragmentarium-1.0.8 -s testscript.fqs myAnimation.frag" you can't stop it except from [ctrl+c] in the console window, so the stop button is only working when the Script Editor is visible, the idea is that one would develop and test a script in the editor and then run it on a number of machines to render batches of frames unattended, but I'm sure an intrepid programmer could use QtDesigner to create their own control window The Stop button works like this... 1) Select Stop then 1a) wait for the current image to finish, image is saved. 1b) select abort in the progress dialog, image is not saved.
|
|
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #10 on: July 25, 2015, 12:02:44 PM » |
|
So far so good... This is a very short test of applying a set of frames to a sampler2d parameter using FQS... voila! animated surface texture. http://www.digilanti.org/fragmentarium/fqScript/sampler2d-test.mp4 1948499 Jul 25 02:48 here is the sampler2d-test.fqs file... // Fragmentarium qscript // testing sampler2d parameter // 3Dickulus 07/25/15
// pad function from http://blog.hvidtfeldts.net/index.php/2010/11/scripting-in-structure-synth/ function pad(number) { number = number + ''; // convert to string while (number.length < 5) { number = "0" + number; } return number; }
// frame specs function setFrameSpec(w,h,m,s) { // set the tile buffer size app.setTileWidth(w); app.setTileHeight(h); // set tile multiplier app.setTileMax(m); // how many frames to accumulate app.setSubFrames(s); }
seconds = 10; fps = 25;
// starting point function init(){ // used to calculate range frames and/or total frames app.setFps(fps); // this number should be => EasingCurve max frame / fps app.setAnimationLength( seconds );
// false = save images // true = open a preview window for EACH image (be careful) app.setPreview(false);
// false = no control from frag // true = control from frag app.setAnimation(true);
// begin app.setFrame(0); app.setStartFrame(0); app.setEndFrame(0); }
// call our initialization function init();
// set how many frames (seconds x fps) maxFrames = seconds * fps;
// Fragmentarium will create our filename from this app.setOutputBaseFileName("./anim/test.png");
// iterate frame tick up to maxFrames for (i = 1; i <= maxFrames; i+=1) {
// set the current frame app.setFrame(i);
// size of tiled/frame to render setFrameSpec(64,36,10,10);
// adjust parameter(s) app.setParameter( "myTexture = ./My_Params/InvestigateThis/anim/InvestigateThis." + pad(i) + ".png" ); // setting the sampler2d with a new texture requires rebuilding the shader (locked var) app.initializeFragment();
// if the user wants to stop rendering break before next image if(!app.scriptRunning()) break;
// render and save an image app.tileBasedRender();
}
|
|
« Last Edit: July 25, 2015, 09:15:09 PM by 3dickulus »
|
Logged
|
|
|
|
3dickulus
|
|
« Reply #11 on: July 26, 2015, 01:42:48 AM » |
|
This is a list of fqScript commands encapsulated by the script "app" object that will be available in v1.0.9 release, beta testers ?
General commands
void setFrame(int); Sets the current frame number.
int getFrame(); Returns the current frame number.
void loadFragFile(String); Opens a new editor tab, loads the named fragment file, initializes default preset, initializes keyframes and easing curves if the file contains these settings.
bool initializeFragment(); Returns success or fail. Must be called after altering a locked variable before rendering an image.
Parameter commands
void setParameter(String); Set a parameter from String in the form of "parameter = value" also accepts parameter file formated string.
void setParameter(String, bool); Sets a boolean parameter where String is the parameter name and bool is TRUE or FALSE
void setParameter(String, int); Sets an integer parameter where String is the parameter name and int is any integer.
void setParameter(String, x); Sets a float parameter where String is the parameter name and x is any floating point number.
void setParameter(String, x, y); Sets a float2 parameter where String is the parameter name and x,y is any floating point number.
void setParameter(String, x, y, z); Sets a float3 parameter where String is the parameter name and x,y,z is any floating point number.
void setParameter(String, x, y, z, w); Sets a float4 parameter where String is the parameter name and x,y,z,w is any floating point number.
String getParameter(String); Returns a string representing the value(s) for the named parameter, user must parse this into usable values.
Hires image and animation dialog commands
void setAnimationLength(int); Sets the total animation duration in seconds.
void setTileWidth(int); void setTileHeight(int); Sets the tile width and height.
void setTileMax(int); Sets the number of row and column tiles, this value squared = total tiles.
void setSubFrames(int); Sets the number of frames to accumulate.
void setOutputBaseFileName(String); Sets the filename for saved image, if script has total control this must be set for every frame, if animation is using frag file settings, keyframes etc., then this only needs to be set once and Fragmentarium will add an index padded to 5 digits.
void setFps(int); Sets the frames per second for rendering.
void setStartFrame(int); Sets the start frame number for rendering a range of frames.
void setEndFrame(int); Sets the end frame number for rendering a range of frames.
void setAnimation(bool); FALSE sets animation to script control exclusively. TRUE enables keyframes and easing curves.
void setPreview(bool); TRUE will preview frames in a window on the desktop instead of saving image files.
Control commands
bool scriptRunning(); Returns FALSE when the user selects the [Stop] button in the script editor. For user implemented test to break out of the script control loop.
void stopScript(); For user implemented test to break out of the script control loop. file not found, initialization fail etc.
void tileBasedRender(); Begins rendering the current frame or range of frames using current state.
|
|
« Last Edit: August 02, 2015, 04:31:28 PM by 3dickulus »
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #12 on: July 26, 2015, 01:49:21 AM » |
|
i still wonder why no one is using synthclipse, it has a build in ful fledged opengl accessible javascript parser included, making it easy to combine multiple shader with similar functionality ... just sayin' its for the fun, i see that, so i hope no harm done!
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
3dickulus
|
|
« Reply #13 on: July 26, 2015, 02:05:01 AM » |
|
I think the more complex a program gets, the more intimidating it is or perhaps the complexity makes it difficult to get it organized in the average user's head. I liked Eclipse but it didn't feel comfortable as an IDE, Synthclipse is Eclipse? that has been tailored to GLSL. I would like Fragmentarium to be as friendly for the novice "I just want to make pretty pictures" as it might be for the hard core hackers "I want total control". Fragmentarium-1.0.9 is up. Source code and win exe.
|
|
« Last Edit: July 26, 2015, 07:23:46 AM by 3dickulus, Reason: link »
|
Logged
|
|
|
|
Patryk Kizny
|
|
« Reply #14 on: August 05, 2015, 05:42:01 PM » |
|
It looks pretty cool and I should have gotten familiar with it sooner.
Few questions / notes 1) Does the QS window have to be modal = disables controlling everything below? I would love to keep it opened and execute small scripts not having to open it multiple times, load script, then close. 2) Would that be possible to add 5 buttons to GUI where you could load scripts into, then press button to execute connected script. plus one button to STOP a running script? That would be so cool!
|
|
|
Logged
|
Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
|
|
|
|