[ISL][workshop] Indigo Shading Language

General discussion about Indigo Materials - material requests, material developement, feedback, etc..
Stromberg
Posts: 693
Joined: Mon Mar 02, 2009 5:01 am
Location: Norway
Contact:

Re: [ISL][workshop] Indigo Shading Language

Post by Stromberg » Wed Apr 15, 2009 1:16 pm

Yeah, that would be great :)
I have no idea if this is possible either, but i want to think it is... so some of the coders needs to convince us, before we completely take of :roll:

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

Re: [ISL][workshop] Indigo Shading Language

Post by CTZn » Sat Apr 18, 2009 12:10 pm

With a delay I must report fused's contribution to the topic:

Code: Select all

<!--Generated by Cindigo 1.1.18-->
<!--Using TinyXml-->
<!--Developed by: Yves Colle aka 'fused'-->
<scenedata>

    <material>
        <name>nullMat</name>
        <null_material />
    </material>
    
    <material>
        <name>mortar</name>
        <oren_nayar>
            <sigma>
                <constant>0.2</constant>
            </sigma>
            <albedo>
                <constant>
                    <rgb>
                        <rgb>0.525 0.404 0.267</rgb>
                        <gamma>2.2</gamma>
                    </rgb>
                </constant>
            </albedo>
        </oren_nayar>
    </material>
    
    <material>
        <name>displace</name>
        <phong>
            <ior>1.141</ior>
            <diffuse_albedo>
                <constant>
                    <rgb>
                        <rgb>0.922 0.949 0.549</rgb>
                        <gamma>2.2</gamma>
                    </rgb>
                </constant>
            </diffuse_albedo>
            <exponent>
                <constant>62.5</constant>
            </exponent>
            <displacement>
                <shader>
                    <shader>
                        <![CDATA[#teh shifter shader
def shift (vec2 uv) vec2:
vec2(
        add(
                doti(uv),
                mul(
                        noise(mul(uv, 8.0)),
                        0.1
                )
        ),
        add(
                dotj(uv),
                mul(
                        noise(mul(uv, 8.0)),
                        0.1
                )
        )
)

#teh vec3 -> real shader
def vec2real (vec3 v) real:
div(
        add(add(doti(v), dotj(v)), dotk(v)), #add all compos together
        3.0
)

#teh vec2 -> real shader
def vec2real (vec2 v) real:
div(
        add(doti(v), dotj(v)), #add all compos together
        2.0
)

def getDisplacementMap () real:
vec2real(sample2DTextureVec3(
        0,
        shift(getTexCoords(0))
))

def getBlendMap (real col) real:
if(
        gt(
                col,
                0.05
        ), 1.0, 0.0
)

#def eval (vec3 pos) vec3: vec3(getBlendMap(getDisplacementMap()))
def eval () real: getDisplacementMap() * 0.4]]>
</shader>
                </shader>
            </displacement>
            <texture>
                <uv_set>default</uv_set>
                <path>mask_map.png</path>
                <exponent>2.20000005</exponent>
                <a>0.00000000</a>
                <b>1.00000000</b>
                <c>0.00000000</c>
            </texture>
        </phong>
    </material>
    <material>
        <name>initialShadingGroup</name>
        <blend>
            <a_name>mortar</a_name>
            <b_name>displace</b_name>
            <blend>
                <shader>
                    <shader>
                        <![CDATA[#teh shifter shader
def shift (vec2 uv) vec2:
vec2(
        add(
                doti(uv),
                mul(
                        noise(mul(uv, 8.0)),
                        0.1
                )
        ),
        add(
                dotj(uv),
                mul(
                        noise(mul(uv, 8.0)),
                        0.1
                )
        )
)

#teh vec3 -> real shader
def vec2real (vec3 v) real:
div(
        add(add(doti(v), dotj(v)), dotk(v)), #add all compos together
        3.0
)

#teh vec2 -> real shader
def vec2real (vec2 v) real:
div(
        add(doti(v), dotj(v)), #add all compos together
        2.0
)

def getDisplacementMap () real:
vec2real(sample2DTextureVec3(
        0,
        shift(getTexCoords(0))
))

def getBlendMap (real col) real:
if(
        gt(
                col,
                0.05
        ), 1.0, 0.0
)

def eval () real: getBlendMap(getDisplacementMap())
#def eval () real: getDisplacementMap() * 0.4]]>
</shader>
                </shader>
            </blend>
            <texture>
                <uv_set>default</uv_set>
                <path>mask_map.png</path>
                <exponent>2.20000005</exponent>
                <a>0.00000000</a>
                <b>1.00000000</b>
                <c>0.00000000</c>
            </texture>
        </blend>
    </material>
    
</scenedata>
the file here (igm)

I'm sorry to drop it without a comment but I took no time for that, also there should be an image linked (will fix). As I could tell from the image, plus what I can see now from the igm I think fused did it all :shock:

well done fused !
obsolete asset

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: [ISL][workshop] Indigo Shading Language

Post by OnoSendai » Sat Apr 18, 2009 12:59 pm

I added infix operators to ISL ages ago guys,
You can write a + b instead off add(a, b).

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

Re: [ISL][workshop] Indigo Shading Language

Post by fused » Sat Apr 18, 2009 9:13 pm

OnoSendai wrote:I added infix operators to ISL ages ago guys,
You can write a + b instead off add(a, b).
:mrgreen:

yeah, but i really like add(a, b) :P

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

Re: [ISL][workshop] Indigo Shading Language

Post by fused » Sat Apr 18, 2009 9:29 pm

CTZn wrote:With a delay I must report fused's contribution to the topic:

Code: Select all

...
the file here (igm)

I'm sorry to drop it without a comment but I took no time for that, also there should be an image linked (will fix). As I could tell from the image, plus what I can see now from the igm I think fused did it all :shock:

well done fused !
here are some pics (quite small :) ). its not even close to CTZn's texture used in his famous rendering, but i think its a start. mabe someone else wants to go on from here?


sorry for double post.

edit: if more people are interested im going to write a small tutorial on ISL (with the code above)
Attachments
im1239739980.png
this is the final result. materials are.... not so good :)
im1239739980.png (741.62 KiB) Viewed 3075 times
im1239739064.png
this is what getDisplacementMap() gives
im1239739064.png (154.67 KiB) Viewed 3077 times
im1239739010.png
this is what getBlendMap() gives
im1239739010.png (162.19 KiB) Viewed 3072 times

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

