Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Lightmapping/Shadows (https://forums.graalonline.com/forums/showthread.php?t=134257859)

12171217 02-03-2010 06:57 AM

Lightmapping/Shadows
 
My experiments with lightmapping that will hopefully be finished soon.

Right now the editor supports RGBA values for each light and a falloff value. I want to add support for multiple equations for falloff, such as inverse square, etc. There's more to be added later, such as proper anti-aliasing, support for custom resolution lightmaps (Right now it's half resolution of a Graal level, which is 512x512), but whatever!

Here's a video showing the editor and lightmap compiling.



Note: I clipped the compiling time. It took 19 seconds in that instance (The compiler's not optimized at all at the moment.) and the editing time was sped up by a factor of two. Also, the software I was using to record raped my video. It's 8-bit =(

When you click render, it does the proper calculations and bakes the lights into two PNG files; a colored light map, and a shadowmap, saved as levelName_lightmap.png and levelName_shadowmap.png. Lights blend correctly with one another as well.

Also, I can't release this until V6 is released, as I need to use the requesturlfromgamefile function for this to work 100% properly. That function isn't available in the V5 client.

umm to-do list:

1) More falloff equations.
2) Spotlights.
3) Custom resolution lightmaps.
4) Fake walls in the editor, and likewise ignoring walls.

Oh, if anyone wants this, PM me, I guess.

cbk1994 02-03-2010 07:00 AM

That's really, really cool. Excellent work.

12171217 02-03-2010 07:05 AM

Quote:

Originally Posted by cbk1994 (Post 1553910)
That's really, really cool. Excellent work.

Thanks!

maximus_asinus 02-03-2010 07:10 AM

That is awesome, pure awesome. Would rep you if I could.

12171217 02-03-2010 07:27 AM

Thanks max :)

I'd like to see some servers start using solutions like this for indoor levels..

Clockwork 02-03-2010 09:10 AM

Very nice :D!

coreys 02-03-2010 09:18 AM

Perhaps you should add in your light-map editor the ability to select tiles and declare them as walls and use that in your lighting algorithm to add some more realism? Only walls facing down, of course, since those are the ones you can see...

12171217 02-03-2010 01:04 PM

Quote:

Originally Posted by coreys (Post 1553919)
Perhaps you should add in your light-map editor the ability to select tiles and declare them as walls and use that in your lighting algorithm to add some more realism? Only walls facing down, of course, since those are the ones you can see...

What's extremely annoying is that you never seem to read my posts..

Admins 02-03-2010 03:42 PM

Looks pretty impressive :)
Wondering for what you need requesturlfromgamefile(), is the lightmap generator running on a webserver?

Immolate 02-03-2010 06:42 PM

Interesting. Really interesting.

Crow 02-03-2010 08:27 PM

Quote:

Originally Posted by Stefan (Post 1553940)
Looks pretty impressive :)
Wondering for what you need requesturlfromgamefile(), is the lightmap generator running on a webserver?

I suppose it is. I, personally, wouldn't want to code something that converts raw image data to PNG in GS2.

Tigairius 02-03-2010 09:02 PM

Nice stuff :) Would like to see the code for this.

Immolate 02-03-2010 09:28 PM

Quote:

Originally Posted by Tigairius (Post 1553980)
Nice stuff :) Would like to see the code for this.

I asked too but I realised it said PM him for it. It would be nice if there was a public release in the Code Gallery though.

cbk1994 02-03-2010 10:03 PM

Quote:

Originally Posted by Stefan (Post 1553940)
Looks pretty impressive :)
Wondering for what you need requesturlfromgamefile(), is the lightmap generator running on a webserver?

He said last night he's using PHP and GD to generate the image.

coreys 02-03-2010 11:10 PM

Quote:

Originally Posted by 12171217 (Post 1553928)
What's extremely annoying is that you never seem to read my posts..

Sorry, missed that.

Quote:

Originally Posted by cbk1994 (Post 1553990)
He said last night he's using PHP and GD to generate the image.

I'm considering using some Python code on a webserver to do image generation remotely.

12171217 02-04-2010 05:13 AM

Quote:

Originally Posted by Stefan (Post 1553940)
Looks pretty impressive :)
Wondering for what you need requesturlfromgamefile(), is the lightmap generator running on a webserver?

Yeah. The original implementation used pure GS2, but I wasn't happy with performance and didn't want the NPCServer to suffer.

Unfortunately, the light only collides with tiles because of this; I couldn't trust appending 512x512 bytes of GET data to get a half-res collision map, so I simply did 4096 bytes; the tile map. If you could enable POST on Testbed, though, instantly solved!

With a release, I'd like to host a central, PHP-powered hub for lightmap generation. Might as well go the extra mile; V6 isn't seeing a release soon and I need the requestfilefromblahblahblah function before release..

