PYLA, PhYsically correct LAyers with OSL

Last year, at Blender conference, I’ve show Layered Shading for Physically Correct Materials made of layers or coating, like Car Paint, Polished Nails, Carbon Fiber, etc.

I’ve wrote a very simple OSL Shader to do it, and I’m using it for near every of my projects. It’s now time to release it!

Why now?

Just because NVIDIA / MentalRay annonced MILA, the Physically correct Layer solution for Mental Ray.

MILA is incredibly close to what I’ve done with PYLA, using Cycles and OSL!!! And I wouldn’t let Blender Users do not having features available in MentalRay! :smiley:

I strongly recommend you to read the MILA documentation to understant what you can do with PYLA and Cycles : http://elementalray.wordpress.com/2013/01/22/the-layering-library-mila-ui-beta-shaders/

PYLA is in version 1.0, and it still needs some enhancement.

Currently, it could be slow if you use a lot of layers. It doesn’t support tranparency or refractive layers. There is nothing for diffractive layer (irisation).

But it is very simple to use and it works very well ! It’s a very short and very effective script.

here is a little video (using some other OSL shaders soon to be released…) :

You can download it (and read the doc!) here : http://vadrouillegraphique.blogspot.fr/search/label/OSL

Enjoy it !

Thanks for sharing.

this looks great! Thank you very much for sharing!
Just one thing… I cannot see the docs. Can be they are just under my eyes, but I cannot find them.

Also, would it be possible to have a look at the shaders we see in the video as a reference?

Thank you again :slight_smile:

Thanks for sharing too Youpi3D,
Cycle est vraiment excellent, n’est ce pas?
Dommage qu’il soit encore un peu lent mais ça va s’arranger…:yes::yes:
Spirou4D

Hello !

I’ve made this simple Tutorial to help to understand how to make Layered Shading for Physically correct Photoreal Rendering with OSL/Cycles.

Enjoy it !

Thank you very much Youpi! :slight_smile:

It seems that I have to apologize to Youpi3D. The PYLA shader is not as taxing as I thought. OSL is the culprit here. Just enabling OSL makes the scene render up to 5 times slower when compared to rendering with OSL disabled.

Rendering times h:m:s :

OSL:0 PYLA:0 = 0:15:10
OSL:1 PYLA:0 = 0:58:59
OSL:1 PYLA:1 = 1:00:44

Hi Youpi,
thanks a lot for your osl script :slight_smile:
I can confirm that just activating OSL without using it makes redering about 4-5 times slower. Is it normal ?

Rendering with OSL is slower for me too, this is known. Hopefully we can still optimize it. But 4-5x slower sounds very wrong to me.

@DingTo Slower would be normal if I was actually using it, but it’s just activated and I’ve no OSL Node in my file. Is the OSL code filling the CPU cache and taking the place away for the scene data making each CPU work only with the RAM ? Maybe the code could only be activated for tiles where an OSL node is detected (maybe a bit longer to dynamically load it, but on 2000 tiles with a 4-5 time slower factor, losing some microsecondes for a 100 tiles is not a big deal)? Just a question, I’m really bad in programming, sorry if I just say nonsense.

There is a problem with the last distributions of Blender !

The Fresnel library changed. Why the hell did they do that ?

So, PYLA 1.0 isn’t working anymore.
For those who already used it, open the ‘.oso’ file instead of ‘.osl’ and it will work.

I’m currentely working on next version of PYLA, which will correct this bug, and I hope to post it before the end of the weekend.

Sorry for this inconvience.

And, faster than expected, here is the new version of PYLA: :smiley:

PYLA 1.3

2 news features :
mask layer: for applying the layer where you want!

Secondary Optimization: For having PYLA faster up to 60% faster than just the base shader! Adding layers will not be slower anymore.


Enjoy it !

matali : the slowdown is probably caused by image textures. I made some tests replacing image texture nodes with rgb nodes and the rendering times dropped dramatically:

Textures 2048px + OSL:1 = 0:1:49
Textures 2048px + OSL:0 = 0:0:52

Textures 512px + OSL:1 = 0:1:46
Textures 512px + OSL:0 = 0:0:50

RGB + OSL:1 = 0:0:50
RGB + OSL:0 = 0:0:45

DingTo told me that OSL uses the texture filtering code of OIIO (better but slower). Maybe you can try the same experiment and see if it is the same problem.

RC

nice, thanks for the new release! Next week I will get my hands on a new cpu, time to experiment further with osl :smiley:

Youpi3D: The 1.3 version optimizations work as advertised, now PYLA can be really fast. Really great job!

RC : thank you, it would not be possible without your help !

@RC Tested on a glossy cube with a diffuse plane (no osl nodes) :
Textures + OSL:1 = 0:0:29
Textures + OSL:0 = 0:1:14

RGB + OSL:1 = 0:0:35
RGB + OSL:0 = 0:0:23

Conclusion : image texture and OSL are the problem for me too in this test, but Cycles with OSL enabled already needs about 50% more time, even without a single OSL node.

I’ve been looking at this thread for a little while now, and I have to say, this shader seems to me like it’s an excellent example of what can be done in OSL.

In fact, I went ahead to see if I could copy it with the SVM system and I got this result (it may not be quite as fancy in terms of available options judging from your blog article, but it seems to work quite well and is designed in a way to add as many layers as you need).


???4???5 ???,??????,???1???BEGIN???,isabel marant ??? ???,??? ??????,http://www.marchiquita.gov.ar/InformeDeuda.asp???,timberland ??? ???,??? ??? 2013? ??? ?? ???,??? ?????,prada ??? ???I’M IN LOVE???,timberland ?????4???,??? Skytop???Move On???7???2PM???,??? ???? ???: ??? ?? . ??? ??? ??? ??? ???