Home Technical Talk

The Gamedev Cast is answering questions about PBR!

2

Replies

  • marks
    Offline / Send Message
    marks greentooth
    Beddall wrote: »
    hey,

    The whole thing about sRGB and converting to linear sort of flew over my head a bit. Is this something that comes from high-end rendering? also, there was mention of a link with some way to convert the values, but i don't see it.

    after a bit of reading i think it's to un-gamma correct the textures.. .is this correct?

    also, there is a tutorial half way down this page,... http://maddieman.wordpress.com/2009/06/23/gamma-correction-and-linear-colour-space-simplified/ on how to convert your sRGB textures.... does this look correct?

    cheers


    Basic summary:

    Textures that are authored in Photoshop or rendered out from a 3d package are generally in sRGB (gamma-space).

    All colour math inside shaders is done in linear-space. This means that any sRGB textures need to be converted to Linear before they can be used in the shader (the conversion is done IN the shader when it reads the texture though, so don't sweat it - saving your textures in sRGB is totally fine). The final results of the shader need to be converted to sRGB (gamma-space) at the end of the shading so that it can be displayed correctly.

    Converting between Linear and sRGB is just a math transform that you can find on wikipedia (although granted it's a bit complex to decipher).

    I don't have the link to hand, but CrazyButcher has a little webpage converter tool on it that EarthQuake has linked to in the past. I want to stress that you shouldn't need to worry about gamma correction unless you really know what you're doing with it though.

    Most of the time I see artists asking about gamma correction and gamma conversion, it's because they think it's the solution to a problem they have - more often than not gamma isn't the solution to their problem and something else is wrong instead.
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    The other thing to bear in mind, is that UE4 and Toolbag both have checkbox options to enable them to convert directly from sRGB to linear for you.
  • stevston89
    Offline / Send Message
    stevston89 interpolator
    The way I deal with linear to srgb is by prototyping my spec and gloss in Marmoset. After I have what I like I just use the Hue/ Saturation/ Brightness control on the color picker in Photoshop to get the linear value correct. So for .8 gloss in Marmoset I simply paint down 80% brightness and my values will be correct. The benefit for me there is that I don't have to get confused by the rgb values. Here is the area in the color picker I am talking about:
    Dj590Wf.jpg
  • marks
    Offline / Send Message
    marks greentooth
    If the Linear to sRGB converstion was a linear lookup, that would work. It isn't though, it's a curve, so what you're doing is inaccurate and incorrect.


    This should help illustrate the problem.
    digital_images_sRGB_v_Lin_Grad.jpg


    What the math transforms do is apply a specific curve to your image, one curve to go Linear to sRGB, the opposite curve to go sRGB to Linear:

    GammaLines-Small.png



    I mean, applying a curve like this in photoshop would work but you'd have to make sure it was *exactly* the correct curve otherwise you'd introduce artifacts:
    j4YYVpt5vo5Zl.png
  • stevston89
    Offline / Send Message
    stevston89 interpolator
    I see. So is there a way to get linear values with out having to do the math every time you need to convert? Also how much does the conversion need to be exact? The stuff I have been making looks how I want it to. So am I making stuff that is going to look wrong in certain conditions or is the margin of error acceptable?

    I guess my question overall is how much should I be concerned about this as an artist and if I should be concerned what steps should I take to have accurate values?
  • marks
    Offline / Send Message
    marks greentooth
    It depends what you're using the values for. If it's reflectivity values for PBR specular then it's probably best to use the correct linear values as your reference as using correct measured data is one of the cornerstones of any physically based system.
  • stevston89
    Offline / Send Message
    stevston89 interpolator
    Ok. I always look up real world values as a base for specular and then I go from there. For the most part as long as I am referencing accurate values for specular the rest of it I really shouldn't worry about correct?
  • RogerP
    Offline / Send Message
    RogerP polycounter
    I got a really dumb/beginner question. At the point when you have all your maps ready to go and you are going to be rendering in Toolbag 2, do you have to do anything in particular besides plug the maps on the correct slots in marmo?


    i.e: in substance painter, you have the options of selecting from a drop down the PBR lighting system.
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
  • RogerP
    Offline / Send Message
    RogerP polycounter
    Awesome didn't see that one, thanks for the link ;)
  • Will Faucher
    Offline / Send Message
    Will Faucher polycounter lvl 12
    EarthQuake wrote: »
    Yeah, with the metalness workflow, the albedo map is both the diffuse and specular map in a way.

    For metalic surfaces (white in the metalness map) the specular intensity and color comes from the albedo map, and the diffuse color is set to black (because pure metals reflect nearly all the light that hits them and absorb/scatter very little).

    For non metal surfaces (black in the metalness map), the specular intensity is locked to a fixed value (about 0.04) as most non metals reflectivity is in a very narrow range. The albedo sets the diffuse color in this case like traditional shaders do.


    So if, for example, I set my Metalness to black in UE4, you say that the reflectivity is set to about 0.04 since the reflectivity of non-metals is in a very narrow range. So in that case, why are we seeing Metalness, Albedo, and Reflectivity values in PBR charts like this one?

    Same goes for a Metal surface. If Metalness is set to 1, the albedo levels clearly have values here in this chart, and aren't black, as you said.

    materialref01.png
  • stevston89
    Offline / Send Message
    stevston89 interpolator
    So if, for example, I set my Metalness to black in UE4, you say that the reflectivity is set to about 0.04 since the reflectivity of non-metals is in a very narrow range. So in that case, why are we seeing Metalness, Albedo, and Reflectivity values in PBR charts like this one?

    Same goes for a Metal surface. If Metalness is set to 1, the albedo levels clearly have values here in this chart, and aren't black, as you said.



    Because that stands for:
    Albedo = Diffuse
    Microsurface = Roughness/Gloss
    Reflectivity = Spec

    None of that data even mentions metalness. You assumed because there was an "M" it meant metalness.

    There are two distinct workflows. One is the reflectivty/spec workflow which is nearly the same as last gen in terms of what the maps do ( authoring them is different). The other is metalness which is explained well here http://www.polycount.com/forum/showthread.php?t=134475.
  • Will Faucher
    Offline / Send Message
    Will Faucher polycounter lvl 12
    stevston89 wrote: »
    Because that stands for:
    Albedo = Diffuse
    Microsurface = Roughness/Gloss
    Reflectivity = Spec

    None of that data even mentions metalness. You assumed because there was an "M" it meant metalness.

    No, I didn't assume the M meant metalness. What I did assume was that the chart I linked was for a metalness workflow. Clearly I'm mistaken, and that is what was confusing the hell out of me.
  • stevston89
    Offline / Send Message
    stevston89 interpolator
    Oh my bad I see what you are saying. There is variance in reflectivity, however it's not significant enough for it to be a big deal hence the standardized number. Also there is question over the accuracy of that chart becuase there shouldn't be any color in the reflectance of the non metals as well. If you want accuracy take a look at this chart here http://seblagarde.wordpress.com/2012/04/30/dontnod-specular-and-glossiness-chart/
  • EarthQuake
    No, I didn't assume the M meant metalness. What I did assume was that the chart I linked was for a metalness workflow. Clearly I'm mistaken, and that is what was confusing the hell out of me.

    The chart is from a tutorial I wrote: http://www.marmoset.co/toolbag/learn/pbr-practice It covers PBR in general, and goes over both the metalness and specular map workflows.

    For the chart, the scan data is setup for a specular map workflow. However, you can use some basic logic to make it work with a metalness workflow as well.

    Q: Is it metal?
    Y: Take the reflectance value and throw it in the albedo, set the metalness value to 1
    N: Take the aledo value and throw it in the albedo, set the metalness value to 0 (ignore the reflectivity value)
  • Nam.Nguyen
    Offline / Send Message
    Nam.Nguyen polycounter lvl 9
    sorry if this question has asked before.
    I want to ask about the grayscale value on Metalness map. How the shader will deal with it ? (especially TB2 and UE4).
    is it Metal? with black diffuse and reflectivity is pulled from the albedo map ? or it'll treat as non-metallics ?
  • EarthQuake
    Values other than 0 or 1 will be treated as partially metallic. What this is means is that depending on the value, lets say a value of 0.5, the shader will pull the diffuse and reflectivity from the albedo map, and only darken the albedo map half way.

    Generally, this isn't something you'll want to do very often, usually only for transitioning effects (fuzzy edges etc).
  • Laciodrom
    Offline / Send Message
    Laciodrom polycounter lvl 9
    EarthQuake wrote: »

    Q: Is it metal?
    Y: Take the reflectance value and throw it in the albedo, set the metalness value to 1
    N: Take the aledo value and throw it in the albedo, set the metalness value to 0 (ignore the reflectivity value)

    I'm confused.
    -If take reflectance value and throw it in the albedo, then how can I change the color? (photoshop)
    -How can I set the reflectance value above a texture albedo? (example: wood or metal texture).

    :)
  • EarthQuake
    Laciodrom wrote: »
    I'm confused.
    -If take reflectance value and throw it in the albedo, then how can I change the color? (photoshop)

    The reflectance value can mean both color and intensity, and the albedo map is a full color map, so for colored metals like gold or brass, you set the color in the albedo map.
    -How can I set the reflectance value above a texture albedo? (example: wood or metal texture).

    :)

    Wood is not a metal, so you don't need to set the reflectance value, it will get a value of 4% with most metalness shaders. You would set the metalness value to zero(black) for wood as it is not a metal.

    For metal, see first point.
  • Laciodrom
    Offline / Send Message
    Laciodrom polycounter lvl 9
    EarthQuake wrote: »
    The reflectance value can mean both color and intensity, and the albedo map is a full color map, so for colored metals like gold or brass, you set the color in the albedo map.

    thanks for reply. :)
    Example 1(metal): If you want a cube mid-iron and aluminum
    -metalness map: all white
    -albedo map: how can I split the metals?
    -glossmap: as you please


    example2 (non-metal): a cube half wood and plastic
    -metalness map: all black
    -albedo map: wood with the texture (without AO) and the plastic?
    this link can help me? how?
    https://www.fxguide.com/wp-content/uploads/2013/06/Albedo_values.jpg
    http://i.imgur.com/k9jKjiW.png
    -glossmap: as you please

    Thanks
  • EarthQuake
    Laciodrom wrote: »
    -albedo map: how can I split the metals?

    What do you mean split the metals? I think you're overcomplicating it. In this case, your albedo for the metallic areas is exactly like a traditional spec map. For the albedo map, you create the differences in the two metals directly in the albedo texture. Nothing difficult or complicated about it.
  • tynew
    Offline / Send Message
    tynew polycounter lvl 9
    With the metalness workflow since specular values are already sorted, for an object like wood, does this mean the albedo and gloss values can be anything? Or do albedo values still have to be a referenced value. I ask this because there are many kinds of dark woods.

    I work with Unity and usually things look great in all lighting conditions in marmo, but then suddenly once its in Unity with PBR the textures are way too bright or sometimes too dark. I assume that is because my albedo values still need to be referenced?
  • ZacD
    Offline / Send Message
    ZacD ngon master
    Yeah albedo should still be referenced, look at the Unity PBR charts, and make sure you are working in the right color space (sRGB vs linear). Albedo isn't as much of a hard rule set as reflectance values and reflectance colors for mimicking metals, but it's easier to start with reality and then start picking your own values. Especially when you are doing things on the very light or very dark ends, like white paint vs snow vs white plastic.
  • EarthQuake
    For the most part, diffuse/albedo and gloss/roughness maps simply vary. Yeah, there will be reasonable ranges for most material types, like you would be unlikely to find natural wood that is 0,0,0 or 255,255,255, or to find charcoal brickets that are 100% smooth/glossy.

    You can't find reflectance values for every surface type, so you're going to have to use your better judgement here. Wood isn't a specific material, but rather a huge family of materials types. There is no "correct" albedo or roughness for "wood", as wood has such a huge variance. If you can find measured values from a similar material, you can use some logic to come up with sane values, like unfinished walnut would tend to be darker than unfinished pine, and varnished wood would be smoother than unfinished wood.
  • artsfon
    Yeah, with the metalness workflow, the albedo map is both the diffuse and specular map in a way.
    https://www.artsfon.com/games/
  • artsfon
    Yeah, with the metalness workflow, the albedo map is both the diffuse and specular map in a way.
    https://www.artsfon.com/games/
  • Mink
    Offline / Send Message
    Mink polycounter lvl 6
    deohboeh said:
    In a PBR engine does applying specular maps make it work in legacy manner or does it have some new characteristics? I see in UE4 there is a node for specular and specular power maps.
    I can just answer this one now since they probably won't answer it. UE4, and really any Metal Roughness enviroments specular input has absolutely nothing to do with a legacy specular map. It is by default a value of .5 on any material and it shojld really stay there most of the time. Theres a formula for converting the IOR of a materials specular responce to specular level, and that value is almost always .5 or very very close to it. Specular level is completely irrelevant to anythin with a metallic value of 1. Liquids should have specular values other than .5 and rare materials such as vantablack should have specular values of 0. Human skin pours should be made into a cavity and combined with sone other specularlevel values for increased realism. The 4.20 human face documentation has some excellent information on this. But your average material should have an empty specular input in UE4, and you should be working in roughness and metal values.


    TL;DR Metal/rough PBR specular inputs do not have anything to do with old specular inputs, default and usually should remain at .5 and are reserved for cavity maps and rare use cases. Plugging specular maps from megascans into UE4 materials is a bad idea and does look good.
  • Zack Maxwell
    Offline / Send Message
    Zack Maxwell interpolator
    artsfon said:
    Yeah, with the metalness workflow, the albedo map is both the diffuse and specular map in a way.
    https://www.artsfon.com/games/
    I thought it was weird for anyone to still be lost on this workflow after around 5 years. Lo and behold, a pointless necro....
2
Sign In or Register to comment.