Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
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  
  more than 8 lights in jogl  (Read 5132 times)
0 Members and 1 Guest are viewing this topic.
Offline deepthought
« Posted 2010-08-29 17:44:51 »

How do i do more than 8 lights in jogl? I've heard jogl can only have 8 lights. i've looked around, and it  says that you need some sort of GLSL shader, and that you can't do shadows. is this true? and how do i do shadows?

Thanks in advance!

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline gouessej

« In padded room »



TUER


« Reply #1 - Posted 2010-08-29 18:23:44 »

How do i do more than 8 lights in jogl? I've heard jogl can only have 8 lights. i've looked around, and it  says that you need some sort of GLSL shader, and that you can't do shadows. is this true? and how do i do shadows?

Thanks in advance!
It has nothing to do with JOGL, it is a limitation of OpenGL that you can overcome by the same way. JOGL is only an OpenGL binding. If you want to implement shadows, maybe look at the examples available on the website of JOGL :
http://jogamp.org/

Some engines relying on JOGL might support more than 8 lights, look at how they implement such a feature, for example Ardor3D, JMonkeyEngine, Xith3D, Aviatrix3D, 3DzzD, etc...

Offline deepthought
« Reply #2 - Posted 2010-08-29 21:02:31 »

dynamic lightmapping sounds good. I can figure out how to generate the lightmaps myself, but how do i apply them to the textures?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej

« In padded room »



TUER


« Reply #3 - Posted 2010-08-30 13:06:34 »

dynamic lightmapping sounds good. I can figure out how to generate the lightmaps myself, but how do i apply them to the textures?
I'm not a specialist of lights... You will need this to use your colors or textures as materials if you don't want to define any material separately:
1  
gl.glEnable(GL.GL_COLOR_MATERIAL);


I don't know the details of implementation of the dynamic lightmapping.

Offline lhkbob

JGO Knight


Medals: 32



« Reply #4 - Posted 2010-08-30 17:28:49 »

Lightmapping is just texturing where you fill the texture information with the computed values of your light equations. Most times, lightmapping is used for static light maps because they're quite slow to compute, especially if you take advantage of using much more complicated light equations to get better looking light maps. Dynamic lightmaps are updated more frequently.

8 lights is the required minimum (and often also the max) number of lights available in the fixed function pipeline.  When you use GLSL shaders, you can declare your own variables, so if the hardware is good enough you could have enough variables to store more than 8 lights.

If you really need more than 8 lights, one of the simplest ways to do it is to render the object multiple times, each time with a different set of lights.  The extra renderings have to have additive blending enabled so that the end result appears as though it was lit with all 16 lights, etc.  This works with shaders and with the fixed function pipeline.

Another technique, that I don't recommend you start with, but just so that you know about it is to look into deferred rendering.

As far as I know, shadowing can work with any of these mechanisms because you really only need to have shadows from a couple of lights and shadowing is a per-light operation.

Also, it is rare that a single rendered object will need to be lit by more than 8 lights.  This is a very rare occurrence in the real world and if it does, often lower numbers of lights can get almost the same appearance.  What a lot of engines do is take the 8 most powerful lights in the scene, affecting the current shape to render, render it with those lights and then move to the next object (which has a new set of 8 lights, etc.)

HTH

Offline deepthought
« Reply #5 - Posted 2010-09-04 02:38:33 »

Opengl can't render shadows directly. aparrently there IS a way using the stencil buffer. is this better than lightmapping? if so, how do i do this?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline lhkbob

JGO Knight


Medals: 32



« Reply #6 - Posted 2010-09-04 08:58:23 »

The technique that uses the stencil buffer is called shadow volumes, it was what was used in Doom 3.  Stencil volumes have the advantage that they always have really nice crisp edges and don't suffer from aliasing like shadow maps can (if you've ever looked at the jagged/blocky shadows in a lot of newer games).

However, this comes with a price to pay.  There is a lot of CPU intensive math needed to basically detect the silhouette of the rendered objects from the lights point of view.  Then there is a lot of stencil filling which can be really slow.  It is also very difficult to do soft shadowing.

Given that it is relatively easy to make soft shadows and reduce the aliasing of shadow maps, and shadow maps scale better with scene complexity, I would recommend pursuing shadow mapping.  It seems to be the trend that most game engines are going nowadays, too.

Offline deepthought
« Reply #7 - Posted 2010-09-08 01:23:11 »

i kind of get how shadow mapping works. my only concern is that multiple renderings would slow down the program.  the question is would shadow mapping be simpler than generating lightmaps with java2d, loading them into a texture, then applying it?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline lhkbob

JGO Knight


Medals: 32



« Reply #8 - Posted 2010-09-08 08:19:23 »

Light maps and shadow maps are both used in lighting, but they are really meant for different things. It is certainly possible to store shadow information in your light map, or compute really high quality shadows offline and then map them normally.  Quality light mapping basically requires you to implement a ray tracer that runs offline to generate the light values stored in the texture.

