1
SFML projects / Re: Let There Be Light 2
« on: March 17, 2020, 11:31:27 am »
As I said, there it is:
Shader to add global directional lighting, every pixel is lit from given direction vector without cosidering the distance (slightly modified version of the one included in the library, I only use it to draw light with additive blending):
Also, I needed a shader to correct rotated normal maps of the sprites so there it is:
As you can see, it uses vertex color channels to represent rotation and flipping, so you dont have to set any uniforms while drawing - useful for collective VertexArrays
Red color - if lower than 1.0 (or 255 in sf::Color) flips the normal map horizontally
Green color - if lower than 1.0 (or 255 in sf::Color) flips the normal map vertically
Blue color - is angle in radians divided by Tau (2 * Pi)
Simply use it to draw normal maps
Shader to add global directional lighting, every pixel is lit from given direction vector without cosidering the distance (slightly modified version of the one included in the library, I only use it to draw light with additive blending):
(click to show/hide)
Also, I needed a shader to correct rotated normal maps of the sprites so there it is:
(click to show/hide)
As you can see, it uses vertex color channels to represent rotation and flipping, so you dont have to set any uniforms while drawing - useful for collective VertexArrays
Red color - if lower than 1.0 (or 255 in sf::Color) flips the normal map horizontally
Green color - if lower than 1.0 (or 255 in sf::Color) flips the normal map vertically
Blue color - is angle in radians divided by Tau (2 * Pi)
Simply use it to draw normal maps