Community
Arnold for Maya Forum
Rendering with Arnold in Maya using the MtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generating a Slope Mask for terrain texturing.

12 REPLIES 12
Reply
Message 1 of 13
Anonymous
1231 Views, 12 Replies

Generating a Slope Mask for terrain texturing.

I'm trying to create snow peak mountain and want the snow to only sit on the flatter section of the terrain. Obviously, on steep sections, there would be no snow. How do I do this in Max Arnold? I checked out utility and curvature nodes, but they don't seem to provide anything to create what I want. Thanks.

Tags (1)
Labels (1)
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

I found the answer. You can use the

1) State Vector - Set to N for Normals.

2) Use the Shuffle node and set it to B to isolate the up and down direction.

3) Use RGB Ramp to color the range or set the black and white paint. (Lower color point starts at .5 since normal map starting value is at .5 value.)

Hope this helps others.

Message 3 of 13
madsd
in reply to: Anonymous

Wrote this into an OSL shader.

2 features exposed:
- Power
- Slope

shader SnowMask
(
	float Power  = 4.0
	[[
		float min =0.03,
		float max = 100.
	]],
	float Slope = 0.5
	[[
		float min =  0.0,
		float max = 0.9999999
	]],		
	output color Out = 1.0
)
{
	Out = pow((N[2] - Slope) / .5, 1.0 / Power);
}

4556-3.jpg

4557-4.jpg

4558-5.jpg

Message 4 of 13
Anonymous
in reply to: Anonymous

Awesome, that is pretty awesome. Do you have an elevation feature? Higher the elevation, the more snow coverage.

Message 5 of 13
madsd
in reply to: Anonymous

No, but that could be build into it.

The Power value is snow density and we can map that out over a distance to thin out snow in lower parts while having a massive top.

You can do this with core nodes.

Message 6 of 13
Anonymous
in reply to: madsd

I added something to this effect in addition to adding 4 different sets of textures to build the terrain. It's working, but my node network is getting complicated. Would rather have a single node deal with it. Also would be nice if we can get the Randomizebitmap node to have a feather feature to tile texture without edge seams.

Message 7 of 13
madsd
in reply to: Anonymous

Here, with very low Power, it has only snowed a little. Map this over v channel and pipe to Power in a normalized range which fits the current frame.

This returns a situation where you can map the density out over hight.

4559-6.jpg

Message 8 of 13
madsd
in reply to: Anonymous

And finally,
Added density control over v, this is not a linear mask over some generic distribution, the altitude controls the amount it has snowed, it does not just fade out a constant procerudal over distance.

This way we can return both density inside a given range and play around with the slow in that particular range.

I just set it to thick mountain tops and then thin out relativly fast, so you can see effect is working.

4560-g.jpg

4561-gg.jpg

Message 9 of 13
madsd
in reply to: Anonymous

Check this reply.
It does exactly what you say, fade actual density/power over the hight of the terrain.
https://answers.arnoldrenderer.com/answers/19900/view.html

You would want to add a UVW map modifier to the mesh, planar mapping.
Catch this mapping with an OSL UVW map, same channel number.
Into a range node and work in the scales so the gradient from the map gets more contrasty, thats all you want to focus on, then pipe to Power on SnowMask shader and Hight controls density as well.

Message 10 of 13
Anonymous
in reply to: Anonymous

Awesome dude. Are you uploading the script somewhere where we mere mortals can play with it 🙂

Message 11 of 13
madsd
in reply to: Anonymous

It's the 17 lines of code in the code box in reply #1.

Select them and ctrl+c
Go into max and open the checker.osl node, and open the code window, select everything in there and press ctrl+v. Now the 17 lines should be the only thing in the code window.
Now, press compile in lower left corner of window.
Close window, shader is compiled and working.

Message 12 of 13
RGhost77
in reply to: Anonymous

Also you can try this shader :

http://zenopelgrims.com/dusty-arnold-shader/


Royal Ghost | veda3d.com
Message 13 of 13
madsd
in reply to: RGhost77

We can add additional feature sets to the OSL shader such as Ambient occlusion, I already did this the first day I looked at it, but decided to pull the AO aspect, to also respect for occluded top surfaces, overhangs, this is easy, but pulled since trace call in OSL is not currently supported on the GPU, but once it is, most of these c++ shaders will return redundant, also core arnold nodes.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report