diff options
author | Ton Roosendaal <ton@blender.org> | 2006-01-12 01:36:31 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-01-12 01:36:31 +0300 |
commit | 0665f0d64799e6a38c4ca0930df73271f246e422 (patch) | |
tree | fa488d33452f0bfc6ec91e5bbbec726afcbcb9f3 /source/blender/imbuf/intern/allocimbuf.c | |
parent | b92fa4151645d50e40faa8f4aaea4b7f6149947c (diff) |
Orange;
Until now, the zbuffer was written straight from the internal zbuffer,
which has values that are inverse-proportional (like 1.0/z) which makes
it very hard to use it for postprocess, like zblur or other composit effects
that require Z.
Based on info from ILM, the values stored for Z in exr files is the
actual distance from a camera. I think that's about time to migrate to that
convention!
By default now, after render, the z values are converted to floats. This
saves in exr files now, but not in the Iris Z files. That latter was a
blender-only anyway, so might be not a real hassle to drop. :)
You can see the difference in the image window, but notice the range now
is linear mapped from camera clipstart to clipend.
Note; I just discover that ortho Z values need a different correction...
Diffstat (limited to 'source/blender/imbuf/intern/allocimbuf.c')
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 51d294d2d26..0c1d182f4b2 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -112,6 +112,16 @@ void IMB_freezbufImBuf(struct ImBuf * ibuf) ibuf->mall &= ~IB_zbuf; } +void IMB_freezbuffloatImBuf(struct ImBuf * ibuf) +{ + if (ibuf==NULL) return; + if (ibuf->zbuf_float){ + if (ibuf->mall & IB_zbuffloat) MEM_freeN(ibuf->zbuf_float); + } + ibuf->zbuf_float= NULL; + ibuf->mall &= ~IB_zbuffloat; +} + void IMB_freecmapImBuf(struct ImBuf * ibuf) { if (ibuf==NULL) return; @@ -129,6 +139,7 @@ void IMB_freeImBuf(struct ImBuf * ibuf) imb_freerectImBuf(ibuf); imb_freerectfloatImBuf(ibuf); IMB_freezbufImBuf(ibuf); + IMB_freezbuffloatImBuf(ibuf); IMB_freecmapImBuf(ibuf); freeencodedbufferImBuf(ibuf); MEM_freeN(ibuf); @@ -138,18 +149,36 @@ void IMB_freeImBuf(struct ImBuf * ibuf) short addzbufImBuf(struct ImBuf * ibuf) { int size; - + if (ibuf==NULL) return(FALSE); IMB_freezbufImBuf(ibuf); - + size = ibuf->x * ibuf->y * sizeof(unsigned int); if ( (ibuf->zbuf = MEM_mallocN(size, "addzbufImBuf")) ){ ibuf->mall |= IB_zbuf; ibuf->flags |= IB_zbuf; return (TRUE); } + + return (FALSE); +} +short addzbuffloatImBuf(struct ImBuf * ibuf) +{ + int size; + + if (ibuf==NULL) return(FALSE); + + IMB_freezbuffloatImBuf(ibuf); + + size = ibuf->x * ibuf->y * sizeof(float); + if ( (ibuf->zbuf_float = MEM_mallocN(size, "addzbuffloatImBuf")) ){ + ibuf->mall |= IB_zbuffloat; + ibuf->flags |= IB_zbuffloat; + return (TRUE); + } + return (FALSE); } @@ -345,6 +374,13 @@ struct ImBuf *IMB_allocImBuf(short x, short y, uchar d, unsigned int flags, ucha } } + if (flags & IB_zbuffloat){ + if (addzbuffloatImBuf(ibuf)==FALSE){ + IMB_freeImBuf(ibuf); + return NULL; + } + } + if (flags & IB_planes){ if (imb_addplanesImBuf(ibuf)==FALSE){ IMB_freeImBuf(ibuf); @@ -355,6 +391,7 @@ struct ImBuf *IMB_allocImBuf(short x, short y, uchar d, unsigned int flags, ucha return (ibuf); } +/* does no zbuffers? */ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1) { struct ImBuf *ibuf2, tbuf; @@ -402,6 +439,8 @@ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1) tbuf.planes = ibuf2->planes; tbuf.cmap = ibuf2->cmap; tbuf.encodedbuffer = ibuf2->encodedbuffer; + tbuf.zbuf= NULL; + tbuf.zbuf_float= NULL; // set malloc flag tbuf.mall = ibuf2->mall; |