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 / [SOLVED] Request for help / code (spotlight shader)

Author
Message
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 29th Nov 2023 15:16
Hi,

Has anybody got some example code and shaders for doing spotlights in AppGameKit Tier 1? I need to be able to create up to 4 spotlights as well as the usual built-in pixel-shaded point lights and ambient lighting.

Many Thanks,
John

The author of this post has marked a post as an answer.

Go to answer

JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 1st Dec 2023 13:48 Edited at: 1st Dec 2023 13:52
This post has been marked by the post author as the answer.
After much head / wall bashing I managed to put something together myself. All done in the fragment shader by setting some shader array and constant values. I'm sure there are better and more realistic implementations but this is a good starting point for me.

The SpotCutoff[] array contains the spotlight angles. You must populate it with Sin(lightAngle). SpotDirection is a normal and SpotPosition is the world position of the light. Don't forget to pass the number of spotlights in gNumSpotLights.

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 2nd Dec 2023 00:05
Nice. Well done
jd_zoo
6
Years of Service
User Offline
Joined: 12th May 2018
Location: Nova Scotia
Posted: 5th Dec 2023 23:04
Curious as I don't know shaders, but is this for 3D and will it produce shadows from the spotlights? That would be huge, the sun being the only shadow producer is limiting.
Automation on Steam now!
Score Table Jr. on Google Play!
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 8th Dec 2023 12:20
Yes, this is for 3D but it won't produce shadows. It still uses AGK's in-built lighting methods.

If someone comes up with a shadow mapping shader that also uses point lights and spot lights I will be very impressed!
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 9th Dec 2023 00:30 Edited at: 9th Dec 2023 00:31

Login to post a reply

Server time is: 2024-11-21 11:47:01
Your offset time is: 2024-11-21 11:47:01