[SOLVED] Make InverseMap fade back to normal slowly?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Dan_The_Noob
Posts: 755
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

[SOLVED] Make InverseMap fade back to normal slowly?

Post by Dan_The_Noob »

Is it possible to have the InverseMap (Invuln Sphere effect) fade slowly back to normal rather than flashing off and on?
I'm trying to use it for a flashbang style effect.

another option, is there a way to make the screen 95% bright white as a colormap? whenever i try, it just gives basically a LightAmp effect instead of being white.
Last edited by Dan_The_Noob on Mon Dec 26, 2022 1:11 am, edited 1 time in total.
User avatar
Player701
 
 
Posts: 1543
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

Re: Make InverseMap fade back to normal slowly?

Post by Player701 »

Dan_The_Noob wrote: Sun Dec 25, 2022 6:33 pm Is it possible to have the InverseMap (Invuln Sphere effect) fade slowly back to normal rather than flashing off and on?
I'm trying to use it for a flashbang style effect.
As far as I know, InverseMap is a special effect applied in hardware rendering via shaders. I haven't worked with them myself, so I cannot be specific here, but as far as I know, you can create and apply custom shaders in your mods. But I'm not sure if they can be controlled from script code like you want it to. And it won't work with software rendering at all, which may or may not be a problem for you.
Dan_The_Noob wrote: Sun Dec 25, 2022 6:33 pm another option, is there a way to make the screen 95% bright white as a colormap? whenever i try, it just gives basically a LightAmp effect instead of being white.
Yes, there is. Example for powerup items:

Code: Select all

Powerup.Color "ff ff ff", 0.95;
This can also be controlled via GetBlend, if you want the effect to fade with time. For example, when the player receives the following inventory item, their screen will instantly turn almost completely white, then slowly fade to normal over 2 seconds:

Code: Select all

class TestInv : Inventory
{
    const LIFETIME = 70; // 2 seconds

    override color GetBlend()
    {
        double alpha = 0.95*(1-(double(GetAge())/LIFETIME));
        return Color(int(alpha*255), 255, 255, 255);
    }

    override void Tick()
    {
        Super.Tick();

        if (GetAge() >= LIFETIME)
        {
            Destroy();
        }
    }
}
User avatar
Dan_The_Noob
Posts: 755
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Make InverseMap fade back to normal slowly?

Post by Dan_The_Noob »

Player701 wrote: Mon Dec 26, 2022 12:13 am
Dan_The_Noob wrote: Sun Dec 25, 2022 6:33 pm Is it possible to have the InverseMap (Invuln Sphere effect) fade slowly back to normal rather than flashing off and on?
I'm trying to use it for a flashbang style effect.
As far as I know, InverseMap is a special effect applied in hardware rendering via shaders. I haven't worked with them myself, so I cannot be specific here, but as far as I know, you can create and apply custom shaders in your mods. But I'm not sure if they can be controlled from script code like you want it to. And it won't work with software rendering at all, which may or may not be a problem for you.
Dan_The_Noob wrote: Sun Dec 25, 2022 6:33 pm another option, is there a way to make the screen 95% bright white as a colormap? whenever i try, it just gives basically a LightAmp effect instead of being white.
Yes, there is. Example for powerup items:

Code: Select all

Powerup.Color "ff ff ff", 0.95;
This can also be controlled via GetBlend, if you want the effect to fade with time. For example, when the player receives the following inventory item, their screen will instantly turn almost completely white, then slowly fade to normal over 2 seconds:

Code: Select all

class TestInv : Inventory
{
    const LIFETIME = 70; // 2 seconds

    override color GetBlend()
    {
        double alpha = 0.95*(1-(double(GetAge())/LIFETIME));
        return Color(int(alpha*255), 255, 255, 255);
    }

    override void Tick()
    {
        Super.Tick();

        if (GetAge() >= LIFETIME)
        {
            Destroy();
        }
    }
}
ohhh all very useful, cheers!

Return to “Scripting”