Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Deferred Shading, In DBP

Author
Message
EVOLVED
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: unknown
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,
Alquerian
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location: Reno Nevada
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?

Visit the Wip!
bandM
17
Years of Service
User Offline
Joined: 27th Sep 2006
Location: Home
Posted: 7th Jun 2007 20:15
This is perfect,thanks a lot.
EVOLVED
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: unknown
Posted: 7th Jun 2007 20:21 Edited at: 8th Jun 2007 08:18
Quote: "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.
vorconan
17
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
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
SimSmall
19
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
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
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 7th Jun 2007 23:21 Edited at: 7th Jun 2007 23:30
@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.

Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor

Attachments

Login to view attachments
Indecom
16
Years of Service
User Offline
Joined: 23rd May 2007
Location:
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.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jun 2007 02: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.
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 8th Jun 2007 03: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..

Randomness 128
17
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 8th Jun 2007 05: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.

revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 8th Jun 2007 08:17 Edited at: 8th Jun 2007 08:18
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.
Randomness 128
17
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
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.

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 8th Jun 2007 14:44
I got 10 fps with my ATI Radeon 9600 Pro, 3ghz, 1 gb ram. Looked fabulous


Come see the WIP!
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th Jun 2007 15:01
Looks fantastic!

I was averaging 40 fps @ 1280x1024 with a P4 3.2, GeForce 6600GTX & 4Gb RAM



SimSmall
19
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 8th Jun 2007 17:46 Edited at: 8th Jun 2007 17:48
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
vitrus2002
17
Years of Service
User Offline
Joined: 9th Apr 2007
Location:
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?
EVOLVED
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: unknown
Posted: 9th Jun 2007 07:30 Edited at: 9th Jun 2007 09:33
Quote: "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 .
bandM
17
Years of Service
User Offline
Joined: 27th Sep 2006
Location: Home
Posted: 9th Jun 2007 10:01
@Evolved
Did u copy every object for a new light while making shadows?
Hoozer
17
Years of Service
User Offline
Joined: 8th Sep 2006
Location: Bremerhaven (Germany)
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

AMD 64X2 4800+ (939); 2GB; GF 6800LE (@12PS, 6VS; 380 MHz, RAM: 434 MHz)
DP-Sw-Mode-Comp-Entry (updated to V. 1.3):
http://forum.thegamecreators.com/?m=forum_view&t=93582&b=5
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 9th Jun 2007 21:57
Randomness 128, the resolution was 1024*768*32, on a Athlon64 3700+ (socket 754), with 2gb of corsair 3200 (400mhz) of RAM. the fps may be due to the fact that I was on the internet and peoplepc is a resource hog. ill try closing down all of the programs running in the background. what fps did you get? how many lights, how many objects, what resolution, etc..
Randomness 128
17
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 9th Jun 2007 22:15
I was also using 1024x768, with however many lights and objects were in that example. I'm using a 6600GT and got about 90fps.

Another reason could be that I have mine over clocked from 500mhz to 575mhz. The default clock speed for a 7600GT I think is 560mhz.

Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 9th Jun 2007 23:24
@Hoozer: shaders are updated at each frame that mean that, using vectors you can update lights and change their position, range, colors, etc ...

Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor
EVOLVED
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: unknown
Posted: 9th Jun 2007 23:39
Quote: "Did u copy every object for a new light while making shadows?"


Nope, 30 objects in total. but theres an extra 6 renders to draw the dynamic cube maps for the shadows when ever you move them. Im trying to improve shadows process atm trying to make it faster and softer.

@Hoozer

1. Its totally free, Use it as you want. But I need to come up with better demos and scalability so you can use it better.

2. Each light is dynamic so they can be moved or hidden simply hiding the light object that represents that light. Thats whats so great about deferred shading. I can have a 100 fully dynamic parallaxed lights with just 5 renders, and my fps will stay well above 100. Try that with multi-passes rendering with parallax mapping and you`ll feel the drop, bad(to about 1-5fps).

3. There should be no reason why you can`t move,rotate,scale your object, You should get the same perfect per pixel lighting every time.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 10th Jun 2007 00:17
Randomness 128, the default clock speed for my XFX7600GT is 570mhz, even when I over clock it to 620mhz, I notice no difference in fps.
What cpu are do you have? if it is newer than socket 754(AMD) like a 939 or AM2 (I'm unfamiliar with Intel's sockets) then that would make a difference. even if it's a 3700+ 939 @2.2ghz, the front side bus would probably boost performance. also, what type of ram does your gpu have? My card's default is DDR3 1.45ghz.
Hoozer
17
Years of Service
User Offline
Joined: 8th Sep 2006
Location: Bremerhaven (Germany)
Posted: 10th Jun 2007 00:34 Edited at: 10th Jun 2007 00:36
@ EVOLVED: Thanks for the info! With the shadowing showed in Demo2, at an acceptable performance (mine was acceptable, but as I know me, I would have a lot more objects, if I would use it, what most possibly make it much slower) would make this shader "the mother of all shaders" for DB-Pro reduarding the possibilities you get!

