OSL tip of the day.

OSL tip of the day.

madsd
Advisor Advisor
16,544 Views
63 Replies
Message 1 of 64

OSL tip of the day.

madsd
Advisor
Advisor

Hello,

This thread is about using OSL shading and small tips to generate various effects.

 

The first one is edge wear masking.

See node setup and output below, it is useful for creating worn edges, metals and so forth.

You can find AO shaders online or use the one I attached here.

https://www.dropbox.com/s/lkg5zvjouhczujb/BaAmbientOcclusion.osl?dl=0

 

- Set to convext+concave ( mode 2 )

- Use noise to drive edge distance
- Use range node to scale the differences up

2018-04-21_15-36-41.jpg

 

 

16,545 Views
63 Replies
Replies (63)
Message 21 of 64

MI66
Contributor
Contributor

Handy tips, thanks! Dunno how I've managed to miss the Interpolate node, that's exactly what I was after but I guess I was looking for something named a bit differently. Works great.

 

Regarding nodes inspired by Substance, I guess a common workflow there is to

1) start with a shape, similar to the one you've posted above

2) deform the shape (slope blur, directional warp, whathaveyou - very powerful nodes)

3) splat, tile & rotate the deformed shape randomly on top of each other to get an interesting looking height map, based on which you make the rest of the maps.

 

You can almost do the same  things with some of the OSL nodes, but not exactly. 🙂 For example, tiling the shape always keeps a border between the shapes, whereas in order to end up with more random, organic shapes it would be necessary for the shape to be able to overlap its neighbouring shapes additively.

Message 22 of 64

madsd
Advisor
Advisor

Ok, Ill take a look at it.

 

Message 23 of 64

ik3ds
Explorer
Explorer

I tested it so far just with Scanline Default Material, in 3ds max 2020 as soon as I plugin in the map into the diffuse map, my max freezes and crashes. I haven't tried it with other types of materials yet but will give it a go later today.

Message 24 of 64

madsd
Advisor
Advisor

Okay, the Standard Material in max is a dead relic which needs to roast slowly over a bonfire.

Use a physical material instead.

 

Message 25 of 64

ik3ds
Explorer
Explorer

Haha alright thank you 😄

Message 26 of 64

madsd
Advisor
Advisor

Also considder to throw Scanline render on a seperate stick and let it grill next to the standard material 🙂

I would deffo recommend to utilize Arnold instead.

Message 27 of 64

hasen3d
Contributor
Contributor

great love it

Message 28 of 64

Jixal
Enthusiast
Enthusiast

Just, came across this page. Loads of cool OSL stuff, the AO dirt one is super nice!

 

I would dearly love to see some OSL ways of tackling tileable textures, an option or options to solve this would get infinite use. Blender Guru showed an excellent way to do this using OSL..... but that's Blender, not 3DS Max! https://www.youtube.com/watch?v=-VgtSL5ZpYc

Procedural stochastic texturing looks super interesting, Unity has a demo for that - https://blogs.unity3d.com/2019/02/14/procedural-stochastic-texturing-in-unity/

 

The code for Chaosmosaic is out there, but currently, I've no idea how to get it into 3DS. There are no tutorials or obvious directions anywhere?

 

Message 29 of 64

fla3d
Collaborator
Collaborator

@Jixal wrote:

Just, came across this page. Loads of cool OSL stuff, the AO dirt one is super nice!

 

I would dearly love to see some OSL ways of tackling tileable textures, an option or options to solve this would get infinite use. Blender Guru showed an excellent way to do this using OSL..... but that's Blender, not 3DS Max! https://www.youtube.com/watch?v=-VgtSL5ZpYc

Procedural stochastic texturing looks super interesting, Unity has a demo for that - https://blogs.unity3d.com/2019/02/14/procedural-stochastic-texturing-in-unity/

 

The code for Chaosmosaic is out there, but currently, I've no idea how to get it into 3DS. There are no tutorials or obvious directions anywhere?

 


Paul Neale have sorted this problem with this:

 

RandomTilingTextures

Message 30 of 64

Jixal
Enthusiast
Enthusiast

Thanks for the reply, I did a lot of googling but never came across Paul Neale's OSL tricks.

This is definitely a huge step in the right direction, and I really appreciate the ability to do this.

I have to admit I am totally new to OSL and shaders. Adding 3d noise vectors to UVW's is not something I'd ever know how or why to do :P! Certainly understandable from the explanation, but not intuitive to somebody who has no real programming knowledge. 

 

