|
| 1 | +Group { |
| 2 | + name LumaToVector3 |
| 3 | + help "Performs a Sobel filter on the Luminance channel of an image to extract an approximation of a Normal map.\n\nFor a mathematical conversion of a displacement map to normals, do not use Details separation." |
| 4 | + addUserKnob {20 luma_to_normals l "Luma to Normals"} |
| 5 | + addUserKnob {26 div_pre l Pre-Process} |
| 6 | + addUserKnob {7 blur t "High quality blur, may be slower than a regular blur node but will avoid loss of quality in the vectors." R 0 10} |
| 7 | + addUserKnob {7 gain l "height (gain)" t "Increasing this value would result in vectors as per a stronger displacement." R 0 10} |
| 8 | + gain 1 |
| 9 | + addUserKnob {26 div_details l "Details Separation"} |
| 10 | + addUserKnob {7 size t "Bigger sizes will separate high and low frequencies more." R 0 100} |
| 11 | + addUserKnob {7 details_weight t "How much the details affect the final output"} |
| 12 | + addUserKnob {26 div_out l Output} |
| 13 | + addUserKnob {6 zerotoone l "Use 0-1 range" t "Pack the vectors in a 0 to 1 range, so that it can be exported as an 8bit image. May cause clamped vectors, make sure to also use normalize if exporting a normal map to avoid clamped values." +STARTLINE} |
| 14 | + addUserKnob {6 normalize t "Normal maps should generally be represented with a vector magnitude of 1.\nTurning on normalization will scale all vectors to ensure they all have a magnitude of 1.\n\nYou may want to disable it for more interesting effects when generating normals for a fake refraction through an iDistort, where having vectors of different length adds depth." -STARTLINE} |
| 15 | + normalize true |
| 16 | + addUserKnob {26 ""} |
| 17 | + addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"} |
| 18 | +} |
| 19 | + Input { |
| 20 | + inputs 0 |
| 21 | + name Input1 |
| 22 | + xpos -576 |
| 23 | + ypos -320 |
| 24 | + } |
| 25 | + Saturation { |
| 26 | + saturation 0 |
| 27 | + name Saturation1 |
| 28 | + xpos -576 |
| 29 | + ypos -264 |
| 30 | + } |
| 31 | + Blur { |
| 32 | + size {{parent.blur}} |
| 33 | + quality {{"int(max(parent.blur, 15))"}} |
| 34 | + name Blur2 |
| 35 | + xpos -576 |
| 36 | + ypos -223 |
| 37 | + } |
| 38 | + Multiply { |
| 39 | + value {{parent.gain}} |
| 40 | + name Multiply1 |
| 41 | + xpos -576 |
| 42 | + ypos -185 |
| 43 | + } |
| 44 | +set N8fdf0400 [stack 0] |
| 45 | + Blur { |
| 46 | + size {{parent.size}} |
| 47 | + name Blur1 |
| 48 | + xpos -576 |
| 49 | + ypos -134 |
| 50 | + } |
| 51 | + Dot { |
| 52 | + name Dot2 |
| 53 | + xpos -542 |
| 54 | + ypos -45 |
| 55 | + } |
| 56 | +set Nc5a5fc00 [stack 0] |
| 57 | + Matrix { |
| 58 | + matrix { |
| 59 | + {1 0 -1} |
| 60 | + {2 0 -2} |
| 61 | + {1 0 -1} |
| 62 | + } |
| 63 | + name Matrix1 |
| 64 | + xpos -576 |
| 65 | + ypos 38 |
| 66 | + } |
| 67 | +push $Nc5a5fc00 |
| 68 | + Dot { |
| 69 | + name Dot3 |
| 70 | + xpos -432 |
| 71 | + ypos -45 |
| 72 | + } |
| 73 | +set Nc5a5f400 [stack 0] |
| 74 | + Matrix { |
| 75 | + matrix { |
| 76 | + {-1 -2 -1} |
| 77 | + {0 0 0} |
| 78 | + {1 2 1} |
| 79 | + } |
| 80 | + name Matrix2 |
| 81 | + xpos -466 |
| 82 | + ypos 36 |
| 83 | + } |
| 84 | + Dot { |
| 85 | + name Dot4 |
| 86 | + xpos -432 |
| 87 | + ypos 92 |
| 88 | + } |
| 89 | + ShuffleCopy { |
| 90 | + inputs 2 |
| 91 | + red red |
| 92 | + blue black |
| 93 | + alpha black |
| 94 | + name ShuffleCopy1 |
| 95 | + xpos -575 |
| 96 | + ypos 88 |
| 97 | + } |
| 98 | + Multiply { |
| 99 | + value {{(1-parent.details_weight)*(parent.size/10+1)}} |
| 100 | + name Multiply2 |
| 101 | + xpos -577 |
| 102 | + ypos 128 |
| 103 | + } |
| 104 | +push $Nc5a5f400 |
| 105 | +push $N8fdf0400 |
| 106 | + Dot { |
| 107 | + name Dot1 |
| 108 | + xpos -319 |
| 109 | + ypos -175 |
| 110 | + } |
| 111 | + Merge2 { |
| 112 | + inputs 2 |
| 113 | + operation from |
| 114 | + name Merge1 |
| 115 | + xpos -353 |
| 116 | + ypos -49 |
| 117 | + } |
| 118 | + Dot { |
| 119 | + name Dot5 |
| 120 | + xpos -319 |
| 121 | + ypos -23 |
| 122 | + } |
| 123 | +set Nb4693800 [stack 0] |
| 124 | + Matrix { |
| 125 | + matrix { |
| 126 | + {1 0 -1} |
| 127 | + {2 0 -2} |
| 128 | + {1 0 -1} |
| 129 | + } |
| 130 | + name Matrix3 |
| 131 | + xpos -353 |
| 132 | + ypos 25 |
| 133 | + } |
| 134 | +push $Nb4693800 |
| 135 | + Dot { |
| 136 | + name Dot6 |
| 137 | + xpos -181 |
| 138 | + ypos -23 |
| 139 | + } |
| 140 | + Matrix { |
| 141 | + matrix { |
| 142 | + {-1 -2 -1} |
| 143 | + {0 0 0} |
| 144 | + {1 2 1} |
| 145 | + } |
| 146 | + name Matrix4 |
| 147 | + xpos -215 |
| 148 | + ypos 30 |
| 149 | + } |
| 150 | + Dot { |
| 151 | + name Dot7 |
| 152 | + xpos -181 |
| 153 | + ypos 87 |
| 154 | + } |
| 155 | + ShuffleCopy { |
| 156 | + inputs 2 |
| 157 | + red red |
| 158 | + blue black |
| 159 | + alpha black |
| 160 | + name ShuffleCopy2 |
| 161 | + xpos -353 |
| 162 | + ypos 83 |
| 163 | + } |
| 164 | + Multiply { |
| 165 | + value {{parent.details_weight}} |
| 166 | + name Multiply3 |
| 167 | + xpos -353 |
| 168 | + ypos 119 |
| 169 | + } |
| 170 | + Dot { |
| 171 | + name Dot8 |
| 172 | + xpos -319 |
| 173 | + ypos 188 |
| 174 | + } |
| 175 | + Merge2 { |
| 176 | + inputs 2 |
| 177 | + operation plus |
| 178 | + name Merge2 |
| 179 | + xpos -577 |
| 180 | + ypos 184 |
| 181 | + } |
| 182 | + Multiply { |
| 183 | + value 0.5 |
| 184 | + name Multiply4 |
| 185 | + xpos -577 |
| 186 | + ypos 229 |
| 187 | + disable {{!proxy}} |
| 188 | + } |
| 189 | + Expression { |
| 190 | + temp_name0 mag |
| 191 | + temp_expr0 sqrt(pow(r,2)+pow(g,2)+pow(b,2)) |
| 192 | + expr0 mag>1?r/mag:r |
| 193 | + expr1 mag>1?g/mag:g |
| 194 | + name Expression3 |
| 195 | + xpos -577 |
| 196 | + ypos 283 |
| 197 | + disable {{!parent.normalize}} |
| 198 | + } |
| 199 | + Expression { |
| 200 | + temp_name0 facing |
| 201 | + temp_expr0 sqrt(-pow(r,2)-pow(g,2)+1) |
| 202 | + expr2 isnan(facing)?0:facing |
| 203 | + name Expression2 |
| 204 | + xpos -577 |
| 205 | + ypos 322 |
| 206 | + } |
| 207 | + Remove { |
| 208 | + operation keep |
| 209 | + channels rgb |
| 210 | + name Remove1 |
| 211 | + xpos -577 |
| 212 | + ypos 354 |
| 213 | + } |
| 214 | + Grade { |
| 215 | + white 0.5 |
| 216 | + add 0.5 |
| 217 | + white_clamp true |
| 218 | + name Grade1 |
| 219 | + xpos -577 |
| 220 | + ypos 397 |
| 221 | + disable {{!parent.zerotoone}} |
| 222 | + } |
| 223 | + Output { |
| 224 | + name Output1 |
| 225 | + xpos -577 |
| 226 | + ypos 479 |
| 227 | + } |
| 228 | +end_group |
0 commit comments