mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
[Pixel Math] Add comparison operators.
This commit is contained in:
parent
d73d2de662
commit
917165eca6
3 changed files with 15 additions and 3 deletions
|
@ -27,7 +27,7 @@ function Node_Pixel_Math(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
|||
__init_mask_modifier(2); // inputs 5, 6,
|
||||
|
||||
_scroll = array_clone(global.node_math_scroll, 1);
|
||||
array_append(_scroll, ["Less than", "Greater than"]);
|
||||
array_append(_scroll, ["Less than", "Less than equal", "Greater than", "Greater than equal"]);
|
||||
newInput(7, nodeValue_Enum_Scroll("Operator", self, 0, _scroll));
|
||||
|
||||
newInput(8, nodeValue_Vec4("Operand", self, [ 0, 0, 0, 0 ]));
|
||||
|
|
|
@ -92,8 +92,8 @@ void checkPixel(vec2 px, vec2 p) {
|
|||
if(side == 0 && crop_border == 1 && (txs.x < 0. || txs.x > 1. || txs.y < 0. || txs.y > 1.)) return;
|
||||
|
||||
vec4 sam = sampleTexture( gm_BaseTexture, txs );
|
||||
if(side == 0 && sam.a > 0.) return; //inside border, skip if current pixel is filled
|
||||
if(side == 1 && sam.a < 1.) return; //outside border, skip if current pixel is empty
|
||||
if(side == 0 && sam.a == 1.) return; //inside border, skip if current pixel is filled
|
||||
if(side == 1 && sam.a == 0.) return; //outside border, skip if current pixel is empty
|
||||
|
||||
isOutline = true;
|
||||
|
||||
|
|
|
@ -109,11 +109,23 @@ void main() {
|
|||
res.a = 1.;
|
||||
|
||||
} else if(operator == 19) {
|
||||
res.r = res.r <= op.r? 1. : 0.;
|
||||
res.g = res.g <= op.g? 1. : 0.;
|
||||
res.b = res.b <= op.b? 1. : 0.;
|
||||
res.a = 1.;
|
||||
|
||||
} else if(operator == 20) {
|
||||
res.r = res.r > op.r? 1. : 0.;
|
||||
res.g = res.g > op.g? 1. : 0.;
|
||||
res.b = res.b > op.b? 1. : 0.;
|
||||
res.a = 1.;
|
||||
|
||||
} else if(operator == 21) {
|
||||
res.r = res.r >= op.r? 1. : 0.;
|
||||
res.g = res.g >= op.g? 1. : 0.;
|
||||
res.b = res.b >= op.b? 1. : 0.;
|
||||
res.a = 1.;
|
||||
|
||||
}
|
||||
|
||||
gl_FragColor = res;
|
||||
|
|
Loading…
Reference in a new issue