Lighting manager - normal & specular mapped with shadows

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Lighting manager - normal & specular mapped with shadows

Post by stefbuet »

Lighting manager
By Stefbuet :P

Hey,
I've made this lighting manager for my game. As I've received good help from Irrlicht forums, I decided to share it here!
:arrow: Warning : this is OpenGL only.

So, basically this allow you to use point lights , or spot lights with nice effects really easilly in your application because you won't have to touch anything about shaders or that kind of thing.

A nice thing too is the ability to switch with a simple line of code from a per vertex light to per pixel light. You can also change the quality of lights, shadows direcly. Moreover, this system is a good base to do some post processing effects like bloom or motion blur.

What you can do:
-Use point/spot lights
-Normal & Specular mapping
-Switch from per pixel to per vertex shading
-Attenuation of lighting
-Use soft shadows
-Enable or not shadow casting from lights
-add/remove lights/lighted nodes very easilly
-a lot more ....

I wrapped XEffect into this system to be able to use soft shadow mapping. Don't try to use your XEffect built, it won't work because I've done a lot of changes to be able to change lighting rendering, remove lights, and a lot of things, so you should use my version of XEffect instead.

Here is a video (without shadows):
http://www.youtube.com/watch?v=RO3pRcymG-w

Here is a screen shot (exemple from the archive)
shadows + 3 point lights red/green/blue with normal & specular mapping:

Image

And here is the download links.
megauplaod : http://www.megaupload.com/?d=6TN516YB
easyshare : http://www.easy-share.com/1911339959/lighting manager irrlicht.rar
3 exe provided with 3 shadow casts, 1 shadow cast, and no shadow cast.

The licence is Zlib like Irrlicht. I've put it into the archive.

I hope you will like my lighting system.
If you find any bug, or have any comments/reviews, make sure to post here :)

Stef.
Last edited by stefbuet on Thu Jul 15, 2010 11:42 pm, edited 2 times in total.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

tried it. useless....sry but the performance is really bad!i get like 8fps with your demo scene.
my deferred renderer give 60fps with 6 lights(with shadows) and 200 extra lights that don't cast any shadow.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

The performance drop is due to shadow use.
I got 80FPS with this demo shadows on, 600FPS without shadows.
1 point light shadow = 6 x spot light shadow.
That's why I'll use 1 shadow light and all others wont cast shadows.
I would use your defered renderer if it had point lights & normal mapping but I didn't see that, and I don't want to spend my vacacion time only on the lighting system, need to work on the game too.
Last edited by stefbuet on Sun Jul 04, 2010 7:52 pm, edited 2 times in total.
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

Nice demo,

58fps on my QuadCore 3ghz and Nvidia 8800GT
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

stefbuet wrote:1 point light shadow = 6 x spot light shadow.
again? :shock:
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

well, you can't say again, it's just that:
I wrapped XEffect into this system to be able to use soft shadow mapping.
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

still? :lol:
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
Tihtinen
Posts: 76
Joined: Fri Jan 08, 2010 3:12 pm
Location: Finland

Post by Tihtinen »

The demo didn't really work :roll: It looks pretty weird and only the shadows seemed to display properly...
System: Intel Q6600, GF8800gts

Image
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

Tried on my GeForce 9600M GT.
All looks ok, except of performance: 8-9 fps (and this is 512 x 512 window).
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

Tihtinen I had the same blue colored scene when the shader didn't compile, do you have anything in the output console ?
Again : performances are mainly due to XEffect, try it without shadows.
I can make an exe without shadows if u are too lasy :P just ask.
Tihtinen
Posts: 76
Joined: Fri Jan 08, 2010 3:12 pm
Location: Finland

Post by Tihtinen »

stefbuet wrote:Tihtinen I had the same blue colored scene when the shader didn't compile, do you have anything in the output console ?
Well there seems to be 2 failed GLSL compiles

Code: Select all

