Snow shader for mountains
Posted: Wed Oct 06, 2010 11:47 pm
so, in my first attempts at ISL I have figured out how to use the shading normal of my mountains here to color the flatter areas like snow while leaving the steeper angles more of a rock color. this seems to work pretty well, but I would really like to be able to make the rock and snow completely separate materials and just blend them by using the same technique. here is my (probably very overly-complicated) code that gives the results in the image below (the mountains are a displaced plane using a heightfield exported from terragen):
and here is my attempt to implement the same idea into the <blend> element of the material, which gives me only one of the materials or the other, (the "Zless() bool" only changes the material if it is set higher than 1) :
any help in this case (and/or insight on how to improve on the concept) would be much appreciated.
thanks!
Code: Select all
<albedo>
<shader>
<shader><![CDATA[
def Zangle() real:
dotk(normalWS())
def Snow() real:
0.8
def StoneX() real:
0.11
def StoneY() real:
0.10
def StoneZ() real:
0.09
def Zless() bool:
gte(Zangle(), 0.6)
def Xcheck() real:
if(Zless(),
Snow(), StoneX())
def Ycheck() real:
if(Zless(),
Snow(), StoneY())
def Zcheck() real:
if(Zless(),
Snow(), StoneZ())
def eval(vec3 pos) vec3 :
vec3(
Xcheck(),
Ycheck(),
Zcheck()
)]]></shader>
</shader>
</albedo>
and here is my attempt to implement the same idea into the <blend> element of the material, which gives me only one of the materials or the other, (the "Zless() bool" only changes the material if it is set higher than 1) :
Code: Select all
<blend>
<a_name>snow</a_name>
<b_name>stone</b_name>
<blend>
<shader>
<shader><![CDATA[ def Zangle() real:
dotk(normalWS())
def Zslope() bool:
gte(Zangle(), 0.8)
def eval() real :
if(Zslope(),
0.0, 1.0)
]]></shader>
</shader>
</blend>
<step_blend>false</step_blend>
</blend>
thanks!