View Full Version : Shading using angles/normals?
DJSmackMackey 09-28-2003, 07:02 PM Does anyone know a way to shade an object based on the angle of the normals? Meaning, if I have a mesh, is there a way to use a ramp to shade the object depending on how the faces are angled toward each other? I suppose it would be vertex shading of some kind. I'd want it so that if the angle was 0 it would be blue, and if the angle was 180, it would be red, and any angle in between would be shaded somewhere in between red and blue. This probably makes no sense at all, but if anyone can point me in the right direction, I'd appreciate it.
|
|
jeremybirn
09-28-2003, 07:11 PM
Sure, you said "ramp" so I guess this is a Maya question - in Hypershade just connect the Normal Camera Z (or facing ratio) outputs of a Sampler Info node, to the U param input of the Ramp texture.
If you don't like hypershade there's also a Material called "Ramp" (that's a new Material, not the texture with the same name) that includes some built-in gradients based on angle - but most people prefer to set things up themselves in hypershade.
-jeremy
DJSmackMackey
09-28-2003, 07:20 PM
Is the U param the same as the U coord in connection editor?
If so, what that does is color my object using it's UV coordinates, not the engle of the faces to each other. I'm looking to color similar to how you can soften the edges of an object using the normals. but instead of softening the, I want to shade them with a ramp.
Thanks.
jeremybirn
09-28-2003, 07:27 PM
Yes, I meant to connect the facing ratio to the U coordinate, so that normal info is used (instead of UV coords of the geometry) in controlling the color of the ramp.
I'm not sure if this is exactly what you want, so I hope this suggestion is helpful, but it does give you entirely angle-driven or normal-driven control over a ramp, and you could use it to do something like make a sphere become transparent right at it's outer edges from any angle of view, etc.
-j
DJSmackMackey
09-28-2003, 07:35 PM
Oh, ok, I see what your saying. No, what I'm looking for is a way to shade based on the normals, not based on the view, but rather based on the angle of the faces to each other. So that, say from inside a model of a cube shaped room, the four edges where the walls meet and where the ceiling and floor meet the walls would be shaded red, but the closer to the center of each wall, the more blue they would be. But don't worry, it's really not all that important, I was just curious. Thanks though!
lazzhar
09-28-2003, 07:59 PM
Not sure, but i think you could use what's called Ambient Occlusion to get a shading in a room like that ? If you're using Mental Ray, there is a shader called DirtMap that could calculate AO for you.
DJSmackMackey
09-28-2003, 08:20 PM
Is that easy to set up? I'm planning on purchasing Maya 5 complete, which I believe comes with Mental Ray, so that would be perfect.
Originally posted by lazzhar
Not sure, but i think you could use what's called Ambient Occlusion to get a shading in a room like that ? If you're using Mental Ray, there is a shader called DirtMap that could calculate AO for you.
If he wants to color a surface depending on its curvature, I think u and v derivatives are rather what he wants, not AO. Don't know how MR handles that, though.
lazzhar
09-28-2003, 09:20 PM
Originally posted by DJSmackMackey
...No, what I'm looking for is a way to shade based on the normals, not based on the view, but rather based on the angle of the faces to each other....
AFAIK, AO uses distances between points on surfaces to calculate the shading.
I'm new into this stuff, but I'm thinkin if we could maximise the MAX distance of AO so the faces that its normals intersect get affected by each other.
In the case of a box room, i'm thinking it could be easy to use the gray pictures rendered with AO and play a bit to change its colors. to get a complicated shading we need rendering more passes !
As I said, I dont have good knowledges in this stuff, it's just an idea, who knows maybe it could help ;)
If I understand the initial poster correctly, this is the kind of shader he's after: A Normal derivative fed into a color ramp. See the attached screenshot.
lazzhar
09-28-2003, 09:43 PM
Could you explain what that 2 Nodes(in the right) are for? I guess it's on Cinema4D.
The very right node is the Nv derviative, the node to the left of it is an abs function, simply turning negative values into positive. Taking a second look at my shader, I realize that I made the stupid mistake of assuming Nv were a float where it's probably a vector (how come I can't find Nv in the RISpec3.2 document?). So you would want the magnitude of the derivative, which would not require the abs step any more. In order to shade bends in both u and v directions, you should add the magnitudes of Nv and Nu derivatives and plug them into the color ramp.
I hope this is not too confusing, I realize that my post may be very hard to understand.
BTW, it's Pixels, not Cinema.
DJSmackMackey
09-28-2003, 10:57 PM
Yes, that's exactly what I was trying to do! Thanks! Does anyone know how to do that in Maya?
augustus
09-29-2003, 09:49 AM
Maybe Phil Wittmer's curvaceous shader can help you.
http://www.modernmayhem.com/
CGTalk Moderation
01-14-2006, 10:00 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.