OSL | Raytype = Magic
Posted: Wed Jun 13, 2018 5:39 am
Hi
Disclaimer: I am not a programmer. I went to art school to avoid math and did Graphic Design with gouache, ruler pens (reissfeder) and No1 sized brushes. I did have an Amiga back then (with a math coprocesor and 4Mb of ram so I could learn LightWave) but the only tech we were allowed to use was Xerox (to rip and enlarge 'fonts' from newspapers and magazines). I was one of the best in school in calligraphy and left handed! Now I suck at calligraphy. Because I'm having too much fun using C4D and Octane.
This is my first OSL script ever. It's ridiculously simple but it works and it's VERY powerful. In the C4D plugin we can't use the
The section in the OSL docs about
Usage:
This script blends between two colors/textures based on what type of ray is hitting the object. You can use it everywhere, for any parameter that has texture input. Instead of colors you can use other shaders or even other Raytype OSL shaders within other Raytype OSL shaders within oth... well... you get the idea.
It can be used to turn off shadows, AO, change material properties in reflections or refractions, turn off GI or use completely different material for GI on specific objects or lights and much much much much much more.
A & B: Textures/colors that are blended.
Ray: Type of ray that you want to test. Example: You apply Raytype OSL on Opacity and choose Shadow ray. When a shadow ray hits your object, only for that ray, opacity of your object can be different. So, that ray will then pass through your object and the result is -> no shadows!
Swap: Swaps the A & B inputs.
Instalation:
There is a great new manual for C4D that describes how we can use OSL shaders in C4D. The best way IMO is to drop the .osl file into your
Orbx file - please check out the notes!
Raytype osl code / text file.
BONUS: OSL 'texture' that blends textures based on InstanceID.
I will be back (bearing gifs) with follow-up posts and C4D scenes to explain the best use cases and to show you what this thing can do. Stay tuned!
Remember: this is OSL, so there is an ORBX file and an
Regards
Milan
Disclaimer: I am not a programmer. I went to art school to avoid math and did Graphic Design with gouache, ruler pens (reissfeder) and No1 sized brushes. I did have an Amiga back then (with a math coprocesor and 4Mb of ram so I could learn LightWave) but the only tech we were allowed to use was Xerox (to rip and enlarge 'fonts' from newspapers and magazines). I was one of the best in school in calligraphy and left handed! Now I suck at calligraphy. Because I'm having too much fun using C4D and Octane.
This is my first OSL script ever. It's ridiculously simple but it works and it's VERY powerful. In the C4D plugin we can't use the
"popup"
widget so I had to go with a bunch of if
statements so the code looks complex, but trust me this is pre-school type of stuff. No math, just plain old 'if this than that'.The section in the OSL docs about
Raytype
function has been haunting me for months. And finally this Sunday I took 20 minutes to figure out what happens when we use it and how the hell do we even use it. And I was blown away. And then I used it on opacity... Mind. Blown.Usage:
This script blends between two colors/textures based on what type of ray is hitting the object. You can use it everywhere, for any parameter that has texture input. Instead of colors you can use other shaders or even other Raytype OSL shaders within other Raytype OSL shaders within oth... well... you get the idea.
It can be used to turn off shadows, AO, change material properties in reflections or refractions, turn off GI or use completely different material for GI on specific objects or lights and much much much much much more.
A & B: Textures/colors that are blended.
Ray: Type of ray that you want to test. Example: You apply Raytype OSL on Opacity and choose Shadow ray. When a shadow ray hits your object, only for that ray, opacity of your object can be different. So, that ray will then pass through your object and the result is -> no shadows!
Swap: Swaps the A & B inputs.
Instalation:
There is a great new manual for C4D that describes how we can use OSL shaders in C4D. The best way IMO is to drop the .osl file into your
\MAXON\CINEMA 4D RXX\plugins\c4doctane\res\osl_scripts
folder and then it will be available in the pull down menu along with all other scripts.Orbx file - please check out the notes!
Raytype osl code / text file.
BONUS: OSL 'texture' that blends textures based on InstanceID.
I will be back (bearing gifs) with follow-up posts and C4D scenes to explain the best use cases and to show you what this thing can do. Stay tuned!
Remember: this is OSL, so there is an ORBX file and an
.osl
file that should work for users of Standalone and other DCC apps or maybe even other render engines! Regards
Milan