A huge gripe at the moment though using this technique, the shader network also gets incredibly bloated!
For example, I'd like to use this to randomize a Megascans surface asset, like some grass.

There are often 6 textures per material.

This OSL technique requires 7 nodes per texture.

So that's now 42 nodes which are floating around.... if we then want to blend it into another PBR material, say dirt. That would require 84 nodes in total. (Not counting the nodes required for blend masks)

And that's just for one blended material!  

 

We also have to manually construct these shaders, the Blender example has a PBR texture loader. Amazing! So much time-saving. Instead of an 84 node tree, it's about 7?!?! Be great to get some functionality that a free software like Blender has.

 

Oh and p.s: I figured out how to add in the chaos mosaic shader code. I was looking under the OSL section for the OSL Map. Couldn't find it at the time as it's located under Maps, silly me! >_<.  

 

0 Likes
Message 31 of 64

madsd
Advisor
Advisor

We can compile a single shader doing what the noodle above does very easily.

That will reduce clutter significantly.

 

 

0 Likes
Message 32 of 64

fla3d
Collaborator
Collaborator

That would be amazing, a single randomize uvw node to put into the uvw node of multiple maps, something like that?

0 Likes
Message 33 of 64

madsd
Advisor
Advisor

We can put everything on that screenshot except the material into a single node if you think that would be a good idea, just implement it all into the bitmap lookup node.

 

But we could also just do everything up till UV transform nodes rotation slot and stick a single node out, one that has an output called......rotate or something.

 

Which every last node you prefer to be main node for the thing, I can make it happen, just say which.

 

If you prefer to have bitmap and uvtransfomr nodes, and then this special node, OK.

 

0 Likes
Message 34 of 64

fla3d
Collaborator
Collaborator

I think a single node for the UVW would work, because we usually have multiple textures to apply to a material that must share the same transforms.

Here is an example of how I think it would work, with the node in the UVW transform, I don't know if this is the same thing as @Jixal was thinking, but the height would go to the Displacement in the Arnold properties sharing the same transform.

material.PNG

 

0 Likes
Message 35 of 64

madsd
Advisor
Advisor

So everything goes to the UVTransform node, OK.

 

Let me cook up that situation for you.

 

0 Likes
Message 36 of 64

Jixal
Enthusiast
Enthusiast

As soon as I hit post, I realized part of what I was saying was a bit overboard, as you can instance those nodes into each bitmap! (Can't edit Autodesk Forum posts anymore)

 

However, one node to do the work of 7, like fla3d indicated would be amazing, as it removes chances to make an error. 

0 Likes
Message 37 of 64

madsd
Advisor
Advisor

Sure, bit late now, so will look at it tomorrow and post a shader with all the relevant settings.

Cus you would want some features exposed in this new UV Transform node v2.

 

 

0 Likes
Message 38 of 64

madsd
Advisor
Advisor

Hi guys.

I had a look at it and I have to say, this is not a very solid way to do it you can break it very easily.

Its not the ideal way to shuffle textures up, you get super ugly seams as soon as the input texture isnt very uniform.

 

So with that, I will retract my offer to compile a node from the above noodle as I would feel I would waste my time on something not optimal.

 

I will however do an effort to polish some other initiatives in near future and hand that solution over.

 

 

 

 

0 Likes
Message 39 of 64

madsd
Advisor
Advisor

Calibrating for Albedo is missing, and there is no smoothstepped alphas.

Fixing this and upgrading it, then I might as well hand over my Triplanar node, that needs no UV coords, and maps all surfaces on all objects perfectly without any unwrapping.

 

So stay tuned out there, you want something better.

0 Likes
Message 40 of 64

Jixal
Enthusiast
Enthusiast

Thanks for having a look at this.

 

I mainly render archivz/ civil infrastructure/ engineering projects, which require large aerial shots with geometry derived from CAD/ various other sources. So being able to easily populate a scene with uvw transforms instead of unwrapping is becoming a must-have for quick turn around projects. We have access to so many amazing textures and materials but implementing them swiftly often hits a bottleneck.

 

The current solution works, it isn't ideal, but at least it works, so that's something =).

It is basically secret knowledge at this point. Unless you know the specific trick that has been illuminated in this thread, chances are the average user won't be implementing this OSL blended texture solution.

 

Looking forward to future developments! And I'll definitely start looking into programming and OSL, the power is clear, it's just hard to access.

0 Likes