Home Technical Talk

Texture Leveling

polycounter lvl 14
Offline / Send Message
pixeldamage polycounter lvl 14
I noticed when going through several textures including those from recent Resident Evil games (0, 4 & 5) that they tend to have a good deal of blank space at the right end of the histogram. Basically it appears they've just dropped the brightness a little to push the 'hump' to the left with the highlights tailing out around the centre. I tried a few experiments and found I tended to prefer the look using this method - it seems to help textures suck up a bit more light before blowing out in the max viewport as well. Now this method goes against what I thought was the best method. Riki from eat3d recommends leveling textures as this is logically the best way of getting the whole range without crushing any values. Does anyone know what's technically going on here and why Capcom choose to do this? I'd really be interested to know the science behind this...

Replies

  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    resident evil is a horror game. So my guess is that there's lots of darkness?

    Also if you've got specular highlights they'll help fill in the high end detail.

    However all of this is very dependent on your lighting system. Some systems do not like dark textures.
  • Sean VanGorder
    Options
    Offline / Send Message
    I'd be interested in knowing this as well. I also have a habit of keeping my levels towards the lower end of the spectrum. I like the look of it better, but I also run into problems of it being TOO dark sometimes. I was always under the assumption that leveling your textures was so you could let the lighting do a lot of the brightness control.
  • pixeldamage
    Options
    Offline / Send Message
    pixeldamage polycounter lvl 14
    sprunghut: interesting note about the spec. RE5 is set in Africa though so there's plenty of bright bright sunshine so I don't think that's really the reason.

    seanEG: so other polycounters are doing it too. Interesting. I agree about your assumption, that's what I thought too but then there does seem to be something to darkening them.
  • Will Faucher
    Options
    Offline / Send Message
    Will Faucher polycounter lvl 12
    You don't always want your textures to be completely "levelled". Most of the time it just doesn't look right. There is no preset rule that says "textures must always be levelled". Just do what you think looks good. The end result is all that matters. I rarely ever level my textures entirely, unless it looks better. Sometimes it tends to make the whole texture too noisy. And sometimes, I purposely "de-level" my textures to lower the contrast.
  • cman2k
    Options
    Offline / Send Message
    cman2k polycounter lvl 17
    I definitely believe there is merit in controlling the leveling of your textures. I think many other companies besides Capcom have done this in the past. In it's essence, it's a super-cheap contrast control for the art direction and style of your game. There are ways to use the levels to get maximum range, get all your textures in the same range, achieve realism, or achieve stylization. None of these are necessarily more right or wrong then the other.

    However, when authoring textures it is important to know about levels. Sometimes some of the textures in your scene just don't match up very well, and it could very well be the levels that are giving you more or less contrast in different parts of your scene. Levels can certainly be a valuable tool in that way...just being aware of them and how they can affect your scene can give you another avenue towards keeping a coherent look to your environment.
  • equil
    Options
    Offline / Send Message
    i'm not 100% sure i understand the question, but you simply don't (or ideally shouldn't) put highlights in the diffuse, since that's what the specular component is for. And having very dark shadows in the diffuse isn't great either, as you end up with "unlightable" areas. So midtones is pretty much all you end up with.

    But again that's in an ideal and congruent world. There's a million other visual factors to consider depending on the material, style and look, and i haven't played either of those games so i dunno.
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    There is also the consideration that the render pipeline may have gamma correction or modulation built in. UT2k3/4 often had a modulation component on its final blend character materials, as well as I believe quake3 modulated character textures also. At the least there was a way to turn it on I belive. Of course these effects are doable on anything since.
    Just as often the maximum value per channel is clamped at 1.0.

    If your texture has a lot of values already toward 1, any post processing brightness will wash out the detail in the textures toward white. However if you push your values darker, but still maintain significant detail in the texture, the post processing will be able to brighten the scene significantly before your textures wash out, and also likely darken the scene some before losing detail to darkness.
  • pixeldamage
    Options
    Offline / Send Message
    pixeldamage polycounter lvl 14
    I just looked at the example textures in MapZone (procedurally generated) and took a nice grass texture into PS. Looked at the levels and voila all skewed towards the lower end. Not all the textures follow this rule but since they're procedurally generated why not have them all leveled if that's the best way.

    cman - Yeah I too am starting to think this is just down to preference/style/engine and there is no rule for leveling all textures

    Prophecies - Yeah I agree with you as that's what I do. Its just Riki had mentioned textures should always be leveled (eat3d nextgen texturing tutorial) which he reiterates several times as does by pinning the arrows around the top and bottom of the histogram's hump.

    Vailias - interesting points. I haven't looked much into tonemapping in UDK but perhaps that adds another variable?

    equil - no we're talking about texture levels (image>adjustments>levels) and the distribution of RGB input/output values.
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    As I said. It's very engine specific.

    here's a bit from the UDN about how dark you should make your textures:

    http://udn.epicgames.com/Three/Lightmass#Getting the best quality with Lightmass

    It shows some pretty good examples.
  • cman2k
    Options
    Offline / Send Message
    cman2k polycounter lvl 17
    I've seen Riki's methodology, and for a while I started to use it. It is good for getting your textures all in the same range (you'd be surprised how many aren't), and it tends to lend itself well to 'realism'.

    Epic's methodology is geared towards stylization and getting the most out of their lightmaps. This isn't engine-specific....it's the unique way they achieve their style and quality. edit: I have been corrected - Epic's methodology is purely towards realism, not stylization.

    Again, neither right nor wrong, just different means to different ends. Understanding what affect each of these has on your scenes goes a long way towards empowering you to achieve what you want visually.

    I don't agree that this is extremely engine specific. While gamma correction/modulation can be a factor to consider, in most engines it can and should be used to correct your final image, not modify it in a drastic way. That's what (artist-controllable) texture levels and color correction are for.

    All this levels stuff really just hearkens back to the old days of texture painting. Read some painting tutorials, and they'll speak specifically towards controlling your color palette's hues and values. You still have to be conscious of that stuff, even if you are sourcing your stuff from photos sometimes....
  • G3L
    Options
    Offline / Send Message
    G3L polycounter lvl 9
    Sorry to go off-topic a bit...kinda relates to Capcom and textures though lol

    A friend of mine insisted on this about Japanese developers but...

    Is it true that console games from Japan, mainly Square-Enix and Capcom DON'T use normal maps? That's got to be fiction...I even looked at the assets in game and they have them unless they're using some completely different method of which I've been unaware of. And no he wasn't joking or being sarcastic and I was like BS...I know if people start reassuring me I will have asked such a stupid question lol

    I'd rather get that out of my system now ><
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    G3L wrote: »
    Is it true that console games from Japan, mainly Square-Enix and Capcom DON'T use normal maps? That's got to be fiction...<

    Capcom definitely use normalmaps. They use an engine called MT framework.

    http://www.andriasang.com/e/blog/2010/09/13/3ds_mt_framework_detailed/
  • G3L
    Options
    Offline / Send Message
    G3L polycounter lvl 9
    sprunghunt: ooo nice find! i wasn't even aware that was their engine...good to know, thanks man! says it clear as day in the article...normal maps :)
  • pixeldamage
    Options
    Offline / Send Message
    pixeldamage polycounter lvl 14
    sprunghunt: Interesting. Though the point about Photoshop giving values in gamma space is confusing. My version appears to give RGB127 as mid gray and not RGB186.

    I tried copying their example images into photoshop to see if I could replicate their results. The second image doesn't seem to give a value of 0.08 at all (even looking at their histogram screegrabs I can't see where they got that value). The second image has a median value of 65 (65/255=0.22). I must be missing something.


    Is there an equation for calculating these figures? I can see the first image's hump is skewed to a higher key and the second is in the low range so i'm guessing they're saying that for Lightmass its best to keep textures in the mid range (and that with gamma in mind, this means slightly towards the high end). Most importantly they iterate the obvious - to keep extremes of bright and dark values to a minimum by creating low contrast diffuse maps to let the lighting engine with spec/gloss/normals to do the work.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    sprunghunt: Interesting. Though the point about Photoshop giving values in gamma space is confusing. My version appears to give RGB127 as mid gray and not RGB186.

    I tried copying their example images into photoshop to see if I could replicate their results. The second image doesn't seem to give a value of 0.08 at all (even looking at their histogram screegrabs I can't see where they got that value). The second image has a median value of 65 (65/255=0.22). I must be missing something.

    .22 in gamma space is the roughly the same as .08 in linear space. so far as i remember to reverse gamma you multiply by (1/gamma).
    so 1/2.2 = .454
    0.22 * 0.454 = .09

    working between linear and gamma spaces is a total mindfuck :/
    I dont know why they are talking about linear and gamma values. This stuff should be transparent to the user. perhaps the screengrabs are linear.

    I believe you have the jist of it though. midrange values in the texture allow for broader ranges in shading.
  • JordanW
    Options
    Offline / Send Message
    JordanW polycounter lvl 19
    On photoshop being in gammaspace and not linearspace

    The easiest test is to create an image with every other pixel being black and white, then put what photoshop says is 50% grey (127,127,127) beside it. Notice what photoshop says is "halfway" between white and black is actually WAY darker than the image with every other pixel alternating black and white. What is actually 50% grey in photoshop is 186.


    Cman2k, our methodology about brightness of textures is not a stylization. The UDN document is saying if you want realistic lighting and are striving for realistic rendering you should have low contrast, bright textures.

    Video game textures tend to be too dark and too saturated with too much lighting painted in. As we get better at rendering GI, dynamic shadows etc, texture artists need to learn to create more physically correct diffuse maps and materials. This is separate from any stylization discussion.


    Also to speak to the original issue of RE games having dark textures.

    This may have been useful in the past before color grading and GI based lighting. Now if you were to make your textures dark you'll end up making it a pain in the ass to light and color grade. If a surface is already very dark then you can never have any interesting contrast between dark and bright lighting. It really limits your color range. Darkness and mood should be created through good lighting and color grading NOT through textures. (if you're developing for DS or iphone and you dont have nice lighting or colorgrading then you can ignore that)
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    JordanW wrote: »

    Cman2k, our methodology about brightness of textures is not a stylization. The UDN document is saying if you want realistic lighting and are striving for realistic rendering you should have low contrast, bright textures.

    Could you expand on that a bit more. hows is having a bright low constrast diffuse texture more realistic, surely this is totally dependent on the physical properties of the surface. how do you handle objects with low albedo?
    (isnt that what the diffuse map is representing, diffuse reflectance.)

    I think I must be misunderstanding something.
  • cman2k
    Options
    Offline / Send Message
    cman2k polycounter lvl 17
    I'd love to know more as well, it's an interesting topic and I'd love to understand it better.

    I understand the ideal of removing lighting from your textures and making your diffuse absent of as much lighting as possible, so that a good lighting system can do it's work in the most accurate way possible.

    What I don't understand is why lower contrast or brighter textures are more realistic? Even in the absence of light, would a surface really be lower in contrast or brighter? This seems counter-intuitive...not saying you are wrong, just not the way my mind thinks of it. I guess I've always thought of a "neutral" texture as having a good balance of lights and darks, at even ends of the spectrum....I dunno.

    This is why I assumed it was a stylization. I always thought the idea was to OVER-emphasize the effect of your lighting, kind of exaggerating it so that it's more obvious than would be realistic. So that stuff like lighting/shadowing/color-bleeding would all be more apparent. Beauty in contrast, etc.
  • JordanW
    Options
    Offline / Send Message
    JordanW polycounter lvl 19
    When I say bright I'm speaking in relative terms, bright compared to what people are used to creating in games. Obviously an asphalt texture is going to be darker than a grey shirt but in the past I would say most people have gone too dark.

    This page may help, it has some examples:

    http://udn.epicgames.com/Three/TakingBetterPhotosForTextures.html

    Notice the final image of the skin is extremely low contrast and bright:

    X_POLAR1024.jpg

    Also notice this polarized image of a plant has very little contrast and lighting and is pretty close to what you should expect for diffuse:

    plant.jpg

    I want to gather more practical examples I just havent had the time, if you're interested in this stuff you could read up on the techniques I outlined in the UDN document and take some polarized-light images of different surfaces to see what the diffuse would be.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Ok so what's this gamma thing about? surely that's irrelevant to the user.
    Doesnt UDK reverse the gamma on load, render linear and then Gamma correct the framebuffer.
  • JordanW
    Options
    Offline / Send Message
    JordanW polycounter lvl 19
    r_fletch_r wrote: »
    Doesnt UDK reverse the gamma on load and then Gamma correct the framebuffer.

    Yes.

    The gamma comments came from people saying

    "sprunghunt: Interesting. Though the point about Photoshop giving values in gamma space is confusing. My version appears to give RGB127 as mid gray and not RGB186"


    If people rely on photoshop to tell them what is 50% grey, they will be wrong. Photoshop says something is 50% but it's actually incorrect.

    PhotoshopLies.png

    the top left box is what photoshop says is 50% brightness. Bottom left is 186,186,186
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    isnt this a case of monitor calibration over photoshop being wrong?
    once 127/50% grey is gamma reversed its going to be 50% grey in linear space.
    if you manually correct it to 187 its going to be 75% grey in linear space.


    my brain hurts :/
    s21860_brain%20full%20of%20fuck%20sagan.jpg
  • JordanW
    Options
    Offline / Send Message
    JordanW polycounter lvl 19
    Nope, it's photoshop being wrong :)


    When 127/50% grey (in photoshop ) is gamma reversed it ends up being 0.217 in 0-1 space (AKA NOT 50% between 0 and 1 which is where it really matters, in linear space)

    When 186/73% grey (in photoshop) in gamma reversed, it ends up being 0.5 in 0-1/linear space.

    Gamma conversion is pow(x,2.2) for reference
  • cman2k
    Options
    Offline / Send Message
    cman2k polycounter lvl 17
    Shit is craaazy.

    Thanks for the elaboration, Jordan!
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    JordanW wrote: »
    Nope, it's photoshop being wrong :)


    When 127/50% grey (in photoshop ) is gamma reversed it ends up being 0.217 in 0-1 space (AKA NOT 50% between 0 and 1 which is where it really matters, in linear space)

    When 186/73% grey (in photoshop) in gamma reversed, it ends up being 0.5 in 0-1/linear space.

    Gamma conversion is pow(x,2.2) for reference

    Is there a way to fix this with a custom ICC colour profile for photoshop? Has anyone tried? I've seen this issue before...
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Its not wrong though. 50% Grey (perceptual/gamma) is equal to 20% Grey (linear)
    Its not photoshop doing it wrong its down to how our eyes perceive light.

    Here true linear gradient placed next to a perceptually correct(Gamma)gradient.
    gamma-1.png
  • JordanW
    Options
    Offline / Send Message
    JordanW polycounter lvl 19
    I'm not exactly sure what you're getting at. YES it's true that photoshop is giving you 50% grey in gamma space. It's not something that's really debatable. The point I'm emphasizing is gamma space is useless and it's deceptive to use the % numbers in photoshop to guide you. When doing math, adding images together, calculating lighting,doing image processing (blurs, sharpening etc) you should be in linear space. Photoshop is very messy about this in the fact that some operations are in linear and some are in gamma. If an artist says "Photoshop says this is 50% grey, which should be halfway between black and white" they are making a mistake. The image I posted earlier depicts that.


    This also goes back to the issue I was trying to address earlier. When creating textures you're not painting pictures, you're painting material properties. Some of them just happen to have color and value. As graphics become more "physically" correct you should understand how they work with lighting and rendering. If you fill your envnrionment with what photoshop thinks is 50% grey and then calculate GI it will be very dark. Like you and I said, 50% grey in photoshop is like 20% grey in linear space which means you intend for the surface to bounce 50% of the light. Once the math is done it only bounced 20% light.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Thats the thing, Gamma isnt deceptive or useless, its modelled on how our eyes see light. We don't perceive changes in light intensity linearly.

    Say we have a scale of 0 too 100 units of light. with black on 1 end and white on the other.

    If a Monitor is emitting 20 units of light then our eyes perceive that as 50% grey. If you amp it up to 50 units of light we see 80% grey.

    Due to this we use a gamma curve so that the monitor knows how to display images in a way that looks right to us. If you got a light meter and read 50% grey off this imaginary monitor it would be our conceptual 20 units of light, not 50.

    So when we reverse .5 gamma to .2 linear we are turning the perceptual measurement back into a correct linear one that is suitable for rendering with. once we have done the linear math and the image is rendered we convert back into gamma space so the mathematically correct image becomes perceptually correct to our eyes.

    Im sure photoshop is as messy as hell but applying a gamma 'correction' by amping up your greys in photoshop so they become .5 linear is not correct.
  • JordanW
    Options
    Offline / Send Message
    JordanW polycounter lvl 19
    You're missing my point. For textures you're not painting an image, you're creating something that is a material property that is supposed to interact with GI and lighting. If you create something that you perceive to be 50% grey and photoshop says is 50% grey, it's going to light like it's 20% grey.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Then why gamma correct at all?

    If you want .5 gamma to be .5 linear then don't gamma correct the image. the reason 50% is becoming 20% is because of the the correction UDK is making.

    This is why you don't gamma correct normal maps or gloss maps.
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    man just do what looks good and make sure all of your assets in a scene have similar production on them.
  • JordanW
    Options
    Offline / Send Message
    JordanW polycounter lvl 19
    r_fletch_r wrote: »
    Then why gamma correct at all?

    Because after the lighting/rendering is done you have to convert the image from linear space to gamma space to be displayed on a monitor. If you didn't un-gamma textures stored in gamma space you would then be re-gamma'ing them at the end after rendering and they would be extremely bright.


    This guy from Naughty Dog covers gamma a lot on his blog:

    http://filmicgames.com/archives/299


    To an extent passeryby is right, in the end it just needs to look good. The thing we need to watch out for is artists in the game industry are just now getting experience with Global Illumination and advanced materials. In the past you were painting a texture that represented a lot of material properties and in some cases was a completely unlit texture that represented the full shading of the model. Now you are painting textures that represent material properties and my point is those aren't always going to look good as a texture flat in photoshop.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    I didn't mean that literally Jordan. I know why we gamma correct.
    what I take reservation with using .7 as your midpoint so its reversed to .5 linear. tor effectively removing udks gamma correction and messing up the lighting math.
    can't you see that your actually re applying the gamma by doing this.
  • JordanW
    Options
    Offline / Send Message
    JordanW polycounter lvl 19
    r_fletch_r wrote: »
    I didn't mean that literally Jordan. I know why we gamma correct.
    what I take reservation with using .7 as your midpoint so its reversed to .5 linear. tor effectively removing udks gamma correction and messing up the lighting math.
    can't you see that your actually re applying the gamma by doing this.

    Sorry, didn't realize you were being facetious.

    I'm not messing up UDK's lighting math by texturing the way I've described. If I want a surface to bounce 50% of light I know how to do it and what it should be created as in photoshop, how is that incorrect?

    This is not messing with UDK's gamma correction. This is in fact suggested by the graphics programmer who created Lightmass. Just read the UDN page posted earlier called "Getting the best quality with Lightmass".

    I think we're beyond the point of this being a useful discussion anymore, and I think examples of texturing and lighting would be extremely useful to anyone curious.
  • kio
    Options
    Offline / Send Message
    kio polycounter lvl 15
    thanks for the link - never really got the whole gamma stuff either. much clearer now. really good read :)
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    JordanW wrote: »
    I think we're beyond the point of this being a useful discussion anymore, and I think examples of texturing and lighting would be extremely useful to anyone curious.

    Indeed, thanks for your time dude.I cant reconcile this in my head so I'm going to go and study this stuff a bit more, and stop stinking up the thread.
  • equil
    Options
    Offline / Send Message
    lets go deeper.

    gamma 2.2 isn't actually a pow(color,2.2) function. the suggested way to convert to linear space is:
    "RGB = ((R'G'B' <= 0.03928) ? R'G'B' / 12.92 : pow((R'G'B' + 0.055) / 1.055, 2.4))"
    followed by
    "Luma = 0.2126 * R + 0.7152 * G + 0.0722 * B"
    The ' means prime, and implies that a color is in gamma space. Great! Now you finally get that perfect 50% gray value. Except it's still not really a middle gray. Because the human visual system has different sensitivity for different colors, a perceptually gray pixel would not be a uniformly lit pixel at half intensity, but in fact be green in the real world (the green "subpixel", or led light, would be brighter than the red and blue ones).

    Also "middle gray" is not actually 127 or 128, but 119(~47%) in sRGB. that's 50% L in the LAB color space. Strangely enough 50% K in CMYK isn't even gray, but very unsaturated blue. I don't even know how that works.

    i have no idea how far this rabbit hole goes but until i see the end i guess i'll just keep falling.
  • pixeldamage
    Options
    Offline / Send Message
    pixeldamage polycounter lvl 14
    Some really great discussion here guys. A lot of this gamma stuff is over my head and I really wish I understood it more. I could see both sides to the main arguments here and its a shame it got a little heated as I would have liked to see it resolved. Jordan's point about Resident Evil not being viable overlooks the fact that I was talking about RE5 where i'm certain they use HDR, tonemapping etc. So this still leaves the question as to why the value ranges are steeped to the lower end. Not sure if I can post examples due to copyright reasons as I had to rip them from my copy of the game.

    edit: just reading the Naughty Dog GDC link from Jordan. Thank you for the great info!
  • pixeldamage
    Options
    Offline / Send Message
    pixeldamage polycounter lvl 14
    Came across John Marston's diffuse texture from RDR today, dropped it in photoshop and looked at the histograms. Low and Behold all the values are in the lower half. Way down there. Check it out for yourself on page 1 of this forum http://forum.xentax.com/viewtopic.php?f=16&t=4992
  • pixeldamage
    Options
    Offline / Send Message
    pixeldamage polycounter lvl 14
    JM.png

    Just started rooting through this thread again. At the moment I'm using IBL in Unity with Marmoset Skyshop and noticing massive differences depending on levelling. Like others here I prefer to make my textures on the lower end (guess that also allows room for the light to add on top).
  • monkeyscience
    Options
    Offline / Send Message
    monkeyscience polycounter lvl 12
    JM.png

    Just started rooting through this thread again. At the moment I'm using IBL in Unity with Marmoset Skyshop and noticing massive differences depending on levelling. Like others here I prefer to make my textures on the lower end (guess that also allows room for the light to add on top).

    I would advise against lowering the levels of your albedo/diffuse maps by half to account for any lighting. You are effectively lowering the light intensity of your scene by half but baking that change into your art content and discarding half the precision of your textures.

    If your lighting is too bright in a properly tone-mapped engine (like Unity + Skyshop), change the lights in the level. If you want to boost your specular highlights in contrast to the diffuse lighting, do so with the specular content or use the specular multiplier Skyshop's materials provide.
Sign In or Register to comment.