- interpolate the normal for models

This commit is contained in:
Magnus Norddahl 2018-11-20 13:41:27 +01:00
parent 426ee2b78e
commit 216191c86d
2 changed files with 4 additions and 2 deletions

View file

@ -144,7 +144,8 @@ FModelVertexBuffer::FModelVertexBuffer(bool needindex, bool singleframe)
{ 0, VATTR_VERTEX, VFmt_Float3, (int)myoffsetof(FModelVertex, x) },
{ 0, VATTR_TEXCOORD, VFmt_Float2, (int)myoffsetof(FModelVertex, u) },
{ 0, VATTR_NORMAL, VFmt_Packed_A2R10G10B10, (int)myoffsetof(FModelVertex, packedNormal) },
{ 1, VATTR_VERTEX2, VFmt_Float3, (int)myoffsetof(FModelVertex, x) }
{ 1, VATTR_VERTEX2, VFmt_Float3, (int)myoffsetof(FModelVertex, x) },
{ 1, VATTR_NORMAL2, VFmt_Packed_A2R10G10B10, (int)myoffsetof(FModelVertex, packedNormal) }
};
mVertexBuffer->SetFormat(2, 4, sizeof(FModelVertex), format);
}

View file

@ -5,6 +5,7 @@ layout(location = 2) in vec4 aColor;
#ifndef SIMPLE // we do not need these for simple shaders
layout(location = 3) in vec4 aVertex2;
layout(location = 4) in vec4 aNormal;
layout(location = 5) in vec4 aNormal2;
out vec4 pixelpos;
out vec3 glowdist;
out vec3 gradientdist;
@ -62,7 +63,7 @@ void main()
gl_ClipDistance[4] = worldcoord.y - ((uSplitBottomPlane.w + uSplitBottomPlane.x * worldcoord.x + uSplitBottomPlane.y * worldcoord.z) * uSplitBottomPlane.z);
}
vWorldNormal = NormalModelMatrix * vec4(normalize(aNormal.xyz), 1.0);
vWorldNormal = NormalModelMatrix * vec4(normalize(mix(aNormal.xyz. aNormal2.xyz, uInterpolationFactor)), 1.0);
vEyeNormal = NormalViewMatrix * vWorldNormal;
#endif