mOOnpunk's Recent Forum Activity

  • I'll look into “Ear clipping”, thanks.

  • Unfortunately all the shapes are pretty much concave, and since its all procedural i can never be sure. I've tried convex but it never renders the shape accurately.

    I would appreciate increasing the limit to 1000.

    What I'm doing is already really complex, delaunay triangulation, centroids, creating local boundaries, joining boundaries into clusters, clusters groups within cluster groups within cluster groups etc.

    It seems to work well most of the time, with some really complex shapes.

    It would be an extra layer of complexity to split the shape up into chunks.

    I'll have to think some more.

  • I'm currently working on making star maps like the game Stellaris.

    I'm trying to render the regions controlled by different teams. I'm using a sprite with mesh distortion to create the outline of boarders (so i get a nice sharp clean edge rather than pixelated edge), and the canvas object to draw the inner solid colour.

    The issue I'm having is in some circumstances the canvas wont render properly, 99% of the time it works though.

    The points are ordered correctly, as they use the same points as the mesh object, which is the correct shape, so i've ruled that out.

    I thought it might have to do with having "convex" checked when filling the polygon, but that made things worse.

    Then i looked in the console log and notice this.

    "quick decomp: max level (100) reached". Related to polygons.

    It only comes up when i notice the rendering error.

    I'm kind of stuck. The mesh object being square grid based cant render such complex shapes. I've tried writing a custom shader but shader files don't support token strings so each point would have to be a separate parameter, which is not feasible.

    Ashley any help?

    Thanks

    Tagged:

  • Are you talking about using AI to help develop and code your game, or AI inside the game being played to control character behaviours and things?

  • I don't know how you would control the 3 different functionality of zoom, pan and rotate with just touch, unless you added the relevant buttons on the screen to touch with one finger while dragging with an other?

  • Very interesting. What about interactions? Does it simply load a .rive file animation to play it? How does it interact with events, and other c3 objects?

  • What are the limitations of this plugin?

    I thought RIVE uses vector graphics?

  • Works now thanks.

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

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

  • 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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You cant destroy the sprite immediately, since the drawing canvas requires the next tick to update, so the sprite is being destroyed i think before it gets a chance to be pasted.

    You may need to add a wait 0.1 seconds before you destroy it.

mOOnpunk's avatar

mOOnpunk

Early Adopter

Member since 29 Mar, 2017

Twitter
mOOnpunk has 5 followers

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • Enduring Visitor Visited Construct.net 90 days in a row
  • Unrelenting Visitor Visited Construct.net 180 days in a row
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

18/44
How to earn trophies