That would certainly be slower than generating shadow maps.  Also, consider that when generating the shadow map, everything you draw only stores depth values. So no lighting, texturing or complex shaders are executed.  Even when using just the fixed pipeline, shadow maps take way less time to render than the colored scene in my experience.  Once you do shader-based lighting, shadow maps are going to be even faster in comparison.

Offline deepthought
« Reply #9 - Posted 2010-09-12 00:57:09 »

know any good sample java tutorials? everything i've found is in c++. i'm no good at porting

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lhkbob

JGO Knight


Medals: 32



« Reply #10 - Posted 2010-09-12 20:03:28 »

For that stuff, no. But a lot of C/C++ ports with OpenGL are pretty straight forward on the opengl side, all the calls are the same once you have a window up.

Offline deepthought
« Reply #11 - Posted 2010-09-22 03:10:24 »

say i use a point light. would i be correct in assuming that to shadowmap a point light i would just map as if it's 6 directional lights pointing outwards?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline lhkbob

JGO Knight


Medals: 32



« Reply #12 - Posted 2010-09-22 06:58:28 »

say i use a point light. would i be correct in assuming that to shadowmap a point light i would just map as if it's 6 directional lights pointing outwards?
Yep, except that it would be 6 spot lights instead of direction lights. Direction light shadow maps usually use an orthogonal projection in the direction of the light.  Spot lights are placed at the light and have a perspective projection in the light's direction with a field of view set for the spread of the light (for 6 spot lights in this situation, I believe it's 90 degrees).

Offline deepthought
« Reply #13 - Posted 2010-09-22 14:09:13 »

\facepalm i meant spot lights.  but thanks for the tip on directional lights.

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline deepthought
« Reply #14 - Posted 2010-09-23 02:06:45 »

do you guys think you could help me figure out how to do shader lighting and shadow maps?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline lhkbob

JGO Knight


Medals: 32



« Reply #15 - Posted 2010-09-24 17:05:55 »

I'd be happy to help with improving things you've put together but it takes a fair amountof work to get the full thing working and I don't have the time that. My recommendation is that you should work first on getting a glsl shaded working that does simple per pixel lighting. Once thats done we can go from there. Alternatively you can go through the code in my signature which can show you the math and workflow to get shadows in the fixed function pipeline.

Offline Momoko_Fan

Junior Member


Medals: 2



« Reply #16 - Posted 2010-09-25 02:59:18 »

Or you can just use a 3D engine and save yourself a lot of time.
jMonkeyEngine 3 has both shader lighting and shadow maps, as well as tons of other features.
Offline lhkbob

JGO Knight


Medals: 32



« Reply #17 - Posted 2010-09-25 08:00:45 »

Engines like that also have mechanisms in place already to handle more than 8 lights.  Looking into an engine's code can be a useful way to learn many things, including the graphics algorithm as well as techniques for code structure, etc.  It depends on what you're looking for: to learn opengl and how 3D really works? or to get a 3D game up and running easily.

Offline gouessej

« In padded room »



TUER


« Reply #18 - Posted 2010-09-25 11:44:01 »

It depends on what you're looking for: to learn opengl and how 3D really works? or to get a 3D game up and running easily.
I agree with you. It is more pedagogical to use plain OpenGL directly but using a 3D engine like JMonkeyEngine 3 is easier to get something up and running. This engine has an excellent support of JOGL, better than what I did in JMonkeyEngine 2 and it has a fully integrated game development environment.

Ardor3D is a good option too. Some people have already worked in a version using JOGL 2 and when it becomes more reliable, we will be ready to switch to it Smiley

Offline deepthought
« Reply #19 - Posted 2010-09-26 21:59:58 »

for now, let's get a shader loaded into JOGL

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline deepthought
« Reply #20 - Posted 2010-09-30 14:20:18 »

did my thread just die?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline lhkbob

JGO Knight


Medals: 32



« Reply #21 - Posted 2010-09-30 15:41:44 »

did my thread just die?
It's probably just time to move to a new one, also I figured you'd take some time to learn about shaders on your own and then ask new questions.

Offline deepthought
« Reply #22 - Posted 2010-09-30 21:36:37 »

I've got shaders from an opengl book. the only problem is getting them into jogl. I understand how, but it's not working. where can i get  some code to load shaders and check for errors?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
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.

xsi3rr4x (48 views)
2014-04-15 18:08:23

BurntPizza (44 views)
2014-04-15 03:46:01

UprightPath (60 views)
2014-04-14 17:39:50

UprightPath (42 views)
2014-04-14 17:35:47

Porlus (58 views)
2014-04-14 15:48:38

tom_mai78101 (82 views)
2014-04-10 04:04:31

BurntPizza (140 views)
2014-04-08 23:06:04

tom_mai78101 (240 views)
2014-04-05 13:34:39

trollwarrior1 (200 views)
2014-04-04 12:06:45

CJLetsGame (207 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!