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.

AppGameKit Classic Chat / [free code & shader] L2D - Simple(ish) 2D lighting system [Tier 1 V2]

Author
Message
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jan 2015 10:52 Edited at: 29th Jan 2015 10:54
Example attached:


This is a simple adaptation of the shader and code I'm using in "Escape the undead". I tried to make it basic.

Let me know if you have any questions... and if you find it useful you're welcome

Don't use any of the images other than the "light_basic.png" as they are for demo purposes ONLY.


Using AppGameKit V2 Tier 1

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jan 2015 10:52 Edited at: 29th Jan 2015 11:03
You can set the ambient light level using:


There are also a few other functions such as SetLightPosition to manually move/position a light.


Using AppGameKit V2 Tier 1

Attachments

Login to view attachments
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 29th Jan 2015 16:00 Edited at: 29th Jan 2015 19:07
Awesome! Now my AppGameKit games are really going to shine!
I just took a peek at the zip, and I can't wait to try this out.
This is very generous of you, and I hope everyone takes advantage of this, because this is very popular right now for 2d games.

THANKS FOR SHARING !!!

...


Coding things my way since 1981 -- Currently using AppGameKit V1 Tier 1
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Jan 2015 16:21
Haven't looked at the code yet, but ran the demo.

I checked the definition of Awesome in the dictionary and it said: See baxslash' lighting demo

Quidquid latine dictum sit, altum sonatur
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jan 2015 16:36
If you start messing with the view zoom you'll realise it needs a little more work but I will make any changes requested and update the first post as I get time.


Using AppGameKit V2 Tier 1
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 29th Jan 2015 17:53
Thanks baxslash
Alien Menace
AGK Developer
19
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Earth (just visiting)
Posted: 29th Jan 2015 18:29
Baxslash, you are a pretty awesome fellow.

Thanks

Apps published: 4
Ched80
13
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 29th Jan 2015 19:39
Cheers Bax! we can never have enough shader examples

lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 29th Jan 2015 20:22 Edited at: 29th Jan 2015 20:23
Nice going Bax.


If anyone cares mine are still available in a thread from oh, last summer I guess, also contains a spotlight (8 pointlights and 2 spotlights, + ambient)





If anyone wants to turn the demo from the video into a top-down horror shmup they're welcome

My hovercraft is full of eels
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 1st Feb 2015 14:33 Edited at: 1st Feb 2015 14:34
@baxslash:
I took a look to your code and I have a question:
Are neccessary the following lines of your code:

Quote: "
SetObjectImage(quad, renderImage, 0)
SetObjectImage(quad, shaderImage, 1)
"


inside the "SyncLitScene()" function?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Feb 2015 15:54
Probably not once the image has already been set. I'm pretty sure they can be extracted to the initialisation code.


Using AppGameKit V2 Tier 1
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 2nd Feb 2015 13:03
Looks awesome. Great work, mate. thanks!

Regards Sph!nx
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 2nd Feb 2015 23:48
Really awesome!

A question:
Is it possible to exclude a certain text object/sprite from the rendering? I don't have a lot of (any) prior shader knowledge - and haven't been able to work it out. It would make sense for something like this to work by showing the object just after the final image has been produced with the shader, therefore being placed "ontop" of the rendered shader image. Any thoughts?

Thanks!

cheers
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Feb 2015 08:59
Paronamixxe, I'm doing that exact thing with my HUD. If you go into the "SyncLitScene()" function at the end of the include file you can change it as follows. All I'm doing is offsetting the view to a point where there are no world objects visible and then rendering the HUD objects which are fixed to the screen:



Using AppGameKit V2 Tier 1
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 3rd Feb 2015 16:22
Great! Thanks a lot!

I wasn't far off atleast

cheers
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 4th Feb 2015 08:32
Great example, thank you !

http://www.dracaena-studio.com
basjak
13
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 6th Feb 2015 17:42
thumb up for baxslash

Login to post a reply

Server time is: 2024-03-29 01:15:02
Your offset time is: 2024-03-29 01:15:02