Home Technical Talk

Are materials always reflective with PBR rendering?

polycounter
Offline / Send Message
Davision3D polycounter
I'm working in UE4 and I would like to have my material without any reflection, so I set metallic and specular to 0 and roughness to 1. But I still get visible reflection going on:

4uGx5oz.gif
Now I'm seriously wondering if it is not possible to make lit materials in UE4 without any reflection? I also tried using only a directional light but it stayed reflective.

For my game I want everything to be static including any reflection, specular etc since I want it to look like you are in a painting. But I also see it problematic for other styles.

Here is the problem in a better context:
uHBm0Tr.gif
with that reflective effect going on it is impossible to merge the grass alphas with the terrain grass texture.

Replies

  • s6
    Options
    Offline / Send Message
    s6 polycounter lvl 10
    My experience with UE4 is limited, but if you can't get rid of that reflection you could always use a pure black cubemap. That way when it does reflect, if it does reflect, it reflects nothing. This is under the assumption reflections are still additive in UE4.

    You might be seeing the constant Fresnel reflection, if UE4 represents that on rough/nonmetal surfaces. It's difficult to tell what it looks like from the top Gif.
  • JustMeSR
    Options
    Offline / Send Message
    JustMeSR polycounter lvl 4
    I don't know about turning them off, but you can minimize their visibility by (setting roughness up to 1 as you did) turning off Screen Space Reflections in postprocessing and by changing default cubemap to 1 colour.
  • WarrenM
    Options
    Offline / Send Message
    You can also plug zero into the specular input. That should take care of any and all reflections.
  • Davision3D
    Options
    Offline / Send Message
    Davision3D polycounter
    Turns out it is a bug. I made a comparison with a older engine version:

    Correct in 4.61:
    ylOOFy0.gif

    Broken in 4.81:
    23n2mjA.gif

    Don't know what is going on and how something this essential can slip through. Well, I hope it gets fixes soon.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    It doesn't look like a bug to me, rather it was buggy earlier, because what you see is a fresnel reflection. This is how it should look and behave. Switching to an unlit shader and some emissive function doesn't help?
  • radiancef0rge
    Options
    Offline / Send Message
    radiancef0rge ngon master
    What you are seeing is probably ue4s change to the disney diffuse model instead of lambert.

    "New: Switched diffuse shading model from Lambert to energy conserving Burley."
  • Davision3D
    Options
    Offline / Send Message
    Davision3D polycounter
    What you are seeing is probably ue4s change to the disney diffuse model instead of lambert.

    "New: Switched diffuse shading model from Lambert to energy conserving Burley."

    If that is true I'm screwed and I have hard time to understand how that should be more realistic and why they make such a big change in rendering when the engine is out of a beta a long time ago. That would mean every material has that fresnel and I assume I have no chance to change that because that is how the engine then renders it.

    For my game the change is much more worse because I only want to have diffuse lit materials and there is the merge problem with grass. I also calculate lighting in my shader by dividing scene color with diffuse color. (There is no other way in UE4 to get the lighting)
    As the result that fresnel effect is even worse with my post processing shader:
    YV1EmAu.gif

    Obscura wrote: »
    It doesn't look like a bug to me, rather it was buggy earlier, because what you see is a fresnel reflection. This is how it should look and behave. Switching to an unlit shader and some emissive function doesn't help?
    Unlit shader means it will have no lighting. What you mean with emmissive funtion?
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Yeah. If you want diffuse lighting then it won't work for you. I just thought maybe that fresnel reflection can be compensated somehow with emissive or maybe with dynamically darkening the color based on fresnel. It was just an idea, but maybe it can make it a little better.
  • JoakimMellergard
    I am not sure if this will solve it but it might be worth a try.
    Disconnect your metallic input and only use specular with a value of 0. Having metallic connected overrides specular input. There's an If-statement for that when the shader is compiling.
    The proper way of doing this though is having a programmer removing all fancy PBR calculations in code. It's a waste of performance to have PBR shaders running and not using it's features.
  • JoakimMellergard
    Also,
    You can try opening ...\UE4\x.x\Engine\Shaders\BRDF.usf
    search for #define PHYSICAL_SPEC_F
    it is by default set to 1 (Schlick). change it to 0 (None) to disable fresnel.
    You can also try changing PHYSICAL_SPEC_D from 2 (GGX) to 0 (Blinn) which might make the shading a little bit more conventional.
  • Vovosunt
    Options
    Offline / Send Message
    Vovosunt polycounter lvl 4
    As far as I can tell you're going with a cell-shaded style, why use BRDF then? Just make/get a new shader that only has the things you need, like a lambertian lighting model with cell-shading clamping (I'm a UE4 scrub, but come on that's a feature that any engine MUST have). You'll save a ton on performance and headaches...
  • radiancef0rge
    Options
    Offline / Send Message
    radiancef0rge ngon master
    yeah should be able to get around this with some really simple shader code editing.
  • Davision3D
    Options
    Offline / Send Message
    Davision3D polycounter
    Obscura wrote: »
    Yeah. If you want diffuse lighting then it won't work for you. I just thought maybe that fresnel reflection can be compensated somehow with emissive or maybe with dynamically darkening the color based on fresnel. It was just an idea, but maybe it can make it a little better.

    That is likely very tricky since it not just fresnel and instead some special fresnel based on lighting with reflection somehow. But if all fails I give that a try.
    I am not sure if this will solve it but it might be worth a try.
    Disconnect your metallic input and only use specular with a value of 0. Having metallic connected overrides specular input. There's an If-statement for that when the shader is compiling.
    The proper way of doing this though is having a programmer removing all fancy PBR calculations in code. It's a waste of performance to have PBR shaders running and not using it's features.
    That didn't help it. From how I understand PBR it is not just in the shader but also in the lighting and UE4 is build around PBR. So if I would get rid of PBR in the shaders the lighting would look strange.
    Also,
    You can try opening ...\UE4\x.x\Engine\Shaders\BRDF.usf
    search for #define PHYSICAL_SPEC_F
    it is by default set to 1 (Schlick). change it to 0 (None) to disable fresnel.
    You can also try changing PHYSICAL_SPEC_D from 2 (GGX) to 0 (Blinn) which might make the shading a little bit more conventional.
    I tried that now but unfortunately that didn't change it. I then went to replace the whole BRDF file with the old one of 4.6 but no change either. The materials/shaders were all compiling again when I opened my project but for some reason there is no change. I even tried to just replace all shader files with the ones of 4.6 but that just crashed the engine.

    While comparing the 4.6 file with the 4.8 one I found out that this is the only #define changed:
    // Fresnel
    // 0: None
    // 1: Schlick
    // 2: Fresnel
    #define PHYSICAL_SPEC_F		1
    
    To:
    #define PHYSICAL_SPEC_F		0
    
    Vovosunt wrote: »
    As far as I can tell you're going with a cell-shaded style, why use BRDF then? Just make/get a new shader that only has the things you need, like a lambertian lighting model with cell-shading clamping (I'm a UE4 scrub, but come on that's a feature that any engine MUST have). You'll save a ton on performance and headaches...
    Sort of cell-shaded, basically using ramps. Mapping lighting to a ramp texture that includes all Hues in V in the post processing material/shader (additionally color luminance gets blended in by 2 additional ramps textures).
    The thing is Unreal engine shader making is basically just making materials in a node based editor which then get compiled as shaders. That is then somehow based on the BRDF. Even if I could just replace the BRDF with something else I doubt I still could make use of the material editor.
    As I see it UE4 is very much constrained in that regard and build around just realistic rendering and shaders.
    yeah should be able to get around this with some really simple shader code editing.
    Doesn't look like it.
  • radiancef0rge
    Options
    Offline / Send Message
    radiancef0rge ngon master
    DeferredLightingCommon.usf line 103

    //float3 Diffuse = Diffuse_Lambert( GBuffer.DiffuseColor );
    float3 Diffuse = Diffuse_Burley( GBuffer.DiffuseColor, LobeRoughness[1], NoV, NoL, VoH );

    uncomment 103 and comment out 104. Then in the console "recompilescripts changed"
    Im not sure if this will work as I don't have the ue4 source downloaded.

    But as far as I can tell that will change the diffuse lighting model of the standard shader back to lambert.
    Even if I could just replace the BRDF with something else I doubt I still could make use of the material editor.
    As I see it UE4 is very much constrained in that regard and build around just realistic rendering and shaders.


    This is not true at all, it just requires some shader work if you don't want to have physically imitated Fresnel, specular, reflections etc
    The thing is Unreal engine shader making is basically just making materials in a node based editor which then get compiled as shaders.

    This is half true - "materials" and "shaders" are different things. Materials contain custom elements that are then compiled with the rest of the shader that contains the lighting calculations. Things like how point lights and spotlights interact with the surface, how the image based lighting works, how the shadows happen etc. That contains the lighting model.

    Imagine you are editing the diffuse of a material. Lets say diffuse is "D" In the shader - in code - the Unreal engineers have already done the complicated work of what happens when light hits the surface. Lets call those calculations "L". So that complicated math we are going to call "DdotL"

    In the material editor lets say I want to multiply a texture map by a color (red) and plug that into the diffuse element of the shader. Thats going to be "2DTexture * (1, 0, 0)"

    So at the end of the day all you are doing is

    ( 2DTexture * (1, 0, 0) ) = D

    and the compiler then takes that D and does the Lighting Calculations to it and you end up with..

    DdotL

    So all of that DdotL information happens in the shader, if you change an element of the shader in code, as long as you wrote it correctly and it compiles you can still edit the inputs of the shader in the material editor
  • GlowingPotato
    Options
    Offline / Send Message
    GlowingPotato polycounter lvl 10
    that is fresnel
  • Davision3D
    Options
    Offline / Send Message
    Davision3D polycounter
    That worked! Thanks a lot! :)

    Recompileing wasn't needed, well the engine automatically recompiled all shaders on loading the project.

    It is tempting to change more of the shader source but for me it appears rather complex with so many files and code.

    As for mateials being different things, it can also vary a lot what materials are. With the default shader materials in Unity you can basically only change the textures and some parameters that the shader allows and there is then no shader compiling required I guess. In UE3 you can do a whole lot with the material editor including changing how lighting works. In UE4 you can not do that not anymore which I'm not sure why.
    Well, I guess materials always just allow you to change how the shaders work and not add to it. Shaders could allow materials to change close to everything or keep it very simple. I think the thing with UE is that it compiles the materials intelligently so the shader code required is low while a whole lot is possible in the material editor.
    DeferredLightingCommon.usf line 103

    //float3 Diffuse = Diffuse_Lambert( GBuffer.DiffuseColor );
    float3 Diffuse = Diffuse_Burley( GBuffer.DiffuseColor, LobeRoughness[1], NoV, NoL, VoH );

    uncomment 103 and comment out 104. Then in the console "recompilescripts changed"
    Im not sure if this will work as I don't have the ue4 source downloaded.

    But as far as I can tell that will change the diffuse lighting model of the standard shader back to lambert.




    This is not true at all, it just requires some shader work if you don't want to have physically intimated Fresnel, specular, reflections etc



    This is half true - "materials" and "shaders" are different things. Materials contain custom elements that are then compiled with the rest of the shader that contains the lighting calculations. Things like how point lights and spotlights interact with the surface, how the image based lighting works, how the shadows happen etc. That contains the lighting model.

    Imagine you are editing the diffuse of a material. Lets say diffuse is "D" In the shader - in code - the Unreal engineers have already done the complicated work of what happens when light hits the surface. Lets call those calculations "L". So that complicated math we are going to call "DdotL"

    In the material editor lets say I want to multiply a texture map by a color (red) and plug that into the diffuse element of the shader. Thats going to be "2DTexture * (1, 0, 0)"

    So at the end of the day all you are doing is

    ( 2DTexture * (1, 0, 0) ) = D

    and the compiler then takes that D and does the Lighting Calculations to it and you end up with..

    DdotL

    So all of that DdotL information happens in the shader, if you change an element of the shader in code, as long as you wrote it correctly and it compiles you can still edit the inputs of the shader in the material editor
Sign In or Register to comment.