I'm guessing specular highlights shouldn't curve?

Started by
11 comments, last by DwarvesH 10 years, 1 month ago

Hello everybody!

I'm implementing a fresh set of lighting shaders and I'm testing using this scenario:

http://dl.dropboxusercontent.com/u/45638513/cur01.png

The bigger cube is in the middle of the scene. To the right is another cube signaling the direction of a directional light that is turned off in this scenario. Ambient and diffuse are also turned off. To the left is another small cube signaling the position of a red point light with blue specular highlights.

If I move back from the point of view of the scene, the specular highlight starts to curve:

http://dl.dropboxusercontent.com/u/45638513/cur02.png

http://dl.dropboxusercontent.com/u/45638513/cur03.png

If I rotate the camera a bit to the right, the curving andle changes, eventually getting this:

http://dl.dropboxusercontent.com/u/45638513/cur04.png

I'm guessing that this is not correct behavior.

If I turn on the directional light and ambient and diffuse, I get pretty weird results:

http://dl.dropboxusercontent.com/u/45638513/cur05.png

Advertisement

Hmm, the curving seems to be persistent under all settings.

GGX Specular: http://dl.dropboxusercontent.com/u/45638513/cur06.png

Beckmann Specular: http://dl.dropboxusercontent.com/u/45638513/cur07.png

Even a hacked non attenuation version has it: http://dl.dropboxusercontent.com/u/45638513/cur08.png

It is hilarious that after so much time I can't write a very good physically based BRDF :).

What's the vertex resolution of the ground plane? It could be per-vertex calculations have a large error when they're interpolated over a large distance over the face of a primitive.

What's the vertex resolution of the ground plane? It could be per-vertex calculations have a large error when they're interpolated over a large distance over the face of a primitive.

Wow, great hint. Thank you! I was so caught up on the shaders that I didn't think about the mesh. The plane was only 4 vertices.

I increased the resolution 100 times and the curving is gone at normal angles.

But at very steep angles I'm getting a "snaking" pattern:

http://dl.dropboxusercontent.com/u/45638513/cur09.png

http://dl.dropboxusercontent.com/u/45638513/cur10.png

Interesting and something to think about why this happens.

Is this per-vertex lighting?

Btw, the curving is probably your view vector being backwards. Try negating it.

Are you normalizing light/camera vectors in the vertex shader? I came across a similar problem some time ago and it was caused by just that.

http://interplayoflight.wordpress.com/2013/05/17/correctly-interpolating-viewlight-vectors-on-large-triangles/

As a rule of thumb I usually normalize nothing in the vertex shader as by doing that you lose "distance" information and the interpolation gives wrong results.

Yes, I'm using per-pixel, a quite heavy pixel shader even.

But I was computing the view vector in the vertex shader.

I went from this:

http://dl.dropboxusercontent.com/u/45638513/cur11.png

to:

http://dl.dropboxusercontent.com/u/45638513/cur12.png

This did help a lot with the snaking.

But there was still some curving, particularly at a fixed small range of angles. After further testing I started to suspect anisotropy. The brick texture has a high surface variance and at a few angles the brick texture disperses the specular highlight vertically. This makes the oval highlight almost circular and over long distances curves it.

I tried a few smoother normal maps and they seem to have substantially less curving. The smoother it it, the less curving it has and the higher frequency you can use.

There should be no curving at all, regardless of roughness of the normal map.

Are you sure the normals are being calculated properly? If it's shifting to one side then it could be your bump map not being scaled properly (should be signed).

The pattern used in the normal map seems to create distortion pattern with anisotropy at higher levels.

Here it is with anisotropy turned off:

http://dl.dropboxusercontent.com/u/45638513/cur13.png

Then, as I raise it at certain thresholds away from the camera distortion patterns occur:

http://dl.dropboxusercontent.com/u/45638513/cur14.png

http://dl.dropboxusercontent.com/u/45638513/cur15.png

http://dl.dropboxusercontent.com/u/45638513/cur16.png

The same thresholds seem to influence the curving, which sometimes curves, sometimes disperses the specular highlight.

For now my fix is to not use such large highlights, i.e. add specular highlight only for a few select smaller objects.

Are you normalizing light/camera vectors in the vertex shader? I came across a similar problem some time ago and it was caused by just that.

http://interplayoflight.wordpress.com/2013/05/17/correctly-interpolating-viewlight-vectors-on-large-triangles/

As a rule of thumb I usually normalize nothing in the vertex shader as by doing that you lose "distance" information and the interpolation gives wrong results.

I now have a core set of shaders that I'm ready to make physically sound, so I read: http://interplayoflight.wordpress.com/2013/12/23/an-educational-normalised-blinn-phong-shader/

I'll play around with that project, might as well start and use FX Composer.

This topic is closed to new replies.

Advertisement