R0J0hound's Recent Forum Activity

  • Shaders in construct are limited in what you can access. So you can't access additional textures currently unless they update it in the future. Best bet would be to add the idea to the suggestion platform and hope it's picked up.

    According to the manual:

    construct.net/en/make-games/manuals/addon-sdk/guide/configuring-effects

    That page lists what you have access to from an effect. Currently the two textures you can have access to are the foreground and background. Maybe with some trickery you could have two sprites stacked and use the backgound samper to get the image below. However that has a lot of cases it probably wouldn't work well.

    An unsupported way would be to use webgl directly but that can be tricky/kinda unsolved for C3. Construct's renderer uses webgl behind the scenes currently, with a focus on batching things for speed. In construct 2 I found that you could end all the current batches and then use any webgl you wanted for maximum flexibility. The only caveat was you needed to make sure the webgl state was unchanged when you finished the webgl code otherwise it would break construct's renderer.

    Construct 3's renderer has been reengineered and updated a few times so it's less clear how to utilize custom webgl, if at all. Last I looked it's setup in **** a way to be more of a black box that you can only interact with in a supported way. Also I believe they plan on utilizing a different api later on, and I could see them reworking the renderer in the future, so that would make any unsupported solution easy to break.

    Anyways if you want to attempt it you'll need a few things. First you'll need to access the webgl context of the canvas. There may be something in the js sdk that provides that or you can attempt to grab it from the canvas itself. Next you'll need to access the compiled shader program for your effect. That's probably the biggest roadblock as that might be hidden behind some closures in construct's renderer. Also even if you can find a list of shader programs in the renderer it may still be an issue of figuring out which one it is.

    Anyways, if you're able to find a way to access your effect's shader program then something like the following might be a way to set a second texture you can access from the effect.

    You'd add this line to your effect:

    uniform sampler2d texture2;

    Then to make that reference a texture you'd need to do something like this:

    function setTexture2(gl, program, texture)
    {
     var u_tex2Location = gl.getUniformLocation(program, "texture2");
     gl.uniform1i(u_image0Location, 4); // texture unit 4.
     gl.activeTexture(gl.TEXTURE4);
     gl.bindTexture(gl.TEXTURE_2D, texture);
    }

    You need to call that function with the webgl context, the shader program of your effect, and the handle to a webgl texture. The texture is either loaded with wegl or you somehow access another texture from a sprite or something. The most fragile part here is I'm assuming that texture unit 4 isn't used by construct's renderer so we take advantage of that by using it. You'd only need to call that function when we want to change the texture.

    Other potential issues that may need to be dealt with is how that will sync with the renderer. There may be other issues I'm not thinking of.

    Overall I generally just try to work within what features construct provides, but there are other potential solutions, they just don't always pan out.

  • It’s a project property. I think it’s called image filtering or sampling or something like that. By default it’s linear but you want nearest. I think you may be able to change that per layer but I’m not sure.

  • You could set the camera angle to mouse.x or something. I’m guessing you might have something else in mind but I’m not sure.

    I know there are examples elsewhere on the forum of setting the 3d camera in different ways that could be adapted I suppose. However in this example I’m only supporting setting the camera with the look at action.

  • Here is an update that changes the view from the camera object's position and angle and looks down a bit. Also added some controls to move rotate and strafe.

    There are many ways to set it up so I just picked one and went with it.

    uc31a894116818fba36c6fcdcec2.dl.dropboxusercontent.com/cd/0/get/Ch9iPbiAe-SU-lafo86rUFlTQ84dDWoDqJSl3cgenBrUUxmdwySslb2N33NBeyAReL2k9lQekudDfIf_LZFjJDqMLhnL3pZGBnRZUlsHJ9FrJm3nTC9VhuKJePOig08ra0ZGB-mqi31MZscBHWtVkjNT/file

  • I just replicated the “look at” action. If any of the other actions that move or change the orientation of the camera are used then they would need to be replicated too.

    Currently the orientation is a 3x3 matrix stored in three sprites. It can be rotated by multiplying with a rotation matrix that rotates the amount you want to rotate. In practice we’d use some simplification of that.

    Another way that may be simpler would be to only use the “look at” action to orient the camera. Just change the look at target.

    X: camera.x+100*sin(a)

    Y: camera.y+100*cos(a)

    Z: camera.z

  • I mean there are only two speakers so the volume is balanced between those two for any direction. Option two seemed simpler when I wrote it. I tend to try that a lot. When construct doesn't have a feature I try to calculate it manually and then somehow work that in to the available features.

    You can probably get some basic overview on how to use JavaScript in construct with a few of the tutorials available. There are lots of ways and none of them seem very clean to me. Anyways, the meat of using the webaudio api to do the audio is to setup a node graph. Rough overview of how it would look is this:

    source1->gain->position--+
    source2->gain->position--+->listener->gain->output
    source3->gain->position--+

    Basically any sound you want to play would need to be added to the graph with a gain node. Then they could be removed as they finish. Of course the nuance of implementing it will look more verbose.

    Anyways, ideally the solution would be simple or added so it can be simple. These solutions are paths to work toward a solution without having to wait on the devs.

  • I can’t wrap my head around a solution to that. As is the impulse corrects the position but as the length is changing the velocities would have to be updated somehow.

    I tried gradually changing the length with a force but haven’t had much success.

  • I don’t think the audio plug-in has been updated with 3d in mind. You could make a feature request to give a z height to the positioned audio since webaudio already has that available, construct just doesn’t use it.

    A second option would be to calculate the volume from the 3d distance to the listener and the falloff equation. It’s mostly just busywork to workout the formula.

    A third option would be to use JavaScript instead to do the audio plugin. There are various libraries that could work or if you could use webaudio directly.

  • There isn’t one way you have to do it. You can set it up any way you like. With any setup you’ll have to do some juggling with events.

    If it’s any consolation I find any changes to this to be complicated too. I attempted to simplify things into manageable chunks but I still find rough to debug or modify.

  • All the code refers to same sprite type. The new choices are a different type.

    I made all the numbers be the same type and used a group variable to differentiate between then to reduce the amount of events.

    There are many ways to setup the events. Currently it does most of the stuff with variables and only deals with sprites when displaying. Nothing is automatic. To display it picks a certain group of sprites and sets it from a certain variable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The physics behavior doesn’t provide that joint.

    A few ideas come to mind though.

    1. Is to do event based physics using verlet. I’ve made rope examples that do that. It’s as simple as if the distance is greater than a certain amount the objects are moved toward each other to correct that, then the velocities are updated. The cons are it’s independent of the physics behavior and working with ridged bodies will require more code.

    2. Joints in the physics engine are done with impulses behind the scene so in theory you could make the joint you want with that. I fiddled with the idea a bit and something like an impulse of (distance-100)/100 toward the other object seems to work but is bouncy. For better results we could copy what impulses box2d calculates for such a joint.

    Edit:

    If d is the distance between the objects and ang is the angle between them, then the impulse should be the following when dist<100. At least from what I’ve read.

    ImpulseAtoB= -(d-100+(A.vx-B.vx)*cos(ang)+(A.xy-B.vy)*sin(ang))/(1/A.mass+1/B.mass)

    I’ll test this later. The units may be off.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound