Author Topic: custom GLSL shader  (Read 5397 times)

hey guys ..I'm implementing complex ior in the substance pbr shader....and its working fine in openGL but not working in Iray(when i render in Iray, it just renders grey colored(not taking ior and extinction coefficient into account) .

any idea why?
do i have to translate this to mdl as well?

ok, came to know that "with a glsl , it requires mdl as well and that has to be declared in the glsl" ...but this line "bsdf fresnel_complex_ior = df::fresnel_factor(ior: color(whatever), extinction_coefficient(color(whatever), base: metallic_model)" is not working.
is this bsdf(fresnel_factor) available in mdl 1.3?
help please///////

It's hard to help you there, you are not giving enough information.
What does your GLSL ior declaration looks like ? Or does it apply in your MDL ?
Don't forget your log file. It can be exported from the Help menu of the software.
-----------
Froyok aka Fabrice Piquet, Technical Artist and Product Designer at Allegorithmic.

hi @Froyok I've now come to an exact explanation to my problem. so right now substance painter(2019.2.2) is using mdl 1.3 right? and fresnel_factor is added in mdl 1.4 . so that's creating a problem. in viewport, my shader is working fine but can't make it in mdl cause of the bsdf not available.
and also mdl doesn't have any view vector function so ......I'm hitting my head now, :P........
any help!!!??

What does your GLSL ior declaration looks like ? Or does it apply in your MDL ?
it should be in both right?
and glsl shader is working fine but when i render it with iRAY, it won't work.

Just to confirm: yes, if you use a user channel in your glsl shader you have to connect it in the mdl as well. Take a look at our own mdl to see how we do it. We use something like: alg::base::annotations::sampler_usage("basecolor", "Base Color/Diffuse").
Don't forget your log file. It can be exported from the Help menu of the software.
-----------
Froyok aka Fabrice Piquet, Technical Artist and Product Designer at Allegorithmic.

thanks for this....
but now the problem is that I need to calculate dot product of view direction and normal....but mdl doesn't give us access to direction vector .....do you have any workaround for this?
or can i convert a bsdf to color? so that I could take directional factor and convert it to greyscale and use this as the outcome of dot(rayDir, normal)..... :-\
Last Edit: October 22, 2019, 11:32:45 am

Hello Bhuwan,

Nice to see that we were able to overcome your first hurdle and get your MDL shader running in Painter
Regarding your goal to implement a complex ior in MDL you will have to deal with the way it represents material
Although you have access to a couple of renderer states the view vector is not among those - one the reason being that it would be hard for pathtracer to compute the material shading if you depends on it.

Now going back to MDL in Painter, the current version supports up to MDL 1.3 which offers you several view dependent functions to represent your effect but not the one you are interested in.
When Painter will upgrade to MDL 1.4, you will indeed have access to the df::fresnel_factor functions which does exactly what you want
In the meantime, I suggest that you approximate this effect using either directional_factor or measured_curve_factor

Regards

Hi Andrea Machizaud , I don't think it is possible to even approximate this with directional factor or any other bsdf in 1.3(I think there isn't much we can do with the bsdfs(in terms of modifying them), cause it outputs a bsdf not a color and can't map it to complex fresnel equation)
but if you have an insight to this can you please explain a bit?
Last Edit: November 08, 2019, 08:15:26 am