box2dLights

Present your own projects here, be they WIPs, betas or finished products. Get feedback from others and help each other out with some lovely testing.

Re: box2dLights

Postby pitbuller » Mon Dec 26, 2011 8:01 pm

I also added bodyOffSetX and Y.
pitbuller
 
Posts: 134
Joined: Mon Jul 25, 2011 9:07 am

Re: box2dLights

Postby mzechner » Tue Dec 27, 2011 1:19 pm

This is incredibly cool! Will report how it performs on my Galaxy Nexus eventually :)
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: box2dLights

Postby pitbuller » Tue Dec 27, 2011 10:44 pm

Just javadocced and cleaned everything.
Everything should have now proper setters. All the functionality that are there are ready to use.

Profiled some bottle necks and made some micro optimizations where needed.
Performance is really great. With default settings, shadows, 1 blur pass, 200x120 FBO I
I can draw 50 dynamic point lights with 32 rays each before fps start drops from max.

Minimal test case:
Code: Select all
public class SimpleTest extends ApplicationAdapter {
   /** the camera **/
   private OrthographicCamera camera;
   RayHandler rayHandler;

   @Override
   public void create() {
      camera = new OrthographicCamera(48, 32);
      camera.update();
      rayHandler = new RayHandler(new World(new Vector2(0, -10), true),
            camera);
      new PointLight(rayHandler, 32, Color.RED, 20, 0, 0);
   }

   @Override
   public void render() {
      Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);
      rayHandler.updateAndRender();
   }
}
pitbuller
 
Posts: 134
Joined: Mon Jul 25, 2011 9:07 am

Re: box2dLights

Postby pitbuller » Wed Dec 28, 2011 12:44 am

http://www.youtube.com/watch?v=lfT8ajGbzk0
Added video from basic test case.

Code for that is basically here:
Code: Select all
      rayHandler = new RayHandler(world, camera);

      for (int i = 0; i < BALLSNUM; i++) {
         final Color c = new Color(MathUtils.random(), MathUtils.random(),
               MathUtils.random(), 1f);
         PointLight light = new PointLight(rayHandler, RAYS_PER_BALL,
               c, LIGHT_DISTANCE, 0, 0);
         light.attachToBody(balls.get(i), 0, 0);
      }

pitbuller
 
Posts: 134
Joined: Mon Jul 25, 2011 9:07 am

Re: box2dLights

Postby pitbuller » Wed Dec 28, 2011 9:23 am

pitbuller
 
Posts: 134
Joined: Mon Jul 25, 2011 9:07 am

Re: box2dLights

Postby Asmodiel » Thu Jan 12, 2012 8:40 am

Hi pitbuller,

Thank you for this amazing work! It really looks great. I tested it on android with GL es1.1, but it seems there's no shadow support. Is it only supported on GL es2.0?
Asmodiel
 
Posts: 8
Joined: Thu Sep 29, 2011 3:28 pm

Re: box2dLights

Postby kalle_h » Thu Jan 12, 2012 9:25 am

Asmodiel wrote:Hi pitbuller,

Thank you for this amazing work! It really looks great. I tested it on android with GL es1.1, but it seems there's no shadow support. Is it only supported on GL es2.0?


Shadows work with GL es1.0 but need alpha channel. Basically on fixed pipeline combined light intesity is accumulated to alpha channerl and shadows are rendered as black quad over the scene using destination alpha blend mode. This work basically well but is bit slow and need alpha channel for render target.

On GL es2.0 frame buffer is used for shadowing. There alpha channel is guaranteed and shadows are done when light map is rendered over the scene. You should try GL es2.0.
kalle_h
 
Posts: 666
Joined: Thu Dec 29, 2011 9:50 pm

Re: box2dLights

Postby mzechner » Tue Jan 17, 2012 2:00 am

I'm so gonna use this in a game. Gotta figure out how to get the shadow mesh out of there. Thief 2D here i come!
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: box2dLights

Postby kalle_h » Tue Jan 17, 2012 9:15 am

mzechner wrote:I'm so gonna use this in a game. Gotta figure out how to get the shadow mesh out of there. Thief 2D here i come!


Shadow mesh would be screen mesh - light mesh. How to deal when different lights shadow mesh vs light mesh intersect? Is that still shadow or only half shadow?

Maybe querrying data from small lightmap texture. I think this would be doable.
kalle_h
 
Posts: 666
Joined: Thu Dec 29, 2011 9:50 pm

Re: box2dLights

Postby pasman » Tue Jan 17, 2012 9:17 pm

Awesome work, just one question, I'm building my game using just SpriteBatch and Sprites, no camera (except for the ortho setup in spritebatch), no box2d but I would really love to use it for some kind of dynamic influence map (I presume that PointLight would do the trick).

Is this possible using your library right now, or would it be overhead?

Thanks
pasman
 
Posts: 10
Joined: Wed Dec 15, 2010 2:11 pm
Location: Cluj-Napoca, Romania

PreviousNext

Return to Showcase

Who is online

Users browsing this forum: No registered users and 1 guest

cron