Posted: 7th Jun 2007 19:50
Hay, As some ppl may be interested.

Since playing STALKER Iv been trying to get deferred lighting going in DBP. Its very nifty if you have a goodish gfx card, In the demo there is 30 fully dynamic lights where I get 300-400fps when vsync is turned off on my 7800gtx.

In the traditional multi-passes rendering there is a to bigger hit on performance when you start to get just 5-6 dynamic lights going. Since most up coming games are now going to use deferred shading(crysis?, Bioshock?, offset?) for there real time lighting/shadows, I think DBP should have slice of the cake(or pie) too.

Basics on how it Works.
First, you need to Store a position texture. like so >


Next, Since DBPs floating point texture are 32 bit we need to create a second position texture that repeats its self base on the fist position texture. This is to get a more accurate world position for finer lighting, otherwise well get blocky per-pixel lighting on lager world.


Now we need to store the world normals data in to a texture.


Now we have all the date we need. We project all 3 texture on to spheres(much faster than using full screen quads) that will represent each light. Reconstruct position/normals so it represents the original 3d world. And draw the per pixel lighting as we normally would do. Then Store the multiple Lighting results we get in a FP texture and project it back on to the main scene with the diffuse texture. so we end up with >


So all in all, main geometry gets Drawn 4 times and the lighting spheres gets Drawn once. But you will need a very good gfx card as it requires 4 full screen floating point texture renders to work.

Iv also added parallax mapping as an extra bonus,you can just about see it in this shot.


Demo here
Requires : VS2.0 and PS2.0 + ability to Draw full screen FP textures.

Im now currently trying to add cubic lighting and cubic base depth shadow maps to get some form of shadowing, Like in stalker. But will require you to own dark shader for the dynamic cube maps if you wish to compile.

EVO,
Posted: 7th Jun 2007 20:06
Totally awesome Evolved, as always. I really need to get my mind into some of this and other shader work. I suppose I will be bugging GG and Freddix

So this takes 4 render passes to complete?
Posted: 7th Jun 2007 20:15
This is perfect,thanks a lot.
Posted: 7th Jun 2007 20:21
So this takes 4 render passes to complete?


There are 5 renders in total , 4 for main geometry and one for the Per-pixel lighting. But the geometry shader instruction count is pretty low so it very fast. Its the pixel lighting render thats the killer.
Posted: 7th Jun 2007 22:47
That's just awesome, lucky my new card supports all these pixel lighting shaders, runs really fast aswell, i got up to 600+ fps
Posted: 7th Jun 2007 23:15
This may be obvious to some, but I know nothing about shaders (perhaps, time to learn): will the process be significantly faster on PS 3.0 and VS 3.0 cards?


This just looks awesome -- I knew DBP was capable of pretty good graphics with the right shaders, but that's just amazing
Posted: 7th Jun 2007 23:21
@EVOLVED:
Like usual:
Can I add it in the next Ultimate Shader Pack ?
Can it be used freely even in commercial product ?
It's a wonderful work again :p
I think you're the best in Shaders dev :p

I noticed a strange issue when approaching ground/objects... look the attached pic for more details.
Posted: 7th Jun 2007 23:23
Just tested that on my cousins computer, got 16 fps. I would love for my games to have a lighting system like this, it totally owns. I just relly need an upgrade very badly, so i cant even use this for quite a while. I am definately going to save this code though.
Posted: 8th Jun 2007 2:01
I got 2 FPS.

But it worked!!

I always reckon that half the battle is to get something working - then look at improving/optimising it. However, I don't think I've managed to speed up any of EVOLVED's demos yet (except by sacrificing visual quality of course).

Thanks for posting that, EVOLVED. As usual, your demos and shaders are an inspiration to us all. I'll be studying this one carefully.
Posted: 8th Jun 2007 3:58
You guys who got low fps mind noting which cards you're trying to use?

As the performance on here was less than encouraging..
Posted: 8th Jun 2007 5:43
Very nice. I got about 90fps at 1024x768, and about 250fps at 640x480.

On my old computer, though, I got 9fps and it looked like this:



What I've been wondering, though, is how a game like Doom 3 handles it's lighting. It's all done in real time, and there are a lot of lights on screen at once.
Posted: 8th Jun 2007 8:17
EVOLVED, this is absolutely awesome (as usual). I got about 60fps with 30 light's, then I turned the lights up to 90 and still got 55fps! it wasn't until i added in 40 objects into the scene that it dropped to 42fps. but anyway, great work! Do you think it would be possible to combine this lighting effect with your existing shadow shader? I don't have a copy of dark shader when that version comes out, but I want to know what you think before I go ahead and waste a bunch of time trying to accomplish the impossible.

edit: I forgot to mention that I'm running a Geforce 7600GT.
Posted: 8th Jun 2007 14:38
@ revenant chaos

Which screen resolution were you using? And what are the rest of your system specs? I'm wondering because your framerate was lower than mine even though your video card is better.
Posted: 8th Jun 2007 14:44
I got 10 fps with my ATI Radeon 9600 Pro, 3ghz, 1 gb ram. Looked fabulous
Posted: 8th Jun 2007 15:01
Looks fantastic!

I was averaging 40 fps @ 1280x1024 with a P4 3.2, GeForce 6600GTX & 4Gb RAM
Posted: 8th Jun 2007 17:46
The precompiled exes work fine

~30 fps in Windows XP
~40 fps on windows 2000

Interesting, as both machines have the same amount of RAM (1GB - the RAM chips are the same speed too), same graphics card (GeForce 7300 GS), but the one running 2000 has an inferior processor.

However, opening in DBP and pressing compile, it crashes... "could not grab image due to an illegal area at line 33" ... on both machines
Posted: 8th Jun 2007 23:11
Nice work! Though only 5 fps on my laptop
Howewer I've got a little problem with it.
When I try to compile the source it makes me know that the size of render-destination image is incorrect. Right, fixed, it's 1024x768 now. Compilation successful!!! Great!
Oh,no! everything is black without any light. Any solution?
Posted: 9th Jun 2007 7:30
noticed a strange issue when approaching ground/objects... look the attached pic for more details.


This is a bit unfixable , but in a game you wont get that close up any way .

Iv just added shadow mapping its a bit/alot slower than I was expecting it to be but can be very scalable. So what you see atm is that its at the max effect settings you`ll get. I still get above 200 fps in 800x600 not to bad but there are only 4 lights.

Screen:


Demo - No DBP source as it a bit of a mess .
Posted: 9th Jun 2007 10:01
@Evolved
Did u copy every object for a new light while making shadows?
Posted: 9th Jun 2007 21:11
@ EVOLVED:
1. Can you answer "Freddix"' two questions please (look at the 7th post)?
2. I don't know much about shaders, but am I right that these lights are only static (so they can't be moved in real time)?
3. Am I right that moving objects (their textures) are correctly influenced by the lights?


Very good work, like all the shaders I have seen from you! Keep up the good work, you are inspiring and teaching us all a lot!

Hoozer