View Full Version : Control Vertex color changing
Hey guys, I was wondering if someone could help show me how to do this...
I have a nurbs plane with a shader on it, lets say a blinn, and what i want to do is when i grab a control vertex and translate it, have the color change according to its height....I've been trying to get it to work for a while now, but haven't gotten it workin yet
Thanks
Norb
|
|
mark_wilkins
01-18-2003, 03:25 AM
you mean the color of just that vertex, or the color of the entire plane based on the position of that vertex?
-- Mark
just the area that gets displaced by the movement of that vertex, so i guess you can say just that vertex
Norb
mark_wilkins
02-16-2003, 12:46 PM
OK, well this isn't EXACTLY what you were looking for, because it's continuous over the surface rather than by vertex, but here I'm assigning a color to each point on the surface based on its height in world space Y:
mark_wilkins
02-16-2003, 12:55 PM
Here's the shading network as you'd see it in HyperShade.
I use a samplerInfo node's Point World Y attribute to grab the world space Y position of whatever point is being shaded. I'm going to use Y position to determine the hue of the shaded point.
That gets plugged into the input 1 X attribute of a multiplyDivide node that multiplies by an appropriate number, which I type into input 2 X in the attribute editor. For this surface, where the maximum height was about 5 units, I chose 50, because hue is in degrees and 5 times 50 is about 250, which will cover most of the hue range from 0 to 360.
Output X of the multiplyDivide node gets plugged into the Input HSV R attribute, which is the hue, of an HSV to RGB node. (This is a bit confusing. Maya wants to call color triplets "R," "G," and "B," even if the node's interpreting them in a different space, like HSV. So, the Input HSV R input is Hue, the Input HSV G input is Saturation, and the Input HSV B input is Value. Just a weird naming thing.)
Again, in the attribute editor, I have to open up the HSV to RGB node to edit the input HSV color. The hue setting doesn't matter, as it's driven by the connection with the multiplyDivide node, but saturation and value should be cranked up because they're driven by nothing but my setting them by hand.
Finally, the output RGB attribute gets plugged into the Color attribute of a shader. I used a Lambert, but a Blinn works just the same way.
This is not per-vertex. Instead, it's calculated per shaded pixel. However, it does change the surface's color based on its height.
-- Mark
CGTalk Moderation
01-14-2006, 04:02 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.