Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
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
1 registered members (degenerate_762), 683 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
lorikob361, LucasJoshua, Baklazhan, Hanky27, firatv
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Questions about lights in shaders #286694
08/26/09 15:44
08/26/09 15:44
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
hello conitec,

currently I have some problems with getting different types of lights work properly in my shader and hope you have some answers to it.

The first problem is, that I can't separate between the different kinds of lights, so I have no Idea how to execute different code for directional, point- and spotlights. Currently I just treat everything as a pointlight.

The second thing is about the sun in combination with pointlights. If I treat the sun as a biiig pointlight (which is the default, because it's in the vecLightPos array) it's deactivated when the model is in the range of too many other lights, because it has the biggest distance. It looks really strange if the sunlight suddenly disappears. Maybe that could be fixed by making the sun the first light in the list.

I thought also about using vecSunDir and calculate it as a real directional light, but then you calculate the sunlight twice, because the sun position is still in the list of lights, which is of course not acceptable.

So, till now I didn't found a satisfying solution to this problem and hope, you can clear things up a little
Scorpion

Re: Questions about lights in shaders [Re: Scorpion] #286699
08/26/09 16:13
08/26/09 16:13
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Im still new at shaders, but as for using VecSunDir, I think it may be possible.

I dont know about the programming side of it, but from a concept point of view,
couldnt you process VecSunDir first, and then process all the VecLight's next.
But only process the VecLight if(VecLightPos[x]!=VecSunPos).
That way the sun will only be processed once, whether it is in the VecLight list or not.
I have no idea on the efficiency of this concept though.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Questions about lights in shaders [Re: EvilSOB] #286721
08/26/09 18:50
08/26/09 18:50
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
What you need for spotlights is vecLightDir, its non zero when you have a spotlight. All 3 sorts of lights are in the light array.

Re: Questions about lights in shaders [Re: Spirit] #286739
08/26/09 20:32
08/26/09 20:32
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
The problem is, that I don't know the index number of the sun in the array (or some kind of flag, etc.).
If I evaluate vecLightDir, the sun would be treated as a spotlight (because it has a direction, too), which is even worse...

So all in all I am looking for a correct way of identifying the different light types and a way of avoiding the sudden forfeiture of the sun.

Re: Questions about lights in shaders [Re: Scorpion] #286766
08/27/09 07:03
08/27/09 07:03
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
The sun is the last light in the array. Here's the info to identify the lights:

vecLightPos.w > 10000 -> sun
vecLightDir.w > 0 -> spotlight
Otherwise -> pointlight


Re: Questions about lights in shaders [Re: jcl] #286859
08/27/09 20:45
08/27/09 20:45
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
Wow, love your easy and simple answers to my so puzzling problems^^

Thanks!


Moderated by  old_bill, Tobias 

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