PDA

View Full Version : Understanding Lighting and Specularity


speedsix
08-12-2003, 11:34 AM
Hi this is my first post and id just like to say what a great board this is :wavey:

I've been using Maya 4..5 PLE for a month or so now, my only previous 3d experience was a dabble in Rhino+BMRT a year or so previous but I'm really getting into it.

I just wanna run through lighting though, some of the terminology but mainly I want to know exacty what the apps are doing when I work with lights and how they link up with real worl lighting.


The main concept I had trouble with initially was specularity, its always stood out as a bit of an odd attribute. I didn't understand the difference between this and general reflection. (which I understand now theyre the same thing)

If I just run through how I understand lighting and can others correct me where I'm going wrong?


Ok if you take a reeeally basic real real world siituation such as shiny ball sitting on the ground. Looking at the ball theres 3 shades to the surface, a dark shade running round the bottom (reflection of the floor) a light shade round the top half (reflection of the sky) and a bright spot somewhere (reflection of the sun)

So basically all lighting on a surface is a reflection of other lit surfaces with the light usually all eminating from the sun and transfering from surface to surface.

What I have trouble is transferring this into my 3D app, it doesn't seem to go well thinking like this.

The first thing that I found was (in maya) was you can't give actual surfaces light energy unless you shine a light on them, which can be awkward.

Lets say you wanted to do a shiny ball in a room with no direct lighting (ie the sun isnt shining through the window) In reality the ball would recieve light from the walls, which would receive light from outside through the window. How would you model this in the program?

I've found you can either setup lights to act as the walls (which technically are light sources, this works) or shine lights onto the walls which 'should' light the ball without actually having any light aimed directly at the ball, this doesn't seem to work.

I know it's all about faking it but I just like to link things up as closely as possible to real world stuff.

Thinking like this I think you could name the surface attributes/program procedures as follows (this is where my sucky physics shines :p)

leaving out the simple ones like colour etc..


Creating a Light

The program creates a (assuming its a regualar round light) sphere of particles emitting light energy (the diffuse part) and a extra bright part at the centre to represent the actual bulb (or wahtever) this is the specular part. This light then reflects off all the surfaces in the scene, but is not visible if looked at directly.

Diffuse

This determines how much of the light created by the lights reflects off the surface (not affected by the reflection property)

Reflectivity

This determines how much of the light created by the other surfaces reflects off the surface

Specular Eccentricity/Rolloff

The size of the reflection of the 'fake' light bulb created when you create a light source.

Specular Colour

This seems to adjust the reflectivity of the fake bulb (specular highlight) reflection on the surface. I noticed if it is turned to black the surface doesn't reflect other surfaces either so this is like another reflectivity propety but one that effects reflectivty of light sources instead of the regular reflectivty which is for reflection of other surfaces.

Well thats my newbie take on lighting, hope its not all total garbage!


Look forward to being corrected ;)


Dom.

