View Full Version : effect plugin whoes!

10 October 2005, 10:34 AM

Im working on my first plugin, hurray :D! Its actually an extension to the existing blur post effect but with a "select edges" option in the pixel selection section.

Its all working too but I have a weird problem when reading from the image channels.. It seems to work perfectly in a square render (800x800) for example, also if the rendered object keeps in the left square in a 640x480 one. If it goes into the right side I get very strange artifacts.. I read data simply as y*image_W + x looping through all pixels. The resolution for sure is read right and I have really no idea why this occurs. Heres the function for getting the outline right now:

bool SelEdges::IsEdge (int xPos, int yPos, float thresh)

int x, y;

//get normal
Point3 n = Normalize(DeCompressNormal((ULONG)m_nBuffer[yPos*m_imageW+xPos]));
float z = m_zBuffer[yPos*m_imageW+xPos];
float zPerc = (z-m_minZ)/(m_maxZ - m_minZ);

float threshZ = thresh;

int xTest,yTest;
for (yTest = yPos-1; yTest <= yPos+1; yTest ++)
for (xTest = xPos-1; xTest <= xPos+1; xTest ++) {
int x2, y2;
x2 = xTest;
y2 = yTest;
if (x2 < 0) x2 = 0;
if (x2 > m_imageW) x2 = m_imageW;
if (y2 < 0) y2 = 0;
if (y2 > m_imageH) y2 = m_imageH;

int pos = y2*m_imageW+x2;

//difference in normal
Point3 nHere = Normalize(DeCompressNormal((ULONG)m_nBuffer[pos]));

float d = DotProd (n,nHere);

if (fabs(d) < thresh) return true;

//difference in z value

float zHere = m_zBuffer[pos];
float zHerePerc = (zHere-m_minZ)/(m_maxZ - m_minZ);

if (fabs(zHerePerc-zPerc) > 0.1 )return true;


return false;

I also attached some images of the error. I didnt really know where else to post this, maybe somebody of you knows whats wrong (if its any help i can try uploading the whole project somewhere)

Thanks a million,


10 October 2005, 12:35 PM
OK sillly me!

A friend found my stupid error...

if (x2 < 0) x2 = 0;
if (x2 > m_imageW-1) x2 = m_imageW-1;
if (y2 < 0) y2 = 0;
if (y2 > m_imageH-1) y2 = m_imageH-1;

its working now!

ill post the plugin later, we use it for softening the edges of our characters.


CGTalk Moderation
10 October 2005, 12:35 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.