Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
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] Shadows.  (Read 516 times)
0 Members and 1 Guest are viewing this topic.
Offline DrewLols

Senior Member


Medals: 2
Projects: 1


Noob going through metamorphosis...


« Posted 2014-05-03 20:50:13 »

So, I finally figured out how to export 3D models from Blender, and successfully load them into LibGDX.  My question is, is it possible to cast shadows with LibGDX that doesn't require me understand OpenGL extensively?  I don't want to have to use many classes outside of Environment, ModelBatch, etc for this.  Also, if this is possible, I'd like to selectively cast a shadow on certain surfaces.  Is there a painless way to do this in LibGDX?

Did you know that 90% of statistics are wrong?
Online Drenius
« Reply #1 - Posted 2014-05-03 20:53:03 »

Shadows on the model or shadows in the whole scene?
Offline DrewLols

Senior Member


Medals: 2
Projects: 1


Noob going through metamorphosis...


« Reply #2 - Posted 2014-05-03 21:03:15 »

Shadows on the model or shadows in the whole scene?

I suppose shadows on a particular model.  I would like entities to cast shadows on an environment model, but not on themselves or other entities to keep the performance up.

Did you know that 90% of statistics are wrong?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DrewLols

Senior Member


Medals: 2
Projects: 1


Noob going through metamorphosis...


« Reply #3 - Posted 2014-05-04 19:51:11 »

I'm hoping for something like this:




The shadow on the pokemon is casted on the ground, and not itself.  I'm assuming this is to increase performance, which is what I'm looking for.  I don't need anything fancy.  Just some basic shadows so the player knows when the character is rooted to the ground.  I know that Jmonkeyengine has something like this, but alas, I decided to work with LibGDX for its portability.

Did you know that 90% of statistics are wrong?
Online Drenius
« Reply #4 - Posted 2014-05-04 20:02:29 »

My question was more whether you want to give the models shadows based on light direction (which is pretty easy) or want them to cause shadows casted to something else, which is what you mean.
This is a little bit more complicated. Did you look into FBOs?
Offline DrewLols

Senior Member


Medals: 2
Projects: 1


Noob going through metamorphosis...


« Reply #5 - Posted 2014-05-04 21:56:20 »

My question was more whether you want to give the models shadows based on light direction (which is pretty easy) or want them to cause shadows casted to something else, which is what you mean.
This is a little bit more complicated. Did you look into FBOs?

Uh, I don't understand the difference.  xD  I did not look into FBO's. although I've heard of them.  Light based shadow casting sounds fine, though.

Edit: Oh, uh, I think I already basic shading on my models.  Yes, what I want is to cast shadows onto other models in a way that is as painless as possible.  I just looked into FBO's (Frame buffer objects, correct?), and from what I can see, it is an object that renders offscreen before being rendered on screen.  How does this apply to shadows?

Did you know that 90% of statistics are wrong?
Online Longarmx
« Reply #6 - Posted 2014-05-05 00:08:09 »

What you may want to look into is ray-casting. What you do is you send out a bunch of rays from the light source. If they get to the ground, then they make that part of the ground lighter. Hence, if they get blocked by a player or something then that part of the ground will still be dark. I'm sure somebody else here can give you a better explanation if you want it.

Offline BurntPizza
« Reply #7 - Posted 2014-05-05 00:19:56 »

What you may want to look into is ray-casting. What you do is you send out a bunch of rays from the light source. If they get to the ground, then they make that part of the ground lighter. Hence, if they get blocked by a player or something then that part of the ground will still be dark. I'm sure somebody else here can give you a better explanation if you want it.

Full-blown raytracing or raycasting is most likely overkill, depending on what exactly you mean by it and how exact you want to be. Shadow mapping or the more-involved shadow volumes technique are probably what you want.
Sorry OP, I don't think there is an easy(er) way out of it.
Online Longarmx
« Reply #8 - Posted 2014-05-05 00:22:25 »

Ah yes, that's what I was referring to. Forgot what it was called though.

Offline Cero
« Reply #9 - Posted 2014-05-05 01:35:47 »

https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/ShadowMappingTest.java

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cero
« Reply #10 - Posted 2014-05-05 02:01:44 »

I changed the code a little bit so that you can move the sphere with the arrow keys and page_up/down for up and down

http://www.java-gaming.org/?action=pastebin&id=918

Appearently "DirectionalShadowLight" is something Xoppa is working on and is purely experimental at the moment. So watch Xoppa's blog and/or copy the source code of the DirectionalShadowLight if you wanna use it.

This is relevant to my interests.

Pages: [1]
  ignore  |  Print  
 
 

 

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

The first screenshot will be displayed as a thumbnail.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (58 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
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!