Home Technical Talk

Light, Shadow, and Specularity

1
polycounter lvl 19
Offline / Send Message
poopinmymouth polycounter lvl 19
It's a bit long and it doesn't really fit well into forum format, so you'll have to travel off site.

http://mr-chompers.blogspot.com/2009/06/light.html

* Unfocused light falls off inverse squarely. Double the distance, 1/4 the brightness. Half the distance, 4x the brightness.
* Surface roughness determines how clearly the light source is reflected. Smooth surfaces give you the exact shape, rough surfaces give you a scattered shape.
* Apparent size is what's important, not absolute size. A medium source 1 meter away is apparently larger than a giant source 50 meters away.
* Apparent size of the light affects the softness of the shadow edge and penumbra. Larger apparent sizes make softer shadows and smoother penumbras, smaller sizes make sharper shadows and harsher penumbras.
* Specular reflections do not fall off. They stay the same intensity regardless of distance. Lessening the reflectance of the surface, or making the apparent size of the light larger, is necessary to lessen the specular hotspot's intensity.

Replies

  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Also, perna baby, you know you're my favorite white guy. Fellow scandi and all. You have full exemption from my you-don't-know-shit accusation. You know vaguely more than shit, so you can go to recess while the rest of class is learning.
  • EarthQuake
  • [Deleted User]
    Offline / Send Message
    [Deleted User] insane polycounter
    The user and all related content has been deleted.
  • Wells
    Offline / Send Message
    Wells polycounter lvl 18
    ALL LIES.

    you're a witch!
  • TheSplash
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    i actually knew most of that already :(
    but thanks for posting :D
  • MattBradley
  • [Deleted User]
    Offline / Send Message
    [Deleted User] insane polycounter
    The user and all related content has been deleted.
  • Ghostscape
    Offline / Send Message
    Ghostscape polycounter lvl 13
    holy shit poop is back
  • elte
    Offline / Send Message
    elte polycounter lvl 18
    Ah, thanks for the link poop
  • Joseph Silverman
    Offline / Send Message
    Joseph Silverman polycounter lvl 17
    Cool stuff! Specular in general is definitely something not enough people understand in 3d.

    Didnt somebody else post this exact thread with their own article like a few weeks ago though?
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    I just want to know when we'll get non point lights to play with in engines. Spherical harmonics and light maps are good hacks in the meantime, but they don't respect the character moving around in the environment the way a light with a 3d position would.

    I can't imagine trying to make a good portrait with just bare light bulbs, and I don't know why non-point lights aren't being pushed more on the graphics side.

    Shader writers, give me a softbox shader!
  • Lamont
    Online / Send Message
    Lamont polycounter lvl 15
    I see what you're doing. Carrying things over from cinema/photography into game applications. I can see a softbox shader being written, and I don't see why there isn't one already. Turning lighting artist into Gaffers. That's one thing I like about photography: if the models skin was a little too oily (and I didn't have blotters), I'd just swap for a bigger softbox and get closer. Didn't have to ask her to move, makeup artist come in and change her position. Just 15 seconds of rolling a lamp out and a new one in.

    Let me root around the internet for a bit. There was something I read a few years ago that talked about this.
  • Lamont
  • Zotter
    This is awesome and perfectly coincidental to boot considering I was really kicking my ass recently over spec maps and specularity in itself and really trying to understand them.

    Thank you a thousand times over!
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    I already know all this shit. You should also explain the difference between specular and reflectivity and how they relate to games, ie specular dots don't exist in real life everything is a cube map but that doesn't always look right in games. You could fill a couple pages with what you should actually be reflecting and why and how it works in the real world.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Please elaborate your "everything is a cube map point" as it's confusing. Cube maps are a poor aproximation of how lighting in the real world works.

    A followup article specifically relating this more photography geared post to how it relates to videogames is an awesome idea, and I shall endeavor to create one in the near future. Good idea.

    And you can most certainly have specular dots, and often do, anytime the lightsource is a small point light. (bare light bulb hanging from the ceiling, the SUN, etc. All that's necessary is a relatively small apparent lightsource that is roundish, and all your specular highlights on smooth, round surfaces will be dots.
  • ImSlightlyBored
    Offline / Send Message
    ImSlightlyBored polycounter lvl 13
    yo everyone knows that life is a cubemap
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    sphereLights.jpg

    I made this not so long ago, and it's just a crude hack. Still it work better than simple point lights and exhibit the 'apparent size' parameter you're talking about (glad to see you here btw poop :) )
    I don't see why there isn't one already.

    Simple: computation power ;)
    area lights in offline rendering are often heuristic, trial and error processes. "cast X number of rays along the normal, how many hit the area light?" or the other way around, or whatever technique you use :)

    and poop don't be that agressive, the 'everything is a cube map' idea makes a lot of sense. We actually talked about it for the rendering of wis avatars' pics remember? Cube map can easily be seen as the rasterization of every procedural lights around for a given point in space. (mip chains in cubemaps are a very efficient hack to simulate roughness too)
  • JohnnyRaptor
    Offline / Send Message
    JohnnyRaptor polycounter lvl 15
    shit im a cubemap too!

    specular highlights are just reflections of the lightsource, duh!

    cool article, will have to look through it for some mind candy
  • dejawolf
    Offline / Send Message
    dejawolf polycounter lvl 18
    fresnel reflection! yarrr.. or how an otherwise dull surface can have a pretty decent ability to reflect stuff at an angle. all it really boils down to in that case though is rim light.
    the rougher the surface, the more rim light.
    well i guess it had something to do with the light not bouncing directly off a surface, but instead was carried by it for a little bit before bouncing.
  • JohnnyRaptor
    Offline / Send Message
    JohnnyRaptor polycounter lvl 15
    everything reflects at the grazing angle, even a piece of paper. try it by putting one infront of your monitor, and look at the surface from as low an angle as possible
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    sphereLights.jpg

    I made this not so long ago, and it's just a crude hack. Still it work better than simple point lights and exhibit the 'apparent size' parameter you're talking about (glad to see you here btw poop :) )


    and poop don't be that agressive, the 'everything is a cube map' idea makes a lot of sense. We actually talked about it for the rendering of wis avatars' pics remember? Cube map can easily be seen as the rasterization of every procedural lights around for a given point in space. (mip chains in cubemaps are a very efficient hack to simulate roughness too)

    Yeah even this shader from Brice is an excellent mini-step forward. <3<3 Brice <3<3

    A cube map is only accurate from a single position in space. A literally infinitesimal point. It doesn't take into account moving closer and further from lights, or their apparent size changing based on that distance. It also doesn't affect the shadows in the ways that make me desire "real" softbox light sources.

    That's why I said they're a nice hack. I know we have to walk before we can run, and cube maps are nice, but they don't even come close to the look of what I'm after. I'm guessing the next baby step will be multiple cube maps per room with blending in order to emulate falloff. Still doesn't get me the shadows that I want though.

    Real life is nothing like a cube map. It's the other way around. A cube map attempts (and fails) at emulating real life.
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    and poop don't be that agressive

    i agree with this
  • vik
    Offline / Send Message
    vik polycounter lvl 13
    I`m a cubemap and so is my wife!
  • Japhir
    Offline / Send Message
    Japhir polycounter lvl 17
    yo momma's a cube map!
  • Zack Fowler
    Offline / Send Message
    Zack Fowler polycounter lvl 11
    I imagine that Malcolm's point was that in real life there is no fundamental distinction between "specular" and "reflection" lighting unlike the hacks used for 3D rendering systems. Game engines create a schism between blurred-out reflection (approximated by specular lighting) and crisp reflection (approximated by cubemaps) when there is not really any such thing as non-reflective specular and really it's more of a sliding scale of how crisp or blurry the reflection is.
  • sprunghunt
    Offline / Send Message
    sprunghunt polycounter
    That's why I said they're a nice hack. I know we have to walk before we can run, and cube maps are nice, but they don't even come close to the look of what I'm after. I'm guessing the next baby step will be multiple cube maps per room with blending in order to emulate falloff. Still doesn't get me the shadows that I want though.
    .

    You've never seen an engine that does straight up realtime reflection? It's possible although hideously expensive. You can do it in ut3 in a limited way.

    The problem with regular specular approximation is that it only uses light from the lightsource. It doesn't use light from any other source (such as reflections from nearby surfaces). So a grey ball sitting on a red surface won't get any red light illuminating it like it would in real life.

    There was a film FX studio where their motto was "never say phong"...
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    ZackF wrote: »
    I imagine that Malcolm's point was that in real life there is no fundamental distinction between "specular" and "reflection" lighting unlike the hacks used for 3D rendering systems. Game engines create a schism between blurred-out reflection (approximated by specular lighting) and crisp reflection (approximated by cubemaps) when there is not really any such thing as non-reflective specular and really it's more of a sliding scale of how crisp or blurry the reflection is.



    That would be a good topic to cover when I do a game specific adaptation of this.

    You'll notice though, that the article doesn't talk about specularity of an object as a separate function as reflection, because there isn't a separation in real life. I'm aware that games break them apart to more easily render the real life principle.

    I don't know if you're getting his point either, which is why I asked him to clarify. I was imagining he mentioned cubemaps where the objects are lit using a cube map (not reflecting based on a cubemap).
    sprunghunt wrote: »
    You've never seen an engine that does straight up realtime reflection? It's possible although hideously expensive. You can do it in ut3 in a limited way.

    The problem with regular specular approximation is that it only uses light from the lightsource. It doesn't use light from any other source (such as reflections from nearby surfaces). So a grey ball sitting on a red surface won't get any red light illuminating it like it would in real life.

    There was a film FX studio where their motto was "never say phong"...

    I guess this time I wasn't clear. I was speaking about games that use cubemaps to *light* an object, not provide something for them to reflect.
  • Mark Dygert
    And you can most certainly have specular dots, and often do, anytime the lightsource is a small point light. (bare light bulb hanging from the ceiling, the SUN, etc. All that's necessary is a relatively small apparent lightsource that is roundish, and all your specular highlights on smooth, round surfaces will be dots.
    If that's all you have around catching and throwing light...
    Unless you're in a dark hole (which is probably what you mean?) and a small pinprick of sun light is all the light you have, you're going to reflect a lot more than just the sun. The moon might give you a greater chance to catch just it as a specular highlight?

    Realtime raytracing will save us all!
    Every demo I've seen is impressively slow, deliberate and not much is going on. Which makes me think the only game we'll get in the near future is chrome sphere chess... Or you can have any color of spec map as long as it's black.

    True story, Henry Ford said that when they where painting the firsts real world cube maps on the first Model A. Until then no one had reflections in the real world. When you look in the mirror, that's right, you have Henry Ford to thank!

    Everyone keeps working on accurate reflections and spiffy water shaders but studio after studio don't ever bother upgrading their animation systems in meaningful ways. Maybe if they get realtime reflections working they'll finally see how stiff and wooden their preformces are.../end rant
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Well, you're debating my rebuttal to a poorly made argument, so there is bound to be some confusion.

    My understanding was that Malcolm was implying that no objects ever have small white specular highlights, or dots as he called it. The diffused lighting an object is receiving does not have to be black for the specular highlight to be showing on top, so you don't need something in a dark room, it can be out in broad daylight. You'll get lots of things reflecting on the object, you'll have diffused lighting illuminating the side facing the sun, and if it's a shiny, smooth surface, you'll also have a small white specular hotspot that is essentially a very nice reflection of the sun. It's just several magnitudes brighter than all the other objects reflecting off the object, so it's very readily apparent. (as a small white dot)

    However this could all be fluff around an argument he isn't even making.
  • Mark Dygert
    Well, you're debating my rebuttal to a poorly made argument, so there is bound to be some confusion.

    My understanding was that Malcolm was implying that no objects ever have small white specular highlights, or dots as he called it. The diffused lighting an object is receiving does not have to be black for the specular highlight to be showing on top, so you don't need something in a dark room, it can be out in broad daylight. You'll get lots of things reflecting on the object, you'll have diffused lighting illuminating the side facing the sun, and if it's a shiny, smooth surface, you'll also have a small white specular hotspot that is essentially a very nice reflection of the sun. It's just several magnitudes brighter than all the other objects reflecting off the object, so it's very readily apparent. (as a small white dot)

    However this could all be fluff around an argument he isn't even making.
    I'm not rebutting what you said, just that your example (SUN) casts a lot of indirect light around, so you get a lot of reflections besides the small dot. To get just a highlight you need to mute the indirect bounce lighting, that's not so easy to do with the sun. Next time say moon...

    Ahh ego's, they pass like two ships in the night (without radar) =P
  • Zack Fowler
    Offline / Send Message
    Zack Fowler polycounter lvl 11
    Poop: Since he was saying "you should talk about this instead" (paraphrase) it would seem he was specifically not referring to the content of the article. I'm not going to put words in his mouth but it seems pretty intuitive to draw the conclusion I did from what he said here:

    "difference between specular and reflectivity"
    "specular dots don't exist in real life everything is a cube map"

    Still speculation on my part. Can you clarify, Malcolm?
    Vig wrote: »
    Everyone keeps working on accurate reflections and spiffy water shaders but studio after studio don't ever bother upgrading their animation systems in meaningful ways. Maybe if they get realtime reflections working they'll finally see how stiff and wooden their preformces are.../end rant

    Hah, I definitely agree with you there. I think the main reason for that is that you can't really show off sexy slick animation in promotional screenshots, and even though game marketing is more about video these days a bit of that still image fetish keeps lingering around from the days before live streaming video.

    The worst part of it is that animation weaknesses have a direct impact on gameplay. So many studios don't seem to understand that. Epic isn't really one of the most problematic offenders, but the first example that I could think of for this is how sniping in Gears of War can be rather frustrating because of the way the Locust will often pop around unnaturally while moving around the pieces of cover.
  • vargatom
    Vig wrote: »
    Realtime raytracing will save us all!
    Every demo I've seen is impressively slow, deliberate and not much is going on. Which makes me think the only game we'll get in the near future is chrome sphere chess... Or you can have any color of spec map as long as it's black.

    Don't get me started on render times for glossy reflections that don't flicker ;)

    On the other hand, specular + lots of lights gave us surprisingly results recently, at least from the way everyone was wondering about the "cloth shaders" ;)
  • nezach
    Neal Blevins (Also known as the SoulburnScripts guy) has a good discussion of this topic spread around the CG Education part of his site. http://www.neilblevins.com/cg_education/cg_education.htm

    He has a section called "The Truth About Specular Highlights" partway down the page here -

    http://www.neilblevins.com/cg_education/metal_and_refs/metal_and_refs.htm

    that covers a fair bit of what the blog went over in general and Max specific terms. Granted it's focused on offline rendering and a bit dated, but it's the theory that's important, no?
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Nice links Nezach. I was thinking on the way home, the item I care about this most on, are faces, so I bet it would be possible to emulate window light or a softbox in the shader side. Try to emulate the scattered rays and the shadow transition based on light distance.

    If only I knew a Belgian shader artist.....
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    Hi poop! Yeah what I meant by no specular dots is I've met many people who don't actually think about what the specular dot is in real life, ie the specular dot in a game is just a white dot you tune in the shader most times but in real life it's either the reflection of a light source like a bulb in a studio or out doors the specular dot is actually the sun reflecting and diffusing based on the surface's roughness. Chrome you would actually see the sun's reflection and something rougher you would see more of a sheen but it's still the sun mostly creating the sheen. Doing a render outside for example if you want to simulate specularity accurately you would turn off specular dots from your light sources and reflect only lights themselves if your renderer supports that and or use an hdr reflection map that has the sun present in it to achieve the iconic specular dot. Or use a procedural sky with a sun that gets reflected by the shaders. In games we usually break it down to I want my surface to look reflective like chrome so I'll use a cube map and a tight specular dot, or I want my surface to look like brushed steel so I'll use just a specular dot that is wider and blurry. So in real life everything is a cube map reflection of what's around the object that is receiving the reflection, maybe saying cube map is the wrong term but I find that relates to game artists better. I think it's a really interesting subject that most game artists just take for granted instead of understanding why specularity exists and how/where it comes from in the real world.

    Here's an example, sorry for the old render. The gun doesn't have any specular coming from a light source I turned them all off since they were fakes and instead used the specularity from the hdr environment map the metal on the gun is reflecting. The hdr map is a shot of beach with sun and sky giving the iconic specular dot look which I thought looked pretty cool.

    http://www.malcolm341.com/spas12big.htm
  • CheeseOnToast
    Offline / Send Message
    CheeseOnToast greentooth
    Cube map can easily be seen as the rasterization of every procedural lights around for a given point in space. (mip chains in cubemaps are a very efficient hack to simulate roughness too)

    I've only ever seen the mip chain trick used to work on a per-material basis. Would it be possible to control it on a per-pixel level using a gloss map?
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    ZackF, sorry my computer's in the shop just getting to reading the posts now on my girlfriend's laptop, but yeah you got it. I was just thinking about this on the way home yesterday and in my parking garage there are no circular light sources, everything is a tube so conventional specularity won't work to simulate that environment you'd have to use a cube map or somthing fancy that can create strips of specular. I was also watching a children's show at my sister's house where they zoomed into the child's eyes very closely and you could see the specular dots were actually 2 umbrella lights, one circular and one square.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    I know specular is still hacked, but we have a reasonable handle on good looking specularity so far. I'm more wishing that the diffused lighting would come along. We basically have point lights if we want it to be dynamic, shadow casting, and have falloff obeyed, or we can have spherical cubemap based lights, but lose all falloff and dynamic shadow casting abilities.

    I want soft light sources that do falloff and do cast dynamic shadows.
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    I agree 100% poop. I've been told it's still too expensive. We're using cascading shadow maps I imagine you guys and almost everyone else is doing the same. We tried gaussian blurring the shadow map to at least give a fake softness and our game went down to zero frames per second. This is on the xbox360 of course, you might have better tech available on the pc only side at this point.
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    I've only ever seen the mip chain trick used to work on a per-material basis. Would it be possible to control it on a per-pixel level using a gloss map?

    Hi, sorry I'm late but everything as been petty much said/trolled in this thread :)

    except for this.

    cubemapgen6.jpg

    at the time i would only have proudly point to my own maya shader, but nowadays a lot of realtime shaders does it, it became a pretty common tech ;) ( Xoliul's for max )
  • cptincognito
    From an interview with Carmack about Rage's lighting model:
    There were a whole set of techniques that I looked at post Doom 3, for example things that shaped area lights, special shadowing, different ways to do specular highlights, displacement bump mapping, and a whole raft of things. And the real takeaway that I came away with was most of these are things that you have to point out to people. You have to be able to say “isn’t it cool that that highlight there is square instead of circular?” Things like that that really don’t make that much of a difference.
  • Eric Chadwick
    Brice, I've heard from a couple different rendering programmers, at different studios, that per-pixel mip-lookups were going to be prohibitively expensive to actually use in a real game rendering situation. Did you find this not to be so? Would love to be able to use this!

    Also, I recall this from the Valve lighting paper a few years ago. No self-shadowing, and the model isn't the greatest, but it is fully dynamic and it's neat to see the breakdowns. Some videos of it in action here.

    Shadetree.jpg

    Great thread.
  • JordanW
    Offline / Send Message
    JordanW polycounter lvl 19
    I know specular is still hacked, but we have a reasonable handle on good looking specularity so far. I'm more wishing that the diffused lighting would come along. We basically have point lights if we want it to be dynamic, shadow casting, and have falloff obeyed, or we can have spherical cubemap based lights, but lose all falloff and dynamic shadow casting abilities.

    I want soft light sources that do falloff and do cast dynamic shadows.



    Don't we all :) I think someone mentioned it earlier but there's really just not a fast way to approximate this. The nice thing about the methods we've used so far is it's a super slim equation to approximate diffuse lighting from a point lightsource = the dot product of the Normal and the Light vector, once you start trying to approximate light sources that are not a point it gets really hairy from a diffuse lighting standpoint, you have to think about what is required. The surface point needs to know how much of the light source can it see from where it's sitting, The easiest but poorest performance is going to be casting a ray, basically for every point you shoot a bunch of rays and find out if you can see a light source, the more rays that hit a light source the brighter you are, and this will end up creating lighting from different shaped lights.

    Maybe we could project some 3d texture that represents the shape and falloff of a light and then do some blurred shadow to fake non-point diffuse lighting....although you really would only benefit from this on big flat surfaces, I think it's still close enough to represent a character or some other object with varying normals using N.L.

    The specular solution is easy, just store some sort of cubemap or image that you project on the mesh aligned with a "specular highlight" and you get a non-circle highlight.
  • nezach
    I want soft light sources that do falloff and do cast dynamic shadows.

    Something like this? http://developer.download.nvidia.com/shaderlibrary/webpages/hlsl_shaders.html#shadow_PCSS
  • skolapper
    My bike does this. Its just a small sliver of light, above the headlight cut out for the front faring. Does not really bother me. My guess would be to buy some blacked out tape and cover it, though that would not really be that attractive.
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    Brice, I've heard from a couple different rendering programmers, at different studios, that per-pixel mip-lookups were going to be prohibitively expensive to actually use in a real game rendering situation.
    Hello Eric, I'm glad to see I might teach some stuff to veterans like you hehe

    My guess here: Programmers are lazy bastards, they don't get anything about aesthetic so they rely on their field of expertise: everything new/that they don't know about or that requires work is always too expensive ;)
    That being said, I don't know what's the inherent cost of a regular cubemap fetch, but it has to be uber cheap considering how old the trick is. I'm going to consider here the difference between regular texCUBE() and texCUBElod() since they both have to somehow convert 3d vector to 'cubemap space'. The second is actually 'twice as expensive' because it makes two samples of mips to smoothly lerp between them without stepping (that's why it's probably more efficient to have a preblurred cubemap when you do ambient cube as in your valve paper).
    In practice when I was working at CCP I used 'glossy cubemaps' all over the place for WiS interiors (yes, every single pixel on the screen) without it being a bottleneck. I've been doing experiments of raymarching trough cubemaps (50, 100 texture fetch?) and it still runs on my good old 6800 Go laptop gpu.
    So without being completely 100% sure, I'd say it's bullshit :)
    go go blurry cubemaps, we'll get rid of varnished realtime rendering...
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    nezach wrote: »

    Something exactly like that, but I want to see it on a face. Not only do I want to see a nose shadow behaving like that metal strip, where it's sharper at the base and fuzzier at the tip, but I also want to see that shadowing effect the pores and texture in the normal map as the surface wraps away from the light.
  • nezach
    From an interview with Carmack about Rage's lighting model:

    Heh, right. And how many gamers are going to look at a surface in Rage and go "woah, streaming megatextures!"?

    Of course the scenario makes sense to me and my cynical nature if I swap "people" with "investors". You can give Impressive Technical Numbers for megatextures, but a square highlight is just a square highlight. What's likely to impress the money guys more?
1
Sign In or Register to comment.