mmontoya Posted September 3, 2007 Share Posted September 3, 2007 In an attempt to fully take in the procedural goodness of Houdini, I wanted to solicit od[members'] suggestions for how one might go about creating a procedural shader to simulate the multicolored patterns of a Coleus leaf. [see images below] Central to a successful implementation is the following question: Is it possible for a shader to be geometry-aware? This would be necessary for the shader to modulate it's color and pattern based on P's distance to the leaf's edges and/or veins. One method might be to use a Measure SOP to create poly groups based on area (if one extrudes a base leave to have thickness (intead of using a simple plane) the resulting edge poly's will have less area than those on the surfaces). Another idea might be to create the central veins of the leaf usign nurbs curves (or L-system rules) and calculate the distance of shading point P from a given point on the vein curve. Beyong a certain jittered distance, we would begin introducing another color and/or texture. Though I can grok the logic necessary to create such a shader, as a Houdini newbie, the concrete implementation details are currently beyond me. Any thoughts? Your help is greatly appreciated. 1 Quote Link to comment Share on other sites More sharing options...
photex Posted September 4, 2007 Share Posted September 4, 2007 Is it possible for a shader to be geometry-aware? Off the top of my head: Point attributes applied to the geometry and used in a shader as a parameter, UVs perturbed by noise or some such doohickey or the built-in variable P == point position in the shader (get it from the globals vop if you're aren't writting it by hand). I don't mean to make any of that sound like some simple obvious solution, this looks like a really good challenge! Hope you don't mind me giving it a shot. _chip Quote Link to comment Share on other sites More sharing options...
mmontoya Posted September 4, 2007 Author Share Posted September 4, 2007 (edited) Hope you don't mind me giving it a shot. Not at all, that's the whole point of my post! I agree that one definitely would need to get P from the Globals in the VEX shader, but it seems to me that one would also need to evaluate the distance of P from a given reference. Given the axial bias on the leaves' patterns, it seems like the most logical thing to do would be to create a longitudinal "vein" using a NURBS curve that runs the length of the leaf and then use a progressing value along U on this curve. The thing is, how do we tell the shader where along U to perform the distance lookup? If the leaf were a parametric NURBS patch it would be easy enough to use equivalent values of U for the patch as well as the curve. For a poly, this gets more complex - one possibility would be to align the UV coords axially to coincide with the leaf's major axis. Increasing values of U on the vein (which would be normalized in the range from 0 - 1) would then correspond to increasing values of U in the leaf's texture map in the correct direction. While this seems straightforward for a mono-vein, it begs the question - how do we deal with a more complex (and realistic) branching vein? How would be able to step through increasing values in this scenario? It seems like we would need some sort of recursive binary search algorithm to deal with the branches until we come to a leaf node and then go back to the last branch (much like the governing logic in L-Systems) until we've exhausted all possible branches. (Again, the devil is in the [implementation] details - how to go about coding a mechanism like this within a shader?) As for the color modulation, one thought would be to create a CLUT (color lookup table) where we layout all the colors we want assigning their index to a given distance, namely delta P[x,y,z] - U[x,y,z] (in shader space [for scalability]). Jittering these distance would create rough, noise-like boundaries between the colors instead of abrupt transitions. I haven't yet seen a shading challenge on this forum - if this seems like an attractive candidate, by all means, I'd be very interested in seeing the many creative ways of implementing something like this! Any takers? Mario? Edited September 4, 2007 by mmontoya Quote Link to comment Share on other sites More sharing options...
mmontoya Posted September 5, 2007 Author Share Posted September 5, 2007 (edited) I've reconsidered my approach - After a little research the following two approaches stand out: 1. Point Cloud - I'm thinking the organic color patterns could be generated using a Scatter SOP to generate a point cloud on the leaf's surface with points that would have the desired colors for the leaf pattern. One approach would be to progressive transform the leaf through several iterations using a PeakSOP, each time scattering points until we reach the target leaf boundaries (the rendering leaf - utilizing as many iterations as there are desired color gradients). Using a custom Vex SOP, we could then look up the scattered points from a given reference (could be the vein) and use this to add additional pertubation based on distance to our final color. 2. Attribute Transfer - This approach seems much simpler (and likely faster), which is to simply use a LineSOP with the point attributes defining the colors we desire and transfer it's color to the leaf's surface using an Attribute Transfer SOP. This solves the problem of how to use multiple branching veins posed above. I'll give these two a shot, and post back with results. Edited September 5, 2007 by mmontoya Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.