Wiki

Reference Geometry for Curves

Because RiCurves surfaces are specified as a central curve and a width, it is often not possible to directly use a “vertex point Pref” as with other primitives. The problem is that this value will not change over the width of the curve; it will always provide the point at u = 0.5. This may not be a major issue for thin curves but fur larger ones it makes the technique useless.

The following shader illustrates how to compute a good reference point for curve primitives, with or without reference normals and with both types of projections. Note that because curves are specified using a point and optional width and normal at every vertex, a reference point and optional reference width and reference normal are also needed. The default values this shader uses for Nref and widthref allow it to behave exactly like the curve primitive when N or width are not specified.

In its current form, it computes a correct Pref (called realPref) and simply displaces the curve there to demonstrate its correctness. Real world shaders would integrate realPref into their shading process in different ways, of course.

surface curve_pref( varying point Pref = 0; varying normal Nref = 0; varying float widthref = 1 ) { vector dPrefdv = Dv(Pref); vector dPrefdu; if( Nref != normal(0,0,0) ) { dPrefdu = dPrefdv ^ normalize(Nref); } else { uniform matrix proj = matrix “raster” 1; if( comp(proj, 2, 3) == 0 && comp(proj, 3, 3) == 1 ) { dPrefdu = vector(0,0,1) ^ dPrefdv; } else { dPrefdu = normalize(vector(Pref)) ^ dPrefdv; } } uniform vector unit = vector “object” (1 / sqrt(3)); uniform float wscale = length(unit); point realPref = Pref + normalize(dPrefdu) * wscale * widthref * (u - 0.5); P = realPref; float diffuse = I.N; diffuse = (diffuse*diffuse) / (I.I * N.N); Ci = Cs * diffuse; Oi = Os; Ci *= Oi; }

  • The ‘proj’ matrix is used to differentiate between perspective and orthographic projections which orient the curve differently when N is not supplied.
  • The ‘unit’ vector is used to account for the fact that ‘width’ is supplied in object space for curve primitives.
 
reference_geometry_for_curves.txt · Last modified: 2011/01/29 08:17
 

You are here: Resources » Wiki
Follow us on Twitter
© 2006-2011 dna research. All Rights Reserved.
Trademarks & Copyrights Notices