Originally posted by Ivan Mavrov
View Post
Announcement
Collapse
No announcement yet.
An assortment of OSL shaders for your perusal
Collapse
X
-
You can probably trust the built-in "fresnel" function.
Code: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); }
Ivan M.
Comment
-
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?
Comment
-
Originally posted by Ivan Mavrov View PostYou 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?
Comment
-
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:
https://groups.google.com/forum/#!to...ev/Pm4rAapxOj0
it seems tho that the recommended way that SPI does it is to have a closure that does both diffuse + spec togetherLast edited by sharktacos; 02-09-2016, 09:07 AM.
Comment
-
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?
Comment
-
i scripted one such shader.
http://forums.chaosgroup.com/showthr...688#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.Lele
Trouble Stirrer in RnD @ Chaos
----------------------
emanuele.lecchi@chaos.com
Disclaimer:
The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.
Comment
-
Originally posted by sharktacos View PostNow 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?
Best regards,
VladoI only act like I know everything, Rogers.
Comment
-
Originally posted by davision View PostIs 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.
Best regards,
VladoI only act like I know everything, Rogers.
Comment
-
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-------------------------------------------------------------
Simply, I love to put pixels together! Sounds easy right : ))
Sketchbook-1 /Sketchbook-2 / Behance / Facebook
Comment
Comment