I once tried to use your "parallax-mapping-shader for multiple-lights" and it turned out to eat too much performance (or I made something wrong)! Would this (new) "Deferred"-shader perform better than the (old) mentioned one?
(I think you said so, when talking about "multipass" in the first post and in the last.)

Last Question: What kind of performance would you exspect, if you would use this "Deferred"-shader together with your "SoftShadow"-shader (if it's possible)?
(I suppose it would be an absolute killer, requireing a 8800-series card to perform at an acceptable rate! As you see I'm a fan of your "high-quallity-stuff" and I would use it all at once, if I only could! (An overclocked GeFo6800LE is not the best card to do that!) )



Really great work!

Hoozer

AMD 64X2 4800+ (939); 2GB; GF 6800LE (@12PS, 6VS; 380 MHz, RAM: 434 MHz)
DP-Sw-Mode-Comp-Entry (updated to V. 1.3):
http://forum.thegamecreators.com/?m=forum_view&t=93582&b=5
Randomness 128
17
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 10th Jun 2007 00:52 Edited at: 10th Jun 2007 00:53
Quote: "Randomness 128, the default clock speed for my XFX7600GT is 570mhz, even when I over clock it to 620mhz, I notice no difference in fps."
In one test, over clocking mine from 500mhz to 575mhz brought the frame rate from about 57fps to about 64fps. Going any higher doesn't seem to make much difference, though. Maybe the card can't get enough power from a PCI-E x16 slot to make it much faster.

Quote: "What cpu are do you have?"

Pentium 4 HT 3.0GHz. Socket LGA 775.

Quote: "also, what type of ram does your gpu have?"

DDR3 1GHz


I figured out why, though. I had turned off v-sync. Turning it back on dropped the frame rate down to about 60fps.

revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 10th Jun 2007 01:08
that would do it, though on my card, no matter what i do to it (short of changing the resolution), I cant get my fps to budge. with all of the settings turned up i still get 55-60 fps. why that is i dont know, but mabey some one else does.
Randomness 128
17
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 10th Jun 2007 01:38
Same with me on Half-Life 2. Quite odd.

bandM
17
Years of Service
User Offline
Joined: 27th Sep 2006
Location: Home
Posted: 10th Jun 2007 17:08
Here's deferred shading on an DBO object.



And the demo;
http://rapidshare.com/files/36331835/DeferredDBO.rar.html

Have fun!
SimSmall
19
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 10th Jun 2007 21:40
This new one doesn't compile for me either, same error. Line 33 cannot grab image due to illegal area, does anyone else get this?
bandM
17
Years of Service
User Offline
Joined: 27th Sep 2006
Location: Home
Posted: 10th Jun 2007 22:10
It works for me,using 6.6b,anyway here's the solution,
Change this lines:


To this:
SimSmall
19
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 12th Jun 2007 12:23 Edited at: 12th Jun 2007 20:48
ah, 6.6 I'm on 6.5 I think, or if I downloaded the patch without applying it, I'm on 6.2...

I initially replaced out the dll calls with the values I know my screen is set at. Ill try 6.6... The simple, obvious solutions, never occur to me

Edit: yep, all fine and dandy in 6.6b with a nice respectable 120 fps -- I'm going to have to learn how to do this stuff...
Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 12th Jun 2007 23:27
Evolved, I was trying to find some of your shaders from your website but the domain seems to be owned by someone else. Do you still put your shaders online somewhere?

http://3dfolio.com
bandM
17
Years of Service
User Offline
Joined: 27th Sep 2006
Location: Home
Posted: 12th Jun 2007 23:29
Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 12th Jun 2007 23:34
Thank you bandM.

Evolved used to have his work on vector3r.com but that domain is now owned by someone else.

http://3dfolio.com
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jun 2007 00:24
Here's a faster and lower quality version of the same idea.

Use the up/down keys to move the camera forward/back and the mouse to change direction.

Press <space> to exit and save the latest images used to construct the final view.

If you study these and the demo carefully, you'll see why EVOLVED used the trick of having two textures to store position data.

I get an FPS of 8 to 30 with this demo, whereas I got only 2 fps with EVOLVED's demo. His included additional features such as normal mapping, etc, of course.

Attachments

Login to view attachments
K_i_D
16
Years of Service
User Offline
Joined: 23rd Jun 2007
Location: ALA
Posted: 24th Jun 2007 01:34 Edited at: 24th Jun 2007 21:02
Evolved, your demo with deferred shading does not work on DBPro 6.2. Problems with depth shader - he doesn't work on DBPro and on NVIDIA FX Composer 1.7 (all depth objects is white)... Please, somebody help me... Maybe need DBPro 6.6?

LGA-775 P4 540j 3.2Ghz / 1GB DDR2 533MHz / PCI-E16X GeForce8600GT 256MB GDDR3 128Bit / 200GB SATA

Login to post a reply

Server time is: 2024-05-04 12:07:21
Your offset time is: 2024-05-04 12:07:21