Snow shader for mountains

General discussion about Indigo Materials - material requests, material developement, feedback, etc..
FakeShamus
Posts: 508
Joined: Wed May 02, 2007 11:34 am

Snow shader for mountains

Post by FakeShamus » 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):

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>
any help in this case (and/or insight on how to improve on the concept) would be much appreciated.
thanks!
Attachments
alpine3_crop.jpg

User avatar
fused
Developer
Posts: 3558
Joined: Fri Sep 22, 2006 7:19 am
Location: Berlin, Germany
3D Software: Cinema 4D

Re: Snow shader for mountains

Post by fused » Wed Oct 06, 2010 11:49 pm

:O

wow. very nice shader.

edit: unfortunately you can not use the normal shader functions in the blend channel currently

FakeShamus
Posts: 508
Joined: Wed May 02, 2007 11:34 am

Re: Snow shader for mountains

Post by FakeShamus » Thu Oct 07, 2010 12:10 am

bummer, wasn't aware of that.
will it work with exponent or bump? if there was some other way to differentiate the snow from the rock texture at least that would be a start.

User avatar
fused
Developer
Posts: 3558
Joined: Fri Sep 22, 2006 7:19 am
Location: Berlin, Germany
3D Software: Cinema 4D

Re: Snow shader for mountains

Post by fused » Thu Oct 07, 2010 12:18 am

It won't work with any channel that takes a displacement parameter, afaik. These channels are blend, displacement and bump.
It should work with any channel taking wavelength dependent or independent parameters. So yes, you could use it on exponent.

User avatar
zeitmeister
2nd Place 100
Posts: 1997
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

Re: Snow shader for mountains

Post by zeitmeister » Thu Oct 07, 2010 12:50 am

Wow, this looks so natural! Really natural spreading of the snow! Best I've ever seen so far!
Could you add custom values for the elevation values, or does the shader evaluate that by itself? An now, the typical slightly sparcling could be added in the exponent channel...
Keep it up, that's gonna be fantastic!
Cheers, David



DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.2.23 | Indigo for C4D 4.2.22 | C4D R14.042 | Mac OS X 10.13.6 | Windows 10 Professional x64

FakeShamus
Posts: 508
Joined: Wed May 02, 2007 11:34 am

Re: Snow shader for mountains

Post by FakeShamus » Thu Oct 07, 2010 1:53 am

thanks,
you can control the snow coverage by changing the "Zless() bool" comparison value (set to 0.6 in the code above) which basically controls how steep the surface can be before it switches from the snow color to the rock color (I think a noise function could also be added in there somewhere to randomize the break up some) but there is no elevation parameter yet, so it just covers all of the surfaces evenly depending on the slope. elevation settings would be nice. but I'm a total beginner at this stuff.

User avatar
Borgleader
Posts: 2149
Joined: Mon Jun 16, 2008 10:48 am

Re: Snow shader for mountains

Post by Borgleader » Thu Oct 07, 2010 2:07 am

That....IS EPIC! :shock:
benn hired a mercenary to kill my sig...

User avatar
zeitmeister
2nd Place 100
Posts: 1997
Joined: Tue Apr 22, 2008 4:11 am
Location: Limburg/Lahn, Germany
Contact:

Re: Snow shader for mountains

Post by zeitmeister » Thu Oct 07, 2010 2:50 am

Depending on the slope:
Well, that's exactly what snow does. Plus, a little bit more, because snow sticks in some cases... but as I said, that's really fantastic.
Maybe a very small, but high reflective perlin noise in the exponent?
Cheers, David



DAVIDGUDELIUS // 3D.PORTFOLIO
·
Indigo 4.2.23 | Indigo for C4D 4.2.22 | C4D R14.042 | Mac OS X 10.13.6 | Windows 10 Professional x64

FakeShamus
Posts: 508
Joined: Wed May 02, 2007 11:34 am

Re: Snow shader for mountains

Post by FakeShamus » Thu Oct 07, 2010 3:20 am

