FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

examples/light/lighttest has no light
Goto page 1, 2  Next
 
Post new topic   Reply to topic     Forum Index -> ArcLib
View previous topic :: View next topic  
Author Message
cyhawk



Joined: 12 Feb 2009
Posts: 10

PostPosted: Thu Feb 12, 2009 8:31 am    Post subject: examples/light/lighttest has no light Reply with quote

I am just getting to know ArcLib and wanted to try the lighttest example. It compiles and runs fine, but there are no shadows (or no light depending on how you look at it).

A screenshot:
[img]http://s3.amazonaws.com/scrnshots.com/screenshots/119974/lighttestpng[/img]
http://www.scrnshots.com/users/cyhawk/screenshots/119974

I have made the image files accessible and arc.log says:
Code:
0  Info  arc.window - window: open(2D Shadows, 640, 480, 0)
51  Info  arc.window - Derelict GL, GLU, SDL, and SDL_image successfully loaded
523  Info  arc.texture - Texture testbin/penumbra.png with ID 1 has been loaded.
540  Info  arc.texture - Texture testbin/light.png with ID 2 has been loaded.


My video card is a GeForce Go 7600 (256MB) with Omega 2.169.21 drivers.

Do you have any advice?
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Thu Feb 12, 2009 12:07 pm    Post subject: Reply with quote

Hello,

This is good for me to know, actually. What operating system are you running on?

My advice would be to wait until I get the problem figured out, unfortunately. The lighting code does work fine on Windows, however it may have problems on linux, which is weird because the code uses OpenGL and was originally developed on linux.

~ Clay
Back to top
View user's profile Send private message AIM Address
SirAlaran



Joined: 19 Feb 2007
Posts: 84
Location: Silicon Valley

PostPosted: Thu Feb 12, 2009 12:20 pm    Post subject: Reply with quote

clayasaurus wrote:
Hello,

This is good for me to know, actually. What operating system are you running on?


Take a second look at the screenshot Very Happy
_________________
Current projects: Project Fermitas, Arctographer tile map editor, Arclib game library.
Gentoo | Textadept
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Thu Feb 12, 2009 6:21 pm    Post subject: Reply with quote

Wait, OK, you are on Windows. It should be working.

Let's try a little bit of trouble shooting here then.

Do you have this folder

http://svn.dsource.org/projects/arclib/downloads/testbin/

in the same directory as your exe file?

~ Clay
Back to top
View user's profile Send private message AIM Address
cyhawk



Joined: 12 Feb 2009
Posts: 10

PostPosted: Thu Feb 12, 2009 7:40 pm    Post subject: Reply with quote

Yes, I have copied testbin with the images to the folder. I will try to follow what goes on in OpenGL and try to find out where things disappear. Thanks for any tips in the meanwhile.
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Fri Feb 13, 2009 12:02 pm    Post subject: Reply with quote

Tips... let's see...

1) http://www.incasoftware.de/~kamm/projects/index.php/2007/09/08/soft-shadows-2d/#more-4

2) http://www.gamedev.net/reference/articles/article2032.asp

3) The lighting code uses some fairly basic OGL features and doesn't use any extensions, which is why I'm having trouble thinking of what is going wrong. However, I'd recommend concentrating on the lighttest.d file and tweaking OpenGL parameters there to see if you get any interesting results.
Back to top
View user's profile Send private message AIM Address
cyhawk



Joined: 12 Feb 2009
Posts: 10

PostPosted: Sat Feb 14, 2009 3:10 pm    Post subject: Reply with quote

Thanks, I've read those articles! I really like this method for 2D shadows!

It turns out that my OpenGL context has no destination alpha channel and so when the lights are about to be drawn with "GL_ONE_MINUS_DST_ALPHA" they do not get drawn at all (the alpha defaults to 1).

I see that setupPixelFormat sets up the bit depths of the SDL window in arc/arc/window.d. Is there a hook for modifying the window setup procedure?
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Sun Feb 15, 2009 1:06 pm    Post subject: Reply with quote

No there isn't a hook for modifying it. Would you be able to test out different alpha settings and see if you can find one that works for you, then tell me which one you used?
Back to top
View user's profile Send private message AIM Address
cyhawk



Joined: 12 Feb 2009
Posts: 10

PostPosted: Sun Feb 15, 2009 1:27 pm    Post subject: Reply with quote

I have now created a copy of window.d to compile with lighttest.d and changed setupPixelFormat to

Code:
private void setupPixelFormat()
{
   SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
   SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
   SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
   SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
   SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
}


The lighttest finally works with this hack! Looks nice too!

PS: Sorry, I posted this in the wrong topic (twice). I've removed them now.
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Sun Feb 15, 2009 9:29 pm    Post subject: Reply with quote

I put the fix in. Thanks for finding it! Smile
~ Clay
Back to top
View user's profile Send private message AIM Address
cyhawk



Joined: 12 Feb 2009
Posts: 10

PostPosted: Mon Feb 16, 2009 6:13 am    Post subject: Reply with quote

I have played with this example a bit more and modified a few things:

http://home.sch.bme.hu/~cyhawk/lighttest2.zip

One is important: set filtering to linear for the penumbrae (filtering defaults to nearest_mipmap_nearest which I think is a bit unexpected).

The others are not that important. I replaced light.png with a physically correct attenuation (1/(1 + d^2)). Of course now the lights have infinite range which may be a bit of a problem Smile but looks alright. I also replaced penumbra.png with a physically more correct version. Instead of a linear gradient it is based on how much of a circle would be visible, so it is an approximation of spherical lights while the linear gradient (at least I think it was linear) was an approximation of cylindrical lights.

I like how it looks now and feel inspired to create a game that uses it heavily Smile.
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Feb 16, 2009 10:24 am    Post subject: Reply with quote

Alright, I applied your new changes + lightmaps into the ArcLib trunk.
I also added the py files to the trunk so others can generate their own light maps.

Do you want your name as cyhawk in the 'AUTHORS' file? Are you fine with your codes being zlib/png licensed?
Back to top
View user's profile Send private message AIM Address
cyhawk



Joined: 12 Feb 2009
Posts: 10

PostPosted: Mon Feb 16, 2009 10:29 am    Post subject: Reply with quote

My name is Daniel Darabos, and I am fine with the licensing. My changes are miniscule, but thanks for the attribution!
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Feb 16, 2009 10:58 am    Post subject: Reply with quote

I appreciate all the help I can get Cool Especially if lighting will now work on more gfx cards.
Back to top
View user's profile Send private message AIM Address
cyhawk



Joined: 12 Feb 2009
Posts: 10

PostPosted: Thu Feb 19, 2009 8:06 am    Post subject: Reply with quote

I have merged the "dominos" blaze demo with the lighttest! Smile There are some artifacts (the rectangles in the demo are quite thin), but the dynamic interplay of shadows and physics is very nice.

http://www.scrnshots.com/users/cyhawk/screenshots/123706
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> ArcLib All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group