• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
DwarvesH

I'm guessing specular highlights shouldn't curve?

12 posts in this topic

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

 

0

Share this post


Link to post
Share on other sites

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

0

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.

0

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.

0

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

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.

0

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

0

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.

0

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.

0

Share this post


Link to post
Share on other sites

One strange thing I noticed that those samples do:

float3 nor = tex2D(NormalSampler, texCoord).xyz;
nor = nor * 2.0 - 1.0;
nor.y = -nor.y;

What could be the possible reason for inverting the up component of the normal?

0

Share this post


Link to post
Share on other sites

The normal is still in tangent space so Y is not the "Up" direction, Z is.

 

You wouldn't do this normally no but sometimes due to the way the normalmap is baked out, you might need to flip the X or Y component to get correct lighting.

0

Share this post


Link to post
Share on other sites

The normal is still in tangent space so Y is not the "Up" direction, Z is.

 

You wouldn't do this normally no but sometimes due to the way the normalmap is baked out, you might need to flip the X or Y component to get correct lighting.

 

Thanks, it makes sense. After further investigation I did notice that the "Green" part of the normal map is flipped. I guess I need to add an option to the content creator to fix such maps so that I don't have to maintain multiple versions of the same shaders.

 

Anyway, after months of study and work this is my result:

 

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

 

How does that look? This is the best visual result I ever got and the shaders support (non optimally) any number of light on a forward path. I used the higher resolution textures found in that blog post, but the albedo texture is disabled. It is just a normal map and an optional AO map, which is turned on in that screenshot. This is how an untextured object will look in the engine.

 

I read in one of the physically based rendering papers that an object should look good with only lighting, and I think truer words have never been spoken (in the domain of rendering).

 

The curving artifacts are still there, but depend on texture. This high resolution one has 0 curving or artifacts. High contrast normal maps under 512x512 will curve the shit out.

 

There are two more things I need to master and I'm done.

 

1. Toksvig AA, precomputed or not. I discovered Tokvig a while ago, but I'm always having a problem with it. In all the reference applications, Tokvig does stabilize the specular shimmering and gives some AA, but it also changes the perceived roughness of the surface a bit and spreads out the marginal highlights, basically altering the shape. So the choices are normal shimmering specular of different shaped non-shimmering ones. But whenever I "implement" Toksvig, and I put implement in quotes because it is just basically and extra multiplication with a simple expression based on normal length, I do not get that shape change. I'm comparing it right now with the results in FX Composer and things are slightly different. You do need a magnification glass to see the difference often, but it is there.

 

2. AA. That screenshot has some nasty shader surface aliasing. And from some angles it can be a lot worse. I'm guessing that the high contrast normal texture is partially to blame for increasing the surface aliasing:

 

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

 

That surface aliasing is pretty bad. The best SMAA is not good enough to fix this. Maybe with temporal reprojection it would help a bit.

 

What can be done about it?

 

One thing that I'll try it supersampling. I know of a technique used only for specular highlight supersampling. I never tried it on the entire lighting process, so there is no telling what results it will give. It is a constant backbufffer supersampling solution, meaning that 4x does not increase the resolution 4 times nor does it drop the performance by 75%. But there is still a steep performance drop.

 

On the other hand, more and more modern games do come with a SSAA solution out of the box. My GTX 660 TI is not strong enough for that, but I guess top end cards are so strong today that you can run some games with SSAA?

 

Anyway, I'll post my SSAA result here in a few days.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0