• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] SetDayNightModels and fade filters

Status
Not open for further replies.
Level 5
Joined
Jan 18, 2012
Messages
92
Is there some sort of incompatibility issue when trying to use SetDayNightModels("", "") and then using fade filter?. I want to make really dark nights, but want to smooth out transition between day and night using a fade filter. However, the CineFadefilterBJ doesn't seem to do anything so the switch is very sudden.
 
Level 11
Joined
May 16, 2016
Messages
730
Is there some sort of incompatibility issue when trying to use SetDayNightModels("", "") and then using fade filter?. I want to make really dark nights, but want to smooth out transition between day and night using a fade filter. However, the CineFadefilterBJ doesn't seem to do anything so the switch is very sudden.
You need Real Variable, you should use periodic event which changes filter paramateres depending on Real and day time.
 
Level 5
Joined
Jan 18, 2012
Messages
92
Thanks for the quick response, I'll try to do it once I get home.

EDIT:

I forgot to update the post seeing as I've managed to solve the problem.

Here's the code, tough it does depend on some other stuff in my map, maybe someone will find it useful:

JASS:
//! zinc

library ObDayCycle requires Object
{
    public struct ObDayCycle extends Object
    {
        private static constant real transSteps           = 24;
        private static constant real timeDay              = 5.90;
        private static constant real timeNight            = 17.90;
       
        private boolean inTransition;
        private real transCurrent;
       
        private boolean isNight;
       
        static method create() -> thistype
        {
            thistype this = thistype.allocate();

            this.inTransition = false;
            this.transCurrent = 0;
            this.isNight = true;
           
            return this;
        }
       
        method isDay() -> boolean
        {
            return !this.isNight;
        }
       
        private method translate()
        {
            real percent;
           
            if (this.transCurrent < thistype.transSteps / 2)
                percent = (1 - (this.transCurrent / thistype.transSteps)) * 100;
            else
                percent = (this.transCurrent / thistype.transSteps) * 100;
               
            if (this.transCurrent == thistype.transSteps / 2)
            {
                if (this.isNight)
                    SetDayNightModels(gl_str_empty, gl_str_empty);
                else
                    SetDayNightModels(gl_tex_dn_terrain, gl_tex_dn_units);
            }
           
            CinematicFilterGenericBJ
            (
                0.1, BLEND_MODE_BLEND, gl_tex_black_mask,
                0, 0, 0, percent,
                0, 0, 0, percent
            );
           
            this.transCurrent += 1;
           
            if (this.transCurrent > thistype.transSteps)
            {
                this.transCurrent = 0;
                this.inTransition = false;
            }
        }
       
        method onAdd()
        {
           
        }
       
        method update()
        {
            real time = GetFloatGameState(GAME_STATE_TIME_OF_DAY);
           
            if (this.inTransition)
            {
                this.translate();
                return;
            }
           
            if (time > thistype.timeDay && time < thistype.timeNight && this.isNight)
            {
                this.inTransition = true;
                this.isNight = false;
            }
            else if (time > thistype.timeNight && !this.isNight)
            {
                this.inTransition = true;
                this.isNight = true;
            }
        }
    }
}

//! endzinc
 
Last edited:
Status
Not open for further replies.
Top