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 Map Shader - Lighting Direction Question

Author
Message
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 27th Dec 2013 22:17 Edited at: 27th Dec 2013 22:30
Perhaps Green Gandalf or another DBPro guru can lend a hand here.
This subject has apparently come up many times, but I haven't seen a definitive answer.

Last year, GG posted a decent normal map shader example here:
http://forum.thegamecreators.com/?m=forum_view&t=201251&b=1

Now, if I add a camera code that lets me move around the objects, I notice that the reflected light doesn't seem to come from any actual light source, since I can HIDE LIGHT 0 and SET AMBIENT LIGHT 0 and it doesn't change the scene. Moving Light 0 (or any other light I make) doesn't seem to make any difference either.

My question, in short, is how can I adjust the light position/angle to change which side of the object is lit? This only seems to be an issue when normal mapping is applied, because any other time, I can move light sources around effectively.

D.D.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 27th Dec 2013 22:40 Edited at: 27th Dec 2013 22:43
This is because the light position is set with in the shader and not DBP light. What you need to do is pass a variable to the shader to update the light position or other variables:



Finally beat GG to the punch

"Get in the Van!" - Van B
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 28th Dec 2013 00:49 Edited at: 28th Dec 2013 01:01
Ok, that makes sense... so first we set our vector and then pass the information to the shader.

So if my player has a candle (or candlelight spell) going, obviously the light position will have to update every loop like any moving light.

I guess my only other question for now is, are the SET EFFECT CONSTANT commands all that's needed in order to execute the actual on-screen changes? Meaning, I don't have to edit the actual shader file.

(As you can tell I'm a shader newb, but I do plan on learning the language.)

D.D.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Dec 2013 01:05 Edited at: 28th Dec 2013 01:06
Quote: "So if my player has a candle (or candlelight spell) going, obviously the light position will have to update every loop like any moving light."


Yeah

Quote: "I guess my only other question for now is, are the SET EFFECT CONSTANT commands all that's need in order to execute the actual on-screen changes?"


Yes. Some post processing shaders do require more work but that's only on the DBP side with setting up render targets and sync masks and such but for the most part what actually affects the shader is the variables you pass to it via SET EFFECT CONSTANT commands.

Quote: "(As you can tell I'm a shader newb, but I do plan on learning the language.)"


I'm still learning, I just experiment and that's how I've mostly learned plus the many examples you'll find on the forums.

"Get in the Van!" - Van B
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jan 2014 01:27
Quote: "Finally beat GG to the punch"




That's what happens when I take a short break.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-06 16:50:09
Your offset time is: 2026-07-06 16:50:09