
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

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>
OnoSendai wrote:I added infix operators to ISL ages ago guys,
You can write a + b instead off add(a, b).
here are some pics (quite smallCTZn 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 !
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)
CDATA is short for "Character Data".CTZn wrote:Also the word "cdata" is not exposed in the documentation... like a car with no key
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.
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.
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>
Users browsing this forum: No registered users and 66 guests