Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Incorrect Normals render

Author
Message
Kuper
10
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 17th Feb 2016 15:17 Edited at: 17th Feb 2016 15:18
I get this weird seam in my Normals

I use standart shader code
matrix WorldIT:WorldInverseTranspose;
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
float3x3 wTBN=mul(TBN,WorldIT);



so I cant guess which cause this
I find some ways to compute tangent entire in vertex shader but
I get totally different render with them
float3 Tangent=float3(IN.Normal.y-IN.Normal.z,0,IN.Normal.x);
float3x3 TBN={Tangent,cross(IN.Normal,Tangent),IN.Normal};
Green Gandalf
13
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 4th Apr 2016 15:33 Edited at: 4th Apr 2016 15:33
Did you ever get this sorted out? If not could you post a simple demo so I can take a look?


Powered by Free Banners
Kuper
10
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 5th Apr 2016 14:43
Hi GG !
Setting optimize in panda exporter to: "Normal" help a little bit
But to have really good normals in round surfaces I need to create custom normals and
write them to uv layers.I didnt do this yet
Here is technique:
http://www.crytek.com/download/Triangle_mesh_tangent_space_calculation.pdf
Green Gandalf
13
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 5th Apr 2016 15:04
Seams like those in your screenshot usually arise when your model isn't welded so adjacent faces each have separate normals on their coincident vertices. One solution is to calculate some sort of average over all normals at each shared vertex (and renormalized of course). The coding details are somewhat messy although straightforward in principle. I'm not convinced that article will help you very much.

Even a welded model will have an annoying seam in some situations - DBPro spheres for example have a North-South seam which causes problems for normal mapping (because the tangents are not calculated correctly along the seam). Most of my normal mapping shaders now have an option to reduce or even remove such seams.


Powered by Free Banners
Kuper
10
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 5th Apr 2016 15:36
Quote: "to calculate some sort of average over all normals at each shared vertex"

exactly
Quote: "Most of my normal mapping shaders now have an option to reduce or even remove such seams."

You mean calculating tangents inside vertex shader?
Green Gandalf
13
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 5th Apr 2016 16:25
Quote: "You mean calculating tangents inside vertex shader?"


Not quite - more of an ad hoc smoothing as in the extract below:



If I recall correctly that particular fix was suggested by Paul Johnston - although I usually use a slightly simpler variant of the same idea. But that fix assumes the normals are calculated correctly.


Powered by Free Banners
Kuper
10
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 6th Apr 2016 11:38
Thanks Green Gandalf!

Login to post a reply

Server time is: 2018-09-23 19:28:37
Your offset time is: 2018-09-23 19:28:37