GML MoonLighter Night Cycle (Tech Talk) (Help)

M

MirthCastle

Guest
Hey All,

I have been trying to recreate the MoonLighter night cycle in GMS - I think I am CLOSE - but not quite there... I'm missing something i can't put my finger on... My goal is to have a dynamic day-night cycle - where the nighttime ends up looking like Moonlighter.

Please See Moonlighter:
https://dl.dropboxusercontent.com/s/iea6qbtti4r5asb/SNAG_0000_1155.mp4

There is a few things happening in that scene -
#1 - The glowy multilayer lights - got-em - though my colors are off it seems
#2 - the "Inner glow" of the multilayer lights - dont-got-em (help)
#3 - Fireflies - don't-got-em (yet) - I think they really make the scene!
#4 - Nighttime ambient light - got-it - but not well (help)

Here is my scene:
https://dl.dropboxusercontent.com/s/7ogecvum4wnrch7/SNAG_0000_0001.mp4

I can't quite put my finger on it - Notice how mine has the blue - but it seems exactly like I just put a layer above the world colored blue with alpha lolol - ?
Q: What is happening in MoonLighter where theirs doesn't look like that???

One theory I have is they are using separate "nighttime" sprites that have the dark blue hue to them.

If they are - is there a way we can manipulate the scene to "recolor" all the sprites into a nighttime version? This would make it so there isn't a need for an overlay surface - then i could just add the lights to a layer above and call it woot!

If it HAS to be a different sprite - I would also like to be able to re-render all my sprites with the correct hue and save the sprite.. can you help me produce this with gamemaker to batch recolor?

Can you have a look at my shader and process and suggest improvements? I would like to get as close to the Moonlighter scene as possible? Help a brother out?

////Making the surface (I didn't stop here - this is where I have ended up - maybe I need a better blend-mode? Ive tried Subtracting, Max, Add - etc

/// @desc Make Surface
if ( surface_exists(skySurf) ) {
surface_set_target(skySurf);
draw_clear_alpha(c_black, 1);
with ( obj_light ) {
gpu_set_blendmode(bm_add);
draw_sprite_ext(spr_gradient3, -1, x, y, scale2, scale2, 0, c_white, 1);
draw_sprite_ext(spr_gradient3, -1, x, y, scale1, scale1, 0, c_white, 1);
gpu_set_blendmode(bm_normal);​
}
surface_reset_target();​
} else {
skySurf = surface_create(room_width,room_height);​
}


///Shader (here i'm just using the additive method for the surface, then setting alpha based on how white it ends up - I am also coloring the light and the world based on the white-to-black

//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 colour = texture2D( gm_BaseTexture, v_vTexcoord );

float total = ( colour.r + colour.g + colour.b ) / 3.0;
colour.r = mix(16.0 / 255.0, 224.0 / 255.0, total );
colour.g = mix(16.0 / 255.0, 128.0 / 255.0, total );
colour.b = mix(64.0 / 255.0, 0.0 / 255.0, total );​

colour.a = clamp(colour.a - total, 0.15, 0.7);
gl_FragColor = colour;​
}

For the lights - I am using a simple 35% grey circle to achieve the layers themselves
 
Last edited by a moderator:
M

Maokoor

Guest
Hi,

"If it HAS to be a different sprite - I would also like to be able to re-render all my sprites with the correct hue and save the sprite.. can you help me produce this with gamemaker to batch recolor?"

This is the way i do, because a global color change is not really satisfying to me. I use gimp2 (freeware). Generally, i use the temperature function to "blue" all pixel, and then i reduce brightness, and usualy i need to increase contrast too. And sometime, i finally choose brand new color for some details.

Why just not use a global color change ? because in real life, objects (or textures) don't all reflect night light the same way ! (think about the shore and the sea !)

Sorry i can't help you more for the moment !
 
M

MirthCastle

Guest
Thanks for your reply.

Do you think that is what they are doing in the video?
 
M

MirthCastle

Guest
Now that im delving into this stuff - im learning i've spent waaaaay too much time on the logic side and not the pretty side..

I did find an example of a hue shader on the marketplace - but it is for GMS1.4 - im not certain that some of those functions exist anymore.

