Skip to content

Instantly share code, notes, and snippets.

@U-MA

U-MA/sample_merge.vfl

Last active Apr 18, 2020
Embed
What would you like to do?
VEX でカスタム COP 作成
#pragma opname sample_merge
#pragma oplabel "SampleMerge"
#pragma opmaxinputs 4
#pragma inputlabel 1 "R"
#pragma inputlabel 2 "G"
#pragma inputlabel 3 "B"
#pragma inputlabel 4 "A"
#pragma label useChannelOfR "Use channel of R"
#pragma choice useChannelOfR "0" "R"
#pragma choice useChannelOfR "1" "G"
#pragma choice useChannelOfR "2" "B"
#pragma choice useChannelOfR "3" "A"
#pragma label useChannelOfG "Use channel of G"
#pragma choice useChannelOfG "0" "R"
#pragma choice useChannelOfG "1" "G"
#pragma choice useChannelOfG "2" "B"
#pragma choice useChannelOfG "3" "A"
#pragma label useChannelOfB "Use channel of B"
#pragma choice useChannelOfB "0" "R"
#pragma choice useChannelOfB "1" "G"
#pragma choice useChannelOfB "2" "B"
#pragma choice useChannelOfB "3" "A"
#pragma label useChannelOfA "Use channel of A"
#pragma choice useChannelOfA "0" "R"
#pragma choice useChannelOfA "1" "G"
#pragma choice useChannelOfA "2" "B"
#pragma choice useChannelOfA "3" "A"
float sample(
int opinput;
int useChannel;
) {
vector4 c;
c = cinput(opinput, PL, IX, IY);
if (useChannel == 0) {
return c.x;
}
else if (useChannel == 1) {
return c.y;
}
else if (useChannel == 2) {
return c.z;
}
else {
return c.w;
}
}
cop2 sample_merge(
int useChannelOfR=0;
int useChannelOfG=0;
int useChannelOfB=0;
int useChannelOfA=0;
) {
R = sample(0, useChannelOfR);
G = sample(1, useChannelOfG);
B = sample(2, useChannelOfB);
A = sample(3, useChannelOfA);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.