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 / Normal mapping with Lightmap shader scrolling textures?

Author
Message
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 31st Oct 2007 06:20 Edited at: 31st Oct 2007 06:21
I have made a small level with 3D world studio, and when I load it everything looks fine, but when I apply a normal mapping shader to it the textures seem to be scrolled randomly. Has anybody found a way prevent this? I have attached a screen shot to show you what I mean.

here is the shader


If need be, I can upload an example which displays the problem.
Any insight as to why the textures are shifted when the shader is applied would be greatly appreciated.

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Oct 2007 18:45
I'd guess it's the UV coords that are wrong. The shader seems to assume there is a lightmap on Stage 0, 32x32 tiled textures (base texture and normal map) on Stages 1 and 2 and finally a normalizing map on Stage 3. Is that how you've used it - and how your object is constructed? Lightmapped objects often have their own set of UV coords.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 31st Oct 2007 21:14 Edited at: 31st Oct 2007 21:15
Quote: "Is that how you've used it"


The texture stages have been applied correctly, lightmap is on stage 0, the diffuse textures on stage 1, and the normal maps on stage 2, and the normalizer on stage 3.

Quote: "and how your object is constructed?"

I'm not really sure how I should answer this, but it is made with 3D world studio which is a CSG modeler. In the example I have uploaded, I just made 5 cubes for the walls and floor, then make a sixth cube to cut out the doorways which was later deleted. although this demo doesn't suffer as much from the shifted textures, inside the zip are screen shots showing what to look for. I also have changed the shader to use 16x16 tiles because I didn't scale the textures within 3DWS.

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Oct 2007 21:56 Edited at: 31st Oct 2007 21:57
You need to know how many sets of UV coords your object has - and I certainly don't know (not without delving into your mesh or making guesses). The shader assumes only one set - but as I said before, lightmapped objects often have a different set for the lightmap.

I will make a quick guess that there are two sets of UV coords: Stage 0 for the lightmap and Stage 1 for the base and normal maps (or the other way round). Won't take long to modify the shader and test that idea. Will report back ASAP.

Edit That simple demo you posted is ideal by the way - it demonstrates the problem clearly.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Oct 2007 22:09
My first guess seems to be right. Try this:

revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 1st Nov 2007 18:36
That's Perfect! I can't thank you enough. It fixed alot of other things in the level That didn't seem quite right. For instance, on the edge of a doorway one of the textures was rotated like 30 degrees and I figured I would just have to cover it with trim. I have tried to re-create my original screenshot so you can see how much better it looks. Thank you again.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-19 02:11:42
Your offset time is: 2024-05-19 02:11:42