Could you provide an example of how I would do a global color change? Or change the hue of all the sprites on the screen? This seems to be the consensus on how they are doing it in MoonLighter
 

Neptune

Member
Ita definitely a shader right? I dont think redrawing sprites is a good approach. You could make a shader that adjusts your RGBs based on time of day
 
M

MirthCastle

Guest
@Vether - Thank you for your reply - Are you saying I can use a shader to change the RGB of all the sprites on screen? Or continue using a surface that changes colour?

If we're talking about the same thing - I think I did try something like that - the issue fell with handling the lights - if I change all the colours - how to specify with the shader NOT to change the colours off all the sprites under the lights?? I was able to change all the colours (very very poorly) but the lights changed too. I tried separate layers, but I still couldn't figure out how to keep things "lit" in that scenario.

I say I think - because I am absolutely certain that I didn't do it correctly. Can you help with an example?
 

Neptune

Member
Ah so youre saying certain sprites arent restored to their normal colors when under 100% light opacity?

Yeah itd be hard to do that sprite to sprite. But you could setup conditionals in the shader to only restore certain colors (by certain percents?).

So restore red and green completely but only restore blue to a max of 70% or something.

Thats my only idea, otherwise redrawing sprites maybe xD
 

Neptune

Member
I might not be describing what im meaning correctly. Ill be busy most of the day, but later ill send a screenshot of my system, and you can be the judge if its what youre looking for.
 
M

MirthCastle

Guest
WOAH! You know how many searches that DID NOT bring this up for me.. gonna watch all of them!
 

Joe Ellis

Member
The torches on moonlighter are moving\scaling exponentially, yours are more linear,
The torches on moonlighter look like theyre breathing and have more presence
You need to look into exponential or non-linear blending techniques,

The simplest way I can think of is by treating the scale the same as an object's vertical speed with gravity, each step it adds speed until it hits the floor, but with the glow scale you'd also need to add gradual slowing rather than instant stop,

Another way I know of is by each step multiplying by 1.1 (or other small value slightly above 1)

The non-linear merging in moonlighter definitely makes a difference, its the first thing I noticed
 
M

MirthCastle

Guest
@Joe Ellis - Roger that.. ill look into it.

See, this is why we have these conversations! Thanks for your observation! :)


EDIT: @Joe Ellis - Yeah - If i'm listening (reading) what you are saying correctly - What I see is the torches in ML sorta speed up as they get bigger, then reach an apex and drop out quickly - where mine are slowly growing and shrinking?

I agree the ML ones look better. I'm gonna update (i'm using a sin-wave) the math to do that better.
 
Last edited by a moderator:

Joe Ellis

Member
Hahaha, thats funny cus they say you should look at the "bigger picture", but with pretty much any production, game, film, you have to do both, well I guess they have minions working on the small details while the producers look at the big picture, but if your a single person unit kind of thing (indie) you have to learn to look at it from many angles
 
M

MirthCastle

Guest
@Joe Ellis - Hey sorry went MIA - Had some family issues -

I am making a role playing, real time strategy-esq, turn based combat, adventure game :) Sorta like Fallout 1 and 2

@The Reverend - I have gone over your tutorial a few times and I still can't seem to get all the pieces together - what I have figured out that I think I need - is some kind of mask over the top of the coloring of the world (over the application surface)
If I had a mask - I could tell it to NOT color anything where the lights and fireflies would be - but I don't have a clue how to make that happen yet.. I think I need another surface that I can place over the application surface - the new surface would contain only alpha values I use to tell the color-izer (official term) - if I can figure out this mask - then I can use RGB values too - to add stuff like clouds?

so even if it is an alpha of 0 is some places on the mask, there are still colour values I can ride to darken areas a little further and make it look like a cloud is overhead blocking the moon.
 
Yes, you could create a mask but it gets more complicated then.
I havent done it yet because i want to learn more about normals and shadows first though.

The video is part of a series intended to teach shaders step by step.
The videos from lesson 17a forward teach using additional textures, multiple render targets (in case you only target windows and ubuntu) and masks. Its a different kind of mask but shows what you need.
 
Top