Created
January 14, 2014 05:58
-
-
Save greggman/8413752 to your computer and use it in GitHub Desktop.
Compute the z buffer representations for a particular bit depth. Meant to be pasted into JavaScript console.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res = 24; near = 0.1; far = 3500000; end = 1 << res; rangeInv = 1.0 / (near - far); j = []; last = 0; for(i = end - 16; i < end; ++i) {cz = i; cz = cz * 2.0 / (end - 1) - 1; z = near*far*rangeInv*2/(cz+(near+far)*rangeInv); j.push(" " + i + " = " + z.toFixed(3) + (last == 0 ? "" : (" range: " + (z - last).toFixed(3)))); last = z; }; console.log(j.join("\n") + "\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment