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 / Multiple lights on parallax shader with fog

Author
Message
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 22nd Jul 2010 22:04 Edited at: 22nd Jul 2010 22:05
Hai,

There isn't really a forum for HLSL or shaders so this'll have to go here because I know everyone looks at the DBP section now and then.

Basically, I started with Evolved's parallax shader which uses a normalmap and a heightmap to make an awesome bumpy-mappy effect. I reorganised the code to make it so I could understand it, got some help to add fog to the shader and now I'm stuck.

I currently need 4 lights instead of 1. - I know this is possible but I don't have a clue how to do it.

I spoke to Diggsey about it on MSN and he said that I should make a set of light variables for each light. So I set out attempting to rewrite all the lines that used the word "Light" again with "Light2" instead (I thought I'd try 2 lights before launching into 4). It got to the stage where he told me I can only use 8 TEXCOORDs in the structure Output. So I could only really do up to 2 lights anyway. - I then found some code later on which required a better understanding of what is going on and gave up, because I don't know HLSL or how the shader really works... xD

So I'm here. ! Here is the code for the shader:


I was wondering if anyone would be nice enough to either halp me to do the lights properly or point me in the right direction. (It'd have to be a very clearly defined right direction or I won't get it xD)

Thanks

revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 23rd Jul 2010 03:45 Edited at: 23rd Jul 2010 03:52
Ok, this should get you moving in the right direction.
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 23rd Jul 2010 03:58 Edited at: 23rd Jul 2010 04:19
Well, I thought it nearly worked but upon closer inspection (after changing light1 to be green and keeping light2 as red) I could only see green. I changed light2s position to be -150,150,0 as well, so that I could see it on the same polygons but only green shows up.

This picture shows an inverted cylinder (part of a map in 1 of my games) at 0,0,0 (the camera is looking straight up through it) and only 1 side is coloured. I should have a green and a red side to that cylinder.
<Removed>




EDIT: Ignore that
I changed:

to

and it worked fine, now I've just got to figure out how to do that 2 more times.

<Removed>

Thanks a lot, 2 lights is better than 1 even if I don't get 4 working properly. xD




EDIT2: Ignore that as well xD
I didn't realise what you'd done at the bottom because I'm not sure what "techniques" are in HLSL. But I just took out Light2 and used all 4 in Light1, now I have awesome pretty lights. !



So you've completely saved the day in 1 full swoop; I now understand HLSL a bit more, and I have 4 working lights (with room to expand) !!! I can't thank you enough.

revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 23rd Jul 2010 08:55
Quote: "I didn't realise what you'd done at the bottom because I'm not sure what "techniques" are in HLSL. But I just took out Light2 and used all 4 in Light1, now I have awesome pretty lights."


The purpose of "Techniques" is to be able to store more than one effect in a single shader. The technique to use can be set by using Set Effect Technique EfxID,TechniqueName$.

Each light is drawn in a separate "pass", and therefore the more lights drawn the longer it will take. In best practice, the lights would be left as separate techniques (Light1,Light2,Light3,etc..)
in case you only need so many lights at a particular time to keep things as fast as possible.
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 23rd Jul 2010 13:31
@ revenant chaos
Oh I see.

Well for this particular usage I pretty much need 4 lights all the time so I'm not worried. I can always edit it if I need to.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Jul 2010 13:37
Well done COwbox. You're making good progress with this. Keep it up.
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 23rd Jul 2010 13:47
Making progress?

I haven't started yet xD - This 4-light shader will be used in the next project after World Off Road.

(I was just testing it in Soup because it's 1 of my few games that uses shaders )

C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 23rd Jul 2010 20:24 Edited at: 23rd Jul 2010 20:33
Ok, now I have these 4 lights, I wish to enquire how feasible soft shadows are?

Would there be issues having all 4 lights create shadows? / Would it strain the GPU a lot to do this sort of thing? / How do other people do soft shadows with multiple lights?

As an alternative:

I know that DBP's built in shadows work over the top of that shader. - Is there any way to use that knowledge to make shadows from these 4 lights I use? - I'm willing to sacrifice the soft shadows, I just wish to know what my options are.

Login to post a reply

Server time is: 2026-07-25 05:32:47
Your offset time is: 2026-07-25 05:32:47