I tried myself to get the lamp to update but it doesn’t work. The pre and post draw callbacks don’t work either, they have the strange effect of replacing your view with the rendered texture too, so I’d avoid that route.
However, I did get object color to work.
Here the player character has its object color switched to red just before rendering, then switched back.
to use object color as a driver in nodes you need two ‘material’ nodes.
One set to shadeless and with object color enabled and the other set to shaded and with object color disabled.
Use the first one as a driver. It will give you three channels, rgb which you can use in different ways to control things in your node setup. I usually split RGB channels and then recombine with 0.0 inputs them to use as 3 different vectors.
To handle a lot of objects in your scene you can do this:
for ob in list:
ob.color = color
render_objects = [ob for ob in own.scene.objects if ob.get("render")] ## objects you want to be cut off since they are under water, give them a "render" property.
It’s best if you create a list at the beginning of the game and maintain it though, rather than getting the objects every tic.
Another alternative is to use ‘local’ or ‘view’ geometry co-ordinate data in your node setup for objects to be culled since rendering from different cameras will give different data for the rendered scene and your rendered texture:
I’m not sure how you’d use that to your advantage though. Maybe you can think of something.
I got it working!
It seems to work ok with different camera orientations, hopefully you can use it.