Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / Raytracing question - Specular or Reflection? Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
TaskForce_Reivax

May 23, 2005, 06:11 AM

Greetings all,

I'm working on a ray-tracer (well, just started) and I was thinking about how to do it and what all features I should support. While thinking, I got confused by one thing: Isn't specular reflection and usual reflection the same thing? I mean, atleast I've never seen them together. Of course in the case of a specular reflection, the geometry of the light source is not visible in detail (it's all blurred like). But isn't that some kind of diffuse reflection?

Please correct me if I seem to be totally lost.

Thanks in advance.

 
tokjunior

May 23, 2005, 06:57 AM

A specular reflection is a "perfect" reflection. That is, it's reflected through the normal. "Regular" reflection... I guess you mean diffuse reflection? This is basically fake, it's an invention. It's used since real surfaces never are completely smooth. There are always small irregularities.
Take a plate of metal, for example. In a computer simulation, this would just be a quad having one surface normal, making the reflections perfect. A plate of metal in real life has tons and tons of microscopic bumps, and a different normal for each point on the surface. Needless to say, the light would basically scatter in more or less random directions, since the normals would point in all directions. Diffuse reflection is a fake model of this.

 
TaskForce_Reivax

May 23, 2005, 07:26 AM

Thanks for the info; I think I misunderstood the terms. From what you say, I understand that the term "specular reflection" is used to describe a usual reflection.

Earlier, from the tutorials I read, I came to the conclusion that the following terms meant,
Reflection: Used to describle a perfect reflection.
Diffuse Reflection: Used to describe a cone of random reflections.
Specular Reflection: Used to describe a perfect reflection which ONLY reflects the light emitting geometry.

Now I feel that a specular reflection was described that way for efficiency while rasterizing polygons. That is, the light reflected by non light emitting geometry would not be so noticeable and could be left out.

Am I right on track with the terms now?
Please correct me if I'm still wrong, and any ideas regarding this subject are always welcome.

Thanks.

 
rneckelmann

May 23, 2005, 07:50 AM

Reflection: Used to describle a perfect reflection.


True.

Diffuse Reflection: Used to describe a cone of random reflections.


True, depends on how you implement it of course.

Specular Reflection: Used to describe a perfect reflection which ONLY reflects the light emitting geometry.


True to some degree if you replace the word "reflection" with "lighting". I think you should read Jacco Bikker's excellent tutorials on the subject, in particular: http://www.flipcode.com/articles/article_raytrace02.shtml

 
TaskForce_Reivax

May 23, 2005, 08:06 AM

Thanks for the fast relpies. I've already read all of Jacco Bikker's ray-tracing article series. Those articles are actually what inspired me to try and write my own ray-tracer. He has done a good job; very easy to understand the concepts from his tutorials.

Now that I've got the terms right, let me get back to the question which originally confused me: Why should anyone implement specular reflections if they already have diffuse reflections?

Thanks.

 
tokjunior

May 23, 2005, 08:13 AM

Since you can't make shiny objects using only diffuse lighting :)
When you're talking about specular and diffuse reflections, you usually talk about reflecting light-rays, not geometry. When you're talking geometry, you just talk about reflections in general.

 
davepermen

May 23, 2005, 08:18 AM

specular reflection is just the lightsources reflecting on your objects. if you have correct (glossy) reflections of the whole scene, and hdr calculations everywhere, specular reflections would get created by the ordinary reflection calculation.

it's just a cheat to get them working fast without huge global calculations..

 
TaskForce_Reivax

May 23, 2005, 08:45 AM

Thanks again for the fast replies, everyone.

I think Davepermen said what I was thinking. So basically, it's actually useless (and unwanted overhead) to calculate specular reflections when you're already calculating diffuse reflections.

More thoughts are always welcome.

Thanks.

 
tokjunior

May 23, 2005, 08:58 AM

No, it's not useless. You can't get speculars by calculating diffuse reflections. Specular reflections are viewer-dependent, where diffuse aren't.
You can get what appears to be diffuse reflections by rendering only specular reflections using extremely intense light and HDR, but it doesn't really give very good results.
Plus, the overhead is very small. Doing speculars when you have diffuse is basically a few multiplications.

 
TaskForce_Reivax

May 23, 2005, 09:37 AM

tokjunior wrote: Specular reflections are viewer-dependent, where diffuse aren't.

Eh? Since diffuse reflections are a type of reflection, won't they be view-dependant also? Correct me if I still haven't got the terms right, but I think you are referring to diffuse lighting instead of diffuse reflection.

 
davepermen

May 23, 2005, 09:39 AM

speculars are theoretically useless, but as i said, they are a very quick hack to solve an else... _very_expensive_ task. that is, doing imperfect, glossy reflections, with the whole scene, with 100's rays per .. ray, all in hdr..

just to get those fancy highlight-dots on your spheres :D the specular term in the blinn/phong equation happily "solves" this with some exponentiation ... neat, not? :D