jeremybirn
08-12-2003, 02:51 PM
You mention many things, but I'll take a stab at it. In real life, surfaces reflect light in different ways: Diffuse reflection, as seen in a material like a plaster wall, picks up and scatters light from all directions
Specular reflection, as seen in shiny metal or a mirror, picks up and reflects light all at the same angle, keeping rays parallel for focused reflections.Surfaces in real life always do some combinations of these kinds of reflection, for both direct and indirect (reflected) light, but you need to simulate each of the effects separately in the computer: Diffuse shading simulates diffuse reflection of direct light from a light source
Specular highlights (roughly) simulate specular reflection of direct light from a light source
Global Illumination simulates diffuse reflection of indirect or bounced light from other surfaces
Raytraced reflections simulate specular reflection of other surfacesGlobal Illumination functions are supported by the Mental Ray renderer which is included with Maya, but not by the Maya renderer you get with the PLE. A free version of Mental Ray is included in the Softimage EXP (http://www.softimage.com/products/exp/v3/) package if you really want to try it, but remember that most people working on bigger projects use faster cheats and fakes instead of Global Illumination and Raytracing, so even though they are the closest to "correct" they are not requirements for making realistic images. This is an incomplete outline - some omissions above seem to be that GI includes simulation of focused, specularly reflected light as well as diffuse, and there are other ways light bounces off surfaces, like a blurred Glossy reflection - but I hope it helps in a general way.

-jeremy

speedsix
08-13-2003, 03:45 PM
great post thanks alot.

I still dont understand a few thingds though.

Lets say you wanted to light a simple ball in a room, if the renderer supports GI then I suppose all you do is create a single light source i.e the sun and let the light bounce round and do the rest, through the window, off the walls and onto the ball.

Now say you wanted to do this without GI (i.e maya) everyone seems to put additional light sources to simulate GI, i.e lights positioned on the walls. I understand this but why can't you light the ball by making the walls themselves give out light?

I've tried to do this and it doesn't work although I'm not sure if im doing it right. I tried upping the incandescence of the walls, this does 'light up' the ball sort of. You can see the white walls reflecting of the ball but the ball is all white, none of its original colour comes through.

I know it's not really important and the correct effect is easily acheived with multiple light sources, I just don't understand why lighting in programs like maya is split into two totally spearate categories, light from light sources and light from other objects? Surely they both the same thing, an object doesn't know if it's recieving light from a light source or indirectly from another object?


Thanks alot, hope that make some sense! :beer:


p.s wow you work for pixar, im honoured! :buttrock: :cool:

Refracted
08-13-2003, 05:35 PM
Surely they both the same thing, an object doesn't know if it's recieving light from a light source or indirectly from another object?

oh but it *does* know. Those effects are calculated seperatly in most render engines.. The direct light is easily done by scanlining, but the indirect enery needs a different technique altogether.

As for making the walls emit light, that would technically requite an GI engine. A wall cannot simply be transformed into a direct light by increasing a value in the shader.. Though it might be reflected more in other surfaces, it's not actually casting any light unless you're using "GI" to sample from it.

i'm sure someone will chime in if i've said something terribly wrong (my experiences are with 3ds and brazil r/s) but i beleive the same basic theories hold true (i hope?)

speedsix
08-13-2003, 06:32 PM
oh but it *does* know. Those effects are calculated seperatly in most render engines.. The direct light is easily done by scanlining, but the indirect enery needs a different technique altogether. Yes I understand the render engine treats them separately but why, they're the same in real life aren't they?

Surely materials in a 3d application should just have a reflectivety attribute which works on both direct and indirect light sources (sun/lamp/walls/floor/sky whatever). This would do away with the diffuse/specularity/reflection attribute as they currently stand.

the bumpmap applied to the surface would control how sharp/diffuse the reflections are and another attribue to control the tint of the reflection.


or is this newbie getting very confused? :blush:

Dom

playmesumch00ns
08-13-2003, 06:47 PM
The differences you're coming across are mainly because of the huge complexity involved in accurately calculating lighting. Non-GI methods were used exclusively in the past (and in most production cases still are) because doing a GI simulation is so slow! AS computers get faster, and crazy mathematicians like H.W. Jensen get better at figuring out faster and more accurate cheats, GI is becoming more and more useable in a production environment. That's why there's this split between GI and non-GI renderers.

non-GI renderers

In a non-GI renderer all lighting calculations are performed from the perspective of the shading point, P. P could be any point on your shiny ball, but let's assume it's the topmost point.

In order to work out how much light is reflected from the surface of the ball and what colour it is (i.e. what colour it appears at that point in the rendered image), we first have to know how much light is actually hitting the surface at P.

A physically accurate solution would consider all light (whether it be from a light bulb, the sun, or light bouncing off the walls) coming from all directions and hitting that point.

Of course this would be a ridiculously slow calculation to perform. but we can make a fair approximation to it by only considering the directions that make the biggest contribution to the amount of light reaching the surface at P (the irradiance at P) - the directions to light sources that you have specified, be they point lights, spot lights, etc. So instead of having to do the irradiance calculations for an infinite number of directions, we only have to consider maybe 3 (in a traditional 3-point lighting setup). Of course, this leaves out a lot of light, how much depends on the conditions you're trying to simulate, but generally using CG lights like this will leave you coming up very short in terms of irradiance.

When we know how much light (roughly!) has hit the surface, we know that a certain percentage of that light is going to be reflected towards the camera. The intensity and colour of the light that ends up at the camera from P can be found using a BRDF (Bi-Directional Reflectance Function) - basically something that models what goes on when light interacts with a surface by bouncing off it.

The two major components of this interaction are:

Diffuse reflection models rough surfaces. It approximates the way that rough surfaces tend to scatter light evenly in all directions. This means that the amount of light reaching the camera from P depends only on the lighting angle, or how "side-on" the surface at P is when the light looks at it.

Specular reflection models the way we see a lightsource relflected in shiny objects. A perfect specular reflection of the sun in a mirror looks exactly like the sun reflected, but most objects tend not to be completely mirror-like. They're slightly rough, breaking up and softening the specular highlight. This is what parameters like specular eccentricity and rolloff do - they "smear out" the highlight to simulate "slightly rough" objects. The values of these paramters (and indeed their names) have nothing to do with real-world lighting and only relate to the mathematical fudges we use to achieve this effect.

Lights In non-GI renderers don't actually emit anything. A point light is essentially just a position, a colour and an intensity value. They just say to the surface point being shaded "I'm giving you x amount of light".

So we can only add light to a scene by putting in little markers (light sources) that tell the objects in the scene how bright they are. This leaves out all the possibilities of light reflected off walls etc so we have to add extra light sources that look like the light reflected off the walls. Basically whenever you add more and more lights to a scene you're making up for the shortfall in irradiance discussed above. Every new light you add that simulates a little bit of bounce off the wall, or the floor, makes the irradiance approximation that much more accurate in terms of amount, and of direction.


GI renderers

GI renderers basically try and approximate the physically accurate "perfect" method of lighting: considering all light of all "types" (direct, bounce etc) coming from all directions.

They basically do very similar things but in different ways.

Radiosity renderers perform a sort of balancing act, "squidging" light rays out through the scene. In a way they do what you wanted to do: they make the walls themselves give out light, but in a horribly complicated way.

Photon mappers chuck out tiny little light particles and see where they bounce. In an abstract sense, this is closest to what actually happens in the real world.

The important thing about GI renderers is that things like reflection, specular reflection, caustics etc -- things that many many very smart people have spent years and years dreaming up incredibly clever fakes for in non-GI renderers -- should all emerge naturally from a GI renderer. i.e., if you set your material properties and light properties right, and put everything in the right position, caustics, bounce lighting and specular highlights should be produced automatically, which is what ultimately we will come to expect of our rendering technology in the future.

But we won't be there for a few years yet.;)

speedsix
08-13-2003, 08:04 PM
Excellent thanks!! :applause:


So basically (at the moment) it's too expensive to setup a scene 'as is' and let the render engine do the rest, hence all the fudges to make up for it?

Dom

stew
08-13-2003, 11:25 PM
GI renderering is often harder to control than non-GI. Esp radiosity is a little hard to handle, it's very easy to get an overexposed look or too much color bleeding.

Luckily, there are newer algorithms that provide very realistic lighting at low rendering cost while still being controllable in a local manner. Ambient occlusion or lightprobe environment maps come to mind.

Filmmky
08-14-2003, 01:44 AM
It's also worth mentioning that in real world productions, the final images are rarely the result of one single render pass. In most cases, renders are broken up into different passes (shadows, reflections, diffuse, specular, among others) as to alow the final sweetning to happen in compositing. That usually happens due to memory of render time limitations on the part of the 3D process. Once all the separate elements are available to a compositor, he/she can pump out changes to the look of the image much more quickly, without having to re-render all the 3D elements.

Another down side to GI as far as its use in VFX for integration with live-action is that in order to have the light bounce from a wall/floor/actor, a 3D representation of such surfaces mus exist in order for the light to bounce from them (that is unless you go into HDRI (this pushes the debate to a whole new level)). That creates aditional overhead for the modeling and tracking departments, thus shifting the aditional thinking/executing from you (the lighter) to someone else, not really saving the production any time. Therefore, you'll find that GI solutions are most helpful in full CGI productions that don't involve live action footage.

One aspect of GI related technology that is finding its way into more and more productions is Ambient Occlusion, but I'll leave that discussion for some other time :p

Cheers,

jeremybirn
08-14-2003, 10:04 AM
Originally posted by speedsix
why can't you light the ball by making the walls themselves give out light? I've tried to do this and it doesn't work although I'm not sure if im doing it right. I tried upping the incandescence of the walls, this does 'light up' the ball sort of.

But try swapping the shaders and using an incandescent ball to 'light up' a reflective room instead, and the raytraced reflection won't be at all confusable with illumination. :)

-jeremy

ThePredator42
09-09-2005, 03:44 PM
Ok I see this is ancient threat, but it fits the question I have. And even more, since the question came to my mind after finishing Jeremy´s book.
(by the way, in case you haven´t - read it, read it, read it!)


This is how I now understand the relation between specular highlights and reflections - please tell me if I´m right or wrong:

1) All the bright lights on an object are reflections of bright lights in the real world, e.g. a window or the sun.
2) To cheat around this, CG mostly uses a shader setting that simulates this - specularity
3) Specularity can be either sharp, or blurred, and the aforementioned cheat can be adapted to that.

