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 / Horrendous Texture Seams With Evolved's Normal Mapping Shader

Author
Message
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 13th Jul 2013 15:21 Edited at: 13th Jul 2013 15:27
Texture Seams Showing With Evolved's Normal Mapping Shader.

I been having a problem for a long time now with texture seams appearing when I try to use normal mapping. I've had this on the back burner for a while now dealing with other things.



I have attached a zipped project folder containing a small demo of the problem with all necessary files and source. Download to pick at it as you like. Everything is included.

I should also add I completely flattened the normal map to ensure it wasn't creating seams.

Here is a copy of the shader:


Here is a copy of the demo source:


Someone please help me fix this texture seam issue!

Thanks.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jul 2013 18:44
There shouldn't be seams when you conpletely flatten the normal map so something odd is going on. I'll try to look into that later tonight.

Just before I hit the post button I recalled the fix I had to add to my normal mapping shader for what seems () to be the same issue. No time to check carefully right now but if I'm right it's to do with the way DBPro calculates tangents along seams of objects (DPRo spheres for example have a North-South seam). There's an easy fix for some objects such as spheres if that's the problem here.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 14th Jul 2013 00:21
That's not a DBP sphere I modeled a sphere with a big texture seam running horizontally for the purpose of the example. That way it would be more like a character exported from a modeling program.

Thanks for looking into it.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jul 2013 02:08
Quote: "That's not a DBP sphere"


I know - but you get a similar problem with a DBPro sphere.

Default DBPro lighting doesn't use tangents so isn't affected.

I've just been playing with your object and it seems to have a strange UV coordinate discontinuity along the horizontal seam. That's bound to cause problems with binormals and tangents and may be part of your problem. The fix I usually use for DBPro spheres doesn't quite work for your object as it stands and a UV discontinuity might be the cause - but I'm not sure (because DBPro spheres also have a UV discontinuity and seem OK).

On closer inspection your object has differing numbers of vertices, normals and UV coordinates, i.e. 74, 62 and 74, but that seems to be covered by the duplication list.

