Advertisement

Tangent space lighting broken, many seams.

Started by December 21, 2019 12:11 PM
5 comments, last by MidLevelGameDev 5 years, 1 month ago

My renderer first does an ambient pass, and then individual lighting passes. All materials have shaders that are compiled once for each pass type, with different macros defined (so far it's just nothing for ambient, and the DIRECTIONAL_LIGHT macro for a directional light pass).

Now here are my vertex shader and fragment shader source. Notice how I'm not doing any normal mapping nor any texture reads. All it is is just simple Blinn-Phong diffuse and specular lighting, but in tangent space. And here is my result:

The asset was originally from a DirectX game, it was converted into an .obj file and then exported from Blender with a script I wrote. I can post it here, too, if you suspect that to be the issue, but I kinda doubt it.

(Ignore the POS varying variable in my shaders, that was for when I was attempting to debug and tried drawing some values directly).

bumpersticker

Advertisement

Hi.

Are you 100% sure the source normals are correct? Perhaps you can validate this by drawing them as colors.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Normals seem completely fine, here is the result of drawing the contents of a_nrm directly:

Overall, I know it's definitely not a normal mapping issue (since it's disabled), it has to be either my model (unlikely), the exporter, the Blinn-Phong lighting code or the TBN matrix causing issues.

Look how the ball lighting changes when the ball rotates, it's very unnatural:

I am now 100% sure the TBN is at fault. If I remove any use of the TBN and do lighting in world-space, then everything is fine.

This topic is closed to new replies.

Advertisement