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 / Having difficulty implementing a light map in a shader

Author
Message
pdq
20
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 10th Mar 2010 04:20
I am having difficulty implementing a light map in my shader code below.

The light map works with a diffuse shader that consists of a light map and color map, but I just cannot get it to work with my bump mapping shader.

Any ideas?



THX
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Mar 2010 11:28
I've done this many times in much the same way without problems so I'd guess the shader is not the problem.

In fact I've just tried your shader with the demo you posted yesterday (modified very slightly) and as far as I can tell it works fine.

Here's the code I've just used:



So you must have done something different somewhere.
pdq
20
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 10th Mar 2010 14:48
Thanks for looking at this Gandalf. This is actually a continuation of the last discussion I had with you. Silly me, I discovered that I actually do need a light map. Basically, I am losing the bump information when I apply the light map.



Looking at the code above, if I comment out the lightmap lines, the shader of course works fine without the lightmap, but as soon as re-enable those lightmap lines I lose the bump mapping effect.

I am at work right now, but when I get home I am going to upload a test demo to show you the problem I am having.

THX
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Mar 2010 16:49 Edited at: 10th Mar 2010 16:50
Edit OOPS! Deleted a daft post. I'll wait for your demo.
pdq
20
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 11th Mar 2010 03:51
OK, I figured it out. I had the DoNotGenerateExtraData set to 1 when loading the effect.

New problem. Please see the screenshot. Notice the shadows appear correctly oriented on the right rockwall, but are incorrect on the left as if the lighting is coming from behind the camera.

THX
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 11th Mar 2010 04:18
I too have run into that problem with 3DWS objects, but couldn't find a solution (other than switching to MapScape).
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Mar 2010 12:12
Quote: " Notice the shadows appear correctly oriented on the right rockwall, but are incorrect on the left as if the lighting is coming from behind the camera."


Is the attached shader any better? If it is then perhaps the problem is the shader. The shader doesn't include a lightmap feature - but I'm sure you can add that if you need it. Note that it uses Stage 1 UV coords - I used it to test with your earlier demo where the stage 0 UV coords were the lightmap UV coords.
pdq
20
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 11th Mar 2010 16:29
I'll try out tonight after work. I hope it isn't a 3DWS thing.
pdq
20
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 12th Mar 2010 01:28
Well the problem still seems to be there even with your ggbump04.fx shader. Again the right wall looks to be illuminated from the front; whereas, the left wall is being illuminated from behind the camera. I also tried one of Evolved's shaders and got the same result.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Mar 2010 11:14 Edited at: 12th Mar 2010 12:40
Does sound like a problem with the model then. Have you checked the normals on the surface that's wrong?

Could you post the model - or is it the one I already have? I'll see if I can have a closer look.

Edit I took a chance and tried the model you posted earlier - and yes the problem is quite clear. My guess is that the UV coordinates have been reflected on some polys so that the normal map is oriented the wrong way. Remember that for normal maps the UV coords must be oriented so that as you face the image (U,V) = (0,0) is top left, (1,0) is top right, (0,1) is bottom left and (1,1) is bottom right, and similarly for intermediate values. That almost certainly is something you'll have to fix in your modelling software. It should be easy - but I can't help you with the software itself I'm afraid.

Here's another screenshot illustrating your problem using your object with my media and shader. I think the clue is the floor section at the "cross-roads".

I also saved the mesh and inspected the X file - there is nothing odd there except possibly the UV coords issue (which is hard to check without drawing out a few suspect polys with pen and paper - you could try that and see if I'm right ). I doubt there's anything wrong with the normals.

pdq
20
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 12th Mar 2010 15:12
Thanks Gandalf for looking into it. I exported the model from 3DWS. I'll post this problem under the 3DWS discussion board to see if anyone came up with a solution.

Login to post a reply

Server time is: 2026-07-26 21:11:53
Your offset time is: 2026-07-26 21:11:53