I'm fighting somewhat with Blenders image creation module. I struggle to map my calculated colors to the required range from 0.0 to 1.0. I need it to be very precise.

For example: I have a value 0.5 that will result in a value of 128 in the related color channel of the image. Then I have a value of 0.50390625 that I expected to result in 129, but becomes a 128 as well. Is there a formula or a list somewhere that shows exactly what ranges of floats are mapped to what integers? Or maybe someone can point me to the source-files, then I'd try to figure it out by myself. (I tried to locate the source file for this module but couldnt find it.)

  • $\begingroup$ Hi. How are you setting the colours? With code (if so, then please show the code) or via the UI? $\endgroup$ Jan 4, 2019 at 16:59
  • $\begingroup$ Hello Ray, I'm tryin to export simple 3d-models into a texture. The xyz coords of the vertices will become the rbg values of the textures (this format is used in some virtual worlds). For example a value for a color channel is calulated like this: tmpx = (vert.co.x + (boundingBoxSize/2) - xrange) / boundingBoxSizeX $\endgroup$
    – 32Smooth
    Jan 4, 2019 at 17:08
  • $\begingroup$ If that code is relevant to your question I suggesting adding that in. $\endgroup$ Jan 4, 2019 at 17:12
  • $\begingroup$ its not relevant, since I would like to know how the Blenders image module turns floats into integers :) $\endgroup$
    – 32Smooth
    Jan 4, 2019 at 17:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.