Advertisement Jump to content
Sign in to follow this  
DwarvesH

I'm guessing specular highlights shouldn't curve?

This topic is 1776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

 

Share this post


Link to post
Share on other sites
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 :).

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Is this per-vertex lighting?

 

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!