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?
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.
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.
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?
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.
Ah yes, that’s what I was referring to. Forgot what it was called though.
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.