Skip to content

Instantly share code, notes, and snippets.

@U-MA
Last active April 18, 2020 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save U-MA/ad594d4561ea0876ef8a7665b99a9699 to your computer and use it in GitHub Desktop.
Save U-MA/ad594d4561ea0876ef8a7665b99a9699 to your computer and use it in GitHub Desktop.
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