Announcement
Collapse
No announcement yet.
An assortment of OSL shaders for your perusal
Collapse
X
-
Originally posted by ikomitov View PostActually, VRayOSLTex and VRayOSLMtl are already MaxScript-able. Here is a small MaxScript excerpt that demonstrates how to control the VRayOSLTex map, including getting and setting the properties of the shader. This example uses the CamMapScale shader posted by Rens:
Hope this helps in your MaxScript adventures!
Best regards
DaveMaxscript made easy....
davewortley.wordpress.com
Follow me here:
facebook.com/MaxMadeEasy
If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.
Comment
-
Originally posted by vlado View PostIvan, maybe you should put that on the docs page...
Best regards,
Vlado
Best regards,
Ivan
Comment
-
Originally posted by Dave_Wortley View PostThanks Ivan, that's great... Can I put a request in to have a method to return the tweak names? Similar to how in maxscript we have 'getPropNames'
Best regards
Dave
Best regards,
Ivan
Comment
-
Originally posted by ikomitov View PostYes, I'll extend the interface. If you can think of other methods that might be useful, please let me know.
Best regards,
IvanMaxscript made easy....
davewortley.wordpress.com
Follow me here:
facebook.com/MaxMadeEasy
If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.
Comment
-
Rens,
A question for you: I'm working on implementing the Disney Principled BRDF in OSL. For the "spec tint" they say they tint the incident specular towards the base color, while keeping the grazing specular achromatic (this on a GGX brdf). Any ideas as to how to approach that in OSL? The GGX closure has fresnel built into it (the eta parameter), but I suppose one could also do the Fresnel manually too, like this
Code:float fresnelReflectionFactor(normal bumped_normal, float ior, color TintSpec) { float c = abs(dot(I, bumped_normal)); float g = ior * ior - 1.0 + c * c; if (g > 0.0) { g = sqrt (g); float A = (g - c) / (g + c); float B = (c * (g + c) - 1.0) / (c * (g - c) + 1.0) ; return 0.5 * A * A * (1.0 + B * B); } return 1.0; }
Comment
-
Originally posted by sharktacos View PostRens,
A question for you: I'm working on implementing the Disney Principled BRDF in OSL. For the "spec tint" they say they tint the incident specular towards the base color, while keeping the grazing specular achromatic (this on a GGX brdf). Any ideas as to how to approach that in OSL? The GGX closure has fresnel built into it (the eta parameter), but I suppose one could also do the Fresnel manually too, like this
.I'm just not sure how to tint just just the incident specular/reflections without affecting the grazing specular/reflections.
To answer your question, the GGX closure Fresnel parameter will scale the reflection, but not tint it. If I remember correctly you'd mix the tint colour and white using a Fresnel function like you posted. However I'd use Schlick as it's a bit quicker.
Have a look at the rhfunctions.h file, it has several reflection funtions.
To mix you could use something like this:
Code:a = Fresnel_Amount; c1 = Tint; c2 = White; r = Reflection_Without_Fresnel; out = r * ( (c2 * a) + (c1 * (1 - a)) );
Comment
-
Thanks. This mixes between two colors using the fresnel as the mask. So if the tint color is red, you get white edges and red in the middle. But for Fresnel it should be dark red in the middle and white on the edges. Perhaps I'm not getting what Reflection_Without_Fresnel refers to. Is it the same as the reflection amount (Ks)?
Perhaps I could multiply the mix by the Fresnel to tint it:
Code:color Mix = r * ( (c2 * a) + (c1 * (1 - a)) ); Mix = a * Mix;
Last edited by sharktacos; 02-06-2016, 10:58 PM.
Comment
-
Well, it depends on if you would want to drive the zero incidence / front facing colour completely or have it as a pure tint only. Looking at the paper they have a metalness parameter, so your example would be the one to use. And then you change the Fresnel falloff amount to switch to a metal, and leave the tint colour as just a pure tinting.
And in my example r would be a pure reflection closure without Fresnel falloff, like a raw reflection.
Comment
-
Don't know whom to get on the nerves with this, propably vlado:
If I use the Mix normal map with a VrayBump2Normal in one of the inputs, max allways crashes.
Rens, could you be so kind and make a blur map? Just a map which burs its input map, maby with several bur algorithms.
And if possible keep it seamless.
I was allways wondering why max dosn't allready has such map, could be so usefull.
Thanks for the uv transform. I wish for that for a long time.German guy, sorry for my English.
Comment
-
Originally posted by Rens View PostWell, it depends on if you would want to drive the zero incidence / front facing colour completely or have it as a pure tint only. Looking at the paper they have a metalness parameter, so your example would be the one to use. And then you change the Fresnel falloff amount to switch to a metal, and leave the tint colour as just a pure tinting.
And in my example r would be a pure reflection closure without Fresnel falloff, like a raw reflection.
Code:color TintColor= mix(1,BaseColor,Specular_Tint); //mix between baseColor and white based on Specular_Tint amount color Tint = mix(TintColor,1,Fresnel); //mix between tintColor and white based on Fresnel Fresnel *= Tint;
Comment
-
-
Originally posted by vlado View PostYes, I know. We will correct the crash, but I'm not sure we can fix the actual issue.
Best regards,
Vlado
Are there other Maps that can cause the same?
If somone else runs into that Problem too:
As workaround, you can bake the vraybump2normal and put the resulting Texture into the input.Last edited by Ihno; 03-06-2016, 05:46 AM.German guy, sorry for my English.
Comment
-
Originally posted by Ihno View PostJust out of interest, this happens because the VrayBump2Normal is only calculated properly while rendering?
Best regards,
VladoI only act like I know everything, Rogers.
Comment
-
Originally posted by Rens View PostNice! I was looking at that a couple of months ago, but the main issue with implementing this in OSL is that you can't write BRxFs/closures yourself. In this case specifically you need a new closure for the diffuse. You could however, come to think of it, try and scale an existing closure somehow? So you could scale the Lambert closure to fit.
Code:color BaseLess = BaseColor * ( (1.0 - Fresnel) * 0.5 ); // reduce diffuse by 0.5 at grazing angles for smooth surfaces color BaseMore = BaseColor * Fresnel * 2.5; // increase diffuse by up to 2.5 at grazing angles for rough surfaces. BaseColor = mix(BaseLess,BaseMore,RoughnessAmount);
Comment
Comment