Also, is there a way to add more GUIControl elements to the scripted RC? Having access to this simply by opening scripted RC and having a simple weapon script that a server manager could install as a sort of "plugin" would be awesome.

coreys 02-04-2010 05:59 AM

Actually a really good idea to use a webserver to generate things like this. You should also release the PHP code so people can put it on their own webserver so you don't have all that stress on whatever server you're using.

12171217 02-04-2010 06:03 AM

Quote:

Originally Posted by coreys (Post 1554090)
Actually a really good idea to use a webserver to generate things like this. You should also release the PHP code so people can put it on their own webserver so you don't have all that stress on whatever server you're using.

Of course. I'm pro-open source; for the most part.

fowlplay4 02-04-2010 06:14 AM

Quote:

Originally Posted by 12171217 (Post 1554085)
Yeah. The original implementation used pure GS2, but I wasn't happy with performance and didn't want the NPCServer to suffer.

Did it work client-side?

Also the plugin thing: http://forums.graalonline.com/forums...ad.php?t=87384

12171217 02-04-2010 06:19 AM

Quote:

Originally Posted by fowlplay4 (Post 1554095)
Did it work client-side?

Of course, but the speed wasn't even comprable to what I ended up doing with the PHP server, and the client would be essentially immobilized until the rendering was done.

Might've been because I was using those panel display things; I could always try just writing the PNG information directly from an array, but then the max loop limit still comes into play, and I feel the PHP server is the most elegant solution.

coreys 02-04-2010 08:58 AM

Quote:

Originally Posted by 12171217 (Post 1554091)
Of course. I'm pro-open source; for the most part.

Good man ;)
If you're still looking for some performance improvements, and you're familiar with Python, the Python Imaging Library should be much faster than GD (PIL is written in C). If not, I hear imagemagick is faster than GD.

12171217 02-06-2010 05:51 PM

Quote:

Originally Posted by coreys (Post 1554108)
Good man ;)
If you're still looking for some performance improvements, and you're familiar with Python, the Python Imaging Library should be much faster than GD (PIL is written in C). If not, I hear imagemagick is faster than GD.

I'll port it to Python when I get ungrounded :< I'm on my phone.

Admins 02-07-2010 04:07 PM

For increasing the loop limit there is obj.maxlooplimit, for using TSockets you need to contact me for enabling them on your server (need the host/ip and port range).

Crow 02-07-2010 04:09 PM

Quote:

Originally Posted by Stefan (Post 1554760)
For increasing the loop limit there is obj.maxlooplimit, for using TSockets you need to contact me for enabling them on your server (need the host/ip and port range).

I never understood how to change the loop limit, never worked for me. Post an example, maybe?

Admins 02-07-2010 04:20 PM

Just set the variable in onCreated? this.maxlooplimit = 100000; or so, default is 10000

xXziroXx 02-07-2010 04:40 PM

Makes me think of this:


Crow 02-07-2010 04:56 PM

Quote:

Originally Posted by Stefan (Post 1554762)
Just set the variable in onCreated? this.maxlooplimit = 100000; or so, default is 10000

Yea, I tried that before. That didn't seem to work, still got the error.

calani 02-14-2010 10:47 AM

Incredible. Props!

cbk1994 02-14-2010 11:06 AM

Quote:

Originally Posted by Crow (Post 1554765)
Yea, I tried that before. That didn't seem to work, still got the error.

It works for me, but sometimes you have to let it "update". If you set it, then run the script again (or add a sleep after setting it) it tends to work.

Crow 02-14-2010 11:30 AM

Quote:

Originally Posted by cbk1994 (Post 1556101)
It works for me, but sometimes you have to let it "update". If you set it, then run the script again (or add a sleep after setting it) it tends to work.

Thanks for that hint, I'll give it a try later.

adam 02-20-2010 02:53 AM

Nice work

12171217 01-09-2011 01:41 AM

I was thinking about rewriting this for Google's AppEngine in Python, but I'll definitely need socket support this time around. How do you go about enabling that on your own server? Or on Testbed? Can the server owner do it?

fowlplay4 01-09-2011 01:43 AM

Quote:

Originally Posted by 12171217 (Post 1621449)
I was thinking about rewriting this for Google's AppEngine in Python, but I'll definitely need socket support this time around. How do you go about enabling that on your own server? Or on Testbed? Can the server owner do it?

You have to PM Stefan, with the what and why.

cbk1994 01-09-2011 01:53 AM

Quote:

Originally Posted by 12171217 (Post 1621449)
I was thinking about rewriting this for Google's AppEngine in Python, but I'll definitely need socket support this time around. How do you go about enabling that on your own server? Or on Testbed? Can the server owner do it?

PM Stefan or send him an email ([email protected]) and tell him the server and the host and port you need enabled.


All times are GMT +2. The time now is 03:08 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.