Hi Nathan, When you call image->request() within draw_handles(), I think you either need to update the "count" each time, or you can use new_request_pass() right before your request() call.
I believe that might help. Cheers, Ivan On Wed, Mar 28, 2012 at 11:44 AM, Nathan Rusch <nathan_ru...@hotmail.com> wrote: > Hey all, > > I’ve got a NoIop that does some OpenGL drawing based on its input image > (drawing GL points from input pixels). Currently it works in most cases, but > as soon as I add a node somewhere upstream of it while viewing the 3D view, > I get the infamous "get(channels=0xf), but request() not called" warning and > my source channels come in all black. > > My drawing code is based on Johannes’ js_ColorCube (many thanks for putting > that out there), but since that was apparently never really finished, I’m > not 100% sure the approach I’m using is safe/legal as far as fetching the > input image data is concerned. I’m curious if anyone can point out any > issues with my code that may be causing this behavior, since I know I’m not > the first person to do this. > > Here are what I believe to be the relevant pieces of code (sorry for the > long message): > > /////////////////////////////////////////////////////////////////////// > enum {LUMA_709, LUMA_601, HUE, SAT, VAL, CHANNEL}; > // These are hooked to an Enumeration_knob > const char* const valueTypes[] = {"luminance (rec709)", > "luminance (rec601)", > "hue", > "saturation", > "value", > "channel", > 0}; > > class Hist3D : public NoIop { > Channel _sourceChannels[3]; > Channel _customChannel; > Hash _lastHash; > float _whScale, _zScale, _bboxZ; > int _glDisplayListID, _pointSize, _valueType; > unsigned int _bboxShadeColor; > bool _draw, _drawBBox, _shadeBBox; > > public: > Hist3D(Node* node) : NoIop(node) { > _sourceChannels[0] = Chan_Red; > _sourceChannels[1] = Chan_Green; > _sourceChannels[2] = Chan_Blue; > _customChannel = Chan_Z; > _whScale = _zScale = _bboxZ = 1.0f; > _glDisplayListID = -1; > _bboxShadeColor = 0x2d2d2dff; // ~.18 > _pointSize = 2; > _draw = _drawBBox = true; > _shadeBBox = false; > _valueType = LUMA_709; > _lastHash.reset(); > } > > bool doAnyHandles(ViewerContext* ctx) { > return ctx->transform_mode() != VIEWER_2D; > } > > void build_handles(ViewerContext* ctx) { > // Don't draw unless viewer is in 3D mode > if (ctx->transform_mode() == VIEWER_2D) return; > > NoIop::validate(false); > build_input_handles(ctx); > add_draw_handle(ctx); > > const float aspect = (float) info_.format().width() / (float) > info_.format().height(); > ctx->expand_bbox(node_selected(), 0.0f, 0.0f, 0.0f); > ctx->expand_bbox(node_selected(), aspect * _whScale, _bboxZ * > _zScale, -_whScale); > } > > float rgbToZ(float r, float g, float b) { > // ** STUB ** > // Resolves an RGB triplet to its Z value based on _valueType > ; > } > > void updatePointList(Iop* image) { > if (!image || !_draw) return; > > image->validate(true); > > const int iw = image->format().width(); > const int ih = image->format().height(); > const float aspect = (float) iw / (float) ih; > const double glInc = (1.0 / (double) ih); > > ChannelSet req; > req += _sourceChannels[0]; > req += _sourceChannels[1]; > req += _sourceChannels[2]; > if (_valueType == CHANNEL) req += _customChannel; > image->request(0, 0, iw, ih, req, 1); > > if (_glDisplayListID != -1) glDeleteLists(_glDisplayListID, 1); > > _glDisplayListID = glGenLists(1); > > glNewList(_glDisplayListID, GL_COMPILE); > { > glBegin(GL_POINTS); > { > if (_valueType == CHANNEL) { > for (int y = 0; y < ih; y++) { > Row row(0, iw - 1); > image->get(y, 0, iw - 1, req, row); > > for (int x = 0; x < iw; x++) { > const float* r = row[_sourceChannels[0]] + x; > const float* g = row[_sourceChannels[1]] + x; > const float* b = row[_sourceChannels[2]] + x; > const float* val = row[_customChannel] + x; > > glColor3f(*r, *g, *b); > glVertex3f(x * glInc, y * glInc, *val); > } > } > } > else { > for (int y = 0; y < ih; y++) { > Row row(0, iw - 1); > image->get(y, 0, iw - 1, req, row); > > for (int x = 0; x < iw; x++) { > float r = *(row[_sourceChannels[0]] + x); > float g = *(row[_sourceChannels[1]] + x); > float b = *(row[_sourceChannels[2]] + x); > > glColor3f(r, g, b); > glVertex3f(x * glInc, y * glInc, rgbToZ(r, g, > b)); > } > } > } > } > glEnd(); > } > glEndList(); > } > > void draw_handle(ViewerContext* ctx) { > if (ctx->draw_solid()) { > Iop* image = dynamic_cast<Iop*>(input(0)); > > if (image) { > Hash imageHash = image->hash(); > imageHash.append(_draw); > imageHash.append(_sourceChannels[0]); > imageHash.append(_sourceChannels[1]); > imageHash.append(_sourceChannels[2]); > imageHash.append(_customChannel); > imageHash.append(_valueType); > imageHash.append(_zScale); > imageHash.append(_whScale); > imageHash.append(_pointSize); > imageHash.append(_drawBBox); > imageHash.append(_shadeBBox); > imageHash.append(_bboxShadeColor); > imageHash.append(_bboxZ); > > // If necessary, recompile GL list > if (imageHash != _lastHash) { > _lastHash = imageHash; > updatePointList(image); > } > > // Do the actual drawing > if (_draw && _glDisplayListID != -1) { > glPushMatrix(); > glRotatef(-90, 1, 0, 0); > glScalef(_whScale, _whScale, _zScale); > glPointSize(_pointSize); > glCallList(_glDisplayListID); > glPopMatrix(); > } > } > } > } > }; > /////////////////////////////////////////////////////////////////////// > > Thanks a lot for any thoughts, > > -Nathan > > > _______________________________________________ > 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