Thanks Jonathan, Haven't had time to get back to this, but it does sound like I might want to bind an attribute to the primitives. Thanks for the tip!
On Thu, Sep 15, 2011 at 10:21 AM, Jonathan Egstad <jegs...@earthlink.net>wrote: > > I suppose there isn't a way for a Material to modify the VertexContext > in vertex_shader, but still pass the original VertexContext to the shading > tree, right? > > So the VertexContext passed up the vertex_shader() call is not the same > VertexContext that is passed up the fragment_shader() call, so they don't > share any data. You can see the fragment shader VertexContext's > initialization in Render.h while the vertex shader's is hidden in the > Primitive::vertex_shader() method. > > ...and there's currently no way to communicate from the vertex_shader() to > the fragment_shader() except via the varying data array and through > attributes bound to the Primitive. > > Also the 'rules' about modifying the VertexContext during the > vertex_shader() call are unclear so some shaders modify the current context > and some don't. Some copy the current context to a new one, modify the new > one and send it up the tree and some don't. > > > > The thing is, I've been using some of the predefined attributes to pass > arbitrary data to the fragment_shader. My only concern is that if you stack > another material that wants to use that attribute, it will pick up my > modified VertexContext, right? > > Not a big deal, since this material is rather specific, but just wanted > to see if there was a different way to tackle this. > > Yes, so you may want to try binding an attribute to the Primitive during > vertex shading. Hopefully it'll persist to the fragment shader stage. The > VertexContext contains a scene pointer so try calling > 'writeable_attribute()' on the Scene's object_list() and setting the > attribute - it *should* work... > > What's missing is robust message passing support between shaders > (vertex<->fragment<->light) and a way to declare attributes that are bound > to a shader context and persist through to the fragment shading stage. > > So the bottom-line is that Nuke's shading system is very rudimentary and > had very little development done on it while Nuke was at DD so it's not well > defined. And I don't see any significant changes in this area since the > Foundry has taken over. > > > Hack away...! :) > > -jonathan > > > > On Wed, Sep 14, 2011 at 3:23 PM, Jonathan Egstad <jegs...@earthlink.net> > wrote: > > > Is it possible to add attributes other than the predefined ones to a > VArray passed through the vertex shader, and have the vertex_shader > interpolate them? > > > > Short answer - not really... > > > > Long answer - the VArray structure was originally just a wrapper around a > Pixel structure which contained 1024 floats. The Channel3D assignments were > defaults with the ability to declare add'l varying attributes - but it was > quickly identified as a memory hog during rasterization and was trimmed down > drastically. Unfortunately much of the varying attribute support went away > with that change - and the AttribContext copy_to_channels() is a remnant. > > > > The ultimate answer is to not pre-cache all the interpolating vertex data > as is done now but to generate it on demand - I think with today's CPUs and > the large number of engine threads that swapping CPU time for memory in this > part of the algorithm (you'd end up recalculating the same vertex data > possibly hundreds of times) would be a big win - especially since rendering > large poly scenes can often take a machine into swap. > > > > -jonathan > > > > > > > So far, if I want to pass some arbitrary info onto the fragment_shader, > I've just been forcing it into any of the predefined slots (PW, PL, N...) > that I don't need in the fragment shader. > > > But I was wondering if it's possible to add new attributes. > > > > > > I notice AttribContext has a "copy_to_channels" method that sounds like > I could use for this, but I'm not sure how to go about creating a new > AttribContext, and filling it with my data. > > > > > > In any case, would that be the best approach to append arbitrary data > to a Varray? Can anyone share any pointers/examples/help? > > > > > > Many thanks, > > > Ivan > > > _______________________________________________ > > > 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 > > > > _______________________________________________ > > 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 >
_______________________________________________ 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