Changing skybox + transition

Hi everyone, i’m trying to make a skybox with a transition effect, from day to night

So far i’m only drawing one of the faces of the altered skybox

here is my script

local MATERIAL = {
Material( "skybox/sky_borealis01ft" ),
hook.Add( "PostDraw2DSkyBox", "skybox", function()
    render.OverrideDepthEnable( true, false )
    render.SetLightingMode( 2 )
    cam.Start3D( Vector( 0, 0, 0 ), EyeAngles() )
	render.SetMaterial( MATERIAL[2] )
	render.DrawQuadEasy( Vector( 200,0,0 ), Vector( -1,0,0 ), 400,400, Color( 55,55,55,255), 180 )
	render.SetMaterial( MATERIAL[1] )
	render.DrawQuadEasy( Vector( 200,0,0 ), Vector( -1,0,0 ), 400,400, Color( 255,255,255,40), 180 )
    render.OverrideDepthEnable( false, false )
    render.SetLightingMode( 0 )
end )

Anyway, right now i’m drawing one quad ontop of another, and attempting to change the alpha so it’s only partially visible over it (and later on i’ll make it transition smoothely)

is there some function or something i’m missing that allows you to change the alpha when drawing?

i’ve also tried it with drawbox, tried setblend, additionally, the color argument of drawquadeasy appears to do nothing, i can’t make it draw red or green or anything by changing it

any ideas?

You could game.ConsoleCommand("sv_skyname painted
"); and Lerp the colors between 4 modes of day… Dawn, Day, Dusk, Night… You can even render other things in the sky.

I’ve read about this when i was looking up my options, but none of the commands suggested seemed to do anything at all, i was thinking of spawning one of those entities from sandbox somewhere, and controlling that via lua (since i’ve read that it’s an engine entity and i cant do it directly)

edit: oh i get how you mean now, it has to be run when the server is set up, not in realtime, how do you manipulate the painted skybox? do i have to spawn an env_skybox or something and modify that somehow?

It needs to be done before anyone joins the server, so on startup essentially… Then spawn env_skypaint

Then, you just :Fire the different options, however it should have functions tied to it now… Here, this lists them:

Yeah i’ve figured it out now, it’s unfortunate that i can’t use the textures though, i would have liked to have some character in the skybox rather than a smooth gradient without clouds

if anyone who comes after knows how to draw the stuff with opacity that i mentioned in the first post, please post a response

You can still use textures… Overlay them in the sky with some transparency…

Take a look at this:

Instead of ! drawing in skybox, allow it to draw in skybox… Then you can render anything you want up there… If you want 2 moons with them orbiting around each other, you can do it…

If I recall correctly you can change it whenever but any clients that were already on the server during the change will need to rejoin. Not sure if a render.RedownloadAllLightmaps will have the same effect, doubt it but maybe. No reason not to do it on startup though.

If you set the skypaint to painted on Initialize, it’ll work, even through restart… Here’s how mine initializes:

Super old code; I am going to turn it into a metatable object with a ton of features and release it most likely.

if ( !ENV_SKYPAINT ) then 
	ENV_SKYPAINT.daynightbrush = NULL; = NULL;
	ENV_SKYPAINT.dust_clouds = { }
	-- ENV_SKYPAINT.day_night_fog = NULL;
	-- ENV_SKYPAINT.weather_fog = NULL;
	ENV_SKYPAINT.light_env = NULL;
	ENV_SKYPAINT.light_envs = { };
	ENV_SKYPAINT.light_string = "z";
	ENV_SKYPAINT.last_light_string = "z";
	ENV_SKYPAINT.last_sky_state_change = 0;

function GM:InitializeDayNight( )
	if ( == NULL ) then = CreateEntity('env_skypaint'); ); );
		game.GetWorld( ):SetFlag( "env_skypaint", ) );
		-- print( "SKYPAINT SPAWNED" )

hook.Add( "InitPostEntity", "day_night:InitPostEntity", function( )
	game.ConsoleCommand("sv_skyname painted
	GAMEMODE:InitializeDayNight( )
end );

But, it grabs everything and initializes if need be… If there aren’t light environments then render.RedownloadAllLightmaps will be needed; if light envs are in the map like evocity v33x, you do not need to call it. I found a great way to produce a believable night-time using black fog at 0.9 to 0.99 density.

Since you Fire the data serverside, clients that join will see it as everyone else. The only difference is the render.Redownload function and not having a light env. I tell anyone that asks, don’t use render.Redownload AT ALL; just use the fog for it, because otherwise models will be black / dark for those people that joined at nighttime when the server is in daytime, and those that joined during day will have bright models ( unless you use the fog )