Maybe a very small, but high reflective perlin noise in the exponent?
that's a good idea, I'll have to play around with that
That....IS EPIC!
all epicness due to Terragen and Indigo. but I have been waiting for a while to be able to create this ISL snow effect. waaaay better than earlier attempts using texture maps: http://www.indigorenderer.com/forum/vie ... ins#p87163

kdarius
Posts: 108
Joined: Fri Jun 12, 2009 5:00 am

Re: Snow shader for mountains

Post by kdarius » Thu Oct 07, 2010 3:44 am

could you please post a material of this or please explain how i would implement this? I asume its not just cut and paste into notepad save the file and use as external.. is it?

User avatar
Borgleader
Posts: 2149
Joined: Mon Jun 16, 2008 10:48 am

Re: Snow shader for mountains

Post by Borgleader » Thu Oct 07, 2010 3:47 am

FakeShamus wrote:all epicness due to Terragen and Indigo. but I have been waiting for a while to be able to create this ISL snow effect. waaaay better than earlier attempts using texture maps: http://www.indigorenderer.com/forum/vie ... ins#p87163
Terragen...I should learn to use that!
benn hired a mercenary to kill my sig...

User avatar
galinette
1st Place Winner
Posts: 923
Joined: Sat Jan 09, 2010 1:39 am
Location: Nantes, France
Contact:

Re: Snow shader for mountains

Post by galinette » Thu Oct 07, 2010 9:36 am

Excellent!
Eclat-Digital Research
http://www.eclat-digital.com

User avatar
OnoSendai
Developer
Posts: 6180
Joined: Sat May 20, 2006 6:16 pm
Location: Newcastle upon Tyne, UK
Contact:

Re: Snow shader for mountains

Post by OnoSendai » Thu Oct 07, 2010 1:23 pm

I've made some changes so that normalWS() can now be called inside displacement parameter shaders. Currently it will only give correct results when used for evaluating the blend factor.

So with these changes you should be able to use the normal to blend between different materials, like so:

Code: Select all


  <material>
    <name>a</name>

    <diffuse>
      <albedo>
        <constant>
          <rgb>
            <rgb>0.1 0.8 0.1</rgb>
            <gamma>1</gamma>
          </rgb>
        </constant>
      </albedo>
    </diffuse>
  </material>

  <material>
    <name>b</name>

    <phong>
      <ior>1.5</ior>
      <exponent>100</exponent>
      <diffuse_albedo_spectrum>
        <rgb>
          <rgb>0.8 0.1 0.1</rgb>
          <gamma>1</gamma>
        </rgb>
      </diffuse_albedo_spectrum>
    </phong>
  </material>
  
  <material>
    <name>default</name>

    <blend>
      <a_name>a</a_name>
      <b_name>b</b_name>
      <step_blend>false</step_blend>

      <texture>
        <path>blackrose_pattern.jpg</path>
        <exponent>2.2</exponent>
        <uv_set>default</uv_set>
      </texture>

      <blend>
        <shader>
          <shader>
            <![CDATA[
						def eval() real :
							if(dot(normalWS(), vec3(0.0, 0.0, 1.0)) > 0.3,
                1.0,
                0.0
              )
						]]>
          </shader>
        </shader>
      </blend>
    </blend>
  </material>
Attachments
blend_normal_shader_test.jpg

User avatar
CTZn
Posts: 7240
Joined: Thu Nov 16, 2006 4:34 pm
Location: Paris, France

Re: Snow shader for mountains

Post by CTZn » Thu Oct 07, 2010 2:00 pm

Code: Select all

:o
obsolete asset

FakeShamus
Posts: 508
Joined: Wed May 02, 2007 11:34 am

Re: Snow shader for mountains

Post by FakeShamus » Thu Oct 07, 2010 2:24 pm

oh sweet! thanks for that.
I like how your version basically decimates my feeble attempts at code.

Post Reply
25 posts

Who is online

Users browsing this forum: No registered users and 8 guests