PDA

View Full Version : Forward Renderer With Cubeshadowmaps.



Luuk van Venrooij
15-03-2010, 09:49 PM
Hi all

Description:
Inspired by the movie by Sascha on his site http://www.saschawillems.de/ I decided to write my own little forward renderer. This demo does simple pointlights with cube shadowmapping. I didn`t add parallax or normal mapping to keep it simple. I use rgba cubemaps in which I decode the depth value because like Sascha I couldn`t get the depth cubemaps and fbo`s to work properly. This demo has 5 lights of which one is dynamicly updated each frame. Each extra light requires one extra pass. The demo can probebly be optimised by handeling more then one light in the shader and clipping the drawing of a light with a scissor test.

Controls:
WASD+Mouse : Movement
F1 : Wireframe
F2 : Lighting only
F3 : Show dynamic updated cubemap
F4 : Switch between FBO or glCopyTexSubImage2D for the cubemap. Note that glCopyTexSubImage2D wont work on nvidia for some reason. Not sure why but the dynamic shadow doesnt get copied anymore.

Inifile:
In the settings.ini you can some properties.
1024 = width
768 = height
0 = fullscreen
1 = 1 = Start with FBO and 0 is start with glCopyTexSubImage2D. When using 0 on nvidia you dont get shadows as explained by F4
512 = Size of the shadowmap. When using 0 in the above make sure this is smaller then the width and height.

And here is a little movie:
http://www.youtube.com/watch?v=fts9RFMUE8Y

And of course the download link:
http://www.genesisdevice.net/downloads/forwardrendering.zip

Source like always is under LGPL.

Greetz Luuk

chronozphere
15-03-2010, 09:54 PM
Great stuff! :D will take a look at the source ASAP.

Edit: I tried to lower the quality of the shadows by setting ShadowSize to a lower value, but It doesn't seem to affect anything. Also, when I zoom in on the shadow edge, I see a straight line (no aliasing). How is that possible? :?

virtual
16-03-2010, 02:49 PM
didn't work on my Gforce 5200FX ,

chronozphere
16-03-2010, 10:07 PM
I guess this demo needs at least a card from the 6xxx or 7xxx series. Your card just doesn't have the required capabilities.

Luuk van Venrooij
17-03-2010, 05:23 PM
I only tested it on geforce 6 and up and the radeon 5xxx series. Does the log indicate any error?

Also I have uploaded a new version. I have improved the shaders a bit, cleaned up the code and added spotlights.

Grab it here:
http://www.genesisdevice.net/downloads/forwardrendering.zip

Greetz

Luuk

virtual
17-03-2010, 05:58 PM
as far as i know 5200FX suport Opengl 2
there is no error message apeared , but the demo stoped in shader loading and show ( send error raport , don't send ) . after pressing the button ( don't send ) some EAccessViolation error message apear , thats all

the log file looks like this


Log started at 17/03/2010, 18:46:31

INIFILE: Loaded settings
WINDOW: Created window
TEXTURE: Model\floor_diffuse.jpg loaded
TEXTURE: Model\wall_diffuse.jpg loaded
TEXTURE: Model\ceiling_diffuse.jpg loaded
TEXTURE: Model\pillars_diffuse.jpg loaded
OBJMODEL: Model\Room.obj loaded
SHADER: Shaders\PointLight loaded
SHADER: Shaders\AmbientPass loaded
SHADER: Shaders\DiffusePass loaded
SHADER: Shaders\ShadowPass loaded
SHADER: Shaders\ShadowDebug loaded

Log ended at 17/03/2010, 18:46:39

Luuk van Venrooij
18-03-2010, 10:30 AM
Indeed the 5200FX should support OGL 2.0 and without any error its hard to pinpoint the problem.

chronozphere
18-03-2010, 05:00 PM
@Virtual: You could run from the sources in Delphi and see where it goes wrong. :)
Just a matter of putting some breakpoints in and run a few times.