Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
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  
  Overhead Maze Lighting / Shadows  (Read 6041 times)
0 Members and 1 Guest are viewing this topic.
Offline renanse

Junior Devvie


Exp: 14 years


Intelligence is light to a dark world.


« Posted 2003-12-24 19:53:11 »

Hello all,

I've been working on a simple overhead maze game in OpenGL using lwjgl and would like some opinions here.  I've got my maze randomly generating...  I've got the thing showing on the screen.  I even have a nice little minimap showing you where you've been, etc.  So, now I'm at the point where I want to add lighting (to simulate a torch being held by the character.)  I've added the light at the position of the character in the maze and adjusted light properties to give off the amount of lighting I'd like...  Then the problem...  The light goes through walls and so forth.   Cry

Reading through the red and blue book and other various sources, I realized that my problem is shadows.  So my question is, what technique would be appropriate to use?  Any suggestions would be appreciated.

Regards,

-- Renanse

Renanse  (ruh-NON-say)
Offline renanse

Junior Devvie


Exp: 14 years


Intelligence is light to a dark world.


« Reply #1 - Posted 2003-12-24 20:03:00 »

Thought a screen shot might be helpful:
http://www.renanse.com/sample_shot_gl.jpg

Renanse  (ruh-NON-say)
Offline renanse

Junior Devvie


Exp: 14 years


Intelligence is light to a dark world.


« Reply #2 - Posted 2003-12-29 14:19:19 »

No answers yet so let me ask in a different way.  Has anyone done stenciled volumetric shadowing in lwjgl and has some sample code they'd like to share?  I just can't seem to get it.   Embarrassed

A little coaching would be awesome.  Thanks!

Renanse  (ruh-NON-say)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tom
« Reply #3 - Posted 2003-12-29 16:09:11 »

There is the nehe shadow tutorial:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=27

Don't know of a lwjgl port, but ther is a jogl one. A link can be found here:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jogl;action=display;num=1064699713
Look for lesson 27.

Offline renanse

Junior Devvie


Exp: 14 years


Intelligence is light to a dark world.


« Reply #4 - Posted 2003-12-29 22:00:24 »

Thanks Tom.

I have read the Nehe tutorial 27 and I've tried porting the jogl demo to lwjgl.  I've got the basic scene there (sans the spheres since we don't have those glu methods available) with all the keyboard commands working etc.

For some reason though, the thing is dog slow and does not cast shadows.  I can fix the slow part by playing with the far and near clipping depth values or eliminating the stencil test, but I can't seem to figure out how to get shadows running.

I've posted my code, as well as a binary and enough stuff to run it in win32 here:

http://www.renanse.com/lwjgl_nehe_27.zip

(sorry, it's a bit rough but I was originally only porting for intent of learning how it worked...)

I think it would be a great tutorial for the lwjgl community to have access to.  Anybody care to help troubleshoot?

Renanse  (ruh-NON-say)
Offline renanse

Junior Devvie


Exp: 14 years


Intelligence is light to a dark world.


« Reply #5 - Posted 2003-12-29 22:15:46 »

Ugh an update:  A friend of mine tried out the example I put together on his machine and it seems to work fine.  Has shadows, good speed and all.

His machine:
1.2 GHz AMD Athlon.. 512 MB Ram.. 64 MB ATI Radeon 7200

My machine:  
2.0GHz Intel P4.. 512MB Ram.. 128MB GeForce4 ti4600

Very frustrating!  Any ideas?

Renanse  (ruh-NON-say)
Offline renanse

Junior Devvie


Exp: 14 years


Intelligence is light to a dark world.


« Reply #6 - Posted 2003-12-29 22:38:24 »

Ok, me once again.  Sorry!   I've determined that the Jogl port also doesn't cast shadows on my machine.  Other demos (like the jogl - nvidia ports) cast shadows ok.  Anyone with more info on all this, please let me know.  In the meantime, I'll try porting one of those demos to lwjgl...

You can tell me to shut up any time now.  Smiley

Renanse  (ruh-NON-say)
Offline elias

Senior Devvie





« Reply #7 - Posted 2003-12-30 09:21:15 »

I'm not sure how old the Nehe 27 lesson is, but it seems to miss the latest development in shadow volume rendering like infinite far clipping planes and carmack's reverse. There's an interesting article on the nvidia site about it:

http://developer.nvidia.com/object/fast_shadow_volumes.html

and the original:

http://developer.nvidia.com/object/robust_shadow_volumes.html

Hope it helps.

- elias

Offline princec

« JGO Spiffy Duke »


Medals: 976
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2003-12-30 15:04:03 »

You could aways do a tile-based hack. I've done this before and it generally looks pretty good.

In map grid coordinates, scan a filled circle from the light position by scanning a square of map cells all around the light and using Bresenham's algorithm to scan from the light source to each tile as you go. The distance to the light (in map units, not pixels) gives you the value to use for light attenuation. Assign this value to the map cell. If the scan out from the centre is blocked by a wall tile then stop the scan at that point.

When you render the map, use the light attenuation value calculated for the corners of the floor tile and modulate it as you draw it. The walls can be taken care of similarly.

Cas Smiley

Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #9 - Posted 2004-01-06 06:58:37 »

Looks like OrangyTang's article on GameDev.net could be useful, find it here.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline renanse

Junior Devvie


Exp: 14 years


Intelligence is light to a dark world.


« Reply #10 - Posted 2004-01-07 12:46:07 »

Thanks.  It mentions being specifically for 2D, whereas I have sortof a isometric 3d viewpoint with some tiles having greater height than others...  I wonder if I can bend his code to my will?  Smiley  Worth a shot.

Renanse  (ruh-NON-say)
Pages: [1]
  ignore  |  Print  
 
 

 
xxMrPHDxx (1 views)
2017-11-21 16:10:57

Ecumene (113 views)
2017-09-30 02:57:34

theagentd (148 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (241 views)
2017-08-02 12:19:43

cybrmynd (241 views)
2017-08-02 12:18:09

Sralse (256 views)
2017-07-25 17:13:48

Archive (874 views)
2017-04-27 17:45:51

buddyBro (1026 views)
2017-04-05 03:38:00

CopyableCougar4 (1578 views)
2017-03-24 15:39:42
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!