How do I turn a specific color into an alpha channel?

0 favourites
  • 5 posts
From the Asset Store
Is a system for building scorecards and achievements online for use in games Using this system, you can create a scorebo
  • I'v been working on a pseudo 3D dungeon crawling prototype but ran into a snag;

    While setting up a dynamic shadow system I came across a problem which, on paper, should be pretty easy to fix yet I can't find the solution I'm looking for.

    As you can see the back layer of the front wall bleeds into the sidewall. Normally, it'd just be a question of shifting the sidewall to the front, but doing so would let the shadow go on-top of the front wall.

    So the solution I thought of is simply making the back wall's black parts turn invisible depending on the camera's angle, but as far as I'm aware there isn't any effects that can do this.

    One other method would be using 2 different animations (One with black, the other without) and switch between them as needed, but I find it way too inefficient considering the size of the textures.

    TLDR;

    Is it possible to turn a sprite's specific color into an alpha channel?

    I appreciate any help I can get!

  • I am not sure I fully understand the problem, but maybe you can cover the part of the wall that you don't want to show with a mask sprite? Destination Out blend mode on the mask will make the wall invisible.

    I would love to see the final game. I've recently made something similar (I guess? maybe not) for a game jam, take a look.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't think masks could be easily be implanted for what I'm doing.

    Here's what the walls normally look like in motion;

    gph.is/g/4DkoJm9

    The front-facing walls have two "Layers" to give the impression of 3D depth.

    My current problem is that with my newly implanted shadows, the back layer of those walls are being rendered ontop of the side walls.

    My preferable solution to this would be making the back layer's black turn invisible.

    So depending on the camera's angle I can toggle this invisibility on/off.

    But I'm not sure that's even possible.

  • I couldn't find the effect that can turn a color transparent, but you can try Alpha Clamp effect. If you make the black color in the wall image slightly transparent (say, 250 alpha), you can configure the Alpha Clamp effect to make this area completely transparent.

    Another idea - if your back wall is a TiledBackground, you can decrease its width:

    Blue line is the full width, red line is the cropped width.

  • The alpha clamp worked!

    Thank you very much for this, you've saved me from an headache and a half!

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