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