Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
2 registered members (Ayumi, 1 invisible), 584 guests, and 1 spider.
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 3 1 2 3
possible to add proper spotlight support to this shader? #402305
06/02/12 11:42
06/02/12 11:42
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hey there,

I'm using the normal mapping shader with specular map support from the wiki:

Normalmapping Shader (wiki)

This shader is only added to our characters.

In our game there are a few cases where player uses a flashlight.

Now the problem:

Though the shader reacts on the light of the spotlight it seems it doesn't know that it's spotlight. It behaves like the spotlight would be a "normal" dynamic light.

Is it possible to modify the shader so that it recognizes spotlights properly?

I'd like to avoid adding a special spotlight shader like the one from AUM 71.

Regards,
Pegamode.

Re: possible to add proper spotlight support to this shader? [Re: pegamode] #402442
06/05/12 09:58
06/05/12 09:58
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Really no one with an answer for that issue?

Is it possible to differ between normal and spotlights within the shader at all?

Re: possible to add proper spotlight support to this shader? [Re: pegamode] #402589
06/07/12 12:34
06/07/12 12:34
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Ok. I know now that I can differ within the shader using:

vecLightDir[0].w <= 0

I'd like calculate in the vertex shader if the vertex in currently in the spotlight cone.

Can someone help me with that?

I think first I have to calculate the angle between the light ray and the vertex, right?

Re: possible to add proper spotlight support to this shader? [Re: pegamode] #402660
06/08/12 18:23
06/08/12 18:23
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Well... the shader you posted looks pretty complicated.
I'm sorry but I don't understand enough of it to do the changes to make It work with spotlights.

But I'm working on my own lighting shader (Which looks imo much better than the engine standart-lighting) for about a week.

At the moment it supports
sunlight, normal maps, up to 7 lights (including the sun), diffuse lighting, specular lighting and a kind of fog.

I'm now about to work on the spotlight-part (diffuse already works, but I've go problems with specular reflections)

So... If you want to I'll share it with you if its finished.


Kartoffel smile

Last edited by Kartoffel; 06/08/12 18:28.

POTATO-MAN saves the day! - Random
Re: possible to add proper spotlight support to this shader? [Re: Kartoffel] #402661
06/08/12 18:31
06/08/12 18:31
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi Kartoffel,

that would be great.

For our project it is important that the shader supports the specular map as separate texture skin:

texture entSkin1; // color map
texture entSkin2; // normal map
texture entSkin3; // specular map

Does your shader supports this or can it be modified to work like this?

Regards,
Pegamode.

Last edited by pegamode; 06/08/12 18:32.
Re: possible to add proper spotlight support to this shader? [Re: pegamode] #402662
06/08/12 18:39
06/08/12 18:39
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
It doesn't support a specular map, yet. But this modification shouldn't take more than 10 minutes.

Should the Specular map support RGB or is it just used as a kind of alpha-value for the specular light?


POTATO-MAN saves the day! - Random
Re: possible to add proper spotlight support to this shader? [Re: Kartoffel] #402663
06/08/12 18:47
06/08/12 18:47
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
It is just used for the specular light, but as our color map has its own alpha channel we can't use this for a specular map.

Re: possible to add proper spotlight support to this shader? [Re: pegamode] #402666
06/08/12 19:56
06/08/12 19:56
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
OK, I made a first version of it now. I still have to look what can be made better and more efficient
and maybe some adittional features (if you're still missing something) - but not today.

here's the code.

Have a look at the first 45 lines.

At the moment the SunColor is used as AmbientColor and FogColor.
The Spotlight arc is static for all lights (but it's adjustable).


And please say if you can find any bugs.

EDIT: Another thing:
The shader uses PixelShader 3.0, It doesn't work with lower versions
keep in mind that people need at least a DirectX 9.0c graphics card to use it.

Well... - even my grandma's PC has got a DX9.0c card... but you might add this to the
minimum system requirements if you're working on something commercial.


POTATO-MAN saves the day! - Random
Re: possible to add proper spotlight support to this shader? [Re: Kartoffel] #402668
06/08/12 20:56
06/08/12 20:56
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Thanks so much.

I'll check it out tomorrow and will give you feedback.

Re: possible to add proper spotlight support to this shader? [Re: pegamode] #402684
06/09/12 06:24
06/09/12 06:24
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hey Kartoffel,

looks great so far.

But there's one strange thing. I wrote a little test program with just a spotlight that rotates 360 degrees, a model and a cam. Once I rotate my model (pan) the lightning gets strange. It depends on what side of the model is currently facing to the cam. One side is lighted double as bright as the other side while the character models back is almost not lighted at all.

Regards,
Pegamode.

Page 1 of 3 1 2 3

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