 <p>I think the problem is float precision.</p> <p>Basically you use a very big float (4 billion) in a division and expect a very small one (0-1) as a result. But the big float is so imprecise compared to the range (0-1) that the result you get is just noise. </p> <p>What you need to do is get those two ranges closer. You can either use a 16 bits int texture instead or you can divide the texture sample with an integer division before converting it to float (and then divide by a smaller float). </p>