That was save ground so far, now here the still unsure parts of my "theory"

4) If an hightlight is not sharp, but blurred - this means that the object is not a perfect mirror. A pool-ball will reflect the overhead lights sharply, an apple will reflect them blurry. THAT means, that the pool ball will also reflect everything ELSE sharp, e.g the other pool balls around it. And the apple will reflect everything ELSE in a blurry way.
5) The reason, that a bright window is visible on that apple, but the rest of the environment isn´t, is due to the high dynamic range of it. The window is so ultra-ultra bright compared to the rest of the room, that it shows up on the apple while the rest doesn´t. At least not that clearly. This can be recreated with HDRI.
6) If I decide to "cheat" using the specularity setting, I should take the blurryness introduced in my highlight into account when setting up the reflections - if I have a blurry hightlight, I need blurry reflections. If I want sharp reflections, the hightlight ought to be crisp as well.

I´d appreciate your opinions on that, thanks!

francescaluce
09-09-2005, 11:51 PM
This is how I now understand the relation between specular highlights and reflections
man, nothing to understand here.. there's no relation
between highlights and reflections. also speculars are
not blurry in the same sense you call the reflections..
but just soft or hard. the only relation you might find
is the one you'll get yourself doing a picture of some
sort and tweaking the variuos thing to get something
beautiful. stop thinking. work it out.
:p