Re: [ISL][workshop] Indigo Shading Language

Post by CTZn » Sat Apr 18, 2009 11:07 pm

fused wrote: edit: if more people are interested im going to write a small tutorial on ISL (with the code above)
That would be great if you could expose a bit of the logic behind the code !


Let's use the doc a bit for a start (page 101):
  • - The def keyword starts a function definition.

    - Next is the name of the function,

    - then the list of arguments to the function, where each argument name is preceeded by the argument type.

    - Then the return type of the function follows.

    - After the colon, the body of the function is defined.
Also the word "cdata" is not exposed in the documentation... like a car with no key :?
obsolete asset

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

Re: [ISL][workshop] Indigo Shading Language

Post by fused » Sat Apr 18, 2009 11:20 pm

CTZn wrote:Also the word "cdata" is not exposed in the documentation... like a car with no key :?
CDATA is short for "Character Data".

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

Re: [ISL][workshop] Indigo Shading Language

Post by CTZn » Sun Apr 19, 2009 3:34 am

yes, and it takes >'s and ['s, how obvious :evil: ;)

I was thinking 'Code DATA' rather... but I trust your source !

Nothing new from me, I think people could grab the igm and play with numbers a bit if they want :)
obsolete asset

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: [ISL][workshop] Indigo Shading Language

Post by OnoSendai » Sun Apr 19, 2009 3:03 pm

CData is part of the XML spec. See http://en.wikipedia.org/wiki/CDATA .
I just use CData sections so that XML parsers don't modify the ISL data. Otherwise whitespace will be collapsed etc..

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

Re: [ISL][workshop] Indigo Shading Language

Post by CTZn » Mon Apr 20, 2009 12:24 am

Aah great, I understand, thanks !

Amazing how a reference on things can change one's perception :D For some reason it didn't come to my mind it was an XML feature, I was opting for a jit compiler feature, some obscure stuff...
obsolete asset

User avatar
Stur
Posts: 594
Joined: Fri Nov 10, 2006 11:52 pm
Location: Nancy, France

Re: [ISL][workshop] Indigo Shading Language

Post by Stur » Mon Jun 08, 2009 7:18 am

