Page 1 of 2

Variables or registers in ISL

Posted: Mon Feb 01, 2010 1:59 am
by galinette
Dear all,

Is it possible to make assignements in ISL? This would help for making complex shaders. I would like to assign return values to variables (any name) or registers (predefined variable name set). Is that possible currently? Is it planned for the future development?

Etienne

Re: Variables or registers in ISL

Posted: Mon Feb 01, 2010 2:44 am
by fenerolina
Hi Galinette, don't know if I can help you but take a look at this thread:www.indigorenderer.com/forum/viewtopic. ... &hilit=isl and this as well:www.indigorenderer.com/forum/viewtopic. ... s&start=15.

Re: Variables or registers in ISL

Posted: Mon Feb 01, 2010 11:20 am
by OnoSendai
Hi Galinette, I was thinking of adding let statements, i.e.

let z = f(x, y)

so I may add those at some point.

Re: Variables or registers in ISL

Posted: Mon Feb 01, 2010 7:14 pm
by galinette
Thanks, that will really help. I'm currently working on a 100% procedural ceramic tile material (soon to be uploaded) with random "misplacements" (shift, rotations) + random amount of joint plaster, bump, etc... That's quite a nightmare to define without assignments.

Also, the use of assignments would significantly reduce the amount of redundant calculation : today, when you need a calculated value several times, you need to recompute it redundantly (except if you make very smart optimizations in your interpreter, but I gess this is much more work to implement than assignments)

Etienne

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 4:48 am
by CTZn
I'm currently working on a 100% procedural ceramic tile material (soon to be uploaded) with random "misplacements" (shift, rotations) + random amount of joint plaster, bump, etc...
I'm a fan of procedural shading, can't wait to see this one ! Clearly, in years the few bitmaps I used were (at most) baked procedurals. And sub-icon sized tiles for textiles bumps tbh.

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 9:45 am
by galinette
Here is a first try. I'm not 100% happy of the overall look but the base features are there. What I wanted to do is to avoid the "perfectness" of usual CG ceramic tiles, especially the unperfect positionning of the tiles.

It's 100% procedural, and you can customize the edge shape, corner roundness, jerky positionning (shift+tilt), and the variable plaster thickness between the tiles. It's made of a 1/0 blend of ceramic and plaster so that materials colors & look can be easily changed without looking into the (long and messy) ISL code.

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 9:57 am
by fenerolina
:shock:

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 10:01 am
by galinette
fenerolina : whaat??

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 10:05 am
by fenerolina
: époustouflant!

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 10:55 am
by psor
fenerolina wrote:: époustouflant!
I agree! :mrgreen:

Galinette if you've some spare time at your hands it would be much
appreciated if you could do some small tutorials on ISL to do stuff like
this. I imagine a lot of people would be happy. ;o))


take care
psor

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 11:25 am
by CTZn
That's going to be an usefull shader, top stuff !

Are you defining the tiles with one white lerp with a dark end ? Can you do (circular) UV remapping ?

Noobish questions but you are hitting my favourite playground :)

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 11:52 am
by galinette
There is no lerp

Basically, I use a "piramydal" func:

def pyra(x, y) = min ( min ( x, 1-x ) , min (y, 1-y)
with x = fract(u) and y = fract (v)
This defines a periodic "pyramidal" 2d function from the u and v coordinates.

To smoothen the pyramid corners, I replace min by an hyperboloid : min_rounded (a,b)=(a+b+sqrt(2+(a-b)²)

Then I use the integer parts of u and v ( floor(u) and floor(v) ) to define a random 2d translation + rotation matrix, which are applied to x and y before the pyramid function. This shakes slightly the pyramid's positions.

Then I transform the shaked pyramids to ceramic plates profile : roundfunc ( clamp ( pyramids(...), 0, 1 ) )
Where roundfunc = sqrt(x*(2-x)) ( elliptic edge profile).

On one other side, I define the plaster height by a smooth noise()

And finally, I use a 1/0 blend between ceramic and plaster, where the criteria is whether the ceramic level is higher or lower than the plaster level : kind of "flood fill"

And I finish with some noisy bumpmaps.

Source is attached (but kinda messy). I'll upload something as soon as I have fixed everything!


What is the condition to make the circular remapping work? Everything is based on uv coordinates, so if these are correctly cylindrically remapped, that should work I suppose.

Etienne

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 2:36 pm
by fenerolina
Really awesome material Galinette! Love the unperfect position of tiles!
Is there a way for a noobish like me to scale the tile size? It only measures 2,5cm.
Could the frequency of the waves in the tiles be too hight for that size ?
Thank you.

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 7:41 pm
by galinette
Fenerolina : actually, everything is governed by UV coordinates. The unit square (1x1 size) is exactly one tile. So if you UV-map with 1 UV unit = 10cm in scene, your tiles will actually be 10cm wide. Everything is well sizeable.

However this will stretch the bevels & plaster joints too. To change these, I need to explain how to do in the shader.

Etienne

Re: Variables or registers in ISL

Posted: Tue Feb 02, 2010 7:48 pm
by galinette
Here is a closeup (width of dark zones : ~3mm) and displacement mapping.

I'm not fully happy with the specular reflection on the rounded edges, as there should be no sharp edge between the round part and the flat top. Maybe something is wrong in the subdivisions/displacement/smoothing

Etienne