.
.
.
GLSL shader failed to compile
0(36) : warning C7011: implicit cast from "vec4" to "vec2"
0(36) : warning C7011: implicit cast from "int" to "float"
0(44) : warning C7011: implicit cast from "int" to "float"
0(46) : error C1115: unable to find compatible overloaded function "pow(float, int)"
0(54) : warning C7011: implicit cast from "int" to "float"
0(55) : warning C7011: implicit cast from "int" to "float"
0(59) : error C1115: unable to find compatible overloaded function "max(int, float)"
0(64) : warning C7011: implicit cast from "vec4" to "vec2"
0(69) : warning C7011: implicit cast from "int" to "float"
0(69) : error C1115: unable to find compatible overloaded function "max(int, float)"
0(69) : error C1115: unable to find compatible overloaded function "pow(error, float)"
0(71) : warning C7011: implicit cast from "vec4" to "vec2"

GLSL shader failed to compile
0(36) : error C1115: unable to find compatible overloaded function "max(int, float)"
0(38) : warning C7011: implicit cast from "int" to "float"
0(38) : error C1115: unable to find compatible overloaded function "max(int, float)"
0(38) : error C1115: unable to find compatible overloaded function "pow(error, float)"
0(41) : warning C7011: implicit cast from "int" to "float"
0(43) : error C1115: unable to find compatible overloaded function "pow(float, int)"
0(50) : warning C7011: implicit cast from "int" to "vec3"
0(51) : warning C7011: implicit cast from "int" to "float"

Unsupported texture format
Unsupported texture format
Unsupported texture format
Unsupported texture format
Unsupported texture format
Unsupported texture format
Resizing window (512 512)
Could not open file of texture: XEFFECTS_SM_1024
XEffects: Please ignore previous warning, it is harmless.
Unsupported texture format
Could not open file of texture: XEFFECTS_SM_1024_2
XEffects: Please ignore previous warning, it is harmless.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

stefbuet wrote:Tihtinen I had the same blue colored scene when the shader didn't compile, do you have anything in the output console ?
Again : performances are mainly due to XEffect, try it without shadows.
I can make an exe without shadows if u are too lasy :P just ask.
I admit i am to lazy. would you provide a version without shadows?
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

I knew it :p
You can know download (new link in the first post) again binary.
3 exe provided with 3 shadow casts, 1 shadow cast, and no shadow cast.

@Tihtinen : I'll try to see if I find something.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

without any shadows the fps is ok. i get around 80. but yeah how well does it scale? for example my deferred render gets around 60fps maybe a bit less for over 200 hundred lights without shadows. but the fps doesn't rise for fewer lights. also my hardware is pretty slow so my deferred render is probably running way faster on your system. same for your own stuff. but what i don't get. your fps drops from 80 to like 12 when having one shadow pointlight. you said that are six spot lights. so i did the same with my system and i get around 35 fps. also a significant drop but yeah its bc of the state switches which are pretty slow on laptop cards. anyway either try to improve your shaders or rewrite your shadowcode. or third option you add phong normalmapping to my system and i will add point shadow lights ;)
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

I know defered lighting is awesome :'(
I get 1024 normal mapped lights / 90 000 poly running 225FPS with a guy demo.
But my problem is about time. I'm still learning shader stuff, I had to learn how to do this normal mapped effect, I'll have to learn how to handle your defered rendered and all that is very time consuming.
I would like to finish a number of things in my game at the end of vacations, and the lighting managment is part of it, but there are also other things.
In the other hand, it would be so cool to have 200 lights in the game, it could make things so beautifull...
However, you seems really busy with your new EditIrr software, so how much time will you need to create point light shadows ?
If it's not too long, I'll probably accept to implement the normal mapped shader into your framework...
It's just a question of time.

Mmm, waiting your responce, I'll try to make a simple defered lighting scene outside of this system during this night. If I manage to do it, I'll do shadows myself too. However I don't know how to do shadow mapping without 6 render pass. I saw there is something using cube map, but Irrlicht doesn't support cube maps for now.
Post Reply