fix(rendering): changed the way faces are determined
This commit is contained in:
parent
c944c0cb09
commit
b8c4d130d4
2 changed files with 979 additions and 966 deletions
|
@ -9,6 +9,7 @@ const int FaceBack = 2;
|
||||||
const int FaceLeft = 3;
|
const int FaceLeft = 3;
|
||||||
const int FaceBottom = 4;
|
const int FaceBottom = 4;
|
||||||
const int FaceFront = 5;
|
const int FaceFront = 5;
|
||||||
|
const int FaceNone = 6;
|
||||||
|
|
||||||
const int SurfaceSmooth = 0;
|
const int SurfaceSmooth = 0;
|
||||||
const int SurfaceGlue = 1;
|
const int SurfaceGlue = 1;
|
||||||
|
@ -31,6 +32,8 @@ uniform mat4 projection;
|
||||||
uniform int surfaces[6];
|
uniform int surfaces[6];
|
||||||
uniform vec3 texScale;
|
uniform vec3 texScale;
|
||||||
|
|
||||||
|
const float faceThreshold = sqrt(2)/2;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
||||||
|
@ -38,12 +41,20 @@ void main()
|
||||||
lPos = aPos;
|
lPos = aPos;
|
||||||
vNormal = normalMatrix * aNormal;
|
vNormal = normalMatrix * aNormal;
|
||||||
lNormal = aNormal;
|
lNormal = aNormal;
|
||||||
int vFace = aNormal == vec3(0,1,0) ? FaceTop :
|
int vFace = FaceNone;
|
||||||
aNormal == vec3(0, -1, 0) ? FaceBottom :
|
|
||||||
aNormal == vec3(1, 0, 0) ? FaceRight :
|
if (dot(vec3(0, 1, 0), aNormal) > faceThreshold)
|
||||||
aNormal == vec3(-1, 0, 0) ? FaceLeft :
|
vFace = FaceTop;
|
||||||
aNormal == vec3(0, 0, -1) ? FaceFront :
|
else if (dot(vec3(0, -1, 0), aNormal) > faceThreshold)
|
||||||
aNormal == vec3(0, 0, 1) ? FaceBack : -1;
|
vFace = FaceBottom;
|
||||||
|
else if (dot(vec3(1, 0, 0), aNormal) > faceThreshold)
|
||||||
|
vFace = FaceRight;
|
||||||
|
else if (dot(vec3(-1, 0, 0), aNormal) > faceThreshold)
|
||||||
|
vFace = FaceLeft;
|
||||||
|
else if (dot(vec3(0, 0, -1), aNormal) > faceThreshold)
|
||||||
|
vFace = FaceFront;
|
||||||
|
else if (dot(vec3(0, 0, 1), aNormal) > faceThreshold)
|
||||||
|
vFace = FaceBack;
|
||||||
|
|
||||||
vSurfaceZ = surfaces[vFace];
|
vSurfaceZ = surfaces[vFace];
|
||||||
if (surfaces[vFace] > SurfaceUniversal) vSurfaceZ = 0;
|
if (surfaces[vFace] > SurfaceUniversal) vSurfaceZ = 0;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue