help with first effect, what have i done wrong? "invalid json"

Not favoritedFavorited Favorited 0 favourites
  • 7 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I keep getting error in when trying to install it in C3, "invalid json".

    I have the following files in a zip, renamed to .c3addon

    in the root directory.

    lang/en-US.json

    {

    "languageTag": "en-US",

    "fileDescription": "Strings for the 'Star Nebula Starfield' effect.",

    "text": {

    "effects": {

    "StarNebulaFX": {

    "name": "Star Nebula Starfield",

    "description": "Generates a procedural 2D starfield with animated nebula clouds and twinkling stars.",

    "parameters": {

    "nebula-color-1": {

    "name": "Nebula Color 1",

    "desc": "First color for the nebula gradient."

    },

    "nebula-color-2": {

    "name": "Nebula Color 2",

    "desc": "Second color for the nebula gradient."

    },

    "nebula-scale": {

    "name": "Nebula Scale",

    "desc": "Size/zoom of nebula clouds. Smaller values = larger clouds."

    },

    "nebula-speed": {

    "name": "Nebula Speed",

    "desc": "Speed of nebula animation."

    },

    "star-density": {

    "name": "Star Density",

    "desc": "Controls the number of stars."

    },

    "star-twinkle-speed": {

    "name": "Star Twinkle Speed",

    "desc": "Speed of star twinkling."

    },

    "effect-brightness": {

    "name": "Effect Brightness",

    "desc": "Overall brightness of the generated effect."

    }

    }

    }

    }

    }

    }

    addon.json file

    {

    "is-c3-addon": true,

    "type": "effect",

    "name": "Star Nebula Starfield",

    "id": "StarNebulaFX",

    "version": "1.0.0.0",

    "author": "Your Name",

    "website": "",

    "documentation": "",

    "description": "Generates a procedural 2D starfield with animated nebula clouds and twinkling stars.",

    "file-list": [ "lang/en-US.json", "addon.json", "StarNebula.fx" ],

    "category": "visual",

    "blends-background": false,

    "cross-sampling": false,

    "preserves-opaqueness": false,

    "animated": true,

    "extend-box": {

    "horizontal": 0,

    "vertical": 0

    },

    "parameters": [ { "id": "nebula-color-1", "type": "color", "initial-value": [0.1, 0.0, 0.2],

    "uniform": "uNebulaColor1"

    },

    {

    "id": "nebula-color-2",

    "type": "color",

    "initial-value": [0.0, 0.2, 0.4],

    "uniform": "uNebulaColor2"

    },

    {

    "id": "nebula-scale",

    "type": "float",

    "initial-value": 3.0,

    "minimum": 0.1,

    "maximum": 10.0,

    "uniform": "uNebulaScale"

    },

    {

    "id": "nebula-speed",

    "type": "float",

    "initial-value": 0.5,

    "minimum": 0.0,

    "maximum": 5.0,

    "uniform": "uNebulaSpeed"

    },

    {

    "id": "star-density",

    "type": "percent",

    "initial-value": 0.5,

    "uniform": "uStarDensity"

    },

    {

    "id": "star-twinkle-speed",

    "type": "float",

    "initial-value": 1.0,

    "minimum": 0.0,

    "maximum": 10.0,

    "uniform": "uStarTwinkleSpeed"

    },

    {

    "id": "effect-brightness",

    "type": "percent",

    "initial-value": 1.0,

    "uniform": "uEffectBrightness"

    }

    ]

    }

    StarNebula.fx file

    // Content for StarNebula.fx

    varying mediump vec2 vTex;

    // Provided uniforms (samplerFront is common without effect.js, uTime if animated=true)

    uniform sampler2D samplerFront;

    uniform mediump float uTime;

    // Custom uniforms mapped from parameters in addon.json

    uniform mediump vec3 uNebulaColor1;

    uniform mediump vec3 uNebulaColor2;

    uniform mediump float uNebulaScale;

    uniform mediump float uNebulaSpeed;

    uniform mediump float uStarDensity; // Received as 0.0-1.0

    uniform mediump float uStarTwinkleSpeed;

    uniform mediump float uEffectBrightness; // Received as 0.0-1.0

    // --- Noise Functions ---

    // Simple pseudo-random number generator

    mediump float random (mediump vec2 st) {

    return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);

    }

    // Smooth noise function (Value Noise)

    mediump float noise (mediump vec2 st) {

    mediump vec2 i = floor(st);

    mediump vec2 f = fract(st);

    mediump vec2 u = f*f*(3.0-2.0*f); // Smoothstep calculation

    // Four corners in 2D of a tile

    mediump float a = random(i);

    mediump float b = random(i + vec2(1.0, 0.0));

    mediump float c = random(i + vec2(0.0, 1.0));

    mediump float d = random(i + vec2(1.0, 1.0));

    return mix(a, b, u.x) + (c - a)* u.y * (1.0 - u.x) + (d - b) * u.x * u.y;

    }

    // Fractional Brownian Motion (simple version)

    mediump float fbm (mediump vec2 st) {

    mediump float value = 0.0;

    mediump float amplitude = 0.5;

    // Loop for multiple octaves of noise

    for (int i = 0; i < 4; i++) {

    value += amplitude * noise(st);

    st *= 2.0;

    amplitude *= 0.5;

    }

    return value;

    }

    // --- Main Shader Logic ---

    void main(void)

    {

    // --- Nebula Calculation ---

    mediump vec2 nebulaCoord = vTex * uNebulaScale;

    nebulaCoord += vec2(uTime * uNebulaSpeed * 0.1, uTime * uNebulaSpeed * 0.05);

    mediump float nebulaValue = fbm(nebulaCoord);

    nebulaValue = smoothstep(0.2, 0.7, nebulaValue);

    mediump vec3 nebulaColor = mix(uNebulaColor1, uNebulaColor2, nebulaValue);

    // --- Star Calculation ---

    mediump vec2 starCoord = vTex * 30.0;

    mediump float starNoise = random(starCoord);

    // Map density (0-1) to threshold (e.g., 1.0 - 0.985)

    mediump float densityThreshold = 1.0 - (uStarDensity * 0.015);

    mediump float stars = pow(starNoise, 50.0); // Sharpen noise peaks

    stars = step(densityThreshold, stars); // Create sparse points

    // Twinkling

    mediump float twinkleValue = noise(vTex * 10.0 + uTime * uStarTwinkleSpeed * 0.5);

    twinkleValue = smoothstep(0.3, 0.7, twinkleValue) * 0.5 + 0.5; // Varying intensity (0.5 to 1.0)

    stars *= twinkleValue;

    // --- Combine and Output ---

    mediump vec3 finalColor = (nebulaColor + vec3(stars)) * uEffectBrightness;

    // Output final color, assume opaque

    gl_FragColor = vec4(finalColor, 1.0);

    }

    I checked with online json validator and it seems valid.

    Thanks.

  • It doesn't provide any other info in the browser console about why it's invalid, or which json file is invalid?

    I did a quick skim comparing your json with the sdk example on github and nothing stands out as amiss. Btw if you put source code in code tags (Ctrl+\) it's a bit easier to read on the forum.

    If it doesn't provide any more info, then I'd try taking the example on the sdk, see if that loads, then try incrementally changing that into your effect to hopefully find the issue.

  • the id StarNebulaFX needs to be lowercased (starnebulafx) in the language file

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks guys.

    I tried making the id lowercase but it still didn't work.

    here is the console log error

    the file

    dropbox.com/scl/fi/ucm840yaiq2jjr88vypmn/star-nebula.c3addon

    saved in notepad in UTF-8 encoding. Compressed as a zip by selecting the 3 files and renaming to .c3addon

  • There are three problems in addon.json: the first two are the website and documentation fields are left empty, but they are required; the third is that the category is set to "visual", but that is not one of the valid category options.

    Use an editor like VS Code that understands the JSON schema - it provides validation for all these requirements, and all three are highlighted as problems when editing your addon.json file.

  • Thanks for your help. Will give it another try. 👍

  • Works now thanks.

    Another issue was that the effect file needed to be named effect.fx as well.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)