diff options
author | Ton Roosendaal <ton@blender.org> | 2003-11-12 23:43:01 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2003-11-12 23:43:01 +0300 |
commit | e9d9a7282eaf15e09698d5fc7d2ef9f4badeaaae (patch) | |
tree | 2c7e056c57da44da09396ba4f4568ae96b940b4a /source/blender/render | |
parent | 3a7dc92cd6d7b88be739c64f7d39c1283b5e13fc (diff) |
All related to unified render:
- fixed bug in halo rendering combined with spothalo
- fixed bug in no antialiasing with sky with spothalo
- cleaned some weird usage of gamma for spothalo and sky
(when rendering sky + spothalo, sky got gamma corrected
- removed old test code and #ifdefs for code readability
On test scenes here unified render looks much better. still some minor
issues with antialiasing... cant pin that down yet.
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/intern/source/pixelshading.c | 115 | ||||
-rw-r--r-- | source/blender/render/intern/source/vanillaRenderPipe.c | 116 |
2 files changed, 30 insertions, 201 deletions
diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 5bd0e09b334..ec9dd633361 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -140,16 +140,6 @@ unsigned int calcHaloZ(HaloRen *har, unsigned int zz) void *renderPixel(float x, float y, int *obdata) { void* data = NULL; -#ifdef RE_PIXSHADE_FULL_SAFETY - char fname[] = "renderPixel"; -#endif -#ifdef RE_FAKE_PIXELS - collector[0] = RE_UNITY_COLOUR_FLOAT; - collector[1] = 0; - collector[2] = RE_UNITY_COLOUR_FLOAT; - collector[3] = RE_UNITY_COLOUR_FLOAT; - return NULL; -#endif if (obdata[3] & RE_POLY) { /* face pixels aren't rendered in floats yet, so we wrap it here */ @@ -163,9 +153,6 @@ void *renderPixel(float x, float y, int *obdata) /* it returns NULL pointers. */ data = renderFacePixel(x, y, obdata[1]); } -#ifdef RE_PIXSHADE_FULL_SAFETY - else RE_error(RE_BAD_FACE_TYPE, fname); -#endif /* RE_PIXSHADE_FULL_SAFETY */ return data; } /* end of void renderPixel(float x, float y, int *obdata) */ @@ -175,9 +162,6 @@ void *renderPixel(float x, float y, int *obdata) void *renderFacePixel(float x, float y, int vlaknr) /* Result goes into <collector> */ { -#ifdef RE_PIXSHADE_FULL_SAFETY - char fname[]= "renderFacePixelFloat"; -#endif static VlakRen *vlr; /* static, because we don't want to recalculate vlr */ /* when we already know it */ static VertRen *v1, *v2, *v3; @@ -186,23 +170,6 @@ void *renderFacePixel(float x, float y, int vlaknr) float *o1, *o2, *o3; float u, v, l, dl, hox, hoy, detsh, fac, deler, alpha; char *cp1, *cp2, *cp3; - -/* RE_error(RE_TRACE_COUNTER, fname); */ - -#ifdef RE_FAKE_FACE_PIXELS - collector[0] = 0; - collector[1] = 0; - collector[2] = RE_UNITY_COLOUR_FLOAT; - collector[3] = RE_UNITY_COLOUR_FLOAT; - /* try to keep the rest as clean as possible... */ - if( ((vlaknr & 0x7FFFFF) <= R.totvlak) - && ! ((R.vlaknr== -1)||(vlaknr<=0)) ) { - /* a bit superfluous to do this always, but */ - /* when this is switched on, it doesn't matter */ - vlr= RE_findOrAddVlak( (vlaknr-1) & 0x7FFFFF); - } else vlr = NULL; - return vlr; -#endif if(R.vlaknr== -1) { /* set by initrender */ /* also set in the pixelrender loop */ @@ -618,12 +585,7 @@ void *renderFacePixel(float x, float y, int vlaknr) if(vlaknr<=0) { /* calculate view vector and set R.co at far */ /* this view vector stuff should get its own function */ - if( (G.special1 & G_HOLO) && - ((Camera *)G.scene->camera->data)->flag & CAM_HOLO2) { - R.view[0]= (x+(R.xstart)+1.0+holoofs); - } else { - R.view[0]= (x+(R.xstart)+1.0); - } + R.view[0]= (x+(R.xstart)+1.0); if(R.flag & R_SEC_FIELD) { if(R.r.mode & R_ODDFIELD) R.view[1]= (y+R.ystart+0.5)*R.ycor; @@ -649,14 +611,8 @@ void *renderFacePixel(float x, float y, int vlaknr) } shadeSpotHaloPixelFloat(collector); -/* renderspothaloFix(collector); */ - } -#ifdef RE_PIXSHADE_FULL_SAFETY - if (!vlr) RE_error(RE_BAD_DATA_POINTER, fname); -#endif - return vlr; } /* end of void renderFacePixelFloat(float x, float y, int vlaknr) */ @@ -715,15 +671,17 @@ void shadeSpotHaloPixelFloat(float *col) /* this is a slightly different approach: I do the gamma */ /* correction BEFORE the addition. What does the other */ /* approach do? */ + + /* removed gamma correction here (ton) looks better, but still not 100% OK */ if (col[3]< RE_EMPTY_COLOUR_FLOAT) { - col[0] = gammaCorrect(rescol[0]); - col[1] = gammaCorrect(rescol[1]); - col[2] = gammaCorrect(rescol[2]); + col[0] = (rescol[0]); + col[1] = (rescol[1]); + col[2] = (rescol[2]); col[3] = rescol[3]; } else { - col[0] += gammaCorrect(rescol[0]); - col[1] += gammaCorrect(rescol[1]); - col[2] += gammaCorrect(rescol[2]); + col[0] += (rescol[0]); + col[1] += (rescol[1]); + col[2] += (rescol[2]); col[3] += rescol[3]; } @@ -1284,12 +1242,6 @@ void shadeLampLusFloat() + ((1.0 - (ma->mirb * R.refcol[0])) * ((ma->b * ib) +ma->ambb)) +isb; } - -#ifdef RE_FAKE_LAMP_SHADE - collector[0] = 0.5; - collector[1] = 0.5; - collector[2] = 1.0; -#endif } @@ -1299,15 +1251,6 @@ void* renderHaloPixel(float x, float y, int haloNr) { HaloRen *har = NULL; float dist = 0.0; unsigned int zz = 0; - -#ifdef RE_FAKE_HALO_PIXELS - collector[0] = RE_UNITY_COLOUR_FLOAT; - collector[1] = 0; - collector[2] = 0; - collector[3] = RE_UNITY_COLOUR_FLOAT; - har = RE_findOrAddHalo(haloNr); /* crash prevention */ - return (void*) har; -#endif /* Find har to go with haloNr */ har = RE_findOrAddHalo(haloNr); @@ -1327,13 +1270,6 @@ void* renderHaloPixel(float x, float y, int haloNr) { if (dist < har->radsq) { shadeHaloFloat(har, collector, zz, dist, (x - har->xs), (y - har->ys) * R.ycor, har->flarec); - /* make a second fake pixel? */ -#ifdef RE_FAKE_HALO_PIXELS_2 - collector[0] = RE_UNITY_COLOUR_FLOAT; - collector[1] = 0; - collector[2] = 0; - collector[3] = RE_UNITY_COLOUR_FLOAT; -#endif }; /* else: this pixel is not rendered for this halo: no colour */ return (void*) har; @@ -1548,14 +1484,9 @@ void renderSpotHaloPixel(float x, float y, float* target) { float u = 0.0, v = 0.0; -#ifdef RE_FAKE_SPOTHALO_PIXELS - target[0] = 0.0; - target[1] = 1.0; - target[2] = 0.0; - target[3] = 1.0; - return; -#endif - + /* this needs to be cleared */ + target[0]= target[1]= target[2]= target[3]= 0.0; + /* Strange fix? otherwise done inside shadepixel. It's sort */ /* of like telling this is a 'sky' pixel. */ R.vlaknr = 0; @@ -1564,12 +1495,7 @@ void renderSpotHaloPixel(float x, float y, float* target) /* Here's the viewvector setting again. */ - if( (G.special1 & G_HOLO) && ((Camera *)G.scene->camera->data)->flag & CAM_HOLO2) { - R.view[0]= (x+(R.xstart)+1.0+holoofs); - } - else { - R.view[0]= (x+(R.xstart)+1.0); - } + R.view[0]= (x+(R.xstart)+1.0); if(R.flag & R_SEC_FIELD) { if(R.r.mode & R_ODDFIELD) R.view[1]= (y+R.ystart+0.5)*R.ycor; @@ -1634,10 +1560,10 @@ void renderspothaloFix(float *col) if(i>0.0) { /* Premul colours here! */ - col[0] = i * lar->r; - col[1] = i * lar->g; - col[2] = i * lar->b; - col[3] = i; + col[0]+= i * lar->r; + col[1]+= i * lar->g; + col[2]+= i * lar->b; + col[3]+= i; } } } @@ -1675,13 +1601,6 @@ enum RE_SkyAlphaBlendingType getSkyBlendingMode() { /* This one renders into collector, as always. */ void renderSkyPixelFloat(float x, float y) { -#ifdef RE_FAKE_SKY_PIXELS - collector[0] = 1.0; - collector[1] = 1.0; - collector[2] = 0.0; - collector[3] = 1.0; - return; -#endif switch (keyingType) { case RE_ALPHA_PREMUL: diff --git a/source/blender/render/intern/source/vanillaRenderPipe.c b/source/blender/render/intern/source/vanillaRenderPipe.c index 1180408ef3c..584b012eedd 100644 --- a/source/blender/render/intern/source/vanillaRenderPipe.c +++ b/source/blender/render/intern/source/vanillaRenderPipe.c @@ -96,25 +96,6 @@ /* ------------------------------------------------------------------------- */ -#ifdef RE_FULL_SAFETY -/* Full safety does the following: */ -/* - add extra bounds checking */ -/* - add extra type checking */ -/* - do a little performance analysis */ -/* - trace the original sources */ - -/* trace the version of the source */ -char vanillaRenderPipe_ext_h[] = VANILLARENDERPIPE_EXT_H; -char vanillaRenderPipe_int_h[] = VANILLARENDERPIPE_INT_H; -char vanillaRenderPipe_types_h[] = VANILLARENDERPIPE_TYPES_H; -char vanillaRenderPipe_c[] = -"$Id$"; -/* counters for error handling */ -static int conflictsresolved; /* number of conflicts in one frame */ - -#include "errorHandler.h" -#endif /* RE_FULL_SAFETY stuff */ - /* ------------------------------------------------------------------------- */ /* External : -------------------------------------------------------------- */ @@ -194,16 +175,6 @@ void zBufShadeAdvanced() int y, keepLooping = 1; float xjit = 0.0, yjit = 0.0; -#ifdef RE_FULL_SAFETY - /* reset trace */ - RE_errortrace_reset(); - conflictsresolved = 0; - fprintf(stderr, "\n*** Activated full error trace on " - "unified renderer using:\n\t%s\n\t%s\n\t%s\n\t%s", - vanillaRenderPipe_c, vanillaRenderPipe_ext_h, - vanillaRenderPipe_int_h, vanillaRenderPipe_types_h); -#endif - Zjitx=Zjity= -0.5; /* jitter preset: 0.5 pixel */ /* EDGE: for edge rendering we should compute a larger buffer, but this */ @@ -279,11 +250,6 @@ void zBufShadeAdvanced() add_halo_flare(); /* from rendercore */ -#ifdef RE_FULL_SAFETY - fprintf(stderr, "\n--- resolved %d conflicts", conflictsresolved); - fflush(stderr); -#endif - if (!(R.r.mode & R_OSA)) { jit[0][0] = xjit; jit[0][1] = yjit; @@ -382,9 +348,6 @@ void calcZBufLine(int y) int countAndSortPixelFaces(int zrow[RE_MAX_FACES_PER_PIXEL][RE_PIXELFIELDSIZE], RE_APixstrExt *ap) { -#ifdef RE_FULL_SAFETY - char fname[] = "countAndSortPixelFaces"; -#endif int totvlak; /* face counter */ int i; /* generic counter */ @@ -401,9 +364,6 @@ int countAndSortPixelFaces(int zrow[RE_MAX_FACES_PER_PIXEL][RE_PIXELFIELDSIZE], if(totvlak > (RE_MAX_FACES_PER_PIXEL - 1)) { totvlak = (RE_MAX_FACES_PER_PIXEL - 1); -#ifdef RE_FULL_SAFETY - RE_error(RE_TOO_MANY_FACES, fname); -#endif } } else break; }; @@ -449,13 +409,11 @@ int composeStack(int zrow[RE_MAX_FACES_PER_PIXEL][RE_PIXELFIELDSIZE], struct RE_faceField* stack, int ptr, int totvlak, float x, float y, int osaNr) { -#ifdef RE_FULL_SAFETY - char* fname = "composeStack"; -#endif float xs = 0.0; float ys = 0.0; /* coordinates for the render-spot */ float alphathreshold[RE_MAX_OSA_COUNT]; + float colbuf[4]; int inconflict = 0; int saturationthreshold = 0; int saturated = 0; @@ -497,9 +455,6 @@ int composeStack(int zrow[RE_MAX_FACES_PER_PIXEL][RE_PIXELFIELDSIZE], stack[ptr].conflictCount = Ccount; if (zrow[totvlak][RE_ZMAX] > Cthresh) Cthresh = zrow[totvlak][RE_ZMAX]; -#ifdef RE_FULL_SAFETY - if (Ccount == 2) conflictsresolved++; -#endif } else { Cthresh = zrow[totvlak][RE_ZMAX]; Ccount = 0; @@ -540,10 +495,17 @@ int composeStack(int zrow[RE_MAX_FACES_PER_PIXEL][RE_PIXELFIELDSIZE], xs= (float)x; ys= (float)y; + /* code identical for rendering empty sky pixel */ renderSkyPixelFloat(xs, ys); + cpFloatColV(collector, colbuf); + + if(R.flag & R_LAMPHALO) { + renderSpotHaloPixel(x, y, collector); + addAlphaOverFloat(colbuf, collector); + } stack[ptr].faceType = RE_SKY; - cpFloatColV(collector, stack[ptr].colour); + cpFloatColV(colbuf, stack[ptr].colour); stack[ptr].data = NULL; stack[ptr].mask = 0xFFFF; stack[ptr].conflictCount = 0; @@ -560,9 +522,6 @@ int composeStack(int zrow[RE_MAX_FACES_PER_PIXEL][RE_PIXELFIELDSIZE], This means layers [ n - c, ..., n ] */ int resolveConflict(struct RE_faceField* stack, int ptr, float x, float y) { -#ifdef RE_FULL_SAFETY - char* fname = "resolveConflicts"; -#endif int face; int layer; float dx, dy; @@ -644,12 +603,10 @@ void integrateStack(struct RE_faceField* stack, int ptr, /* Should be integrated in the rest of the rendering... */ - if((R.flag & R_LAMPHALO) - /*&& - ( VR_covered < ((1 << osaNr) - 1 ) )*/ - ) { + if(R.flag & R_LAMPHALO) { float halocol[4]; int i; + renderSpotHaloPixel(x, y, halocol); /* test seems to be wrong? */ if (halocol[3] > RE_EMPTY_COLOUR_FLOAT) { @@ -872,16 +829,8 @@ void renderZBufLine(int y) { RE_OSAstack_ptr = composeStack(zrow, RE_OSAstack, RE_OSAstack_ptr, stackDepth, x, y, osaNr); -/* #ifdef RE_OLD_INTEGRATION */ -/* printf("Performing old integration\n"); */ -/* integrateStack(RE_OSAstack, RE_OSAstack_ptr, */ -/* x, y, osaNr); */ -/* #endif */ -/* #ifndef RE_OLD_INTEGRATION */ -/* printf("Performing new integration\n"); */ integratePerSubStack(RE_OSAstack, RE_OSAstack_ptr, x, y, osaNr); -/* #endif */ /* d. Gamma corrected blending */ sampleFloatColV2FloatColV(sampcol, colbuf, osaNr); @@ -898,8 +847,9 @@ void renderZBufLine(int y) { /* onto the existing colour in the collector. */ if(R.flag & R_LAMPHALO) { renderSpotHaloPixel(x, y, collector); + addAlphaOverFloat(colbuf, collector); } - addAlphaOverFloat(colbuf, collector); + } } /* End of pixel loop */ @@ -1477,16 +1427,6 @@ void transferColourBufferToOutput(int y) RE_COLBUFTYPE *buf = AColourBuffer; char *target = (char*) (R.rectot + (y * imageWidth)); -#ifdef RE_FULL_SAFETY - /* since the R.rectot always has size imageWidth * imageHeight, this */ - /* check is possible. I may want to check this per assignment later on. */ - if ( (y < 0) || ((y > (imageHeight - 1) ))) { - char fname[] = "transferColourBufferToOutput"; - RE_error_int(RE_WRITE_OUTSIDE_COLOUR_BUFFER, fname, y); - return; - } -#endif - /* Copy the first <imageWidth> pixels. We can do some more clipping on */ /* the z buffer, I think. */ while (x < imageWidth) { @@ -1530,13 +1470,6 @@ void eraseColBuf(RE_COLBUFTYPE *buf) { int calcDepth(float x, float y, void* data, int type) { -#ifdef RE_FULL_SAFETY - char fname[] = "calcDepth"; - if (data == NULL) { - RE_error(RE_BAD_DATA_POINTER, fname); - return 0; - } -#endif if (type & RE_POLY) { VlakRen* vlr = (VlakRen*) data; @@ -1583,9 +1516,6 @@ int calcDepth(float x, float y, void* data, int type) HaloRen* har = (HaloRen*) data; return har->zBufDist; } -#ifdef RE_FULL_SAFETY - else RE_error(RE_BAD_FACE_TYPE, fname); -#endif /* RE_FULL_SAFETY */ return 0; } /* end of int calcDepth(float x, float y, void* data, int type) */ @@ -1593,13 +1523,6 @@ int calcDepth(float x, float y, void* data, int type) void blendOverFloat(int type, float* dest, float* source, void* data) { -#ifdef RE_FULL_SAFETY - char fname[] = "blendOverFloat"; - if (data == NULL){ - RE_error(RE_BAD_DATA_POINTER, fname); - return; - } -#endif if (type & RE_POLY) { VlakRen *ver = (VlakRen*) data; @@ -1615,9 +1538,6 @@ void blendOverFloat(int type, float* dest, float* source, void* data) } else if (type & RE_SKY) { addAlphaOverFloat(dest, source); } -#ifdef RE_FULL_SAFETY - else RE_error(RE_BAD_FACE_TYPE, fname); -#endif } /* end of void blendOverFloat(int , float*, float*, void*) */ @@ -1625,13 +1545,6 @@ void blendOverFloat(int type, float* dest, float* source, void* data) void blendOverFloatRow(int type, float* dest, float* source, void* data, int mask, int osaNr) { -#ifdef RE_FULL_SAFETY - char* fname = "blendOverFloatRow"; - if ((data == NULL) && ((type & RE_POLY) || (type & RE_HALO))) { - RE_error(RE_BAD_DATA_POINTER, fname); - return; - } -#endif if (type & RE_POLY) { VlakRen *ver = (VlakRen*) data; @@ -1648,9 +1561,6 @@ void blendOverFloatRow(int type, float* dest, float* source, } else if (type & RE_SKY) { addOverSampColF(dest, source, mask, osaNr); } -#ifdef RE_FULL_SAFETY - else RE_error(RE_BAD_FACE_TYPE, fname); -#endif } /* end of void blendOverFloatRow(int, float*, float*, void*) */ /* ------------------------------------------------------------------------- */ |