but a perfect renderer would theoretically not have any need for them, thats right.. (i've done such yet.. and it looks more pretty to have the real world generating the "highlights" than just the lightsources... but so what? its 10000 times cheaper to fake it)

 
TaskForce_Reivax

May 23, 2005, 11:00 AM

Yes, that's true. But maybe I'll stick with speculars because I want my ray-tracer to be real-time (yeah I know it's pretty tough, but I'd like to try anyway (: )

Thanks for the help.

 
Lotuspec

May 23, 2005, 12:40 PM

DIFFUSE reflection is a REFLECTION but is NOT VIEWDEPENDENT because light is reflected evenly in all directions, independent of the incoming direction.
SPECULAR (or glossy or whatever you like to call it) reflections on the other hand are VIEWDEPENDENT i.e. the outgoing (=reflected) direction of the light depends on the incomming direction and is in most specular reflection models concentrated around the perfect specular reflection.

So basicly viewdependence and reflection are NOT directly related in any manner.

 
TaskForce_Reivax

May 23, 2005, 01:41 PM

Lotuspec wrote: DIFFUSE reflection is a REFLECTION but is NOT VIEWDEPENDENT because light is reflected evenly in all directions, independent of the incoming direction. SPECULAR (or glossy or whatever you like to call it) reflections on the other hand are VIEWDEPENDENT i.e. the outgoing (=reflected) direction of the light depends on the incomming direction and is in most specular reflection models concentrated around the perfect specular reflection. So basicly viewdependence and reflection are NOT directly related in any manner.

I think that different people interpret the term "diffuse reflection" in different ways. See Jacco Bikker's interpretation (under the heading "Diffuse Reflections") here: http://www.flipcode.com/articles/article_raytrace05.shtml

I understood the concept you tried to convey though, but I think the term for that concept is commonly known as diffuse shading?

 
TheDraguun

May 23, 2005, 02:30 PM

You may want to have a look at this:
http://www.glenbrook.k12.il.us/gbssci/phys/Class/refln/u13l1d.html

Basically raytracing is about incident light. (at a Pixel, at a surface point, ...). If i.e. you want to know the incident light at an pixel, you shoot an ray which hits some surface. You then sample the incident light at this surface point and evaluate how much is transmitted in the inverse direction of your original ray (thus to the pixel).

One kind of evaluation function for this is an BRDF (Bidirectional Reflectance Distribution Function). It says how much light from any incident direction is reflected to your eye. (There are even more complex fuctions like an BSSRDF, ...)

There are multiple ways to sample the incident light (more or less accurate). One is to evaluate shadowrays to all your pointlights (fast). Another is to sample the hemisphere above the surface (expensive in some forms). Or combined.

The more you know about your Reflectance Distribution, the better you can fit your incident light evaluation.

i.e. you decide to combine diffuse reflections (i.e. white paper) and perfect reflections (i.e. varnished surface) (not a pysically correct material model!) then you shoot rays to the lights and weight them with cos and your diffuse factor and shoot one ray into the perfect reflection direction and evaluate the incident light at the hitpoint and weight it with your specular factor.
Or even vary the factors for diffuse and specular dependent on the Fresnel term.

Do not use random rays to simulate diffuse reflection. You need an awful lot of them to get a decent result. Better do an ambient occlusion pass and bend normals to help you with this. Stay with quite focused reflections for the same reason. There is even something like reflectance occlusion out there.

Have fun ... and keep an eye on your code, sometimes its quite messy what a compiler does with it and it gets even worse if the code is a mess, too.

 
tokjunior

May 24, 2005, 02:43 AM

Or diffuse lighting. Or diffuse reflection.
It can have a slightly different meaning depending on context, just use your common sense here.

 
tokjunior

May 24, 2005, 02:54 AM

It's no problem getting it to be realtime.
I mean, are we talking about reflecting objects or light here? You still hasn't really explained what you're meaning.
Speculars refer to specular HIGHTLIGHTS, that is, it's a lightmodel.
And since we're talking lightmodels here, diffuse reflection is just a dot-product between the point-light vector and the normal. It doesn't make a whole lot of difference.
And don't go for a realtime raytracer before you've got a non-realtime one up and going with the effects you're going for. You need to understand it, and understand it well, before you can make it good realtime.

 
Ono-Sendai

May 24, 2005, 05:38 AM

There are several different types of reflection.
Diffuse reflection is where incident light is scattered in all directions. This gives the surface a matt look.
Specular reflection is where incident light is reflected like in a mirror. Glossy reflection is where light is *nearly* reflected like in a mirror but is scattered a little bit. Sometimes glossy reflection is just referred to as specular reflection as well :)

 
TaskForce_Reivax

May 24, 2005, 06:30 AM

Thank to all for the good information.

Ono-Sendai:
I guess what you call "Glossy reflections", The Phantom refers to as "Diffuse Reflections", right? But I think the term you used is more standard.

 
TaskForce_Reivax

May 24, 2005, 06:37 AM

Thanks for the link, good information. Man, I'm increasingly wishing I had taken a physics course for my degree instead of a computer one. :)

 
TaskForce_Reivax

May 24, 2005, 06:44 AM

Yes, I see your point. The next time I see an article with any of these terms, I can't skip the parts which explain the theory behind these terms, because the author might be using them to refer to something else!

 
TaskForce_Reivax

May 24, 2005, 06:54 AM

It's no problem getting it to be realtime.

But I don't know assembly / advanced maths and I plan on writing it in pure C++, so I guess realtime might be a bit far-fetched for me.

I mean, are we talking about reflecting objects or light here?

I was referring to reflecting light from everything. That is, light from light-emitting objects as well as light from light-reflecting/refracting objects.

And don't go for a realtime raytracer before you've got a non-realtime one up and going with the effects you're going for. You need to understand it, and understand it well, before you can make it good realtime.

I don't think I can plan on too many effects unless I'm going for a NON-REALTIME ONLY ray-tracer. :D

 
tokjunior

May 24, 2005, 09:06 AM

Reflecting light from everything, that would mean Global Illumination, which just isn't done realtime. And that includes Jacco's raytracer.
I think that's what got you messed up in the first place, you thought light would be reflected throughout the entire scene :)
Lighting using normal raytracing is done by shooting a ray from the intersection-point towards the lightsources in the scene, to get the angle to use for shading. You don't shoot rays towards the other objects.

 
tokjunior

May 24, 2005, 09:07 AM

Jacco refers to diffuse reflection when he's talking about diffuse reflection, and speculars when he talks about glossy reflection.
You've just misunderstood everything.
Diffuse is diffuse, specular is specular.

 
tokjunior

May 24, 2005, 09:09 AM

Oh yeah, and asm isn't needed unless you want to start using SIMD (sse/sse2/sse3/3dnow and so on).
They're needed to squeeze some extra rays/second out, but not to get a simple tracer running in realtime. Other tricks are more necessary, like adaptive sub/supersampling and crap.

 
TaskForce_Reivax

May 24, 2005, 12:30 PM

Thanks for pointing that out.

All this misunderstanding of mine makes me afraid that what I'm writing will be one messed up ray-tracer!

 
TaskForce_Reivax

May 24, 2005, 01:02 PM

But now I'm again in doubt.
Check out this article of Jacco Bikker's: http://www.flipcode.com/articles/article_raytrace06.shtml. Look at the image under the heading "Interpolate". He says "note the cool diffuse reflection for the floor".

Now, looking at the image I feel that the diffuse reflection which he's pointing out would be view-dependant, not view-independant as you said earlier.

 
Willem

May 24, 2005, 01:39 PM

I fail to see how specular reflection would be "useless theoretically" ? What do you mean by useless ? I can construct a BRDF that models Phong's specular reflection model _perfectly_ using a delta function. This BRDF is completely faithful in that it satisfies the Helmholtz reciprocity law as well as being energy preserving.

As for definitions. According to the definition of "diffuse reflection" given in Henrik W. Jensen's book "Realistic Image Synthesis using Photon Mapping", a diffuse reflection is a BRDF, f_r(w_o, w_i) (where w_o is outgoing direction, and w_i is incoming direction), which does not vanish for _any_ value of w_o. With this definition, the diffuse reflection one usually refers to as "diffuse" (ie., Lambertian reflection, where f_r is a constant rho/Pi) is a special case, and certainly not the only type of diffuse reflection.

Note that specular reflection is also _not_ equivalent to a perfect reflection of the light vector, L, in a surface's normal, N. In fact, such an ideal reflection can only be _approximated_ by Phong's specular model, (V.R)^n (where V denotes viewing direction, and R denotes the reflection of L in N), in the limit as we take n to infinity. In fact, for small n the specular component of Phong's model is more glossy than it is truly specular.

Cheers,
Willem

 
Willem

May 24, 2005, 01:51 PM

TheDraguun wrote:

"Or even vary the factors for diffuse and specular dependent on the Fresnel term."

Fresnel's formula does not give you the ratio of diffuse and specular reflection. What it does is tell you how much light is being _reflected_ and how much of it is either absorbed or refracted.

"Do not use random rays to simulate diffuse reflection. [...] Better do an ambient occlusion pass and bend normals to help you with this."

If you have ever implemented ambient occlusion, you will know that the most straight-forward way to calculate the ambient occlusion factor in the first place is to just shoot a buttload of random rays into space. So if you'd need a lot of random rays to make diffuse reflection to look pretty, you'd need a proportional number of random rays to make your ambient occlusion look pretty.

 
Willem

May 24, 2005, 01:53 PM

In that screenshot, what he calls "diffuse reflection" is really "glossy reflection". It goes to show that you shouldn't try to take the terms used too literally.

 
This thread contains 46 messages.
First Previous ( To view more messages, select a page: 0 1 ... out of 1) Next Last
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.