[ISL][workshop] Indigo Shading Language
Re: [ISL][workshop] Indigo Shading Language
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
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
Re: [ISL][workshop] Indigo Shading Language
With a delay I must report fused's contribution to the topic:
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
well done fused !
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>
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
well done fused !
obsolete asset
Re: [ISL][workshop] Indigo Shading Language
I added infix operators to ISL ages ago guys,
You can write a + b instead off add(a, b).
You can write a + b instead off add(a, b).
Re: [ISL][workshop] Indigo Shading Language
OnoSendai wrote:I added infix operators to ISL ages ago guys,
You can write a + b instead off add(a, b).
yeah, but i really like add(a, b)
Re: [ISL][workshop] Indigo Shading Language
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?CTZn wrote:With a delay I must report fused's contribution to the topic:
the file here (igm)Code: Select all
...
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
well done fused !
sorry for double post.
edit: if more people are interested im going to write a small tutorial on ISL (with the code above)
- Attachments
-
- this is the final result. materials are.... not so good :)
- im1239739980.png (741.62 KiB) Viewed 3075 times
-
- this is what getDisplacementMap() gives
- im1239739064.png (154.67 KiB) Viewed 3077 times
-
- this is what getBlendMap() gives
- im1239739010.png (162.19 KiB) Viewed 3072 times
Re: [ISL][workshop] Indigo Shading Language
That would be great if you could expose a bit of the logic behind the code !fused wrote: edit: if more people are interested im going to write a small tutorial on ISL (with the code above)
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.
obsolete asset
Re: [ISL][workshop] Indigo Shading Language
CDATA is short for "Character Data".CTZn wrote:Also the word "cdata" is not exposed in the documentation... like a car with no key
Re: [ISL][workshop] Indigo Shading Language
yes, and it takes >'s and ['s, how obvious
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
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
Re: [ISL][workshop] Indigo Shading Language
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..
I just use CData sections so that XML parsers don't modify the ISL data. Otherwise whitespace will be collapsed etc..
Re: [ISL][workshop] Indigo Shading Language
Aah great, I understand, thanks !
Amazing how a reference on things can change one's perception 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...
Amazing how a reference on things can change one's perception 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
Re: [ISL][workshop] Indigo Shading Language
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.
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.
Re: [ISL][workshop] Indigo Shading Language
Yes, sort of. More precisely its the point on the mesh thats going to be shadedStur 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 ?
No, not at the moment. Unfortunately...Stur wrote:Is there a way to get the normal vector of this point ?
Thx.
Re: [ISL][workshop] Indigo Shading Language
Ok, another question.
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.
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.0Indigo's doc wrote: getTexCoords(int texcoord_set_index) vec2
Gets the i-th texture coordinates at the shading point, where i = texcoord_set_index.
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.
Re: [ISL][workshop] Indigo Shading Language
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 ).
Re: [ISL][workshop] Indigo Shading Language
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.
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.
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>
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
-
- 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
- Tadaaaa ! ^^
-
- A closeup (which shows my texture is far from perfect :'( )
- im1245274970.png (769.65 KiB) Viewed 2680 times
-
- The result of getStones() function applied to the displacement shader
- im1245270100.png (688.96 KiB) Viewed 2680 times
-
- The result of getBricks() function
- im1245175844.png (425.29 KiB) Viewed 2680 times
-
- default.igs
- The scene
- (58.82 KiB) Downloaded 172 times
Who is online
Users browsing this forum: No registered users and 26 guests