Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/divers.c
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| return unit_float_to_uchar_clamp(value); | return unit_float_to_uchar_clamp(value); | ||||
| } | } | ||||
| MINLINE void ushort_to_byte_dither_v4( | MINLINE void ushort_to_byte_dither_v4( | ||||
| uchar b[4], const unsigned short us[4], DitherContext *di, float s, float t) | uchar b[4], const unsigned short us[4], DitherContext *di, float s, float t) | ||||
| { | { | ||||
| #define USHORTTOFLOAT(val) ((float)val / 65535.0f) | #define USHORTTOFLOAT(val) ((float)val / 65535.0f) | ||||
| float dither_value = dither_random_value(s, t) * 0.005f * di->dither; | float dither_value = dither_random_value(s, t) * 0.0033f * di->dither; | ||||
| b[0] = ftochar(dither_value + USHORTTOFLOAT(us[0])); | b[0] = ftochar(dither_value + USHORTTOFLOAT(us[0])); | ||||
| b[1] = ftochar(dither_value + USHORTTOFLOAT(us[1])); | b[1] = ftochar(dither_value + USHORTTOFLOAT(us[1])); | ||||
| b[2] = ftochar(dither_value + USHORTTOFLOAT(us[2])); | b[2] = ftochar(dither_value + USHORTTOFLOAT(us[2])); | ||||
| b[3] = unit_ushort_to_uchar(us[3]); | b[3] = unit_ushort_to_uchar(us[3]); | ||||
| #undef USHORTTOFLOAT | #undef USHORTTOFLOAT | ||||
| } | } | ||||
| MINLINE void float_to_byte_dither_v4( | MINLINE void float_to_byte_dither_v4( | ||||
| uchar b[4], const float f[4], DitherContext *di, float s, float t) | uchar b[4], const float f[4], DitherContext *di, float s, float t) | ||||
| { | { | ||||
| float dither_value = dither_random_value(s, t) * 0.005f * di->dither; | float dither_value = dither_random_value(s, t) * 0.0033f * di->dither; | ||||
| b[0] = ftochar(dither_value + f[0]); | b[0] = ftochar(dither_value + f[0]); | ||||
| b[1] = ftochar(dither_value + f[1]); | b[1] = ftochar(dither_value + f[1]); | ||||
| b[2] = ftochar(dither_value + f[2]); | b[2] = ftochar(dither_value + f[2]); | ||||
| b[3] = unit_float_to_uchar_clamp(f[3]); | b[3] = unit_float_to_uchar_clamp(f[3]); | ||||
| } | } | ||||
| /* Test if colorspace conversions of pixels in buffer need to take into account alpha. */ | /* Test if colorspace conversions of pixels in buffer need to take into account alpha. */ | ||||
| ▲ Show 20 Lines • Show All 793 Lines • Show Last 20 Lines | |||||