Improve normal maps on ground and walls

This commit is contained in:
2023-03-19 23:52:19 +00:00
parent e90989ee2d
commit 33f31aa385
24 changed files with 112 additions and 178 deletions
+14 -3
View File
@@ -3,13 +3,24 @@ layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
layout (location=2) out vec4 fNorm;
in vec2 tPos;
in vec3 gTexCoords;
in vec4 gPos;
in vec4 gNorm;
in vec4 gColor;
uniform sampler2D tex;
in float gRot;
layout (binding=1) uniform sampler2DArray normalSampler;
layout (binding=2) uniform sampler2DArray diffuseSampler;
vec2 rotateV2 (float a, vec2 v)
{
return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a));
}
void main()
{
fCol = gColor * texture(tex,tPos);
//fCol = gColor * texture(tex,tPos);
fCol = texture(diffuseSampler,gTexCoords);
fPos = gPos;
fNorm = gNorm;
vec4 basenorm = texture(normalSampler,gTexCoords) - 0.5;
//fNorm = fPos - vec4(rotateV2(gRot,basenorm.xz), basenorm.y,0);
vec2 n = rotateV2(gRot,vec2(-basenorm.x,-basenorm.z));
fNorm = vec4(fPos.xyz - vec3(n,basenorm.y),0);
}