PDA

View Full Version : Color Utility API creation


dbsmith
01-28-2008, 03:57 AM
Hey all,
Am trying to create a simple blur/kernel convolution node.
Input = color + integer value (eg 5)
Compute = blur it per-pixel by using the surrounding pixel's values eg kernel =
0.05 0.10 0.05
0.10 0.40 0.10
0.05 0.10 0.05
Output = color

Does the compute method work on a per pixel basis, or is it just called ONCE?
How can I access other pixels other than the current one im on?

//Rough pseudo-code:

MFloatVector resultColor;
MFloatVector & col = block.inputValue(aColor).asFloatVector();
int blur = block.inputValue(aBlurAmount).asInt();

//Get color values from around current pixel....

//This is pseudo-code, showing getting different pixels at different indices....
resultColor = resultColor[-1][-1]*0.05 + resultColor[0][-1]*0.1 + resultColor[1][-1]*0.05 .... etc....

// set ouput color attribute
MDataHandle outColorHandle = block.outputValue( aOutColor );
MFloatVector& outColor = outColorHandle.asFloatVector();
outColor = resultColor;
outColorHandle.setClean();

return MS::kSuccess;

tbaypaul
01-28-2008, 10:56 PM
the easiest way sounds like it would be as a post render process....like paint effects......and that seems to be implemented with the class MRenderData....

compute in a shader or texture is called once for each pixel multi-jittered (stratified) sample point.....and those sample points locations are nearly always filtered with cubic curves in modern ray tracers to arrive at the average sample color which is saved to that pixel element of the image raster/buffer. Technically, the process is known a Monte Carlo Intergration, I think. This is essentially what you are doing, so perhaps your kernel could be implimented at a lower level in the render process....like the other filtering? I wish I could be more helpful.

CGTalk Moderation
01-28-2008, 10:56 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.