16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-09-01 18:39: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

@@ -35,7 +35,8 @@ uniform sampler2DShadow shadowmap;
uniform samplerCube envmap;
#endif
#define NORMALMAP
vec3 normal_p;
#define PARALLAX
#include <light_common.glsl>
#include <tonemapping.glsl>
@@ -51,8 +52,11 @@ void main()
if (tex_color.a < opacity)
discard;
vec3 normal = normalize(f_tbn * normalize(texture(normalmap, f_coord_p).rgb * 2.0 - 1.0));
vec3 refvec = reflect(f_pos.xyz, normal);
vec3 normal = f_normal;
normal.xy = (texture(normalmap, f_coord_p).rg * 2.0 - 1.0);
normal.z = sqrt(1 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
normal_p = normalize(f_tbn * normalize(normal.xyz));
vec3 refvec = reflect(f_pos.xyz, normal_p);
#if ENVMAP_ENABLED
vec3 envcolor = texture(envmap, refvec).rgb;
#else