3 registered members (dr_panther, Ayumi, 1 invisible),
708
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
2 Lights Normal Mapping Shader and 1 Light Normal Mapping Shader
#239669
12/06/08 11:50
12/06/08 11:50
|
Joined: May 2005
Posts: 819 U.S.
Why_Do_I_Die
OP
Warned
|
OP
Warned
Joined: May 2005
Posts: 819
U.S.
|
Hello everyone , for one of my current projects , I modified the shader guitarxxx had posted on the contributions , the 3 light shader , I changed it to be a 2 dynamic light shader (no sun) , and a 1 dynamic light shader(no sun). I mainly did this for speed reasons , the shader runs much faster with just 2 lights and only one pass, and even faster with just one light, so I'd thought I'd share here , maybe someone can find it usefull as well. In the rar there are the scripts you need , all you need to do is copy them to your project folder , and include normalMapping.wdl in your main script , and give your entities the action nMapping1L for 1 light and nMapping2L for using 2 lights. Heres the link: http://www.bloodychainsaw.com/normalmap/NormalMapping.rarHere are some images 2 Lights 1 Light
Last edited by Why_Do_I_Die; 12/06/08 11:55.
|
|
|
Re: 2 Lights Normal Mapping Shader and 1 Light Normal Mapping Shader
[Re: Why_Do_I_Die]
#239702
12/06/08 17:55
12/06/08 17:55
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
Serious User
|
Serious User
Joined: Nov 2005
Posts: 1,007
|
thanks for this man, it works great. Is it possible to have more than one texture map + normal maps per model? and if so could you let me know how to add the needed code?
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: 2 Lights Normal Mapping Shader and 1 Light Normal Mapping Shader
[Re: lostclimate]
#239758
12/07/08 02:57
12/07/08 02:57
|
Joined: May 2005
Posts: 819 U.S.
Why_Do_I_Die
OP
Warned
|
OP
Warned
Joined: May 2005
Posts: 819
U.S.
|
jigalypuff, you can have as many lights as you want in the level , if you are using the 2 lights shader , then you can only have 2 lights active at one time , i.e. , 2 lights have their lightrange > 0, if you are using the one light shader , then you can only have 1 light on at a time , but in the level , you can place as many as you want. The whole idea of having a 2 light shader with 1 pass and a 1 light shader is for speed. The only reason I modified the shader was that other shaders with only had 1 light only used the sun as dynamic light , which to me makes them completely useless. Here is a very simple code you can use to place as many lights as you want in the level and the 2 closest lights to the player will be the ones activated.
action dynamicLight // Attach to entity or entities that are going to be your ligth sources
{
my.invisible = on;
my.passable = on;
my.light = on;
my.cast = on; // Cast shadows
my.red = 255; // Light red color
my.green = 255; // Light green color
my.blue = 255; // Light blue color
my.lightrange = 0; // Light brightness
while(!player){wait(1);}
while(me!=null)
{
if(vec_dist(my.x,player.x) < 200) //// How close the light should be to the player before it activates.
{
my.lightrange = 200; //// Light brightness
}
else
{
my.lightrange = 0;
}
wait(1);
}
}
The code I posted above will handle the lights on it's own , just position the lights in a way that let's the level flow with them. This code is not good for 2 story buildings , because of how vec_dist works , but modifying it to work with 2 or more story buildings should be pretty easy. The script will work with the 1 or 2 light shader. edit: The script is not perfect , and doesn't really calculate the closes to the player , rather than just activates itself if it is close enough to the player , then the engine will use the 2 lights it sees first and ignore extra ones if more than 2 lights are in range at once. However , by cleverly placing the lights , i.e. not putting 5 lights next to each other , but rather in places you want lit , like 1 in a room , another in a hall , another in the next room , ect... , this script should handle the lights pretty good. I will prolly make a more precise script later on to really handle lights properly, activating only the ones closest to the player , and handling 2 or more story levels , but that will prolly be later on when I get more into the game , I'm still in testing stage of things.
Last edited by Why_Do_I_Die; 12/07/08 03:06.
|
|
|
Re: 2 Lights Normal Mapping Shader and 1 Light Normal Mapping Shader
[Re: Why_Do_I_Die]
#239765
12/07/08 05:56
12/07/08 05:56
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
@Jigalypuff) You can use as many diffuse+normal maps on a model as you want. it's in the manual.
You have to use them in sequence. Ex)
Skin1) Diffuse01 Skin2) Normal01 Skin3) Diffuse02 Skin4) Normal02 Skin5) Diffuse03 Skin6) Normal03 etc...
xXxGuitar511 - Programmer
|
|
|
Re: 2 Lights Normal Mapping Shader and 1 Light Normal Mapping Shader
[Re: xXxGuitar511]
#239771
12/07/08 08:10
12/07/08 08:10
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
Serious User
|
Serious User
Joined: Nov 2005
Posts: 1,007
|
@lost climate, if i understood shaders then perhaps i`d have understood the one light only thing Why do i do thanks that works great xxxdisiple cheers man i`ll add the extra textures to the .fx file and see how i go. Cheers to all.
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
|