Right. The burning question then is: What would the code be for that?
You can probably trust the built-in “fresnel” function.
surface FresnelWeightedSurface (
color diffuse_color = color(1.0),
color reflection_color = color(1.0),
float environment_ior = 1.0,
float material_ior = 1.5
) {
float environmentIOR = max(1.0, environment_ior);
float materialIOR = max(1.0, material_ior);
float reflectionWeight;
float transmissionWeight;
vector reflectionDirection;
vector transmissionDirection;
fresnel(
I, N, environmentIOR / materialIOR,
reflectionWeight, transmissionWeight,
reflectionDirection, transmissionDirection
);
color reflectionFilterColor = reflectionWeight * reflection_color;
color diffuseFilterColor = diffuse_color * (1.0 - reflectionFilterColor);
Ci =
diffuseFilterColor * diffuse(N) +
reflection_color * microfacet_ggx(N, 0.25, materialIOR / environmentIOR);
}
Best regards,
Ivan M.
Okay so you are using the built in OSL Fresnel standard library function. That makes sense. I guess the question then is this: If in the next SP the microfacet_ggx will be updated to use per microfacet Fresnel, will the OSL fresnel function also be updated to calculate based on each microfacet of a surface, rather than calculating the Fresnel just once based on the viewing angle?
You got me there. No, it cannot be updated.
It is part of the OSL 1.3.3 standard and even if we edit it - the microfacet normals used for sampling will be on the renderer side of the wall and totally unreachable by the OSL code.
We’ll have to figure something else.
Yeah. I think if we just used the per viewing angle Fresnel to attenuate the diffuse, we would end up with yucky darkening on the edges (an error that comes up a lot with sss), which is one of the issues that per microfacet Fresnel solves.
I asked again in the OSL developers group. Hopefully someone there can suggest a good approach.
BTW, OSL is now at 1.7.4. Are you guys planning on staying with 1.3.3?
Here’s a link to the OSL group thread if you want to have a look. Not sure I follow, as this gets deeper into shader writing than I can swim:
it seems tho that the recommended way that SPI does it is to have a closure that does both diffuse + spec together
We are not planning to stay indefinitely with 1.3.3 - we will update eventually.
Thank you for bringing up the problem in the OSL group. I’ll be following the topic.
Now that I think about it, a blendMtl in additive mode is not energy conserving either. Have you Chaos folks thought of making the additive mode work with weighted averages, rather than just cumulative adds? While this would not entirely make it energy conserving, it would go in the right direction. Thoughts?
i scripted one such shader.
http://forums.chaosgroup.com/showthread.php?79907-V-Ray-3-0-For-3ds-Max-Updates&p=636688#post636688
It lacked the interplay features (shared fresnels and such) of coded ones, but it was energy preserving at the top, and allowed for a few layers to be stacked on each other without breaking reciprocity anywhere.
The unfortunate side-effect of doing it with scripting was that i decided to not analyse the layers for their residual energy (no texture sampling), so i did conserve energy allright, but often a bit too much.
I stopped short of texture mapping of the parameter set, and just did one for the diffuse color to show how.
The code then went the Chaos Group way, a few months before I followed.
Its current status is MIA, but i believe the guys have long been looking at ways to do such a thing, and a bit more to the side.
It can be done, of course, but I don’t like the concept very much as such weighted average composites tend to behave somewhat unexpectedly as you start adjusting the weights… We had to do it in order to support MDL materials, but I still haven’t decided if I want it exposed as part of the blend material itself.
Best regards,
Vlado
Hmmm. I was not aware of any unexpected results with it, but I only have experience with trying it in OSL shaders. Perhaps it could be an option checkbox under “additive mode” that defaults to off?
Incidentally, I don’t see MDL materials in the docs. Where is that?
Rens,
Thank you for sharing these great textures.
Is anyone else having problems with slow updates in the material editor? When I go to the OSL texture, it seems to redraw 3-4 times (slowly) before it lets me work with the interface.
Yes, I have this issue in 3ds Max 2017. I reported it to our OSL developers and they are looking into it.
Best regards,
Vlado
Thanks Rens for all these very useful stuff !
I have a question regarding “The Reflector” one and I am sorry if that have been answered before but I would like to know how to use this l with a texture for the reflection ?(
(I have created a material in Substance Painter and when I export it I need to use a reflection map to re-create it in Max .)
Thanks in advance
Hi - just with the archglass shader - is opacity supposed to work on it? I’m not getting an alpha out of it.
Hey gang, is there a way in OSL to do something like Maya’s surface luminance? That is, can you drive a ramp’s direction (the V-cord) based on the light direction? OSL has a thing called diffuse_ramp, but I don’t think it is supported in Vray…
Nope, I’m afraid not. Why do you need it?
Best regards,
Vlado
It’s for an iris texture where a ramp based on the light direction controls the brightness of the iris. This is nice for getting a stylized iris, like you see in most CG animated films. I have it working with a bunch of nodes in Maya’s Hypershade, but thought it would be nice if I could get it into an OSL texture (I’m not a fan of big messy Hypershade trees).
Maybe there’s a way to use a diffuse color closure to drive the ramp?
Is this safe to ignore (maya) - using the archglass shader.
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_number_of_glass_panes (type: int)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_pane_absorbtion_tint (type: color)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_front_reflective_coating (type: color)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_front_dirt_color (type: color)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_dirt_amount (type: float)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_ior_out (type: float)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_ior_glass (type: float)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_refraction_mode (type: int)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_normalmap_pane1 (type: sampler)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_use_normalmap1 (type: bool)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_normalmap_pane2 (type: sampler)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_use_normalmap2 (type: bool)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_normalmap_pane3 (type: sampler)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_use_normalmap3 (type: bool)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_use_first_normalmap_for_all (type: bool)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_pane_absorbtion_tint_tex (type: sampler)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_use_absorbtion_tex (type: bool)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_front_reflective_coating_tex (type: sampler)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_use_coating_tex (type: bool)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_front_dirt_color_tex (type: sampler)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_use_dirt_col_tex (type: bool)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_dirt_amount_tex (type: sampler)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_use_dirt_amount_tex (type: bool)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_info_page (type: sampler)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_number_of_glass_panes (type: int)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_pane_absorbtion_tint (type: color)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_front_reflective_coating (type: color)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_front_dirt_color (type: color)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
[2016/Oct/19|09:32:07] V-Ray error: Can’t add attribute: vray_dirt_amount (type: float)
Error: ./osl_stuff.cpp:407: status: : (kInvalidParameter): Object is incompatible with this method
Error: status: (kInvalidParameter): Object is incompatible with this method
These errors should not appear. I tested the archglass shader, but it seems to work on our end. Could you provide a little more details how this is happening? What’s your V-Ray version?