Mikal's Forum Posts

  • Some example code, set globalThis.globalRuntime = runtime in startup scripts.

    Also see: construct.net/en/make-games/manuals/addon-sdk/runtime-reference/object-classes/worldinfo

    var topLtX = localVars.topLtX
    var topLtY = localVars.topLtY
    var topRtX = localVars.topRtX
    var topRtY = localVars.topRtY
    var botLtX = localVars.botLtX
    var botLtY = localVars.botLtY
    var botRtX = localVars.botRtX
    var botRtY = localVars.botRtY
    var effectIndex = localVars.effectIndex
    // Get instance details
    var inst = globalThis.globalRuntime.GetInstanceByUID(localVars.uid)
    var wi = inst.GetWorldInfo()
    // Find bounding box
    var minX = Math.min(topLtX, topRtX, botLtX, botRtX)
    var minY = Math.min(topLtY, topRtY, botLtY, botRtY)
    var maxX = Math.max(topLtX, topRtX, botLtX, botRtX)
    var maxY = Math.max(topLtY, topRtY, botLtY, botRtY)
    // Calc bonding box
    var width = maxX - minX
    var height = maxY - minY
    // Set bounding box
    wi.SetX(minX)
    wi.SetY(minY)
    wi.SetWidth(width)
    wi.SetHeight(height)
    wi.SetBboxChanged()
    // Calc normalized relative range (0-1) for texture X,Y coords from pixel locations
    topLtX = (topLtX-minX)/width
    topLtY = (topLtY-minY)/height
    topRtX = (topRtX-minX)/width
    topRtY = (topRtY-minY)/height
    botLtX = (botLtX-minX)/width
    botLtY = (botLtY-minY)/height
    botRtX = (botRtX-minX)/width
    botRtY = (botRtY-minY)/height
    
    // Set effect parameters (takes 5%+ CPU @ 2000 objects)
    /*
    inst._sdkInst.CallAction(C3.Plugins.Sprite.Acts.SetEffectParam, effectName,0,topLtX)
    inst._sdkInst.CallAction(C3.Plugins.Sprite.Acts.SetEffectParam, effectName,1,topLtY)
    inst._sdkInst.CallAction(C3.Plugins.Sprite.Acts.SetEffectParam, effectName,2,topRtX)
    inst._sdkInst.CallAction(C3.Plugins.Sprite.Acts.SetEffectParam, effectName,3,topRtY)
    inst._sdkInst.CallAction(C3.Plugins.Sprite.Acts.SetEffectParam, effectName,4,botLtX)
    inst._sdkInst.CallAction(C3.Plugins.Sprite.Acts.SetEffectParam, effectName,5,botLtY)
    inst._sdkInst.CallAction(C3.Plugins.Sprite.Acts.SetEffectParam, effectName,6,botRtX)
    inst._sdkInst.CallAction(C3.Plugins.Sprite.Acts.SetEffectParam, effectName,7,botRtY
    */
    
    // (take 1%+ CPU @ 2000 objects to find index by effectName), instead pass in effectIndex to function
    // var effectIndex = inst.GetObjectClass().GetEffectList().GetEffectTypeByName(effectName).GetIndex()
    
    // Set effect parameters by ref (faster than CallAction)
    var effectParam = wi.GetInstanceEffectList().GetEffectParametersForIndex(effectIndex)
    effectParam[0]= topLtX
    effectParam[1]= topLtY
    effectParam[2]= topRtX
    effectParam[3]= topRtY
    effectParam[4]= botLtX
    effectParam[5]= botLtY
    effectParam[6]= botRtX
    effectParam[7]= botRtY
  • Playing with adding a procedural noise effect to the particles. Adjusting the procedural noise texture offset parameters based on location gives a sense of movement/rotation/animation. Also adjusting color based on x,y, and gravity. Looking for more ways to use this with particles going forward.

  • Ashley,

    Thanks for the link on the shader compositor, very interesting reading.

    For now, what I have done is remove the pixelSize uniform from my shader and instead pass in similar values for the text object custom effect via user uniforms. I pass it '1.0/Text.width' for my own pixelSizeUser.x and '1.0/Text.height' for pixelSizeUser.y. This seems to work ok so far for iPhone mobile, safari and chrome on MacOS, with both high and low quality fullscreen and multiple resolutions. If the text box size changes, I must update the uniforms. Also if I spawn a Text object with the effect, I also must update the uniforms for the Text object spawned.

    I understand your comment on the complexity, I see different behavior of the effect compositor on mobile and desktop with existing effects, so I see that adding more uniforms, etc. may be difficult.

  • Oh sorry, maybe I was not clear, I’m just going to do the work around in my game for that one object put two shaders). I am not asking for a change to C3. I may even make a dummy shader to try to lower the perf impact a little. I just wanted to see if you thought that was ok.

  • Thanks for the reply and info.

    Do you see any issue with my work around then? Apply a simple shader first that does not use the texture uniforms and then after that apply the shader with that uses the uniforms, since they are then set and available (works for me now.)

    I know there could be some perf impact, but will deal with if we have to.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also, good timing - on the Construct Twitch channel, they just started a tutorial on developing a dialogue system with JSON!

    twitch.tv/constructteam

  • Thanks. The uniforms do get set when you have 2 or more effects on text. Are they then set to the intermediate FB source rectangle and pixelSize? That’s my work around for now to stack two effects on the text object.

    Could you do the same when it’s just one effect? Don’t you render the text to an intermediate texture already and you should know the source rectangle and pixelSize of that intermediate texture and could set the uniforms based on that?

  • This is not JSON driven (is that a requirement?)

    I like this one, it has a nice display and a built-in editor. Also paid. Check it out:

    construct.net/en

  • There is a JSON plugin for Twine and a paid Twine plugin for C2 (and I have a C3 conversion.)

    So you can write dialogue in Twine output to JSON and then import to C3 and use Twine plugin to output.

    C3 Twine plugin (paid)

    colludium.itch.io/twine-plugin

    Twine: twinery.org

    Twine JSON export: github.com/DigitalCarleton/Prairie/wiki/Exporting-Data-from-Twine-to-JSON

  • I will file this as bug if needed, please let me know. However, I am checking if I am missing something fundamental.

    I am creating a new shader and found that the pixelSize uniform was set to 0,0 when I applied the effect to a 'Text' object. I checked this through running remote preview and using spector.js to inspect the uniforms for the effect when the 'Text' object is rendered with the shader. When I apply the same shader to a Sprite object it works fine.

    After seeing that, I tried some other built-in effects on the 'Text' object, to see if I could see a similar error. I found that when I applied 'Bulge' to a text object, the text disappeared in the editor. I then tried remote preview and spector.js with this and found that srcOriginStart and srcOriginEnd were both set to 0,0. So the bulge shader also 'failed'.

    I found that the effects started to work when I stacked another shader (any shader) on the text object (so then there would be multiple renders to multiple FB and then the uniforms were properly set for the fragment shaders.)

    Should I be doing something special with my shader to make it work with the 'Text' object? If there is, likely the same thing should be applied to the builtin Bulge effect also (and perhaps others?)

    Here's the spector.js output for looking at the Bulge effect on the text object:

    Thanks for the help Ashley!

  • This may be due to default resolution that we are rendering the Spine texture, I think right now it's set to around the Spine bounds in pixels. I will take a look at the resolution of rendering and reply back to this thread.

    One other thing you can also look at is the output of the Spine texture atlas png and make sure the resolution of the output of the textures from Spine are at the correct resolution you want to use.

  • MotionBlur effect with an example:

    construct.net/en/make-games/addons/337/motionblur

    Motion Blur w/ x,y directional blur. Based on feedback from TackerTacker, added some blur _in front_ of the direction of motion also which made the effect feel a bit better.

    Example:

    If you do something with it, please share here or tag me on twitter:

    twitter.com/kindeyegames

  • For mobile, I would suggest trying using one of the versions with a lower number of samples (and lower quality) see the github link on the addon documentation page for those.

    For mobile effects, it's always good to benchmark early and tweak as needed. For example, if you only need the GodRays to cover a specific area, size the sprite with the GodRays effect to the minimum size required.

  • New C3 effect to have fun with, it's pretty versatile, so if you do something new with it, please share in this thread, so we all can learn together!

    construct.net/en/make-games/addons/334/godrays

    It was ported from medium.com/community-play-3d/god-rays-whats-that-5a67f26aeac2. Which in turn is based on: developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-13-volumetric-light-scattering-post-process

    Some examples (the Necromancer one is based on a project from TackerTacker):

  • I think the website has the details. I bought the full collection myself when it first came out.