Directional Lighting

Directional Lighting

Postby w_laenger » 09 Feb 2019, 16:44

I noticed that in New Super Mario Bros Wii (and DS), the characters are shaded differently in some levels.
In the castle, it looks like light comes from the bottom (see the toad's chin):
Image
For comparison, another level (see the yellow toad):
Image

I think that something like this could be added to supertux, too.
The current lighting could be called Ambient Light and the directional light can be denoted as Directional Light.
For each level, the ratio between Ambient and Directional Light can be set, e.g. low Directional Light in foggy levels. The sun light vector is another additional setting which is used for the Directional Light.
To calculate the Directional Light, for each texture (also tiles, not only Tux and enemies) a normalmap defines the normal vectors. If the normalmap is missing, the texture is simply assumed to be flat. Since supertux is 2D, light sources (e.g. a lamp) are modelled approximately as a stripe which goes in -z direction. When calculating the Directional Light for a pixel, the minimum angle between the normal (from the normalmap) and a vector to the light source (which directs to the stripe) is used. (directional light similar to Gouraud shading)
Much of the lighting does not need to be calculated dynamically in every frame; for non-moving light sources, it can be calculated when loading the level or combining the tiles. Directional Light for moving light sources can be disabled so that light calculation is not needed for every frame (for performance).
Image

Many current textures are already lighted directionally (with fixed direction), so when enabling Directional Light, different ones need to be used.
Image
Attachments
fixed_texture.png
persp.jpg
w_laenger
 
Posts: 33
Joined: 20 Sep 2018, 15:58

Re: Directional Lighting

Postby Oliver_Buo » 10 Feb 2019, 13:23

supter tux is not super mario......maybe u at the wrong place here !?
User avatar
Oliver_Buo
 
Posts: 286
Joined: 27 Nov 2016, 17:51

Re: Directional Lighting

Postby WeLuvGoatz » 10 Feb 2019, 19:34

Oliver_Buo {l Wrote}:supter tux is not super mario......maybe u at the wrong place here !?


Lol :D :D

But this is an interesting idea.
No.
User avatar
WeLuvGoatz
SuperTux Moderator
 
Posts: 232
Joined: 23 May 2018, 19:15

Re: Directional Lighting

Postby Alzter » 11 Feb 2019, 00:34

So what you're saying is we get 3D lighting for the game so we can light anything from whatever direction with any colour? The only way I can see that working is if we made every art asset in the game shadeless and then gave them a bump map to represent where light would hit them, like the enemies in Super Mario Maker (NSMBU) for example. That sounds really cool in theory but way to hard to make in practice. It would be cool though.
User avatar
Alzter
 
Posts: 330
Joined: 01 Apr 2016, 10:18

Re: Directional Lighting

Postby ProTux » 11 Feb 2019, 03:30

Can the team make a supertux 3d option in the menu?
im back
ProTux
 
Posts: 115
Joined: 04 Nov 2018, 15:27
Location: the world

Re: Directional Lighting

Postby w_laenger » 11 Feb 2019, 11:46

Alzter {l Wrote}:So what you're saying is we get 3D lighting for the game so we can light anything from whatever direction with any colour? The only way I can see that working is if we made every art asset in the game shadeless and then gave them a bump map to represent where light would hit them, like the enemies in Super Mario Maker (NSMBU) for example. That sounds really cool in theory but way to hard to make in practice. It would be cool though.


I'd like to have it combined with the current 2d lighting, which suits better for foggy/cloudy levels.
Making every art asset shadeless at once is too much work and may cause compatibility problems. The Directional Light feature could be made an optional setting. If it's disabled, the current shaded textures are used, and if it is enabled, either shadeless textures with their normalmap or a simple copy-paste duplicate of the shaded texture with flat normalmap is used.
In time, the duplicates can be changed to be shadeless and have a normalmap. By still using the shaded textures, it's possible to add and test a new texture before creating the normalmap, and it shouldn't be hard to implement in practice I think.
w_laenger
 
Posts: 33
Joined: 20 Sep 2018, 15:58

Re: Directional Lighting

Postby ProTux » 16 Feb 2019, 01:16

there should be a 3d supertux settings option.
im back
ProTux
 
Posts: 115
Joined: 04 Nov 2018, 15:27
Location: the world

Re: Directional Lighting

Postby w_laenger » 16 Feb 2019, 15:53

ProTux {l Wrote}:there should be a 3d supertux settings option.

Do you mean a setting to enable Directional Lighting?
w_laenger
 
Posts: 33
Joined: 20 Sep 2018, 15:58

Re: Directional Lighting

Postby ProTux » 16 Feb 2019, 19:20

yes and making supertux 3d and putting an option to where it is 3D.
im back
ProTux
 
Posts: 115
Joined: 04 Nov 2018, 15:27
Location: the world

Re: Directional Lighting

Postby Alzter » 08 Mar 2019, 00:07

ProTux {l Wrote}:yes and making supertux 3d and putting an option to where it is 3D.

I'll have 10000 more worlds, 50 more characters, a VR mode, ten sequels, and a large soda.
User avatar
Alzter
 
Posts: 330
Joined: 01 Apr 2016, 10:18

Re: Directional Lighting

Postby manuel » 08 Mar 2019, 10:18

ProTux {l Wrote}:yes and making supertux 3d and putting an option to where it is 3D.


ST in 3D would be a completely new game and cannot be done with the current engine. With good textures a 2.5D game like the new Donkey Kong games might be possible but not more.
manuel
 
Posts: 190
Joined: 19 Sep 2017, 09:03

Re: Directional Lighting

Postby w_laenger » 29 Aug 2019, 08:18

I think this can be done in SuperTux (except that the walls are not slant).
Image
w_laenger
 
Posts: 33
Joined: 20 Sep 2018, 15:58

Re: Directional Lighting

Postby drummyfish » 30 Aug 2019, 00:02

It definitely could if the engine allows you to write shaders (which I suppose it does if it's based on OpenGL). Best way to prove your point is to do a mockup/prove of concept.
socialist anarcho-pacifist
Abolish all IP laws. Use CC0. Let's write less retarded software.
http://www.tastyfish.cz
User avatar
drummyfish
 
Posts: 448
Joined: 29 Jul 2018, 20:30
Location: Moravia

Re: Directional Lighting

Postby Alzter » 03 Sep 2019, 06:45

Godot has normal maps, although adding a normal map to everything seems like too much effort.
User avatar
Alzter
 
Posts: 330
Joined: 01 Apr 2016, 10:18

Re: Directional Lighting

Postby w_laenger » 22 Feb 2020, 14:02

Alzter {l Wrote}:Godot has normal maps, although adding a normal map to everything seems like too much effort.


I think we don't need a normal map for everything; we can simply use a flat dummy normalmap for textures whose normalmap is not (yet) available.

drummyfish {l Wrote}:It definitely could if the engine allows you to write shaders (which I suppose it does if it's based on OpenGL). Best way to prove your point is to do a mockup/prove of concept.


SuperTux already has shaders. The game is horribly slow in my opinion; so I'm not going to implement a POC of this or any other fancy graphics feature as long as the game takes so much GPU and CPU.

The demonstration video of https://azagaya.itch.io/laigter shows how a skull can be lighted by a moving flame when there is a normalmap:
https://www.youtube.com/watch?v=ZJRqupAr9kY&t=39
In SuperTux, for one flame (or another light source) I'd use two point light sources in the calculation: one at height zero and one at the height which is half of the tile width.

manuel {l Wrote}:
ProTux {l Wrote}:yes and making supertux 3d and putting an option to where it is 3D.


ST in 3D would be a completely new game and cannot be done with the current engine. With good textures a 2.5D game like the new Donkey Kong games might be possible but not more.


I would add bumpmapping but not parallax occlusion or other 3D surface methods because in my opinion it is difficult and annoying to think about the collision boxes during playing when stuff is drawn in 3D in a 2D game.
w_laenger
 
Posts: 33
Joined: 20 Sep 2018, 15:58

Who is online

Users browsing this forum: Marinaois and 1 guest