Could you try the attached edited version of the shader and see if it improves matters? [I know it doesn't completely fix the trial object but that might exaggerate the issue in some way.]
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 14th Jul 2013 03:05 Edited at: 14th Jul 2013 03:06
Thanks.


The changes you made helped a bit. There is still a very visible seam in the object.

Just some context...
I made this a sphere just for simplicity. When I use the shader in game I have people walking around with seams up and down their legs and etc. That's why I purposely made U/V discontinuity in this demo object.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jul 2013 03:14
Quote: "Just some context...
I made this a sphere just for simplicity. When I use the shader in game I have people walking around with seams up and down their legs and etc. That's why I purposely made U/V discontinuity in this demo object."


OK, thanks for clarifying that. I'll have to think of something better. My fix for spheres is based on a suggestion by Paul Johnston some years back. I'll see if I can dig out his original code. I know I simplified it a bit but maybe I left out something vital.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 14th Jul 2013 16:16
I've attached a file to this post.

This shader from Ninja Matt doesn't have any seams but I found it unsuitable since it doesn't have an ambient light. Also he seems to comment that he thinks the shader is inefficient since it has 3 passes.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jul 2013 16:54
Interesting. It's in asm code unfortunately.

Just a long shot - have you tried replacing the normalizing map calls with the normalize function in the pixel shader? Perhaps the normalizing map is inaccurate?
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 14th Jul 2013 17:28
Not that good at shaders just yet. I've been doing a lot of reading this week and I'm picking up a lot of it. I'm not far enough along to understand what you suggested at a code level.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jul 2013 18:36
OK. I'll test it myself later - but it's a bit of a long shot.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 14th Jul 2013 19:28
Thanks.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jul 2013 22:37
That made no difference. Sorry.

I wonder what the essential difference between the two shaders, i.e. Ninja Matt's and Evolved's, is? Something to investigate.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 15th Jul 2013 05:24 Edited at: 15th Jul 2013 05:26
Something to do with tangents. It might be easier to somehow hack in an ambient light global into ninja matts shader.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Jul 2013 16:44
Which of the three shaders in that download are you using? Much of the code is because they're written for several lights in and old shader version. It should be possible to do something similar but simpler in HLSL for PS2 or PS3. If you're using just one light it would simplify matters somewhat.

The conventional tangent space method could be the problem here. It might be possible to circumvent the issue by using object space rather than tangent space for the bumpmapping. The downside is that you'd need a different kind of normal map.

You mentioned that you don't get seams using NM's shader. Could you post the code you used? For some reason I'm having trouble getting any of them to work.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 15th Jul 2013 23:05
Quote: "Which of the three shaders in that download are you using? Much of the code is because they're written for several lights in and old shader version. It should be possible to do something similar but simpler in HLSL for PS2 or PS3. If you're using just one light it would simplify matters somewhat."


The shader that the demo loads. But the way I unsderstood it is that it has 3 passes and I assumed all 3 shaders were used. I really need about 3 lights with an ambient light.

Quote: "You mentioned that you don't get seams using NM's shader. Could you post the code you used? For some reason I'm having trouble getting any of them to work."

Ill post the code in a few hours when time permits.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Jul 2013 02:47
Quote: "The shader that the demo loads."


Why didn't I think of that?

Quote: "Ill post the code in a few hours when time permits."


OK. No rush - quite busy here too (well I will be after I get some sleep ).
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 16th Jul 2013 14:37
Here is the Ninja Matt demo tweaked to use my object and it's flat normal map. I had to edit the shader to change the hard coded texture paths. Download is attached.



The ninja matt shader (pictured above) doesn't have any texture seams. But it also doesn't have any ambient light which makes it pretty useless. The Evolved Shader has ambient light, but also deal breaker texture seams.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Jul 2013 16:59 Edited at: 16th Jul 2013 17:24
Thanks. I'll take a look later. It'll be interesting to isolate the cause of the difference. Both shaders use tangent space normal mapping as far as I can tell.

It'll take me a while as I'll probably have to translate it into the equivalent HLSL in order to read it if you know what I mean .

Edit I think you've got a bit confused there. The shader you're using doesn't have the NormalSpecular technique so it defaults to the first technique, i.e. Lights2. Anyway, I'm trying to modify your original demo to use NM's shader (his demo is too confusing to see what's going on).
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Jul 2013 17:34
The difference between the two shaders you're comparing is that NM's one doesn't have specular and I suspect that's the part that's going wrong. I'll see if I can get his one with specular working. With luck we might be narrowing this done a bit.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Jul 2013 18:15
[Dammit - dropped the mouse and accidentally refreshed the page before posting. Oh well, I'll have to type it all again. ]

Here's what I was about to say:

Try the following code which tries to use NM's shader (the right one this time ) with your original demo. It's hard to see whether it's improved matters since there seem to be seams everywhere. You'll need to use NM's "specular map" which as far as I can tell is simply a 1D lookup texture to avoid awkward specular calculations in the shader (the shader is rather old and was designed for old hardware).

I've got to do something else for a while now and will have another look later. It's possible NM's specular calculation is fake and doesn't use the tangent space stuff at all - I'll check.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 16th Jul 2013 19:17 Edited at: 16th Jul 2013 19:17
Do you still get seems if you use a flat normal map instead of the normal map you're currently using?

This should be one.


TheComet

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 16th Jul 2013 22:56
Quote: "Try the following code which tries to use NM's shader (the right one this time ) with your original demo. It's hard to see whether it's improved matters since there seem to be seams everywhere. "




I don't have seams appearing with the code you posted.


Quote: "Do you still get seems if you use a flat normal map instead of the normal map you're currently using?"

The normal map I am using is RGBA(127,127,255,255). The one you provided is RGBA(128,128,255,255). Either way there was no difference.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Jul 2013 00:39
So you're happy with fake specular reflection then?

My guess is that if you remove the specular reflection then you won't get seams. I'll try to investigate this at some point (not now as we've had a BBQ and a few drinks so nothing intelligent can get done ).
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 17th Jul 2013 01:58
No I find that the ninja Matt shader looks worse. But the seams in the evolved shader are a deal breaker. So is the lack of ambient light in ninja Matt's shader.

Ideally I'd be using evolved's shader with no seams. That was the goal.

I have mentioned ninja Matt's shader as an example of a similar shader that is not showing the same error as a means to help find a solution.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Jul 2013 02:20
With luck it's helped focus on the cause of the issue.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 17th Jul 2013 04:50
If the ninja Matt shader had like 1 more light and ambience then it would be worth using. If evolved didn't have seams then it would be worth using. Overall evolved seems to produce the better visual effect, if corrected.

The primary goal here was to get away from using the stock lights. The normal mapping and specular is also a very good effect to have too.

Login to post a reply

Server time is: 2026-07-06 18:37:15
Your offset time is: 2026-07-06 18:37:15