Wondering if someone who is more knowledgeable in python could look this over and see it there are any glaring errors…seems to work fine but who knows.
#
# Gamma correction node
#
import Blender
from Blender import Node
class GammaNode(Node.Scripted):
def __init__(self, sockets):
color = Node.Socket('Color', val = [1.0, 1.0, 1.0, 1.0])
gamma = Node.Socket('Gamma', val = 1.00, min = 0.0, max = 10.0)
sockets.input = [color, gamma]
sockets.output = [color]
def __call__(self):
ocol = list(self.input['color'])
gama = self.input['gamma']
ocol[0] = ocol[0]**gama
ocol[1] = ocol[1]**gama
ocol[2] = ocol[2]**gama
self.output['color'] = ocol
And a link to the text file since code tags mangle code contrary to their implied function.
I was considering using the math node but started thinking that you probably don’t want to exponentially increase/decrease the alpha channel which would lead to further complications in the node setup.
Anyhoo, I also make a gamma texture node in c and submitted it to the patch tracker which should be just as fast (without the alpha channel complications) as the math node. Probably make a material one as well since it is just simple changes.
I am actually trying to use your script right now and am getting a ‘not a valid dynamic node Python script’ error message when I do. I have a new thread started herehttp://blenderartists.org/forum/showthread.php?t=172021 about it. As I am not a Python coder I can’t tell what is wrong with the code.
Actually, after testing your script, I may be onto something here.
When your script is left set at 1 it works fine, but has no effect (which I assume is normal?).
However, when I set the Gamma to anything other than 1.00 I get the same error message with your script that I got with the other one. Which means I may have a bigger issue and both scripts may be fine.