Ensure your "Antialiasing" in video settings is turned off. OptiFine shaders handle their own antialiasing, and the two systems conflict on 1.12.2.
(Medium or High)