Home Technical Talk

Physically based rendering in games

12346

Replies

  • tynew
    Offline / Send Message
    tynew polycounter lvl 9
    Then for a game engine like Unity, that would seem like an impossible task. Expensive rendering for games really is not an option when you don't want to limit your customer base to those only with high-end systems.

    The only solution I could find for voxel lighting in unity was this one:
    http://www.polycount.com/forum/showthread.php?p=1910356
    Which has not been up for public release.

    If it is going to cause more problems having destructible environments in line with pbr then I may as well have to avoid it all together with the game I am developing. Pbr seems to work very well for static/non destructible environments.
  • EarthQuake
    tynew wrote: »
    Then for a game engine like Unity, that would seem like an impossible task. Expensive rendering for games really is not an option when you don't want to limit your customer base to those only with high-end systems.

    The only solution I could find for voxel lighting in unity was this one:
    http://www.polycount.com/forum/showthread.php?p=1910356
    Which has not been up for public release.

    If it is going to cause more problems having destructible environments in line with pbr then I may as well have to avoid it all together with the game I am developing. Pbr seems to work very well for static/non destructible environments.

    Just for clarity, PBR is not image based lighting, and IBL is not PBR.

    Image based lighting is often a component in physically based shaders, but is not an explicit requirement. You can have a PBR shader that takes only dynamic light sources, it won't look as good or be as convincing, but you certainly can do the same mathy-stuff that makes a PBR shader "PBR" without IBL.
  • Neox
    Offline / Send Message
    Neox godlike master sticky
    tynew wrote: »
    Then for a game engine like Unity, that would seem like an impossible task. Expensive rendering for games really is not an option when you don't want to limit your customer base to those only with high-end systems.

    The only solution I could find for voxel lighting in unity was this one:
    http://www.polycount.com/forum/showthread.php?p=1910356
    Which has not been up for public release.

    If it is going to cause more problems having destructible environments in line with pbr then I may as well have to avoid it all together with the game I am developing. Pbr seems to work very well for static/non destructible environments.

    https://www.assetstore.unity3d.com/#/content/11874

    and i think there is at least one other solution for it that you can use already
  • marks
    Offline / Send Message
    marks greentooth
    Also, games have been using IBLs far longer than PBR. Static/Precomputed IBL in a dynamic environment is the problem here, not PBR.
  • JedTheKrampus
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    It's got to be possible to render environment probe textures with simplified shaders, reduced resolutions, and low framerates compared to the main game with a pretty small performance hit all things considered, and you could surely implement a scheduling subsystem to prioritize re-rendering cubemaps that are closer to environment areas that have changed recently... I just don't know of any game that's done it yet, outside of a tech demo.
  • tynew
    Offline / Send Message
    tynew polycounter lvl 9
    Thanks for the info guys, I will most likely have to skip using PBR until I fully understand how to integrate it into a game with destruction. I'm just an artist, I wouldn't know how to code things for environment probe/cubemap seamless transitions.
  • tynew
    Offline / Send Message
    tynew polycounter lvl 9
    I use a directional light in my game to represent the sun. From what I've seen Unity PBR only works with point lights? Would the voxel lighting Neox linked be a remedy for that?

    I understand that PBR makes materials look correct under different lighting conditions, how much different would PBR objects look without the use of IBL? Would it have to be a custom written shader?

    With skyshop you have to calculate the scene ambience with IBL. With the PBR shaders I've gotten my hands on they have just affected the object and I had no need to calculate ambient lighting.

    Then again all of this talk might be useless if I can't use a directional light to represent the sun with PBR.
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    excuse the huge images below:

    Tynew, that shader i wrote absolutely works with directional lights. There's no reason why it wouldn't at all!

    If you need me to strip out the IBL, that's no problem but you'll need to find some way to create ambient colouring for metallics because of the way PBR shaders work.

    odUHd4k.png
    xpKmmtw.png
    RWdvnvy.png
  • tynew
    Offline / Send Message
    tynew polycounter lvl 9
    Oh awesome gir! I'm not sure whether it is best to keep or remove IBL for my scenario. I will have to try a demo scene with a destructible room with PBR and see how I can make it work. I'll chat to you on Skype.
  • larsbertram
    Hi there,
    i would just like to inform you that Lux – an open source physically shader framework for unity has been officially released on the asset store:
    https://www.assetstore.unity3d.com/#/content/16000

    Lars

    OHDW

    Vpx4

    eDxs

    RuPE

    u8Rb

    o9Rf

    EzCN

    Lars
  • 3dlix
    Hey folks, i did alot of research about PBR in CryEngine 3. But i didn't find a clear answer, if the current Version of the FreeSDK suports Physical based Shading/Rendering! For example like Unreal 4. Thanks guys.
  • Zepic
    Offline / Send Message
    Zepic polycounter lvl 11
    3dlix wrote: »
    Hey folks, i did alot of research about PBR in CryEngine 3. But i didn't find a clear answer, if the current Version of the FreeSDK suports Physical based Shading/Rendering! For example like Unreal 4. Thanks guys.

    The current Cryengine SDK doesn't have the PBS system turned on yet. They will be implementing it in the next couple of months.
  • 3dlix
    Zepic wrote: »
    The current Cryengine SDK doesn't have the PBS system turned on yet. They will be implementing it in the next couple of months.

    yeah thanks,Zebic. i found out that it will released with the 3.6 version. maybe in may... here: http://www.crydev.net/viewtopic.php?f=355&t=121859 :)
  • oks2024
    Hi everyone !

    I'm a graphics programmer, and a friend recently started to become very interested in creating physically based rendering textures.
    It gave me the idea to make a small tool to be able to quickly and easily see PBR textures in a real time engine, and for me it was a good excuse to implement physically based shading.

    I thought this might also interest some of you. You can try it here : http://www.alexandre-pestana.com/physically-based-rendering-viewer/

    This is a very work in progress version, so it may have bugs or incorrect behavior, but I'm working on making it better. I'd be happy to have some feedbacks/suggestions !

    Here is how it works for now:

    You can load you own textures by replacing those in the models/material/0/ folder, they will be automatically reloaded as soon as they are modified.

    You can choose to use the sliders values instead of a texture by using the checkboxes in front of each inputs.

    You can choose bewteen metallic/specular workflow and roughness/glossiness map.

    Some screenshots:

    Physically-Based-Rendering-6.png

    Workflow_Specular1.png

    The default texture is pretty ugly (yes, I'm a programmer :/), sorry for that, and I need to work on the models to make them better.

    This week I've implemented a lot of variations in the BRDF terms, and after that I'll implement the Disney's BRDF.


    Again, if you have any feedback/suggestion/bug report/anything I'd be happy to hear from you !
  • jgreasley
    We've just released Mari 2.6 which has updated BDRF shading and environment lighting added

    https://vimeo.com/90974835

    Is a quick overview and there's been some really interesting custom shaders added by our users to mach Arnold and VRay

    https://vimeo.com/91053166
  • MFN
    Are there any good online resources for material values (Albedo, Reflectivity, Roughness)? I've been searching but it's hard to find much.
  • Joopson
    Offline / Send Message
    Joopson quad damage
    MFN wrote: »
    Are there any good online resources for material values (Albedo, Reflectivity, Roughness)? I've been searching but it's hard to find much.

    This thread has more info than I've found elsewhere: http://www.polycount.com/forum/showthread.php?t=133651
  • MFN
    Very awesome thanks!
  • Skinpop
    Offline / Send Message
    Skinpop polycounter lvl 9
    Hi there,
    i would just like to inform you that Lux – an open source physically shader framework for unity has been officially released on the asset store:
    https://www.assetstore.unity3d.com/#/content/16000

    Lars

    Great work, I haven't had the time to try it yet but I'm wondering if it includes a pipeline for generating cubmap probes and if it supports preblurred HDR cubemaps(maybe RGBM encoded?). Also, does it work with deferred rendering? I've tried implementing a PBL shader for the deferred rendering path but adding g-buffers seem almost impossible in Unity.

    EDIT:
    looks like most of my questions are answered at the store page. How did you solve the gbuffer issue?
  • Xoliul
    Offline / Send Message
    Xoliul polycounter lvl 16
    Hey just wanna drop this video here:

    [ame="http://www.youtube.com/watch?v=LP7HgIMv4Qo"]Physically Based Rendering in Substance - YouTube[/ame]

    This is one of the first ones that is pretty much fully correct. Even if you don't use Substance it still brings up all the right stuff.
  • cman2k
    Offline / Send Message
    cman2k polycounter lvl 17
    yes...this video was awesome. Clearest explanation I've heard yet, and focused on all the right areas for artists.
  • Teessider
    Offline / Send Message
    Teessider polycounter lvl 11
    Watched that stream live, it was great! I've already recommended watching that to the people I work with.
  • Neox
    Offline / Send Message
    Neox godlike master sticky
    Xoliul wrote: »
    Hey just wanna drop this video here:

    Physically Based Rendering in Substance - YouTube

    This is one of the first ones that is pretty much fully correct. Even if you don't use Substance it still brings up all the right stuff.

    really great video, will help a lot of people. tho i have an artistic question, why, as all this is scientifically based data, why is copper not looking like copper at all? i don't have anything to test here, but is it just the roughness that would kick in the reddish tone copper gives to all that it reflects?
    because as it is, it looks like chrome with maybe one layer of coloured clearcoat
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    I think the important thing to remember here Neox, is that most of the scanned data readings used for these base metals (like the copper there) are taken from pure, or as pure as they can get anyway, metals. the likelihood of you ever seeing anywhere close to pure copper in your lifetime is slim to none, it's almost always (even in the case of minted coins) alloyed with another metal like nickel, tin, or brass. Even if you see pure copper (in terms of not being alloyed) it will likely have some form of oxidation on the surface, too.
  • Neox
    Offline / Send Message
    Neox godlike master sticky
    how much sense would such a preset then make considering no one will ever see anytging like that? so basically the preset is useless until you create your own one that reflects the way people would expect it to look like.
  • marks
    Offline / Send Message
    marks greentooth
    Measured data is used as a physical baseline to reference against. If you make a preset which is adjusted for what you expect to see ... as long as it's reasonably close to the "correct" values, that would be the way to do it.
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    Take the base values and think about how it being a alloy or how tarnish and rust and things like that effect the metal.

    Most things just add variation to the surface in albedo, and increase the roughness, while in extream cases of build up of things like tarnish it covers the metal, and should be defined as non metal.
  • Gestalt
    Offline / Send Message
    Gestalt polycounter lvl 11
    Another reason that copper might not be looking as you'd expect is because each metal has unique properties that aren't perfectly described here. Metals have unique 'fresnel' type effects http://i.imgur.com/fihms.jpg and they also absorb specific wavelengths that can't be described for all cases by a single RGB value. http://i.stack.imgur.com/gW0Af.png
  • ZacD
    Offline / Send Message
    ZacD ngon master
    perna wrote: »
    Be careful. There's so many people married to the "pure metal", "1.0 metalness" nonsense that you might get a witch hunt on your ass by stating things like that.

    Metalness has spawned more misunderstanding and more irrational devotion to false ideas than specular maps ever did. It's borderline religious and frankly disturbing how people are willing to throw both their artistic eye and common sense to the wind in perpetuating these notions.

    Yup, we need better documentation and more scanned data to look at.
  • radiancef0rge
    Offline / Send Message
    radiancef0rge ngon master
    perna wrote: »
    Be careful. There's so many people married to the "pure metal", "1.0 metalness" nonsense that you might get a witch hunt on your ass by stating things like that.

    Metalness has spawned more misunderstanding and more irrational devotion to false ideas than specular maps ever did. It's borderline religious and frankly disturbing how people are willing to throw both their artistic eye and common sense to the wind in perpetuating these notions.

    +1. Also it seems the graphics programmers love this workflow a little too much.
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    well, the workflow IS simpler, and cheaper, so i certainly understand why they'd want to use it.

    i dislike that it's forced on people though.
  • radiancef0rge
    Offline / Send Message
    radiancef0rge ngon master
    yeah I guess thats what I meant, they seem to be opposed to exposing f0 as well.
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    exposing in what way? like, what would you like to see different?
  • Joopson
    Offline / Send Message
    Joopson quad damage
    I'd definitely like the option to not use metalness in UE4. I've tried using their specular input, but it's extremely limited, and won't let me get strong enough reflections that look metal-ish, so that's a no-go. Not to mention it's only grayscale.

    I really love how Marmoset does it. Not sure why most engines wouldn't give you the option, because it does open up lots more possibilities for the artist. Even if metalness workflow isn't technically limiting, sometimes it really feels that way.
  • ZacD
    Offline / Send Message
    ZacD ngon master
    Epic has said that the specular option is only there for legacy reasons, and shouldn't be used in most situations. It is kinda limiting, hopefully they will add support for non-metalness PBR workflows.
  • Gestalt
    Offline / Send Message
    Gestalt polycounter lvl 11
    Exposing the f0 would give you control of the different kinds of IORs. Some materials have more reflections facing the camera than others. For most cases it shouldn't be a huge deal, but if it were you'd probably only need a few values since many materials have similar IORs (water based materials tend to be pretty similar for example).

    Right now you can sort of do something similar by manipulating the specular value (you can go over 1 if you want to). I'm not sure if the specular value is actual tied to the fresnel or if it's just multiplied. It might help for people who want a non-metal that is 'shiny', you'd use a low roughness (close to 0) and maybe adjust the specular value a bit as if it were IOR. Also keep in mind that the base color is separate from the glancing reflections, so if you want a material that has very distinct highlights you might want to consider it might have a darker base color.
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    so in the case of the UE4 (among others: the order 1866, codblops2 etc.) their tech papers show that their BRDF is formed of three components:

    Specular distribution, Geometric shadowing, Fresnel.

    the math given in the UE4 tech paper (and in their source code) for Fresnel is this:
    Fresnel = F0 + (1 - F0) * pow(2, (-5.55473 * VoH - 6.98316) * VoH)
    

    where F0 = specular colour (or, "reflection at normal incidence"), and VoH = dot product of view and half vectors.

    given that the BRDF functions by simply doing:
    D * G * F
    

    and that the Fresnel function is the only one to take the specular colour as an input, i'm not sure how you'd control the F0 outside of doing one of the following:
    SpecCol * D * G * F
    Where F0 inside fresnel is now a constant value
    
    or
    Fresnel = (SpecCol * F0) + (1 - (SpecCol & F0)) * pow(2, (-5.55473 * VoH - 6.98316) * VoH)
    

    however i don't think either of those solutions would lead to a truly accurate result... i have however, only just woken up. so i can try some tests later and see :)
  • marks
    Offline / Send Message
    marks greentooth
    Hmmmm looks like their F0 amount is tied directly to specular level. Seems like a legit method, that's what we're doing on A:I - having less parameters to juggle is nice even if it does remove a bit of control.
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    yeah that's the conclusion i came to as well.
  • ZacD
    Offline / Send Message
    ZacD ngon master
    Do fabrics need to be handled in any special way, or do they just act the same as any rough surface?
  • Drew++
    Offline / Send Message
    Drew++ polycounter lvl 14
    ZacD wrote: »
    Do fabrics need to be handled in any special way, or do they just act the same as any rough surface?

    Generally, stuff like glass, plastics, stone, sand and fabrics all have a very similar specular/reflectance value, just different roughness. I averaged the colors of about 10-15 different scanned materials(cotton, nylon, denim, sand, stone, etc...) and it came out to roughly ~(60,60,60) for a specular/reflectance color.

    Hope that helps :)
  • marks
    Offline / Send Message
    marks greentooth
    ZacD wrote: »
    Do fabrics need to be handled in any special way, or do they just act the same as any rough surface?

    Not quite. Ideally you want to use a specialized BRDF for cloth. The specular response of cloth is kinda backwards to typical microfacet BRDF - most noticeably in the strong grazing specular on edges which is due to asperity scattering through fibers that point away from the surface. For front-facing areas there's actually very little specular contribution.

    Regular microfacet BRDF like Cook-Torrance isn't awful but it's definitely not the best way to do it.
  • Skinpop
    Offline / Send Message
    Skinpop polycounter lvl 9
    Why is the metalness property even used? Wouldn't it make more sense to just use the range of reflectivity/specular color? I've heard said that metalness is used to make things more intuitive for artists but I think it mostly causes confusion/misunderstanding.
  • Xoliul
    Offline / Send Message
    Xoliul polycounter lvl 16
    Skinpop wrote: »
    Why is the metalness property even used? Wouldn't it make more sense to just use the range of reflectivity/specular color? I've heard said that metalness is used to make things more intuitive for artists but I think it mostly causes confusion/misunderstanding.

    The reason for that is that you can roughly divide reflectivity of materials in real life, in 2 larger groups, that lie at 2 extremes of the range.
    From 0-2% doesn't happen in real life, at 2% it's pretty much only water. Then most non-metals average around 4%. Metal then sit around 20-25%. There's some exceptions with crystals and diamonds having values like 12-15%, but that's very rare.

    Draw it out on a scale from white to black, where black = 0% and white is 25%. There's a bunch of 'non-existing' zones in there, I'd argue that's a lot less intuitive than just the metalness map. I frequently see people mess this up on Polycount here.

    So the problem with opening up the entire range, is that it allows you to create materials that don't exist, according to measured data. Measured data on which all those PBR calculations rely.
  • Skinpop
    Offline / Send Message
    Skinpop polycounter lvl 9
    Xoliul wrote: »
    The reason for that is that you can roughly divide reflectivity of materials in real life, in 2 larger groups, that lie at 2 extremes of the range.
    From 0-2% doesn't happen in real life, at 2% it's pretty much only water. Then most non-metals average around 4%. Metal then sit around 20-25%. There's some exceptions with crystals and diamonds having values like 12-15%, but that's very rare.

    Draw it out on a scale from white to black, where black = 0% and white is 25%. There's a bunch of 'non-existing' zones in there, I'd argue that's a lot less intuitive than just the metalness map. I frequently see people mess this up on Polycount here.

    So the problem with opening up the entire range, is that it allows you to create materials that don't exist, according to measured data. Measured data on which all those PBR calculations rely.

    Messing it up just means they don't understand the theory behind it, which they should since it's really not that difficult. I guess it's more intuitive for me since I've written pbl shaders and have forced myself to understand how it works. Still don't like the metalness approach though.
  • stevston89
    Offline / Send Message
    stevston89 interpolator
    Skinpop wrote: »
    Messing it up just means they don't understand the theory behind it, which they should since it's really not that difficult. I guess it's more intuitive for me since I've written pbl shaders and have forced myself to understand how it works. Still don't like the metalness approach though.

    Not really. Not everyone has the ability to measure out real reflectance values. So what are they supposed to go off of without the proper data. Metalness is just making sure they can't break their materials while simplifying the process. Personally I don't like it, because I like having more specific control when I need it ( cloth is one of those areas I need more control on).
  • marks
    Offline / Send Message
    marks greentooth
    Skinpop wrote: »
    Messing it up just means they don't understand the theory behind it, which they should since it's really not that difficult.

    Yeah but you can be pretty much guaranteed that in a production environment, there will be people who just don't get it, and will screw the values. It's a decent degree safer to juse use "Metal, or not metal" definitions as that will cover easily 90%+ of your use-cases.

    The other benefit of metalness workflow for us is that by using a mask to define which of the two reflectance ranges your material falls into, that allows us to use the full 0-255 range of your reflectance texture as much as possible.

    Using 0-255 to cover your entire reflectivity range will lead to large areas of unused histogram which leads to more compression artifacts.

    Using 0-255 to cover min/max dielectric range, and the same texture 0-255 to cover min/max conductor range means that you're minimising the amount of unused/wasted histogram in your texture, which means you get more accurate data after compression.


    Cloth specifically really should be using specialized BRDF or additional parameters specifically for that material definition anyway. Especially because cloth does a lot of funky stuff like having coloured specular which is caused by diffuse inter-reflection between fibers on the micro level. Additionally the fresnel curve is different for it, and it usually has aniso reflections rather than isotropic as your "regular" BRDF will have.

    I'd recommend checking out the RAD GDC2014 talk regarding cloth BRDFs, they have some useful info in there (it's available on GDC Vault but I believe it's members only).
  • EarthQuake
    marks wrote: »
    Yeah but you can be pretty much guaranteed that in a production environment, there will be people who just don't get it, and will screw the values. It's a decent degree safer to juse use "Metal, or not metal" definitions as that will cover easily 90%+ of your use-cases.

    The other benefit of metalness workflow for us is that by using a mask to define which of the two reflectance ranges your material falls into, that allows us to use the full 0-255 range of your reflectance texture as much as possible.

    Using 0-255 to cover your entire reflectivity range will lead to large areas of unused histogram which leads to more compression artifacts.

    Using 0-255 to cover min/max dielectric range, and the same texture 0-255 to cover min/max conductor range means that you're minimising the amount of unused/wasted histogram in your texture, which means you get more accurate data after compression.


    Cloth specifically really should be using specialized BRDF or additional parameters specifically for that material definition anyway. Especially because cloth does a lot of funky stuff like having coloured specular which is caused by diffuse inter-reflection between fibers on the micro level. Additionally the fresnel curve is different for it, and it usually has aniso reflections rather than isotropic as your "regular" BRDF will have.

    I'd recommend checking out the RAD GDC2014 talk regarding cloth BRDFs, they have some useful info in there (it's available on GDC Vault but I believe it's members only).

    QFT
  • Joopson
    Offline / Send Message
    Joopson quad damage
    A big issue I'm having with metalness is how exactly the scale works.

    If I have a transition between metal and non-metal, I obviously want the transition to be anti-aliased, which adds a visual fade to the edge, to make it less harsh. The problem is, the values don't convert equally between the color map and the metalness map, and I always have an error where the very edge of the metal, right where the anti-aliasing is, has a very non-metal line that sticks out like a sore thumb. This is making it a lot harder to add, say, scratches through painted metal, or areas with rust, because I always have these stray transition lines.

    To illustrate my point, here's an image of my expectations of metalness, as opposed to how it actually works. I created the "expectations" by grabbing the full-metal sphere and placing white over it. I'm darkening and making the diffuse less apparent in a linear way. 0.5 is half visible, and half the brightness, for instance. But you can see it doesn't actually behave that way.

    I4YYL4Z.jpg


    I've also included an example of the awful non-metal edge in transitions.

    7KhvShA.jpg

    Any tips or explanations about this? Has it bothered anyone else? Am I totally missing something?

    Edit: I should mention that these shots are from Marmoset 2, but it's no different in UE4.
  • stevston89
    Offline / Send Message
    stevston89 interpolator
    @ joopson - I don't think there is a way to eliminate it. In Marmoset if you turn of mip maping it helps, but you wouldn't be able to have no mip maps in a real game environment.
12346
Sign In or Register to comment.