Skip to content

Instantly share code, notes, and snippets.

@indoorjetpacks
Last active October 24, 2019 20:25
Show Gist options
  • Select an option

  • Save indoorjetpacks/ae0ab61b6a27ce672cea5c3346977ce6 to your computer and use it in GitHub Desktop.

Select an option

Save indoorjetpacks/ae0ab61b6a27ce672cea5c3346977ce6 to your computer and use it in GitHub Desktop.
Fixes the default DropShadow node to multiply correctly. adds option for output shadow only similar to how lightwrap has that option
set cut_paste_input [stack 0]
version 11.1 v3
push 0
push $cut_paste_input
Group {
inputs 2
name DropShadow2
help "<b>DropShadow Gizmo</b>\n\nThis gizmo will create a drop shadow for any input image that has an alpha channel <br> with values greater than 0.\n\ninput - the input image to cast the shadow from\n\nbg - the background image the 'input' image and drop shadow will be merged over\n\nOptions include:\n\nenable drop shadow - enable, or disable the drop shadow effect\ninherit input color - shadow color will be the same color as the input image\ncolor - color of the shadow (ignored if 'inherit input color' is active)\nopacity - opacity of the shadow (relative to the 'input' alpha value)\nangle - direction of the shadow (0/360 = left direction)\ndistance - distance of shadow from the 'input' content position \nsoftness - amount the shadow is blurred by \nshrink/expand - erode(-)/dilate(+) the shadow\ninput \[merge operation] bg - operation to combine the 'input' and 'bg' inputs:\n\n 'input' => the A input\n 'bg' => the B input"
note_font Verdana
selected true
xpos 17
ypos -283
addUserKnob {20 User}
addUserKnob {6 enable_dropshadow_effect l "enable drop shadow" t "enable/disable drop shadow effect" +STARTLINE}
enable_dropshadow_effect true
addUserKnob {6 removeInput l "remove input rgba (only output shadow without merging)" +STARTLINE}
removeInput true
addUserKnob {6 inherit_input_color l "inherit input color" t "use the input images colour for drop shadow" +STARTLINE}
addUserKnob {18 color t "sets the color of the drop shadow (ignored if 'inherit input color' is active)"}
color {0 0 0}
addUserKnob {6 color_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
addUserKnob {6 color_panelDropped_1 l "panel dropped state" -STARTLINE +HIDDEN}
addUserKnob {6 color_panelDropped_1_1 l "panel dropped state" -STARTLINE +HIDDEN}
addUserKnob {7 opacity t "sets the opacity of the drop shadow"}
opacity 0.73
addUserKnob {7 dropshadow_angle l angle t "the angle at which the shadow falls\n\n0/360 = left\n90 = top\n180 = right\n270 = bottom " R 0 360}
dropshadow_angle 225
addUserKnob {7 dropshadow_distance l distance t "distance of shadow from the 'input' content position" R 0 100}
dropshadow_distance 65
addUserKnob {7 softness t "the softness of the shadow (i.e. Blur)" R 0 20}
softness 5
addUserKnob {7 size l shrink/expand t "erode (-) or dilate (+) the shadow" R -5 5}
addUserKnob {26 divider l "" +STARTLINE}
addUserKnob {41 operation l input t "merge operation used to combine 'input' and 'bg' " T Merge1.operation}
addUserKnob {26 bg_input_text l "" -STARTLINE T " bg"}
}
Input {
inputs 0
name input
note_font Verdana
xpos 39
ypos -620
number 1
}
Dot {
name Dot6
note_font Verdana
xpos 73
ypos -568
}
set Nafe80a80 [stack 0]
Dot {
name Dot7
note_font Verdana
xpos 188
ypos -568
}
set Nafe80700 [stack 0]
Dot {
name Dot8
note_font Monaco
xpos 298
ypos -568
}
set Nafe80380 [stack 0]
Grade {
channels alpha
multiply {1 1 1 {parent.Grade2.multiply.a}}
name Grade1
label "leave colors unchanged"
note_font Monaco
xpos 266
ypos -327
}
push $Nafe80380
Dot {
name Dot10
xpos 439
ypos -568
}
set Nafebfc00 [stack 0]
Shuffle {
red alpha
green alpha
blue alpha
name Shuffle1
label "alpha only"
note_font Verdana
xpos 408
ypos -518
}
Clamp {
name Clamp1
xpos 408
ypos -462
}
Grade {
channels rgba
multiply {{parent.color} {parent.color} {parent.color} {parent.Grade2.multiply.a}}
name Grade3
note_font Verdana
xpos 408
ypos -309
}
Switch {
inputs 2
which {{parent.inherit_input_color}}
name Switch2
label "inherit input color"
note_font Monaco
xpos 337
ypos -261
}
Dilate {
channels rgba
size {{parent.size}}
name Dilate3
label "shrink expand"
note_font Verdana
xpos 337
ypos -210
}
Blur {
channels rgba
size {{parent.softness}}
filter quadratic
name Blur3
label softness
note_font Verdana
xpos 337
ypos -147
}
Transform {
translate {{"-1*cos(\[value angle]*3.14159265/180)*\[value distance]"} {"sin(\[value angle]*3.14159265/180)*\[value distance]"}}
center {1024 778}
name Transform4
note_font Verdana
xpos 339
ypos -91
addUserKnob {20 User}
addUserKnob {7 angle R 0 360}
angle {{parent.dropshadow_angle}}
addUserKnob {7 distance R 0 50}
distance {{parent.dropshadow_distance}}
}
Dot {
name Dot2
note_font Verdana
xpos 371
ypos -34
}
set Nafebe000 [stack 0]
Dot {
name Dot4
note_font Verdana
xpos 481
ypos -34
}
Dot {
name Dot5
note_font Verdana
xpos 481
ypos 138
}
set Nafef3880 [stack 0]
Dot {
name Dot3
note_font Verdana
xpos 481
ypos 216
}
push $Nafef3880
push $Nafebe000
Premult {
name Premult1
note_font Verdana
xpos 337
ypos 2
}
EdgeDetectWrapper {
channels alpha
erodesize -0.1
name EdgeDetect1
xpos 337
ypos 31
}
Dilate {
channels rgba
size 1.4
maskChannelInput rgba.alpha
name Dilate1
note_font Verdana
xpos 337
ypos 76
}
Copy {
inputs 2
from0 rgba.alpha
to0 rgba.alpha
name Copy1
note_font Verdana
xpos 337
ypos 131
}
Premult {
name Premult2
note_font Verdana
xpos 337
ypos 175
}
Copy {
inputs 2
from0 rgba.alpha
to0 rgba.alpha
name Copy2
note_font Verdana
xpos 337
ypos 206
}
set Nafef2000 [stack 0]
push $Nafebfc00
Dot {
name Dot9
xpos 630
ypos -568
}
Shuffle {
name Shuffle2
label "\[value this.in] > \[value this.out]"
xpos 598
ypos -467
}
Merge2 {
inputs 2
operation copy
bbox A
name Merge2
xpos 585
ypos 329
}
push $Nafe80700
push $Nafef2000
Merge2 {
inputs 2
name Merge8
note_font Verdana
xpos 154
ypos 212
}
Switch {
inputs 2
which {{parent.removeInput}}
name Switch3
label "remove input rgba - drop shadow only"
xpos 154
ypos 323
}
set Naff1ce00 [stack 0]
Dot {
name Dot11
xpos 289
ypos 379
}
push $Naff1ce00
push $Nafe80a80
Dot {
name Dot1
note_font Verdana
xpos 73
ypos 418
}
Switch {
inputs 2
which {{parent.enable_dropshadow_effect}}
name Switch1
label "enable dropshadow"
note_font Verdana
xpos 154
ypos 411
}
Input {
inputs 0
name bg
note_font Verdana
xpos -186
ypos 509
}
Merge2 {
inputs 2
operation multiply
screen_alpha true
name Merge1
note_font Verdana
xpos 89
ypos 509
}
Switch {
inputs 2
which {{parent.removeInput}}
name Switch4
label removeInput
xpos 249
ypos 587
}
Output {
name Output1
note_font Verdana
xpos 249
ypos 641
}
Grade {
inputs 0
channels alpha
multiply {0 0 0 {parent.opacity}}
name Grade2
label "opacity - alpha for below grades"
note_font Verdana
xpos 336
ypos -394
hide_input true
}
end_group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment