Specular highlights added

Project Page Next project post Post History

It's the weekend, almost the beginning of summer, and it's raining outside. So, I'm going to do a write up on Hyperion instead.

I've now added specular highlights to the render engine. Specular highlights are: "the bright spot of light that appears on shiny objects when illuminated" - Specular highlights - Wikipedia.

It looks like this:

See ScratchAPixel's article here

Yep, the bright white spots - they're the specular highlights!

The thing that makes this tricky for me, is that I'm trying to make specular highlights from an image-based lighting source. This is not so easy, because specular is like a relfection - but that's not what we want. We're not creating a reflection (we already did that here), we want bright white specular spots.

Upon researching this, I found one way of doing it was to divide the texture map into regions and calculate the average brightness for a region. Then, put a light in the centre of that area and treat that as the light source. Here's a link to a PDF that talks about this in Bryce.

But, I find this method doesn't really suit all texture maps. From the PDF, you can end up missing areas that might have bright lighting, because the split average has dulled the light intensity down and the light area has bee average down, and thus lost.

So, I tried to come up with something of my own. Instead of trying to place some lights around the sky, I use (what I call) a ramping technique on the reflected values themselves. I'm not convinced by this method. But for now, it seems to work. Here's some results.

First, here's a render with no specular:

No specular highlight

And now a render with specular:

With specular highlight

You may notice in the second render above that the highlight looks quite sharp. This is the nature of specular highlights - they're actually a straight reflection almost. So, to tone this down, I added in some controls to adjust how the highlight is rendered. The two main controls are for the dispersion and the brightness. Let's see how these look.

Specular light dispersion:

Specular highlight with 50% dispersion

And, specular brightness:

Specular highlights with 25% brightness

You'll notice some slight colour in the one above (a dark blue tint in the specular area). Dielectric materials usually have white highlights, while metal based materials are usually the colour of the metal. But highlights can also take the colour of the light itself. In this instance, the blue is a bright part of the sky. I will play with this a little, as maybe parts like this could be de-saturated, or turned to greyscale based on their metallic-ness.

Though the controls are minimal, they seem to do the job. They allow me to add subtle highlights where I could not before. The example below shows this. It's a comparison of a rusty metal sphere with no specular highlight (left), and with specular highlight (right):