dlanier
October 31st, 2006, 14:15
Hi,
I have a strange bug that happens only in mental ray 3.5 for Maya 8, the same code works fine for mental ray for Maya 7.
In an output shader, I copy a user frame buffer to a buffer of miColor* then I apply some filters on this buffer.
The user frame buffer copied to the primary frame buffer gives a correct result...
The pseudo code is :
//ClampD is a clamping function.
void ApplyFilter(const miColor* const _inFB, miColor* const _outFB, int FBWidth, int FBHeight)
{
if (! _inFB || ! _outFB || FBWidth < 0 || FBHeight < 0)
return;
const miInteger FBWidthMinus1 = FBWidth - 1;
const miInteger FBHeightMinus1 = FBHeight - 1;
for (int y=0; y <FBHeight ; ++y)
{
for (int x=0; x<FBWidth; ++x)
{
const int CurPos = x + (y* FBWidth);
//Center = x, y
const miInteger XPixelRight = ClampD(x + 1, 0, FBWidthMinus1);
const miInteger XPixelLeft = ClampD(x - 1, 0, FBWidthMinus1);
const miInteger YPixelUp = ClampD(y - 1, 0, FBHeightMinus1);
const miInteger YPixelDown = ClampD(y + 1, 0, FBHeightMinus1);
const miColor& Center = _inFB[CurPos];
const miColor& Right = _inFB[XPixelRight + (y * FBWidth)];
const miColor& Left = _inFB[XPixelLeft + (y * FBWidth)];
const miColor& Up = _inFB[x + (YPixelUp * FBWidth)];
const miColor& Down = _inFB[x + (YPixelDown * FBWidth)];
_outFB[CurPos].r = 4*Center.r - Right.r - Left.r - Up.r - Down.r;
_outFB[CurPos].g = 4*Center.g - Right.g - Left.g - Up.g - Down.g;
_outFB[CurPos].b = 4*Center.b - Right.b - Left.b - Up.b - Down.b;
//Transform in grey level
miScalar Grey = (_outFB[CurPos].r+ _outFB[CurPos].g+_outFB[CurPos].b) / 3.0f;
Grey = ClampD(Grey,0.f, 1.f);
_outFB[CurPos].r = _outFB[CurPos].g = _outFB[CurPos].b = Grey;
_outFB[CurPos].a = 1.0f;
}
}
}
Does anyone see a reason why this would not work with mray for Maya 8 ?
There doesn't seem to have changes in miColor and moreover I am not using any function from mental ray in this code...
Thank you.
Regards,
I have a strange bug that happens only in mental ray 3.5 for Maya 8, the same code works fine for mental ray for Maya 7.
In an output shader, I copy a user frame buffer to a buffer of miColor* then I apply some filters on this buffer.
The user frame buffer copied to the primary frame buffer gives a correct result...
The pseudo code is :
//ClampD is a clamping function.
void ApplyFilter(const miColor* const _inFB, miColor* const _outFB, int FBWidth, int FBHeight)
{
if (! _inFB || ! _outFB || FBWidth < 0 || FBHeight < 0)
return;
const miInteger FBWidthMinus1 = FBWidth - 1;
const miInteger FBHeightMinus1 = FBHeight - 1;
for (int y=0; y <FBHeight ; ++y)
{
for (int x=0; x<FBWidth; ++x)
{
const int CurPos = x + (y* FBWidth);
//Center = x, y
const miInteger XPixelRight = ClampD(x + 1, 0, FBWidthMinus1);
const miInteger XPixelLeft = ClampD(x - 1, 0, FBWidthMinus1);
const miInteger YPixelUp = ClampD(y - 1, 0, FBHeightMinus1);
const miInteger YPixelDown = ClampD(y + 1, 0, FBHeightMinus1);
const miColor& Center = _inFB[CurPos];
const miColor& Right = _inFB[XPixelRight + (y * FBWidth)];
const miColor& Left = _inFB[XPixelLeft + (y * FBWidth)];
const miColor& Up = _inFB[x + (YPixelUp * FBWidth)];
const miColor& Down = _inFB[x + (YPixelDown * FBWidth)];
_outFB[CurPos].r = 4*Center.r - Right.r - Left.r - Up.r - Down.r;
_outFB[CurPos].g = 4*Center.g - Right.g - Left.g - Up.g - Down.g;
_outFB[CurPos].b = 4*Center.b - Right.b - Left.b - Up.b - Down.b;
//Transform in grey level
miScalar Grey = (_outFB[CurPos].r+ _outFB[CurPos].g+_outFB[CurPos].b) / 3.0f;
Grey = ClampD(Grey,0.f, 1.f);
_outFB[CurPos].r = _outFB[CurPos].g = _outFB[CurPos].b = Grey;
_outFB[CurPos].a = 1.0f;
}
}
}
Does anyone see a reason why this would not work with mray for Maya 8 ?
There doesn't seem to have changes in miColor and moreover I am not using any function from mental ray in this code...
Thank you.
Regards,