Skip to content

Commit

Permalink
Fix geometry clipping problem for GL ES.
Browse files Browse the repository at this point in the history
NoN - no near clipping.
GL ES does not support z-clipping disabling, so harmless hack used here.
Harmlessness condition: z value is not used by pixel pipeline.
gDP.otherMode.depthCompare == 0 && gDP.otherMode.depthUpdate == 0 - z not used for depth compare/update.
Thus we can set vertex z to any value, which will ensure that z/w is in range [-1, 1], e.g. to zero.

Fixed issue #588
  • Loading branch information
gonetz committed Jul 3, 2015
1 parent c50b3c8 commit d881701
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/OpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ void OGLRender::addTriangle(int _v0, int _v1, int _v2)
vtx.z = gDP.primDepth.z * vtx.w;
}
}

#ifdef GLESX
if (GBI.isNoN() && gDP.otherMode.depthCompare == 0 && gDP.otherMode.depthUpdate == 0) {
for (u32 i = triangles.num - 3; i < triangles.num; ++i) {
SPVertex & vtx = triangles.vertices[triangles.elements[i]];
vtx.z = 0.0f;
}
}
#endif
}

void OGLRender::_setBlendMode() const
Expand Down

0 comments on commit d881701

Please sign in to comment.