From what I can tell, 'pw' is an array of 'Channel's, probably a knob storage 
var (meant to represent the channels picked as P-World).

In your foreach, 'z' will be a Channel.

As for ChannnelSet vs. ChannelMask, I'm not in front of the NDK headers right 
now so I could be misremembering, but I believe one of them is slowly being 
phased out in favor of the other. I think ChannelMask is on the way out, but 
needs to be kept around for the time being for source compatibility.

-Nathan


On May 17, 2012, at 7:32 AM, "Steven Booth" <sbo...@legend3d.com> wrote:

> Jordan,
> 
> Before I deal with this, one question.  What is your definition of 'pw', 
> because it can't be a 'ChannelSet'.  Is it an array of ChannelSet's?  An 
> array of 'Channel's?
> 
> Steve
> 
> -----Original Message-----
> From: nuke-dev-boun...@support.thefoundry.co.uk 
> [mailto:nuke-dev-boun...@support.thefoundry.co.uk] On Behalf Of Jordan Olson
> Sent: Wednesday, May 16, 2012 4:01 PM
> To: Nuke plug-in development discussion
> Subject: Re: [Nuke-dev] Inexperienced NDK simple question on pixelIop channels
> 
> Hey Steve,
> thanks heaps for your writeup! To give you an idea of my background, I've 
> been comping and python scripting Nuke for a few years, but only recently 
> attended a class for C++ and am diving into the NDK. So I'm still fairly new 
> to the NDK and C++ in general.
> 
> 
> When you explained that 'channels' may only contain channels being requested 
> of the node by nodes downstream, that was a pretty revolutionary perspective 
> change for me!
> 
> Though adding the if(ch_pw) doesn't prevent the node from crashing, I think 
> we're getting somewhere.
> 
> A couple questions;
> 
> -- When running foreach(z, channels); I presume based on your explanation 
> that "z" does not represent an integer? for some reason I was thinking it 
> represented an integer (which is why I used it to index pw[z])- because I 
> assumed "z" would be an integer range from 0-3.
> If I understand you right, "z" could actually be a "Depth.Z" channel and not 
> an integer like 1. So unless the point world knob contains Depth.Z (which it 
> wouldn't) this would always be NULL.
> 
> -- How are the ChannelMask and ChannelSet classes different from each other? 
> (and even with the class method PointSample:in_channels() ChannelSet& is 
> defined as "mask" which I find confusing).
> 
> I'm re-reading the documentation again- although I'm hacking together code 
> from alot of different source examples, I still don't really get how to bring 
> in a specified layer and access those channels..
> 
> Cheers,
> Jordan
> 
> 
> 
> On Thu, May 17, 2012 at 3:43 AM, Steven Booth <sbo...@legend3d.com> wrote:
>> Jordan,
>> 
>> 
>> 
>> I think I see what might be the problem here.  You define ch_'pw' like 
>> this
>> 
>> 
>> 
>> Channel ch_pw = pw[z];
>> 
>> 
>> 
>> And then use it like this:
>> 
>> 
>> 
>>                 const float* pw_ptr = in[ch_pw] + x;
>> 
>> 
>> 
>> Here's the secret: You have absolutely no guarantee what 'channels'
>> contains.  'channels' are the channels *being requested of you by the 
>> downstream node*.  If you hook a shuffle up to your node (Op), and 
>> shuffle Depth.Z into R, then 'Depth.Z' is going to be placed into the 
>> 'channels'
>> ChannelSet passed to your _engine call.
>> 
>> 
>> 
>> If, then, your 'point world' ChannelSet isn't requested, or isn't 
>> fully requested, then pw[z] is going to eventually return NULL.  That 
>> makes 'ch_pw' NULL, and when you do the 'in[ch_pw]', *that* is going 
>> to be null, which makes pw_ptr NULL, which kind of makes:
>> 
>> 
>> 
>>                 float a = *pw_ptr++;
>> 
>> 
>> 
>> somewhat (well. more like 'really') invalid.
>> 
>> 
>> 
>> What you always need to do is make sure the channel you're processing 
>> is actually being asked for. that your channel references are non-null so:
>> 
>> 
>> 
>>                 Channel ch_pw = pw[z];
>> 
>>                 If (ch_pw) {
>> 
>>                                 . code that uses 'ch_pw'
>> 
>>                 }
>> 
>> 
>> 
>> So, the inner code is only used if 'ch_pw' is not null.
>> 
>> 
>> 
>> Hope that helps
>> 
>> 
>> 
>> Steve
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> -----Original Message-----
>> From: nuke-dev-boun...@support.thefoundry.co.uk
>> [mailto:nuke-dev-boun...@support.thefoundry.co.uk] On Behalf Of Jordan 
>> Olson
>> Sent: Tuesday, May 15, 2012 5:56 PM
>> To: Nuke plug-in development discussion
>> Subject: [Nuke-dev] Inexperienced NDK simple question on pixelIop 
>> channels
>> 
>> 
>> 
>> hey fellow Nuke developers!
>> 
>> I'm writing a pixelIop node at the moment, and having difficulty 
>> figuring out some code.
>> 
>> 
>> 
>> I have an extra knob for "Point World" channelset, and to test it, I'm 
>> trying to copy the pixel values from this set into the standard 
>> channels specified by the user. (default RGBA).
>> 
>> However it's crashing, and I think I need to implement something like 
>> the following example taken from the IDistort Iop code:
>> 
>> 
>> 
>> 
>> 
>>   // missing channels will crash, use black instead:
>> 
>>   Channel uu = uv[0];
>> 
>>   Channel vv = uv[1];
>> 
>>   if (!intersect(tile.channels(), uu))
>> 
>>     uu = Chan_Black;
>> 
>>   if (!intersect(tile.channels(), vv))
>> 
>>     vv = Chan_Black;
>> 
>> 
>> 
>> 
>> 
>> However this ^ is from an Iop node, and I'm having a crash on a 
>> PixelIop. Is there a similar function I could implement on my pixel operator?
>> 
>> Here is my code below, slightly simplified for readability.
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> ............
>> 
>> 
>> 
>> void PointSample::_validate(bool for_real){
>> 
>>                 copy_info();
>> 
>>                 set_out_channels(Mask_All);
>> 
>> }
>> 
>> 
>> 
>> void PointSample::in_channels(int input, ChannelSet& mask) const {
>> 
>>                 mask += (pw[0]);
>> 
>>                 mask += (pw[1]);
>> 
>>                 mask += (pw[2]);
>> 
>> }
>> 
>> 
>> 
>> void PointSample::pixel_engine(const Row& in, int y, int x, int r, 
>> ChannelMask channels, Row& out) {
>> 
>>                 foreach (z, channels)
>> 
>>                 {
>> 
>>                                 const float* inptr = in[z]+x;
>> 
>>                                 const float* END = inptr+(r-x);
>> 
>> 
>> 
>>                                 Channel ch_pw = pw[z];
>> 
>>                 // This doesn't compile because the Pixel Iop has no 
>> tile functionality
>> 
>>                 /*
>> 
>>                                     if (!intersect(tile.channels(), 
>> ch_pw))
>> 
>>                                                     ch_pw = 
>> Chan_Black;
>> 
>>                 */
>> 
>> 
>> 
>>                                 const float* pw_ptr = in[ch_pw] + x;
>> 
>>                                 float* outptr = out.writable(z)+x;
>> 
>> 
>> 
>>                                                 while (pw_ptr < END)
>> 
>>                                                 {
>> 
>>                                                                 float 
>> a = *pw_ptr++;
>> 
>>                                                                 
>> *outptr++ = a;
>> 
>>                                                 }
>> 
>> 
>> 
>>                 }
>> 
>> }
>> 
>> 
>> 
>> ............
>> 
>> 
>> 
>> 
>> 
>> cheers if you could point out why this is crashing!
>> 
>> Jordan
>> 
>> _______________________________________________
>> 
>> Nuke-dev mailing list
>> 
>> Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ 
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>> 
>> (CONFIDENTIALITY NOTICE: The information contained in this email may 
>> be confidential and/or privileged. This email is intended to be 
>> reviewed by only the individual or organization named above. If you 
>> are not the intended recipient, or an authorized representative of the 
>> intended recipient, you are hereby notified that any review, 
>> dissemination or copying of this email, or the information contained 
>> herein is strictly prohibited. If you have received this communication 
>> in error, please notify the sender by return email and delete this 
>> email from your system. Thank You.)
>> 
>> 
>> _______________________________________________
>> Nuke-dev mailing list
>> Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ 
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>> 
> _______________________________________________
> Nuke-dev mailing list
> Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ 
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
> (CONFIDENTIALITY NOTICE: The information contained in this email may be 
> confidential and/or privileged. This email is intended to be reviewed by only 
> the individual or organization named above. If you are not the intended 
> recipient, or an authorized representative of the intended recipient, you are 
> hereby notified that any review, dissemination or copying of this email, or 
> the information contained herein is strictly prohibited. If you have received 
> this communication in error, please notify the sender by return email and 
> delete this email from your system. Thank You.)
> 
> _______________________________________________
> Nuke-dev mailing list
> Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
_______________________________________________
Nuke-dev mailing list
Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev

Reply via email to