import Blenderfrom Blender.Mathutils import Vector as vecfrom Blender.Mathutils import DotVecs as dotimport Blender.Nodeimport mathclass Iylles(Blender.Node.node): def __init__(self, inp, out): d = (Blender.Node.RGBA, 1.0,1.0,1.0,1.0,0.0,1.0) # diffuse col s = (Blender.Node.RGBA, 1.0,1.0,1.0,1.0,0.0,1.0) # spec col a = (Blender.Node.RGBA, 1.0,1.0,1.0,1.0,0.0,1.0) # amb col amb = (Blender.Node.VALUE, 1.0,1.0,1.0,1.0,0.0,1.0) # ambient ref = (Blender.Node.VALUE, 1.0,1.0,1.0,1.0,0.0,1.0) # reflectivity spec = (Blender.Node.VALUE, 1.0,1.0,1.0,1.0,0.0,1.0) # specularity hard = (Blender.Node.VALUE, 1.0,1.0,1.0,1.0,0.0,1.0) # hardness att = (Blender.Node.VALUE, 1.0,1.0,1.0,1.0,0.0,1.0) # attenuation inp.definitions = {'DiffCol':d, 'SpecCol':d, 'AmbCol':d, 'Ambience':amb, 'Reflectance':amb, 'Specularity':amb, 'Hardness':amb, 'Attenuation':amb} out.definitions = {'Colour':d} #for now just use light pos and colour from here #later get them from the scene self.lightloc = vec(-10.0, 0.0, -10.0) self.lighcol = [1.0,1.0,1.0] def __call__(self): t = vec(*self.shi.tex_coord) v = vec(*self.shi.view_normal) n = vec(*self.shi.surface_normal) a = self.ins['AmbCol'] d = self.ins['DiffCol'] s = self.ins['SpecCol'] ka = self.ins['Ambience'] kd = self.ins['Reflectance'] ks = self.ins['Specularity'] katt = self.ins['Attenuation'] kn = self.ins['Hardness'] l = self.lightloc - t l.normalize() r = 2 * n * dot(n, l) - l k = 2.0 ix = [kd * katt * (Mathutils.DotVecs(N, L) ** (k + 1)) * (1 - Mathutils.DotVecs(N, Mathutils.Vector(*viewnorm)) ** (k - 1)) for i in xrange(3)] self.outs['Colour'] = (ix[0],ix[1],ix[2], 1.0)