mrdoob/texgen.js

Changing tint input to be 0-255 instead of 0-1

zoalst opened this issue · 6 comments

Do you think using 0-255 values for the tint parameters would be better? I've found myself always using the 256 rgb value / 255. It could either replace 0-1 entirely, or it could work without changing the current functionality by assuming any input above 1 is a 256 rgb value, although this would make 1 & 255 equivalent inputs. I am willing to code this change.

I don't see why 0-255 to 0-1 would be better...

I feel like it's more readable/user-friendly. It would eliminate the repetition of always dividing by 255. Most color picking websites only provide hex and 0-255 values.

0-255 gives us only 256 values. 0-1 gives us many more. Also, we currently use canvas2d, but we could eventually move to WebGL were colors go from 0 to 1.

@zacharystenger, you could also put this at the end, which divides the value of every pixel by 255:

.div(new TG.Number().tint(255, 255, 255))

The only drawback would be that you'd have to make sure that everything else is in the 0 - 255 range too.

I agree that it's better to keep using float instead of byte. As @mrdoob pointed, when moving from canvas2d to webgl shaders it will be direct conversion. Also using floats you have more resolution per pixel and you avoid errors while rounding values after concatenate several operations.

Cool, thanks for the input & feedback