Home Technical Talk

Proper Specular Maps

polycounter lvl 11
Offline / Send Message
Scizz polycounter lvl 11
When I was first introduced to this 3d stuff and started working with textures, all tutorials and intro videos I watched and read had black and white spec maps..But on here and a lot of other places now, I see colored spec maps. What are the pros and cons of having either? Does it even matter?

Replies

  • pior
    Options
    Offline / Send Message
    pior grand marshal polycounter
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Specular put simply is a Reflection. if you go look at some reflective objects you will notice that they have a tint to their reflections.

    In the image below you will notice that the sky, and other surrounding objects are comming out yellow in the reflections. this is because the other colours are absorbed by the material.

    porsche-gold.jpg

    what you really need to do is study the material you want to reproduce. if the reflections are tinted then you need to tint the specular colour accordingly.
  • Sean VanGorder
    Options
    Offline / Send Message
    The main reason for using color or not is to accurately represent the given material, like r_fletch_r mentioned.

    There is a small benefit to grayscale spec maps though. You can store them in a channel of your diffuse map when importing into a game engine to conserve texture memory.
  • Racer445
    Options
    Offline / Send Message
    Racer445 polycounter lvl 12
    study your materials really really well and USE ALL THE MAPS AT THE SAME TIME. often if you make your spec after your diffuse, your spec will just turn into an afterthought. you must work with the all your maps at the same time to realistically portray an active, dynamic looking material.
    SeanEG wrote: »
    There is a small benefit to grayscale spec maps though. You can store them in a channel of your diffuse map when importing into a game engine to conserve texture memory.

    as far as i know, with DXT alphas aren't compressed, thus taking up just as much vram as a compressed, full color texture.
  • Ark
    Options
    Offline / Send Message
    Ark polycounter lvl 11
    I thought using 32bit images to store a alpha used up twice the amount of memory as opposed to 24bit image with no alpha?
  • Sean VanGorder
    Options
    Offline / Send Message
    Ark wrote: »
    I thought using 32bit images to store a alpha used up twice the amount of memory as opposed to 24bit image with no alpha?

    I may be misinformed then :) Sorry bout that.

    Can anyone confirm that?
  • Bal
    Options
    Offline / Send Message
    Bal polycounter lvl 17
    DXT with alpha, like DXT5, is 2 times bigger than DXT1 (no alpha), so it won't make you win any texture memory, it will allow you to call one less map though.
    On the other hand, you can still have two maps, and instead of having a full color spec map, you use each channel of the second DXT1 map for different maps, like 1 for specular, 1 for gloss, 1 for some other mask.

    Having said that, specular color is often really worth it, so it's worth giving it a try, and just keep an open mind on how to best arrange your maps to have the best result with the less texture memory.
  • equil
    Options
    Offline / Send Message
    there's one historical reason and one physical reason to use colored specular. On one hand using the inverse of the diffuse color is an acceptable way to combat gamma incorrect shader pipelines. But that reason sucks and i'll have none of it.

    The other, "proper" as you call it, way of using colored specular maps relates to the imaginary part of the complex index of refraction of some materials. This is really math-y and not something they usually teach you in school, but it's called the "extinction coefficient". If it's 0 you get white spec, but if it's non-zero, light of the current wavelength gets absorbed instead of reflected, and you end up with a tinted reflection, or colored specular term. Materials can have different extinction coefficients for every wavelength, so some materials don't even have single colored specular, but calculating that is too slow for games unless you're tri-ace, so simplifying it with a color is an acceptable tradeoff.

    When choosing specular colors for these materials, a good thing to remember is that in the real world, metals don't have diffuse terms at all, they absorb all light that enters them. So a metal (in a realtime 3d environment) that has a diffuse color of say gold, should probably have a specular color very close to gold. This isn't really limited to metals. One other example is satin, which really benefits from a tinted spec. Anyway the point is that a lot of objects with colored specular, whether to combat gamma or simulate real materials, get their tint from the diffuse color.

    Since the issue of storage was brought up, if you use a channel for spec color tinting, you can actually fit colored specular and gloss into one dxt1 texture (strength, gloss, tint).

    tl;dr: laugh at me when someone points out that i don't understand physics.
  • Sean VanGorder
    Options
    Offline / Send Message
    Bal wrote: »
    it won't make you win any texture memory, it will allow you to call one less map though.
    On the other hand, you can still have two maps, and instead of having a full color spec map, you use each channel of the second DXT1 map for different maps, like 1 for specular, 1 for gloss, 1 for some other mask.


    This is what I was thinking of. Thanks for correcting me.
  • equil
    Options
    Offline / Send Message
    @perna: well no, it represents how tinted the specular color is by the diffuse. i interpolate between white and the diffuse color, based on this tint value. so mix(white, diffuse, tint).
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    equil wrote: »


    When choosing specular colors for these materials, a good thing to remember is that in the real world, metals don't have diffuse terms at all, they absorb all light that enters them.
    tl;dr: laugh at me when someone points out that i don't understand physics.

    Nothing personal mate but this is totally and utterly wrong.

    Metals dont absorb all light that enters them, they simply tend to be quite smooth and dont diffuse the light which hits them. If they absorbed all light they would be black.


    I know im being picky here and you had the basic idea right so far as shader balancing goes but the 'in the real world' bit was totally misleading.
  • Rick_D
    Options
    Offline / Send Message
    Rick_D polycounter lvl 12
    SeanEG wrote: »
    The main reason for using color or not is to accurately represent the given material, like r_fletch_r mentioned.

    There is a small benefit to grayscale spec maps though. You can store them in a channel of your diffuse map when importing into a game engine to conserve texture memory.

    this is the biggest falsity ever perpetrated. the only way using the alpha channel for spec maps will help is to cut down on texture calls in a material, as you will only call a single texture sample for both diffuse and specular.

    a DXT5 texture (RGB+A) takes up the same amount of memory as two DXT1 textures (RGB).
  • Sean VanGorder
    Options
    Offline / Send Message
    Rick_D wrote: »
    this is the biggest falsity ever perpetrated. the only way using the alpha channel for spec maps will help is to cut down on texture calls in a material, as you will only call a single texture sample for both diffuse and specular.

    a DXT5 texture (RGB+A) takes up the same amount of memory as two DXT1 textures (RGB).

    Already corrected myself a few posts ago
  • Ark
    Options
    Offline / Send Message
    Ark polycounter lvl 11
    r_fletch_r wrote: »
    Nothing personal mate but this is totally and utterly wrong.

    Metals dont absorb all light that enters them, they simply tend to be quite smooth and dont diffuse the light which hits them. If they absorbed all light they would be black.


    I know im being picky here and you had the basic idea right so far as shader balancing goes but the 'in the real world' bit was totally misleading.


    I gotta agree with r_fletch_r here, most metals do have low diffuse reflectance and higher specular reflectance, but saying that metals have no diffuse reflectance is incorrect. I mean look at a metal like Copper, it always has that brownish/orangery colour that comes from it's diffuse reflectance value.

    If you had a material with no diffuse reflectance, then the material would either be black or completely reflective like a mirror depending on how much specular reflection there is.
  • EarthQuake
    Options
    Offline / Send Message
    equil wrote: »
    @perna: well no, it represents how tinted the specular color is by the diffuse. i interpolate between white and the diffuse color, based on this tint value. so mix(white, diffuse, tint).

    This is really a quirky way to do things, and sounds like something a programmer would come up with to torture artists. =P

    Unless you're really hurting for texture memory, a full 24 bit spec, with gloss in the alpha, is going to be by far the easiest and most sensible thing to do. I think the time saved by having your artists use a straight forward approach would make up for any sacrafices you'd have to make to use a 4th channel and double of the size of that texture.
  • Sean VanGorder
    Options
    Offline / Send Message
    So, importing 2 DXT1 textures is more efficient than importing 1 DXT1 texture with an alpha channel, even though importing one will give you less texture calls in the material?

    I'm just trying to gain a better understanding of how texture calls and materials and stuff affect memory.
  • Xendance
    Options
    Offline / Send Message
    Xendance polycounter lvl 7
    SeanEG wrote: »
    So, importing 2 DXT1 textures is more efficient than importing 1 DXT1 texture with an alpha channel, even though importing one will give you less texture calls in the material?

    I'm just trying to gain a better understanding of how texture calls and materials and stuff affect memory.

    I would import only one DXT with alpha channel, uses only one texture sample. In UE 3 with terrain those are really precious, because terrain is limited to 16 texture samples due to hardware constraints.
    Colour tinting could then be done in the shader/material.

    Edit: Though I never use specular on terrain :P
  • EarthQuake
    Options
    Offline / Send Message
    SeanEG wrote: »
    So, importing 2 DXT1 textures is more efficient than importing 1 DXT1 texture with an alpha channel, even though importing one will give you less texture calls in the material?

    I'm just trying to gain a better understanding of how texture calls and materials and stuff affect memory.

    No, one 1 32 bit image is likely more efficient, less texture calls. However, 1 32 bit image is the same vmem cost as as 2 24 bit images. When we think about it that way, we can do some cool stuff with two maps:

    1. 24 bit full color spec
    2. 24 bit combo map
    R. Gloss
    G. Glow
    B. Reflection mask

    Or any other creative combination you can come up with.
  • equil
    Options
    Offline / Send Message
    EarthQuake wrote: »
    This is really a quirky way to do things, and sounds like something a programmer would come up with to torture artists. =P
    I dunno, I think it's pretty simple to use, and it doesn't stop me from using a specular color map when I need one (I take as much artistic freedom as the next guy). One nice thing is that since brightness is separated from tinting, I don't have to worry about something like a deep red spec lowering the overall brightness, something that irritates me a lot when working with specular color maps.

    re:metals, [deleted lengthy explanation]. never mind, I don't feel comfortable trying to educate people about quantum optics.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    equil wrote: »
    [deleted lengthy explanation]. never mind, I don't feel comfortable trying to educate people about quantum optics.

    Any links? Light is something I'm trying to understand well.
  • Rick_D
    Options
    Offline / Send Message
    Rick_D polycounter lvl 12
    EarthQuake wrote: »
    No, one 1 32 bit image is likely more efficient, less texture calls. However, 1 32 bit image is the same vmem cost as as 2 24 bit images. When we think about it that way, we can do some cool stuff with two maps:

    1. 24 bit full color spec
    2. 24 bit combo map
    R. Gloss
    G. Glow
    B. Reflection mask

    Or any other creative combination you can come up with.



    exactly, this is the most efficient way of doing things. if you can afford the texture samples this is the biggest bang for your buck.
Sign In or Register to comment.