• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Dynamic lighting on sprite

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Spritelamp and similar projects are based on shaders, therefore you would either have to find a thing of this kind that already supports GMS, or hire someone to port it for you.
 

GMWolf

aka fel666
Looks like some normal mapping, and some form of shadow casting (not too sure what model).

As always with these questions: yes, its possible. There is no reason for an effect you see in a game not to be attainable in GM. (Outside things using geometry shaders).
GM allows for fragments shaders (as well as vertex shaders) which is what you need for both those effects.

Normal mapping should be pretty easy so do once you learn some vector maths and GLSL. I recommend you learn then both.
The shadows are probably anpittle harder to do.

As @YellowAfterlife said, you can always get someone else to write these things for you, but be prepared to have to hire someone, as something like this doesn't tend to be something people will just do for free.

Good luck :)
 

kupo15

Member
I'm not even sure that's normal mapped.
Sorry for bringing this thread back up but what do you think it is if it isn't normal mapped? I was planning on bring up a thread about how to something like this without normal maps and thought building on this thread was a better idea.
 

Xor

@XorDev
Sorry for bringing this thread back up but what do you think it is if it isn't normal mapped? I was planning on bring up a thread about how to something like this without normal maps and thought building on this thread was a better idea.
Well normal mapping is all about directional lighting, but if you look at the GIF it appears to be flat. There's no lighting along the edges for example. Instead the whole sprite has one normal unlike a normal mapped texture. This means that there's only light attenuation, flat lighting and shadows.
 

GMWolf

aka fel666
Well normal mapping is all about directional lighting, but if you look at the GIF it appears to be flat. There's no lighting along the edges for example. Instead the whole sprite has one normal unlike a normal mapped texture. This means that there's only light attenuation, flat lighting and shadows.
Hmm, isnt there a slight directional effect on the characters?
 
  • Like
Reactions: Xor

Xor

@XorDev
Hmm, isnt there a slight directional effect on the characters?
Yes, but it appears to be flat and textureless. If it were a normal map it would have different lighting brightness depending on the pixel and the light angle. It looks to me like this isn't the case.
 

kupo15

Member
Yes, but it appears to be flat and textureless. If it were a normal map it would have different lighting brightness depending on the pixel and the light angle. It looks to me like this isn't the case.
And textureless? So that means its all shader based or doesn't use any additional mapping texture that is identical to the sprites like normal maps do? So it doesn't even use anything with Sprite Lamp for example either? Or do you think it uses blending or surface techniques with a simple light texture projected or blended in some way?
 

Xor

@XorDev
And textureless? So that means its all shader based or doesn't use any additional mapping texture that is identical to the sprites like normal maps do? So it doesn't even use anything with Sprite Lamp for example either? Or do you think it uses blending or surface techniques with a simple light texture projected or blended in some way?
It looks like there are no normal maps and so no Sprite Lamp (that's what it is for). The shader would define a normal rather than sample a texture. Something like:
Code:
vec3 Normal = vec3(0,0,1);
It could even have a different shader for the floor because it doesn't really need any surface lighting.
I don't know what you mean about the blending. It would simple render the sprite with attenuation and Lambertian lighting as well as mapping a black version of the sprite with low alpha for the shadows.
 

kupo15

Member
The shader would define a normal rather than sample a texture. Something like
Ah I think I get it, thanks for clarifying that! So having the shader define a single normal would be similar if you used a flat, single shaded normal map? As in the normal map spits out the same value no matter where its sampled from? Just making the comparison as an example.

If so, can you dynamically change the vec3 Normal value to use a different value? I get that a shader alone can't produce different values for each pixel without a texture to sample, but if it can produce a single value for everything, surely you can at least have that value change on the fly to produce a different normal value and apply that to everything to make it the effect a little more convincing I would think.

I don't know what you mean about the blending.
I was referring to the simple flashlight effect you can do by using a gradient texture that represents the light and instead using a texture like that to project on top of the sprite. Would give it a flat spot light effect that somewhat simulates a normal map without the dynamicness or texture memory drain. I was curious if you thought maybe something like that was used in the gif since it seems like the whole sprite doesn't light up and darken uniformly to me
 
Last edited:
  • Like
Reactions: Xor

Xor

@XorDev
So having the shader define a single normal would be similar if you used a flat, single shaded normal map? As in the normal map spits out the same value no matter where its sampled from?
Exactly! Technically it not a normal map as that refers to the normal sprites/textures and not how the shader handles it. Many lighting systems use normals, but aren't normal mapping.
If so, can you dynamically change the vec3 Normal value to use a different value?
You could have it dynamic quite easily using a uniform. You only will need to change it if you want the sprite to face a different "3D" direction. For most sprites you'll probably want to keep it flat, but you could have the floor normal facing upwards some.
I was referring to the simple flashlight effect you can do by using a gradient texture that represents the light and instead using a texture like that to project on top of the sprite. Would give it a flat spot light effect that somewhat simulates a normal map without the dynamicness or texture memory drain. I was curious if you thought maybe something like that was used in the gif since it seems like the whole sprite doesn't light up and darken uniformly to me
I see. That's what I mean by attenuation (the light fade-off). You could do this as a texture (passed to the shader as a uniform sampler), but it's very easy to calculate yourself and you don't have to consider about resolution, interpolation or memory. So yes, the shader to have a radial attenuation calculation, but it's probably not a sprite.
 
Top