16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 03:29:19 +02:00

Cleanup of vertex shader by @tmj.

2-channel normalmaps with Z-component reconstruction.
Normal vectors passed from fragment shaders to lightning calculations.
This commit is contained in:
stele
2019-05-03 17:32:46 +02:00
parent 158ebb9c70
commit 410e1452f6
4 changed files with 30 additions and 12 deletions

View File

@@ -33,6 +33,8 @@ uniform sampler2DShadow shadowmap;
uniform samplerCube envmap;
#endif
vec3 normal;
#define NORMALMAP
#include <light_common.glsl>
#include <tonemapping.glsl>
@@ -44,7 +46,10 @@ void main()
if (tex_color.a < opacity)
discard;
vec3 normal = normalize(f_tbn * normalize(texture(normalmap, f_coord).rgb * 2.0 - 1.0));
normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0);
normal.z = sqrt(1 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
normal = normalize(f_tbn * normalize(normal.xyz));
//vec3 normal = normalize(f_tbn * normalize(texture(normalmap, f_coord).rgb * 2.0 - 1.0));
vec3 refvec = reflect(f_pos.xyz, normal);
#if ENVMAP_ENABLED
vec3 envcolor = texture(envmap, refvec).rgb;