Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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  
  Libgdx 2D lights  (Read 3497 times)
0 Members and 1 Guest are viewing this topic.
Offline cubemaster21
« Posted 2013-05-14 16:31:37 »

I'm attempting to figure out how I can add lights to my current game, it's top down 2d and there need to be multiple instances of the lights that are moving. I'll focus on making them dynamic at another date. But, I have no idea how i would do this with libgdx. Any further details can be provided at request. Any help or suggestions is greatly appreciated.

Check out my game, Viking Supermarket Smash
http://www.java-gaming.org/topics/iconified/28984/view.html
Offline 65K
« Reply #1 - Posted 2013-05-14 17:27:11 »

Box2dLights, for instance.

Offline pitbuller
« Reply #2 - Posted 2013-05-14 19:12:21 »

Box2dLights, for instance.

Also notice that only need box2d for shadows. So adding light library work fine even without box2d.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cubemaster21
« Reply #3 - Posted 2013-05-14 22:37:25 »

Well, I guess I'm not so much looking for lighting as I am for creating an alpha mask. That seems like a more reasonable approach to what I'm doing.

Check out my game, Viking Supermarket Smash
http://www.java-gaming.org/topics/iconified/28984/view.html
Offline heisenbergman

JGO Coder


Medals: 14


L___ o_ G___ a__ P___


« Reply #4 - Posted 2013-05-15 02:59:23 »

Box2dLights, for instance.

Whoa, this looks awesome, thanks! Grin

Offline 65K
« Reply #5 - Posted 2013-05-15 06:55:48 »

And each flying bullet gets it own moving light as well Smiley
Kudos to Pitbuller for this little library which allows to enlighten your game without having the slightest clue about the low level details inside.

Quote
Well, I guess I'm not so much looking for lighting as I am for creating an alpha mask. That seems like a more reasonable approach to what I'm doing.
I think you need to be more specific about your requirements. You have the alpha channel in color objects for instance.

Offline pitbuller
« Reply #6 - Posted 2013-05-15 10:11:53 »

If you just want black where there are no light and completely white neutral light that does not distort you game colors that library can do that too. But you need be more specific what you want.
Offline heisenbergman

JGO Coder


Medals: 14


L___ o_ G___ a__ P___


« Reply #7 - Posted 2013-05-15 10:26:36 »

Slightly off-topic, but still about lighting and visibility, this is a great read with some nice interactive apps embedded on the page:

2d Visibility from Red Blob Games

Grin

Offline cubemaster21
« Reply #8 - Posted 2013-05-15 21:30:30 »

As I said that I was really only looking for a method to make an alpha mask, I've finally found something suitable. However, it seems as though it is not efficient at all. This is what I've got.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      Pixmap lightMesh = new Pixmap(width, height, Pixmap.Format.RGBA8888);
      Blending blending = Pixmap.getBlending();
      lightMesh.setColor(0f, 0f, 0f, 0f);
      Pixmap.setBlending(Blending.None);

      int newX = Math.round(x);
      int newY = Math.round(y);

      lightMesh.fillCircle(newX, newY, radius);
      Pixmap.setBlending(blending);
      lightMesh.setColor(Color.BLACK);

Check out my game, Viking Supermarket Smash
http://www.java-gaming.org/topics/iconified/28984/view.html
Offline davedes
« Reply #9 - Posted 2013-05-16 03:08:04 »

Pixmaps are performed on CPU. Before rendering something to the screen, you need to upload the Pixmap RGBA data to the GPU onto a Texture. This is explained here:

https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Textures

Maybe you could explain your situation in more detail, with screenshots of what you're trying to do. If you just want masks, see here:
http://stackoverflow.com/a/5098999

If you just want feathered circles for point lights, you could use a simple PNG sprite or shaders:
https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson3

Ultimately box2dlights is really the best choice for 2D lights. It uses a disc geometry to reduce fill rate which means that multiple lights will perform better on Android. And it should be easy to make it dynamic later on in your game, via box2d.

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.

Riven (12 views)
2014-07-29 18:09:19

Riven (8 views)
2014-07-29 18:08:52

Dwinin (9 views)
2014-07-29 10:59:34

E.R. Fleming (25 views)
2014-07-29 03:07:13

E.R. Fleming (10 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (27 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!