Post processing composite node with custom GLSL fragment shader?

I have rendered an object using a number of composite output nodes : color, depth.
Now I would like to render it again but this time the color of the surface of the object should
be equal to the xyz coordinate at that point. Or some scaled version of it.

How can I do this? I thought it should be easy to define a custom GLSL material in blender
but I cant figure out how to do it.

Does anyone have a suggestion?

It in fact is not that difficult. I’m sure you know the concept of “Material Override” for render layer, right?
Below you’ll see the setup of the shader (left) and setup of the render layer where you need to use the shader like on the left part of the image as material override.

When you render this you’ll get XYZ positions of the pixels - all values (negative and positive) included. All will be measured in blender units.

Works like a charm. Thanks!
By the way what Blender version are you using? Mine is 2.69 and it doesnt match the layout and nodes you are showing.

Are you in Cycles or Blender Internal? Those are Cycles material nodes.

I was in Blender internal but now I see the layout comes from Cycles. It works in both cases. There is also a geometry
output in Blender Internal.

In Blender internal however it doesn’t work well, because the values below zero get clamped. In order to get the proper values you need to add something to “Global” output of geometry node. I usually add something ridiculous like 1000. Then I subtract the same value in compositing.

In cycles this problem does;t exist. Negative values get rendered no problem.

I’m using 2.69 as well. What differences do you see?