Closed JohnBrookes closed 11 years ago
So... somewhere in ShaderPicker getApproximatePosition func (line 281) Theres some rounding happening.
Load up that example and pick the top of the small cube. The localPosition of the Y is retruned as 99.99999999999997 and not 100.
This means it fails the withinBounds check (line370 shaderPicker) and localhitNormals are not set.
Maybe ShaderPicker 310-312 change to _localHitPosition.x = Math.round((((col >> 16) & 0xff) / (scX * 255) - offsX) * 1000000) / 1000000; _localHitPosition.y = Math.round((((col >> 8) & 0xff) / (scY * 255) - offsY) * 1000000) / 1000000; _localHitPosition.z = Math.round(((col & 0xff) / (scZ * 255) - offsZ) * 1000000) / 1000000; Seems to work.
Just a classic floating point problem. The correct way is to fix the bound checks to use epsilon. Rounding is expensive and can even make things works with some values; you're just lucky with a magic 100 number ;)
fixed in 425fb0bdecaea56d7e892c8b55c50a432168bab1
Shader details for normals fail with shader picker on some faces.
Ive tried rolling back through dev branch commits and this issue seems to always have been so.
Test code https://gist.github.com/JohnBrookes/c3073e5434199ba691ac