Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (dr_panther, Ayumi, 1 invisible), 708 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
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 Offline OP
Warned
Why_Do_I_Die  Offline 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.rar
Here 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 Offline
Serious User
jigalypuff  Offline
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: jigalypuff] #239712
12/06/08 18:54
12/06/08 18:54
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
granted i know it is just a demo to test the normal map, but you should fix the spec map on the walls.

Re: 2 Lights Normal Mapping Shader and 1 Light Normal Mapping Shader [Re: lostclimate] #239723
12/06/08 20:20
12/06/08 20:20
Joined: May 2005
Posts: 819
U.S.
Why_Do_I_Die Offline OP
Warned
Why_Do_I_Die  Offline OP
Warned

Joined: May 2005
Posts: 819
U.S.
jigalypuff , I have no idea , i'm not really a shader programmer , I just tried making sense of the code from the forum and edited it till it worked with 2 lights , then it was easy to make it just 1. I know it supports model with difuse texture , plus normal map texture containing specular map in it's alpha channel.

About fixing the spec on the walls , well it was quick demo , and the super glossy reflective walls show very clearly how the effect is working. Of course , for real game you just edit the spec map to the shininess you want , I've tried on other models and the results you get are really nice.

Re: 2 Lights Normal Mapping Shader and 1 Light Normal Mapping Shader [Re: Why_Do_I_Die] #239739
12/06/08 22:42
12/06/08 22:42
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline
Serious User
jigalypuff  Offline
Serious User

Joined: Nov 2005
Posts: 1,007
Erm how many lights can you add in a level? if i add more than 3 everything goes black frown


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: jigalypuff] #239742
12/06/08 22:51
12/06/08 22:51
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
@jigallypuff

Thats the point of this one, its title clearly says "2 LIGHTS NORMAL MAPPING"

perhaps you should also read the post before you reply.

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 Offline OP
Warned
Why_Do_I_Die  Offline 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.
Code:
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 Offline
Expert
xXxGuitar511  Offline
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 Offline
Serious User
jigalypuff  Offline
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 smile

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!
Re: 2 Lights Normal Mapping Shader and 1 Light Normal Mapping Shader [Re: jigalypuff] #240017
12/08/08 20:09
12/08/08 20:09
Joined: May 2007
Posts: 7
R
Reigel_Seven Offline
Newbie
Reigel_Seven  Offline
Newbie
R

Joined: May 2007
Posts: 7
Somehow I was able to combine Grafton's Projection Flashlight shader with this one. Right now it's only the flashlight + 1 room light, but I'll add more lights later on. I'll post the code later tonight (I'm at work).

I say "somehow" because I know pretty much NOTHING about how shaders work, but with some "advanced" cut-and-pasting I was able to figure it out. Thanks to the OP for this! grin

Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1