Jeroen Lamain's edgeRender patch....
Removes floating point calculations and fixes some rounding errors too boot. I created a test program so you can see the differences if anyone is interested you can grab it from http://www.cs.umn.edu/~mein/blender/testedge.c Kent
This commit is contained in:
@@ -168,7 +168,7 @@ int zBufferEdgeRenderObjects(void);
|
|||||||
/**
|
/**
|
||||||
* Add edge pixels to the original image. It blends <bron> over <doel>.
|
* Add edge pixels to the original image. It blends <bron> over <doel>.
|
||||||
*/
|
*/
|
||||||
void addEdgeOver(char *doel, char *bron);
|
void addEdgeOver(unsigned char *dst, unsigned char *src);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@@ -498,14 +498,24 @@ void renderEdges(char *colourRect)
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void addEdgeOver(char *doel, char *bron) /* adds bron (source) to doel (goal) */
|
/* adds src to dst */
|
||||||
|
void addEdgeOver(unsigned char *dst, unsigned char *src)
|
||||||
{
|
{
|
||||||
float c;
|
unsigned char inverse;
|
||||||
int mul;
|
unsigned char alpha;
|
||||||
|
unsigned int c;
|
||||||
|
|
||||||
if( bron[3] == 0) return;
|
alpha = src[3];
|
||||||
if( bron[3] == 255) { /* has been tested, saves a lot */
|
|
||||||
*((unsigned int *)doel)= *((unsigned int *)bron);
|
if( alpha == 0) return;
|
||||||
|
if( alpha == 255) {
|
||||||
|
/* when full opacity, just copy the pixel */
|
||||||
|
/* this code assumes an int is 32 bit, fix
|
||||||
|
|
||||||
|
*(( unsigned int *)dst)= *((unsigned int *)src);
|
||||||
|
replaced with memcpy
|
||||||
|
*/
|
||||||
|
memcpy(dst,src,4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,22 +523,23 @@ void addEdgeOver(char *doel, char *bron) /* adds bron (source) to doel (goal)
|
|||||||
/* input format now. With edge = (c_e, a_e), picture = (c_p, a_p), we */
|
/* input format now. With edge = (c_e, a_e), picture = (c_p, a_p), we */
|
||||||
/* get: result = ( c_e*a_e + c_p(1 - a_e), a_p ). */
|
/* get: result = ( c_e*a_e + c_p(1 - a_e), a_p ). */
|
||||||
|
|
||||||
mul = 255 - bron[3];
|
inverse = 255 - alpha;
|
||||||
|
|
||||||
/* Not sure if the conversion to float is really necessary here... I will*/
|
c = ((unsigned int)inverse * (unsigned int) dst[0] + (unsigned int)src[0] *
|
||||||
/* think about it another day. */
|
(unsigned int)alpha) >> 8;
|
||||||
c = ((mul * doel[0] + bron[0] * bron[3])/255.0);
|
dst[0] = c;
|
||||||
if(c>255) {doel[0]=255;} else { doel[0]= c;}
|
|
||||||
c = ((mul * doel[1] + bron[1] * bron[3])/255.0);
|
c = ((unsigned int)inverse * (unsigned int) dst[1] + (unsigned int)src[1] *
|
||||||
if(c>255) {doel[1]=255;} else { doel[1]= c;}
|
(unsigned int)alpha) >> 8;
|
||||||
c = ((mul * doel[2] + bron[2] * bron[3])/255.0);
|
dst[1] = c;
|
||||||
if(c>255) {doel[2]=255;} else { doel[2]= c;}
|
c = ((unsigned int)inverse * (unsigned int) dst[2] + (unsigned int)src[2] *
|
||||||
|
(unsigned int)alpha) >> 8;
|
||||||
|
dst[2] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void calcEdgeRenderColBuf(char* colTargetBuffer)
|
void calcEdgeRenderColBuf(char* colTargetBuffer)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* int part; */
|
|
||||||
int keepLooping = 1;
|
int keepLooping = 1;
|
||||||
int sample;
|
int sample;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user