-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added "BW" Grayscale and "A" Alpha channel support #2314
Changes from 14 commits
8a5d791
f9f9e4d
4e64d85
c610cdd
9519120
c268007
fad2ffd
6e13d2d
6224a32
20b06e1
5453bd4
e5def78
a6eb314
e292ed1
7332ab7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,9 +87,11 @@ def sv_init(self, context): | |
self.inputs.new('VerticesSocket', "Verts UV") | ||
self.inputs.new('StringsSocket', "U domain").prop_name = 'domU' | ||
self.inputs.new('StringsSocket', "V domain").prop_name = 'domV' | ||
self.outputs.new('StringsSocket', "BW") | ||
self.outputs.new('StringsSocket', "R") | ||
self.outputs.new('StringsSocket', "G") | ||
self.outputs.new('StringsSocket', "B") | ||
self.outputs.new('StringsSocket', "A") | ||
|
||
def draw_buttons(self, context, layout): | ||
layout.label(text="Image:") | ||
|
@@ -133,11 +135,13 @@ def process(self): | |
else: domV = self.domV | ||
|
||
# outputs | ||
bw = [[]] | ||
red = [[]] | ||
alpha = [[]] | ||
green = [[]] | ||
blue = [[]] | ||
|
||
if outputs['R'].is_linked or outputs['G'].is_linked or outputs['B'].is_linked: | ||
if outputs['R'].is_linked or outputs['G'].is_linked or outputs['B'].is_linked or outputs['A'].is_linked or outputs['BW'].is_linked: | ||
imag = bpy.data.images[self.image_name].pixels[:] | ||
sizeU = bpy.data.images[self.image_name].size[0] | ||
sizeV = bpy.data.images[self.image_name].size[1] | ||
|
@@ -163,7 +167,6 @@ def process(self): | |
elif self.boundU == 'EXTEND': | ||
u = max(0,min(u,sizeU-1)) | ||
|
||
|
||
if self.shift_mode_V == 'ALTERNATE': | ||
if (u0//sizeU)%2: v += floor(sizeV*self.shiftV) | ||
if self.shift_mode_V == 'CONSTANT': | ||
|
@@ -183,10 +186,16 @@ def process(self): | |
red[0].append(imag[index]) | ||
green[0].append(imag[index+1]) | ||
blue[0].append(imag[index+2]) | ||
alpha[0].append(imag[index+3]) | ||
else: | ||
red[0].append(0) | ||
green[0].append(0) | ||
blue[0].append(0) | ||
alpha[0].append(0) | ||
if outputs['BW'].is_linked: | ||
bw[0] = [(r+g+b)/3 for r,g,b in zip(red[0], green[0], blue[0])] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are not picky, it's my bad. I was to hurried :P, I'll fix that ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. : ] |
||
outputs['BW'].sv_set(bw) | ||
outputs['A'].sv_set(alpha) | ||
outputs['R'].sv_set(red) | ||
outputs['G'].sv_set(green) | ||
outputs['B'].sv_set(blue) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's magic :D
Unfortunately I'll be on vacation for two weeks (Mexico with no PC). I will be able to handle that only at beginning of December. If you want to fix that in the meanwhile, fell free to modify it. Otherwise I'll take care of it when I'll be back.