Plugin converter

For discussion and help with the Construct 3 Plugin SDK

Post » Tue Nov 28, 2017 8:00 am

Great! That seemed to work. Thanks for the help. I'll post a separate thread on the experimental result.
B
42
S
17
G
14
Posts: 133
Reputation: 10,350

Post » Tue Nov 28, 2017 4:52 pm

Mikal wrote:
Gigatron wrote:@justifun

Just converted in lightspeed ... means 80 times restart C3.. clear cache, rename zip file to .c3addon ... errors somewhere and restart again ... + 3 beers ..
A Nightmare to converting something for C3.
So try this if it's same as the original ;
http://gigatron3k.free.fr/html5/C3/FX/atreshold.c3addon

Regards
...


@Gigatron

Any general tips / guidance on converting over effects? What do you typically have to change in the *.fx file (I'm looking at the effect SDK and comparing some *.fx before and after, but would be interested if you have general tips. I agree with your comments on the other files, right now they are a bit of a pain to deal with.

I'm trying to convert over NormalMapExtended


@Mikal

Here is the variables used by C3 shaders but i my declaration is bit different...
Code: Select all

C3 ..
uniform lowp sampler2D samplerFront;
uniform mediump vec2 srcStart;  <-- new
uniform mediump vec2 srcEnd;    <-- new
uniform mediump vec2 srcOriginStart; <--- new
uniform mediump vec2 srcOriginEnd;  <-- new
uniform mediump vec2 layoutStart; <-- new
uniform mediump vec2 layoutEnd;  <-- new
uniform lowp sampler2D samplerBackground;
uniform mediump vec2 destStart;
uniform mediump vec2 destEnd;
uniform mediump float seconds;
uniform mediump vec2 pixelSize;    <-- new
uniform mediump float layerScale;
uniform mediump float layerAngle;


C3 gigatron shader header;

#ifdef GL_ES
precision mediump float; // or lowp or highp ... all variables are the same precision now !
#endif

uniform  sampler2D samplerFront;
uniform vec2 srcStart;
uniform vec2 srcEnd;
uniform vec2 srcOriginStart;
uniform vec2 srcOriginEnd;
uniform vec2 layoutStart;
uniform vec2 layoutEnd;
uniform sampler2D samplerBackground;
uniform vec2 destStart;
uniform vec2 destEnd;
uniform  float seconds;
uniform vec2 pixelSize;
uniform float layerScale;
uniform  float layerAngle;
vec3 color = vec3(1.,0.,0.); <---- new in C3

void main(){

  -- no need precision declaration again in the main loop ;
  -- except gpu overload then we can adjust precision 
  -- like this -uniform  sampler2D samplerFront-  to uniform  lowp sampler2D samplerFront;
   //vec2 uv= vTex;
 
   gl_FragColor = vec4(color,1.0);

}



Finally no really change on fx file ... in case op special fx we must use some new variables.//
Regards
B
69
S
24
G
29
Posts: 829
Reputation: 22,751

Post » Sat Dec 02, 2017 12:05 am

Got some feedback from Ashley on an issue with c2ids and transferring over a C2 *.capx with a new effect (though maybe this applies to other plugins. This at least applies to parameters in effects files (I found the issue when porting over Extended Normal Map.)

@blackhornet, it would be great if you could update the converter with the below in mind:

Ashley:
Well, it turns out it's actually C2 itself that strips non-alphanumeric characters when saving to the project, so the C2 XML file ends up with an ID like "ambient-green". C3 will import based on this ID. It's easy to fix, because it tells you the ID it's looking for ("ambient-green") so all you need to do is change the "c2id" to "ambient-green" and it will look up correctly.

We can't fix how C2 saves projects at this point, so closing as won't fix - just filter those characters out from your c2ids as well.


My original comment on this:
When I copied over the original example *.capx, C3 'compat' complained in the Chrome console that certain parameters could not be set. Interestingly enough (and this is probably a clue @ashley , the parameters that were not set contained non-alpha characters in their IDs, for example: "Light2 Ambient (Green)". After I corrected the parameters that were not copied and ran C2 and C3 side by side, the effect looks the same in each. Obviously experimental, but feel free to try it.
B
42
S
17
G
14
Posts: 133
Reputation: 10,350

Post » Sat Dec 02, 2017 12:17 am

@Mikal
I believe I caught this late. Was updated in 1.0.0.13.
ImageImageImage
B
71
S
22
G
257
Posts: 3,790
Reputation: 142,696

Post » Sat Dec 02, 2017 2:00 am

blackhornet wrote:@Mikal
I believe I caught this late. Was updated in 1.0.0.13.


Thanks for the reply. I just downloaded the latest again (1.0.0.13) and tried again, same results, there are still non-alpha characters in the c2id, which need to be removed.

Snip from addon.json (see '(' and ')' still included in some of the c2id.

Code: Select all
               {
                        "id": "light-zposition",
                        "c2id": "light-zposition",
                        "type": "float",
                        "initial-value": 0.02,
                        "uniform": "posZ"
                },
                {
                        "id": "color-(red)",
                        "c2id": "color-(red)",
                        "type": "float",
                        "initial-value": 1,
                        "uniform": "colorR"
                },
B
42
S
17
G
14
Posts: 133
Reputation: 10,350

Post » Sat Dec 02, 2017 3:00 am

@Mikal
Updated in 1.0.0.14.
ImageImageImage
B
71
S
22
G
257
Posts: 3,790
Reputation: 142,696

Post » Sat Dec 02, 2017 5:18 am

blackhornet wrote:@Mikal
Updated in 1.0.0.14.


Great, tested, worked, thanks. Updating NormalMapExt.c3addon
B
42
S
17
G
14
Posts: 133
Reputation: 10,350

Post » Tue Dec 05, 2017 4:01 am

A quick tip for converting C2 -> C3 plugins that use project files. This is from another comment, which I can't find right now, but it helped to convert the flodjs plugin.

Replace requested file in C2 code with this.runtime.getLocalFileUrl(<target>)

Example:

Original
Code: Select all
        if(typeof(AudioContext) != 'undefined'){
                        var fetch = new XMLHttpRequest();
                        fetch.open('GET', zic);


New:
Code: Select all
        var urlToRequest = this.runtime.getLocalFileUrl(zic);
        if(typeof(AudioContext) != 'undefined'){
                        var fetch = new XMLHttpRequest();
                        fetch.open('GET', urlToRequest);
B
42
S
17
G
14
Posts: 133
Reputation: 10,350

Previous

Return to Plugin SDK

Who is online

Users browsing this forum: No registered users and 1 guest