question

Mads Drøschler avatar image
Mads Drøschler asked ·

OSL Programming tutorial: Let's write a proper Normal Blend Map



Hi,

Blending normals is not just a question about adding them up in some way, linear blend, overlay tricks or partial derivatives, has been seen through history as attempts to overcome blending multiple normals, while trying to preserve as many details as possible.

These methods does not represent the current front end.

So if you want to blend normals like a BOSS and on the same time, take your first step into writing OSL shaders for Arnold, take a look here and dive in.

The shader is based around an article by Colin Barré-Brisebois and Stephen Hill, where they show many popular blend modes and then their own superior construct called reoiriented normal blending. https://blog.selfshadow.com/publications/blending-in-detail/


VIDEO:
https://youtu.be/d462neeNXyk


I also put up a perma link on the git.
https://github.com/gkmotu/OSL-Shaders/blob/master/NormalBlend.osl

If you skipped directly to shader download, remember to revise your 2 bitmap loaders gamma space.
You want to make sure you work in linear space on everything you send into the shader.
So, and that means, set gamma to 1.0.

Shader should work in any host.

In MAX 2020.3:
- Viewport in High Quality mode with a Physical Material + Legacy normal map + 2 OSL bitmaps and this RNM shader returns normals on mesh in the viewport.
- Arnold renders them in a higher quality simultaniously.




Let me know if you have any questions or suggestions to updates, corrections of errors and so forth.
And if you have other blend functions laying around, let's try put them though the shader.
We can even make a drop down with blend mode types, which I would not realy like :D But its possible.


Its best to just have the most efficient function in main shader and everything else is legacy instantly and gets pulled from shader chains when the master on disk gets updated by TD folks, which could be huge facility injection or 1 man band, makes no difference, its eaqually easy/hard to update master assembly in both scenarios.

If we put up 50 texture artists for a year on some mission for honor and glory, we would give them new shading tools ad hoc as needs/requests comes in. And their shaders when working with them would update in their scenes when we updated the shader on disk, so all artists active open scenes gets this upgrade automatically, no buttons touched. Small latency delay from TD area to artists Shading node canvas, but nothing serious, mili seconds on good network.

normalblend.jpg (1.2 MiB)
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

rachid Hadj Abderrahmane avatar image
rachid Hadj Abderrahmane answered ·

Update for c4D



Just add
ARNOLD_PLUGIN_PATH in the OS variable
NormalBlend.zip


c4d-nmb.jpg (107.6 KiB)
normalblend.zip (578 B)
1 comment Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Perfect, now we got 4 supported ui entries.

0 Likes 0 · ·
rachid Hadj Abderrahmane avatar image
rachid Hadj Abderrahmane answered ·

really nice
Maya
Houdini
mtd & aeTemplate here:
NormalBlend.zip


mtoa-nmb.jpg (48.0 KiB)
htoa-nmb.jpg (25.4 KiB)
normalblend.zip (1.0 KiB)
5 comments Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

ah so you need some complimentary ui files for those 2 hosts.
Thanks for the files.
Ill try ship shaders I am rolling out on my site with these files as well so maya/houdini folks will get these along the downloaded shader.

I may be back to ask for testing or ask for some coop QA for UI :)

0 Likes 0 · ·

it's a pleasure to test your beautiful shaders
I'm ready

0 Likes 0 · ·
Mads Drøschler avatar image Mads Drøschler rachid Hadj Abderrahmane ·

Great.
I stole your images and will make a 4th for MAX, then submit a post in my OSL Shaders category on my site with some explainations and so on, full credit for the UI file work OFC.

Ill attempt to make a template that other shaders can follow.

0 Likes 0 · ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.