diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2012-02-14 17:25:23 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2012-02-14 17:25:23 +0400 |
commit | 40e2942f259f9de59fcf93fc99121ff46f630398 (patch) | |
tree | 821d0c1778e6121175f287b77c248ab43ce3237e /source/blender/imbuf | |
parent | 6825577cad890865db5e246198681e3fb3ad18a3 (diff) |
Fix related to #30152, rainbow colours produced when loading hdr image to 3D viewport/ the Nyan cat bug.
Issue is caused by scaling for power of 2 dimensions and mipmapping that happens through GLU. It looks like the library cannot handle float colour values above 1.0 correctly. Since we are close to release I will just clamp the srgb result for now even though it will result in a small performance loss for 16 bit textures only.
I tried a few things before that, glGenerateMipmaps + no scaling (supported for 2.0 GL hardware and up), or using our own scaling instead of glu among them which worked very nicely and gave a speedup too. However, since we are close to release and there may be issues with GPU mipmap generation, see:
http://www.gamedev.net/topic/495747-another-glgeneratemipmap-question/
(old discussion but better be sure than sorry)
I went for the most compatible solution. Maybe after release this can be tested if other devs agree.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 1 | ||||
-rw-r--r-- | source/blender/imbuf/intern/divers.c | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 996bfd35581..07f1b9e4683 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -391,6 +391,7 @@ void IMB_buffer_float_from_float(float *rect_to, const float *rect_from, void IMB_buffer_byte_from_byte(unsigned char *rect_to, const unsigned char *rect_from, int profile_to, int profile_from, int predivide, int width, int height, int stride_to, int stride_from); +void IMB_buffer_float_clamp(float *buf, int width, int height); /** * Change the ordering of the color bytes pointed to by rect from diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index a8ca282de66..d9ec3bf60c6 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -742,3 +742,10 @@ void IMB_color_to_bw(ImBuf *ibuf) rct[0]= rct[1]= rct[2]= rgb_to_grayscale_byte(rct); } } + +void IMB_buffer_float_clamp(float *buf, int width, int height){ + int i, total = width*height*4; + for(i = 0; i < total; i++){ + buf[i] = MIN2(1.0, buf[i]); + } +} |