Updated Shader to reduce math operations and branching