Is it possible to load an image as a property for an effect?

0 favourites
  • 3 posts
From the Asset Store
Elevate your games with our AI Chatbot Integration! Seamlessly connect your Construct 3 projects with GPT-4 for dynamic,
  • Hey all,

    I think I know there is not a property for effects that can be used to load an image, but I was curious if there would be a way to load a texture in an effect from a file at runtime?

    Put simply, I'm authoring a color LUT effect.

    I also have other effects that I need to be able to reference images from, but they need not to be hardcoded, and must be user set. (think about lens dirt on a bloom effect).

    For the color LookUpTable, I used to simply set the effect to a sprite, and the sprite WAS the lookuptable. The issue with that is it will only work on a per "layer" basis, and not a per object basis for things like palette swapping.

  • Short answer is no. Long answer is maybe.

    You can already load textures at runtime. To use additional textures in an effect there are two parts in webgl. On the shader side just add another sampler uniform.

    To make it reference a texture you need to select a texture unit, bind a texture, and finally bind the shader program and set the sampler uniform to the texture unit index you’re using.

    Construct’s renderer doesn’t use too many texture units so you could use an unused one to bind a texture to. To do that all you need is to get the webgl context.

    The part I’m iffy about is setting the uniform on the shader. To do that you need the shader program for that shader. And that’s something that construct keeps track of. Possibly could be other ways to get the shader handle.

    Anyways that’s just a general outline for how it could be done for webgl. Construct doesn’t provide anything to help with that nor does it do much to prevent that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks, that's a good direction. Looks like I might have to add this to my, "nice to have" list and tackle it if I have time. I don't actually need palette swapping in my current project, but it always bothered my that my luts were sprites overlaying the entire viewport.

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