A scriptable RenderEffect plug-in can be declared by specifying the <superclass> as RenderEffect and by declaring an apply event handler. When declared, the render effect can be seen in Render Effects > Add dialog.
When the scripted effect is added as one of the rendering effects and "Update Scene" or "Update Effect" buttons are pressed, the apply event handler is called and passed a bitmap which can be modified with any changes the render effect wants to make. The bitmap you are given is the current rendered image that has had all of the prior effects in the render effects list applied to it. You modify this bitmap in place, typically by using the getPixel() and setPixel() functions. This modified bitmap is then passed onto the next render effect in the list or to the render output if it is the last effect.
To allow scripted Effects to take advantage of the g-buffer channel access, the following handlers are present:
The handler expression must evaluate to an array of the g-buffer channel names that are required. The g-buffer channel names are:
#zDepth #matID #objectID #UVCoords #normal #unClamped #coverage #mask #node #shaderColor #shaderTransparency #velocity #weight
The preApply handler allows the scripted effect to analyze the incoming render bitmap and its channels in order to precondition the delegate's effect processing.
So, you might add an on channelsRequired do to add #node and #coverage channels to the renderer’s bitmap, and an on preApply bm do to get the #node channel out as a mask and then set it into a delegate’s mask parameter to limit an effect to a given object.
The render() function can be called re-entrantly within scripted renderEffect. In releases prior to 3ds Max 4, attempting to do this caused a runtime error saying that the renderer could not be called while a render was already under way.
Here's a simple example that extends the Blur effect to add another rollout that has a node picker button. If you pick a node it generates a channel mask and uses that to limit the blur to that object: