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 / trying to do lights in agk 2

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 8th Dec 2014 16:47
I am working on some 3d editor and wanted to place a light whenever the user places a object type of light inside it, i modelled a light model in blender for the job! but it seems to only create one point light and no more!



Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Dec 2014 16:53
I think that it might be the shader setup - it probably assumes that your only using a directional and single point light.

Personally, I'd just make a shader to suit however many lights I want - say 8, as it needs to be an amount that you can't exceed. Then, you'd do everything by hand - pass each lights position, range, colour to the shader, and apply the shader to your objects. This would also allow quite fine control over the rendering of your objects, maybe you'll need normal mapping, or lightmap textures, or specular.

I think that with AppGameKit, you really have to make your own shaders - and it's not too difficult with light sources etc, hopefully not as difficult as you imagine (assuming you haven't messed with shaders yet). I think that shader knowledge is a necessary evil when developing a 3D game with AppGameKit, and the minute that you get shader #1 working how you want, well you'll wonder why you dragged your heels.

I am the one who knocks...
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 8th Dec 2014 17:26
hah! yeh I thought it might be shaders, and the limit of lights is 8 right?

Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Dec 2014 18:29
I think the limit is upto you when you use shaders - as each light has to be calculated separately anyway, you could have 20 lights... but the number of lights will affect performance.

I am the one who knocks...
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 9th Dec 2014 01:57 Edited at: 9th Dec 2014 02:15
hmm,after testing one light it drops 10 frames on a test run, but still runs at 50fps capped at 60, so I imagine more lights will mean more fps drops! I do have a point light following the ball, as can be seen here:

https://www.youtube.com/watch?v=vodj9Ax6ADc&list=UUzQyPGQQRTfDIechirk66PA&index=1

And this without the point light:

https://www.youtube.com/watch?v=LsID5FYxD9A&index=4&list=UUzQyPGQQRTfDIechirk66PA

the low fps in the video though is because of the screen recording app running/recording in the background on the not so great hp touchpad. but runs at a smooth looking 50fps without recording. Doubt I will bother with more shaders because I still have a few loops to put in for animation eventually.

Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 9th Dec 2014 03:58
if you want.....you could simulate a light with code.

you can change the color value of an object even if it has a texture

the brighter you want it...set the colors to 255,255,255
the darker you want it....set the colors to near black 0,0,0

can even make the object alternate colors if you wish since its just an editor your making and want it to be noticed

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 9th Dec 2014 10:38
You can also use virtual lights. You may have 100 lights in your scene but only actively use a max of 3 at any one time, the ones nearest to the camera at any given time.

shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 9th Dec 2014 10:52
how do you make virtual lights,i saw this in darkbasic but only with the 'extends' thing I additionally bought!

Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 9th Dec 2014 10:57
Well a light is just a structure which holds data like position, rotation, colour, intensity etc

So create your own structure and then create 100 of these 'virtual' lights. Then at any given time, find the three closest lights and then set your three real lights to these positions, colours etc

I've never done it but I think this is how it works, the hard part is then placing your lights in the scene in a way that the player will not notice too much.

shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 9th Dec 2014 11:01
but 3 lights is also an fps drop probably! I can imagine even worse outcomes on real low-end mobile devices, my hp touchpad aint brilliant... but not that bad! that I test my projects on.

Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 9th Dec 2014 11:43
You would have a variable in your lighting system, 'max_real_lights'. Make this 1 if needed, you can still have 100 virtual lights

For windows/mac you may set this to 8 while for mobile it may be 1 or 2?

Login to post a reply

Server time is: 2024-11-25 13:32:46
Your offset time is: 2024-11-25 13:32:46