Add normal maps to the floor

This commit is contained in:
2023-03-17 16:51:02 +00:00
parent 6425ef3f0a
commit 850fdf1783
16 changed files with 52 additions and 55 deletions
+5 -2
View File
@@ -11,8 +11,11 @@ void main() {
vec3 distVec = pos - lightPos;
vec4 normbit = texture(normals, vTexPos);
vec3 norm = normbit.xyz - pos;
float y1 = float(normbit.w == 0 ? 1 : dot(normalize(norm), normalize(distVec)));
float y = float(y1 > 0 ? 1 : 0);
float y1 = dot(normalize(norm), normalize(distVec));
float y2 = float(y1 > 0 ? 1 : 0);
//float y = y2;
float y3 = clamp(0.5 * (y1 + 1),0,1) ;
float y = float(normbit.w == 0 ? y2 : y2);
float dist = dot(distVec, distVec);
if (dist > rad) {
discard;
+6 -4
View File
@@ -4,11 +4,13 @@ in vec3 vPos;
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
layout (location=2) out vec4 normal;
uniform sampler2DArray tilesetSampler;
layout (binding=0) uniform sampler2DArray tilesetSampler;
layout (binding=1) uniform sampler2D normalSampler;
void main()
{
fCol = texture(tilesetSampler, vTexPos);
//fCol = texture(tilesetSampler, vec3(0.3,0.1,0) + vTexPos);
fCol = vec4(0.2,0.3,0.6,1);
//fCol = vec4(0.6,0.4,0.3,1);
fPos = vec4(vPos,1);
//normal = vec4(vPos.xy,vPos.z-1,1);
normal = vec4(vPos.xy,vPos.z-1,1);
normal = vec4(vPos + vec3(0.5) - texture(normalSampler,2*vTexPos.xy).xyz,0);
}
+1 -1
View File
@@ -17,7 +17,7 @@ void main()
vec4 p3 = vec4 (p1.xy,100,1);
vec4 p4 = vec4 (p2.xy,100,1);
vec2 d = vec2(p1.xy - p2.xy);
vec4 norm = vec4( d.y, -d.x, 0, 1);
vec4 norm = vec4( d.y, -d.x, 0, 0);
gNorm = p1 - norm;
gPos = p1; tPos = vec2 ( 1,-1) ; gl_Position = vec4(theMat * p1); EmitVertex();
gNorm = p1 - norm;