Thank you for the, answered all my questions and was able to get my
material shader to work as expected, would be great to get that
information into the Nuke documentation.

I'm using the GeoInfo point vertices to try and determine the point
location within the primitive, so this seemed like the easiest
solution to do so and is working quite well for me. Not quite sure how
to do this in the nuke vertex_shader but am always up for suggestions.

Cheers,
Josh

On Sat, Apr 9, 2011 at 5:44 PM, Jonathan Egstad <[email protected]> wrote:
> GeoInfo point vertices are not normally accessed in a Material except during 
> the vertex_shader() call, and then you're only dealing with the current 
> vertex.
>
> The Material fragment_shader() method use interpolated values that are 
> assigned during vertex_shader() and are accessible via the passed-in 
> VertexContext structure which is built by the renderer as it walks across the 
> scanline.
>
> IllumShader::surface_shader() is called from within 
> IllumShader::fragment_shader() and it precalculates P, V and N from the 
> VertexContext by dividing out w like so:
>    Vector3 P = vtx.PW() / vtx.w();
>    Vector3 V = vtx.scene()->cam_vectors.p - P; V.normalize();
>    Vector3 N = vtx.N() / vtx.w(); N.normalize();
>    surface_shader(P, V, N, vtx, surface);
>
> It also handles the alpha blending logic in an attempt to make it easier to 
> write a simple surface shader.
>
> The complication of Nuke shaders vs. Renderman surface shaders is that Nuke 
> shaders work more like Renderman co-shaders which require significantly more 
> management of the shading process than the traditional monolithic surface 
> shaders.
>
> -jonathan
>
> On Apr 9, 2011, at 9:15 AM, Josh Imbruglia wrote:
>
>> I'm having problems calculating the world space coordinates of the
>> primitives in the material's fragment_shader(const VertexContext &,
>> Pixel &out) function.
>>
>> If I use the following code in an IllumShader I get the correct
>> coordinates, but in the material it's incorrect. If anyone knows why
>> this is the case and can shed some light on it, I would be greatly
>> appreciated. Also, how does the IllumShader calculate the point P for
>> the surface_shader function?
>>
>> int count = vtx.primitive()->vertices();
>> for (int i = 0; i < count; ++i)
>>    vtx.geoinfo()->matrix *
>> Vector4(vtx.geoinfo()->point_array()[vtx.primitive()->vertex(i)],
>> 1.0)).truncate_w();
>>
>> Thanks!
>> Josh
>> _______________________________________________
>> Nuke-dev mailing list
>> [email protected]
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>
> _______________________________________________
> Nuke-dev mailing list
> [email protected]
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>
_______________________________________________
Nuke-dev mailing list
[email protected]
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev

Reply via email to