View previous topic :: View next topic |
Author |
Message |
cyhawk
Joined: 12 Feb 2009 Posts: 10
|
Posted: Thu Feb 12, 2009 8:31 am Post subject: examples/light/lighttest has no light |
|
|
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 |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Thu Feb 12, 2009 12:07 pm Post subject: |
|
|
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 |
|
|
SirAlaran
Joined: 19 Feb 2007 Posts: 84 Location: Silicon Valley
|
Posted: Thu Feb 12, 2009 12:20 pm Post subject: |
|
|
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 _________________ Current projects: Project Fermitas, Arctographer tile map editor, Arclib game library.
Gentoo | Textadept |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
|
Back to top |
|
|
cyhawk
Joined: 12 Feb 2009 Posts: 10
|
Posted: Thu Feb 12, 2009 7:40 pm Post subject: |
|
|
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 |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
|
Back to top |
|
|
cyhawk
Joined: 12 Feb 2009 Posts: 10
|
Posted: Sat Feb 14, 2009 3:10 pm Post subject: |
|
|
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 |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Sun Feb 15, 2009 1:06 pm Post subject: |
|
|
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 |
|
|
cyhawk
Joined: 12 Feb 2009 Posts: 10
|
Posted: Sun Feb 15, 2009 1:27 pm Post subject: |
|
|
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 |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Sun Feb 15, 2009 9:29 pm Post subject: |
|
|
I put the fix in. Thanks for finding it!
~ Clay |
|
Back to top |
|
|
cyhawk
Joined: 12 Feb 2009 Posts: 10
|
Posted: Mon Feb 16, 2009 6:13 am Post subject: |
|
|
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 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 . |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Mon Feb 16, 2009 10:24 am Post subject: |
|
|
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 |
|
|
cyhawk
Joined: 12 Feb 2009 Posts: 10
|
Posted: Mon Feb 16, 2009 10:29 am Post subject: |
|
|
My name is Daniel Darabos, and I am fine with the licensing. My changes are miniscule, but thanks for the attribution! |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Mon Feb 16, 2009 10:58 am Post subject: |
|
|
I appreciate all the help I can get Especially if lighting will now work on more gfx cards. |
|
Back to top |
|
|
cyhawk
Joined: 12 Feb 2009 Posts: 10
|
Posted: Thu Feb 19, 2009 8:06 am Post subject: |
|
|
I have merged the "dominos" blaze demo with the lighttest! 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 |
|
|
|