Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Box2dLights - dynamic 2d lights out of the box.  (Read 9184 times)
0 Members and 1 Guest are viewing this topic.
Online pitbuller
« Posted 2012-01-06 13:39:19 »

Source:
http://code.google.com/p/box2dlights/
Applet:
http://dl.dropbox.com/u/10960490/Uusi%20kansio/index.html


I writed library for dynamic 2d soft lighting. Its use box2d geometry and raycasting and create light meshes from collision data.
Library work with gles 1.1 or gles 2.0 automatically depending on context.

Rendering flow go something like this.

1  
2  
3  
4  
5  
6  
normal rendering/spriteBatch etc

rayHandler.setCombinedMatrix(camera.combined);
rayHandler.updateAndRender()

ui stuff

Nothing special is needed it just works.

When creating a Rayhandler user just need to give box2d World
1  
rayHandler = new RayHandler(world);

Lights can be created easily like this:
1  
new PointLight(rayHandler, RAYS_NUM, new Color(1,1,1,1), lightDistance, x, y);


After light is created rayHandler manage, update and render it so nothing special is needed from user.

Source is licensed with apache 2.0 so its compatible with libgdx.


Public method are all java docced and at google code wiki there are more information.

Quote
FEATURES:

    Gaussian blurred light maps
    Point light
    Cone Light
    Directional Light
    Shadows
    Dynamic/static/xray light
    Culling
    Handler class to do all the work.

On android 8 dynamic lights and two gaussian blur pass and shadows take about 5ms total.

I have used my library for Boxtrix, Lonely miner and one yet not published project with success and there are several developers currently using library for their games. Intergration for any box2d based game should take about 5minutes at most.

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-01-06 14:17:56 »

Wow that demo looks amazing! It is a bit too bright so I can't see where some of the beads are but beautiful nonetheless. Smiley

Online pitbuller
« Reply #2 - Posted 2012-01-06 21:32:17 »

Wow that demo looks amazing! It is a bit too bright so I can't see where some of the beads are but beautiful nonetheless. Smiley

Almoust everything is adjustable. Demo is bit over to top but just for underlining the idea.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #3 - Posted 2012-01-06 22:42:54 »

Hmm Gaussian blurred light maps, Cone light and PointLight can be very useful for me. This will great after I learn a bit of libgdx basic.

Offline ReBirth
« Reply #4 - Posted 2012-01-17 04:55:30 »

Hi can you post a full working HelloWorld project? I can't set any up Sad

Online pitbuller
« Reply #5 - Posted 2012-01-17 10:29:23 »

Hi can you post a full working HelloWorld project? I can't set any up Sad
Will do.
Online pitbuller
« Reply #6 - Posted 2012-01-17 11:03:30 »

There you go. Standalone test project.
http://code.google.com/p/box2dlights/downloads/list
Read wiki entries too.
Offline ReBirth
« Reply #7 - Posted 2012-01-17 23:38:17 »

There you go. Standalone test project.
http://code.google.com/p/box2dlights/downloads/list
Read wiki entries too.
Woohoo thanks! Smiley

Offline 65K
« Reply #8 - Posted 2012-04-10 20:56:33 »

Congrats to your lighting stuff !

In the last view days I started to add a second renderer module besides Java2D to my game, and with very little knowledge of LibGdx and OpenGL I got it basically working and the lighting is quite impressive and easy to set up.

Now I wonder about the following:
I have a top-down tile based game and want to show the current field-of-view of the player's sprite (with Java2D I only darken whole tiles which are out of sight).
That works with a dynamic point light. Now, when I render the light after the sprite, the sprite gets too bright, so I do it vice versa. That's ok.
But now the enemy sprites are naturally effected by lighting and thus the optical impression is quite different compared to the player's sprite.

As I know too little about OpenGL, my question is: is there any way imaginable to adjust the appearance ?
Maybe only rendering the box shadows but not lighten the rest ? Or modify the light fall off, so it starts darker but keeps it brightness longer ?

Online pitbuller
« Reply #9 - Posted 2012-04-10 22:19:57 »

You can modify light color and range. Try usin colo like r =0.4, g =0.4, b =0.4 That make the visual not so bright but you keep the darkening. Darkness value can be changed with ambientLight value.


If you are using gl es2.0 then you can set Gamma correction and also test with diffuse lighting.



For softening lights a bit you might want to add small and not so bright x-ray point light top of character.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 65K
« Reply #10 - Posted 2012-04-11 07:50:22 »

Thanks, I didn't see the diffuse switch - that did the trick. Smiley

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (23 views)
2014-09-12 09:08:26

Norakomi (56 views)
2014-09-10 13:57:51

TehJavaDev (69 views)
2014-09-10 06:39:09

Tekkerue (34 views)
2014-09-09 02:24:56

mitcheeb (56 views)
2014-09-08 06:06:29

BurntPizza (40 views)
2014-09-07 01:13:42

Longarmx (25 views)
2014-09-07 01:12:14

Longarmx (32 views)
2014-09-07 01:11:22

Longarmx (31 views)
2014-09-07 01:10:19

mitcheeb (39 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!