CGTalk > Software > Autodesk Maya
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 04-30-2013, 11:09 PM   #1
cwisbg
PRO
 
cwisbg's Avatar
portfolio
Brandon Gillespie
generalist
High Impact
Denver, USA
 
Join Date: Aug 2007
Posts: 173
Send a message via AIM to cwisbg
Shader based on face angle

Im looking for what I think the mountain shader should be, maybe I haven't messed with it enough, but it was not giving me what I though it would do.
All I am after is a way to blend two textures based on the objects face angle. Example would be a mountain outcropping, faces pointing up get grass, and things that are say 90 will be dirt, and even better faces that point down will get rocks.
I was messing with sample info and trying to get that to work, similar to a camera facing ratio shader but no dice. Anyone know the secret recipe?
__________________
www.cwisbg.com
 
Old 05-01-2013, 02:19 AM   #2
VB2341
Frequenter
portfolio
Varun Bajaj
Troy, US
 
Join Date: Jan 2013
Posts: 125
There's two ways to do it, one using sampler info, and the other way using a baked normal map, the results will basically be the same.

The sampler info node can give you the camera normal (normals with respect to camera). If you use the vectorProduct node, plug in the camera normal and matrixEyeToWorld attributes of the sampler info, you will have world space normals. You can also use texture map extraction and extract a normal map (projected onto a plane). This probably isn't the best way though, using the sampler info would allow you to have a fully procedural workflow.

Basically, the y component of the world normal will tell you the slope of a surface. If the y component is 1 (and the vector is normalized) the face normal points straight up, if it's 0, then the face normal is pointing solely in the XZ plane (horizontally). If it's -1 the face is pointing straight down.

Taking the dot product between the normal vector and the vector 0 1 0 using the vectorProduct node, and checking the normalize output box will give you the y component of the face normal. Some of the results may be negative, if the face normal points down. Keep that in mind when driving your ramps or whatever else.
 
Old 05-01-2013, 02:21 AM   #3
petey
Veteran
 
petey's Avatar
Pete Shand
Melbourne, Australia
 
Join Date: Apr 2006
Posts: 75
Hey, sounds like you're on the right track.

There's a common method which involves using the sampler info node and a ramp to shade based on the facing angle.

I've attached a screen grab below. Basically you need to connect the "facingRatio" attribute from the sampler info to the "uvCoord>vCoord" of the ramp. You can then apply different colours/textures to different bits of the ramp.

 
Old 05-01-2013, 06:28 PM   #4
Duncan
Expert
 
Duncan's Avatar
Duncan Brinsmead
Principal Scientist
Autodesk
Canada
 
Join Date: Jun 2002
Posts: 2,984
Facing ratio is based on view angle, so it won't work for what he wants.

Instead try using a snow texture. You can texture the two colors. Rotating the 3D placement node rotates the up direction for the snow. You can also do things likes texture the threshold to make the boundary irregular. Or if you have a bump map you may wish to connect the bump outNormal to the snow normalCamera.
 
Old 05-04-2013, 03:29 PM   #5
pshipkov
PRO
portfolio
pshipkov a
AF
 
Join Date: Jun 2010
Posts: 82
I have this tension node. In one of its modes it can measure angles between edges and generate map based on that. This will allow you achieve what you are after.
 
Old 05-04-2013, 05:09 PM   #6
cwisbg
PRO
 
cwisbg's Avatar
portfolio
Brandon Gillespie
generalist
High Impact
Denver, USA
 
Join Date: Aug 2007
Posts: 173
Send a message via AIM to cwisbg
I think the snow node will do it for us. I would however be interested in this tension node, sounds very useful. Thanks for all the replies!
__________________
www.cwisbg.com
 
Old 05-04-2013, 05:09 PM   #7
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:51 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.