ciao
francesca

soulburn3d
09-10-2005, 12:05 AM
1) All the bright lights on an object are reflections of bright lights in the real world, e.g. a window or the sun.

Basically true, basically highlights don't really exist in the real world, everything is a reflection. If it's a reflection of a light bulb, you'll get something that looks like a cg highlight, but it's really a reflection of that light. Highlights in cg are faked reflections of point light sources.

2) To cheat around this, CG mostly uses a shader setting that simulates this - specularity

Yes, to cheat doing reflections all the time, and to allow point light sources (which don't exist in the real world) to make reflections, specularity was made.

3) Specularity can be either sharp, or blurred, and the aforementioned cheat can be adapted to that.

Yes.

4) If an hightlight is not sharp, but blurred - this means that the object is not a perfect mirror. A pool-ball will reflect the overhead lights sharply, an apple will reflect them blurry. THAT means, that the pool ball will also reflect everything ELSE sharp, e.g the other pool balls around it. And the apple will reflect everything ELSE in a blurry way.

A blurred reflection is causes by bumps in your surface. A pool ball is very smooth, and so you get a perfect reflection. An apple has lots of tiny bumps, so the reflection is blurred.

5) The reason, that a bright window is visible on that apple, but the rest of the environment isn´t, is due to the high dynamic range of it. The window is so ultra-ultra bright compared to the rest of the room, that it shows up on the apple while the rest doesn´t. At least not that clearly. This can be recreated with HDRI.

Yes. The rest of the room IS actually reflected, but because it's not very bright the blurriness of it makes it hard to see. Whereas the window is very bright, and so is far easier to see.

6) If I decide to "cheat" using the specularity setting, I should take the blurryness introduced in my highlight into account when setting up the reflections - if I have a blurry hightlight, I need blurry reflections. If I want sharp reflections, the hightlight ought to be crisp as well.

yes.

A few articles you may find helpful:

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

- Neil

ThePredator42
09-12-2005, 11:05 AM
Thank you Neil,

I appreciate your input. Cool links, just going thru them!

Funny, I´ve been tweaking material properties for so many yrs now, but only after Jeremy´s book I got to think about the underlying real-world properties.

Before that, I was merely trying to understand the difference between maya´s "specular rolloff" and "eccentricity". Quite unsuccessfully, I might add :D

ThePredator42
09-13-2005, 09:54 AM
Hey Neil,

those tutorials are AWESOME!!!

Michael.

soulburn3d
09-13-2005, 03:12 PM
Thanks, glad you've found them useful.

- Neil

jeremybirn
09-13-2005, 04:28 PM
Thank you Neil,

I appreciate your input. Cool links, just going thru them!

Funny, I´ve been tweaking material properties for so many yrs now, but only after Jeremy´s book I got to think about the underlying real-world properties.

Before that, I was merely trying to understand the difference between maya´s "specular rolloff" and "eccentricity". Quite unsuccessfully, I might add :D

Neil is one of those brilliant guys who reminds you that one Canadian can do the work of many Americans. (Not saying every time he reminds you of this that you believe him; that's another story.)

If you want to understand specular rolloff, make one specular highlight in the center of a sphere, and another on the edge hitting an angle facing away from you. With a low enough specular rolloff, you see the Fresnel Effect kicking in, and it blocks the highlights that are reflected from near the camera, and only shows you the highlights hitting near the edges of a sphere. (This is a weak, not very controllable, fresnel implementation. Maya's Ramp shader gives you a gradient to control this which works much better than anything you can do within Blinn.)

-jeremy

ThePredator42
09-19-2005, 08:48 AM
Aaaah! *suddenenlightenment*:lightbulb

so it´s a sort of "Complex IOR/Fresnel Fake" in the entire "Specular Reflection Fake"!
all the time I considered Specular Rolloff to be merely an overall intensity of the highlight...

You´re right, it doesn´t seem to be very controllable...

Thanks for sharing your knowledge, I owe you guys a beer :o)

CGTalk Moderation
09-19-2005, 08:48 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.