Hey ! ISL Workshop is a geat tool to learn ISL ! Cool.

As far as I understood, "pos" parameter of function "eval()" represents the (x,y,z) coordinates of the pixel being shaded, right ?

Is there a way to get the normal vector of this point ?

Thx.

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

Re: [ISL][workshop] Indigo Shading Language

Post by fused » Mon Jun 08, 2009 7:26 am

Stur wrote:Hey ! ISL Workshop is a geat tool to learn ISL ! Cool.

As far as I understood, "pos" parameter of function "eval()" represents the (x,y,z) coordinates of the pixel being shaded, right ?
Yes, sort of. More precisely its the point on the mesh thats going to be shaded :)
Stur wrote:Is there a way to get the normal vector of this point ?

Thx.
No, not at the moment. Unfortunately...

User avatar
Stur
Posts: 594
Joined: Fri Nov 10, 2006 11:52 pm
Location: Nancy, France

Re: [ISL][workshop] Indigo Shading Language

Post by Stur » Fri Jun 12, 2009 12:36 am

Ok, another question.
Indigo's doc wrote: getTexCoords(int texcoord_set_index) vec2

Gets the i-th texture coordinates at the shading point, where i = texcoord_set_index.
What is the unit of the coordinates ? At first I thought coordinates were measured in pixels, but it seems that i & j vary from 0.0 to 1.0

So, am I right if I say that, the texture coordinates are measured in fraction of the texture size ?

Or am I completely wrong ?

Thx.

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

Re: [ISL][workshop] Indigo Shading Language

Post by fused » Fri Jun 12, 2009 2:33 am

you're right. (0,0) represents the upper left corner of the texture (or lower left? no idea ^^ ) and (1,1) the lower/upper right (depending on what 0,0 was in the first place :) ).

User avatar
Stur
Posts: 594
Joined: Fri Nov 10, 2006 11:52 pm
Location: Nancy, France

Re: [ISL][workshop] Indigo Shading Language

Post by Stur » Thu Jun 18, 2009 10:55 am

Ok. Here is my contribution to this topic.

First I must say I'm gratefull to CTZn and Fused to have started and actively contributed to this topic. It gave me the heart to dive into ISL.

I wanted to give a try to this wall, but without bitmap. I was aiming a 100% procedural wall. I do not know if it's wise or not, it has probably a cost in terms of rendering time, but I did it as a challenge to myself, and as a learning exercise.

After many trials, here is what I got.

Code: Select all

	<material>
		<name>Mur</name>
		<diffuse>
			<albedo>
				<shader>
					<shader>
						<![CDATA[
					#
					# pi() : well ... returns Pi.
					#
					def pi() real : 3.14159265358979
					
					#
					# waver() : draws a wave then a flat spacer
					#
					# nb : angle in radians at which the curve is evaluated
					# waveW : width of the wave
					# spacerW : width of the space between waves
					#
					# remark : (waveW + spacerW) should be <= 1.0
					#
					def waver(real nb, real waveW, real spacerW) real :
						if(
							lt(
								mod(nb, waveW + spacerW)
								, waveW
								)
							, sin((mod(nb, waveW + spacerW) / waveW) * pi())
							, 0.0
							)
					
					#
					# getBricks() : draws a brick pattern
					#
					# brickW : brick width
					# brickH : brick height
					# mortarW : mortar width
					# mortarH : mortar height
					#
					# remark : 	(brickW + mortarW) should be <= 1.0
					#			(brickH + mortarH) should be <= 1.0
					#
					def getBricks(real brickW, real brickH, real mortarW, real mortarH) real:
						waver(
							if(
								lt(
									mod(dotj(getTexCoords(0)), (brickH + mortarH) * 2.0)
									, brickH + mortarH
								)
								, doti(getTexCoords(0))
								, doti(getTexCoords(0)) + (brickW + mortarW) / 2.0
								)
							, brickW
							, mortarW
						)
						*
						waver(
							dotj(getTexCoords(0))
							, brickH
						 	, mortarH
						)
					
					#
					# myNoise() : draws a noise map
					#
					# conc : concentration, err, well couldn't find a better word. The biggest the value is, the more concentrated looks the noise
					# f : factor by which is multiplied the noise to control intensity
					#
					def myNoise(real conc, real f) real:
						(
							(
								fbm(getTexCoords(0) * conc, 10) + 1.0
							) / 2.0
						) * f
					
					
					#
					# getStones() : blends the brick wall with the noise map to draw a stones like map
					#
					def getStones() real:
						max(
							min(
								getBricks(0.2, 0.1, 0.01, 0.01)
								* 6.0
								, 1.0
							)
							- myNoise(50.0, 0.5)
							, 0.0
						)
					
					#
					# colMortar : mortar color
					#
					def colMortar() vec3: vec3(0.4)
						
					#
					# colStone() : stone color
					#
					def colStone() vec3: vec3(0.5843, 0.5412, 0.4627)
					
					#
					# eval(vec3) vec3 : called by the albedo shader
					#
					def eval(vec3 pos) vec3:
						if(
							lte(getStones(), 0.2)
							, colMortar()
							, colStone()
						)
											
						]]>
					</shader>
				</shader>
			</albedo>
			<displacement>
				<shader>
					<shader>
						<![CDATA[
					#
					# pi() : well ... returns Pi.
					#
					def pi() real : 3.14159265358979
					
					#
					# waver() : draws a wave then a flat spacer
					#
					# nb : angle in radians at which the curve is evaluated
					# waveW : width of the wave
					# spacerW : width of the space between waves
					#
					# remark : (waveW + spacerW) should be <= 1.0
					#
					def waver(real nb, real waveW, real spacerW) real :
						if(
							lt(
								mod(nb, waveW + spacerW)
								, waveW
								)
							, sin((mod(nb, waveW + spacerW) / waveW) * pi())
							, 0.0
							)
					
					#
					# getBricks() : draws a brick pattern
					#
					# brickW : brick width
					# brickH : brick height
					# mortarW : mortar width
					# mortarH : mortar height
					#
					# remark : 	(brickW + mortarW) should be <= 1.0
					#			(brickH + mortarH) should be <= 1.0
					#
					def getBricks(real brickW, real brickH, real mortarW, real mortarH) real:
						waver(
							if(
								lt(
									mod(dotj(getTexCoords(0)), (brickH + mortarH) * 2.0)
									, brickH + mortarH
								)
								, doti(getTexCoords(0))
								, doti(getTexCoords(0)) + (brickW + mortarW) / 2.0
								)
							, brickW
							, mortarW
						)
						*
						waver(
							dotj(getTexCoords(0))
							, brickH
						 	, mortarH
						)
					
					#
					# myNoise() : draws a noise map
					#
					# conc : concentration, err, well couldn't find a better word. The biggest the value is, the more concentrated looks the noise
					# f : factor by which is multiplied the noise to control intensity
					#
					def myNoise(real conc, real f) real:
						(
							(
								fbm(getTexCoords(0) * conc, 10) + 1.0
							) / 2.0
						) * f
					
					
					#
					# getStones() : blends the brick wall with the noise map to draw a stones like map
					#
					def getStones() real:
						max(
							min(
								getBricks(0.2, 0.1, 0.01, 0.01)
								* 6.0
								, 1.0
							)
							- myNoise(50.0, 0.5)
							, 0.0
						)
										
					#
					# eval() real : called by the displacement shader
					#
					def eval() real:
						getStones() * 0.02
						
						]]>
					</shader>
				</shader>
			</displacement>
		</diffuse>
	</material>
I know my comments are not explicit enough for someone to understand ISL, but it's late here so I will (try to) explain later. I'll also answer questions.
And I'll edit this post to publish more results of small parts of the above code, like Fused did in his topic. It helped me to understand.

Here is the result :
The wall is a simple plane with uv coords in a studio setup.
Attachments
im1245275990.png
Tadaaaa ! ^^
Ok, the colors are too dull. I think it's a "gamma" trouble, as there is no gamma ^^.
im1245275990.png (732.25 KiB) Viewed 2682 times
im1245274970.png
A closeup (which shows my texture is far from perfect :'( )
im1245274970.png (769.65 KiB) Viewed 2680 times
im1245270100.png
The result of getStones() function applied to the displacement shader
im1245270100.png (688.96 KiB) Viewed 2680 times
im1245175844.png
The result of getBricks() function
im1245175844.png (425.29 KiB) Viewed 2680 times
default.igs
The scene
(58.82 KiB) Downloaded 172 times

Post Reply
37 posts

Who is online

Users browsing this forum: No registered users and 26 guests