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 / Fallout 3 Engine - Interiors

Author
Message
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Jan 2009 18:41 Edited at: 16th Jan 2009 18:41
Hi guys, don't know if you know but I'm making a DBP version of the Fallout 3 Engine. So far i'm trying to get interiors working right, mainly how there lit. I've come up with a few ingenious ideas and this one seems to work well, for a test a made a few static objects so I could use the engine to build three interiors (one filed with light sources) with interconnecting doors. Used Evolveds Per-Pixel Lighting shader (6 lights) with my light system and this is what it made:


Note: white cubes represent light source positions.

What do you think?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.

Attachments

Login to view attachments
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 16th Jan 2009 19:00
Looks great! I can see some fantastic results coming out of this.

djchaos
17
Years of Service
User Offline
Joined: 26th Mar 2007
Location: Brighton, UK
Posted: 16th Jan 2009 19:14
how did u get more than 8 lights?

Your mod has been erased by a signature
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Jan 2009 19:21
Cheers AndrewT

Heres a demo, WASD to move camera, E to enter doors or new interiors, 2.0 SM graphic card is needed for the shader. I've left the Music folders empty, but if you put mp3's in them, the engine will play them. Models where put together quick, so there quite basic. I've also turned off collision on the doors, just if you want to look at the map from the outside you can go through them.

Note: You'll notice that it takes alot longer to to load the first interiors than the others, this is because I forget to setup my arrays correctly. Because I did this dim _Array() as udt_xxx and did this when adding to that array array insert at bottom _Array() it takes alot longer to add the data and even longer the bigger the array gets, but if you make a pre-defined array so dim _Array( MAX_xxx ) as udt_xxx then add data to a position in that array, it nearly instant. Not at my PC at the moment but I will edit them.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.

Attachments

Login to view attachments
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Jan 2009 20:40 Edited at: 16th Jan 2009 20:43
Weird...? I just downloaded the demo that I uploaded and it crashed on a different computer, mabye it's Vista problem on this PC. Works fine on my brothers PC which also has Vista, strange. Anyone tried it out yet, cause I might have to upload it again if theres a issue?

djchaos, gimme a sec... my nets on and off at the moment, fixing it as I write this.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 16th Jan 2009 20:43
Quote: "how did u get more than 8 lights?"

Maybe he doesn't have more than 8 lights per object. I think that each portion of his level has its own shader, so each portion can have 6 lights.

Looks very interesting.

Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Jan 2009 21:55 Edited at: 16th Jan 2009 21:57
Math's on the ball, but actually every static object has it's own shader, any object I put into the world automatically picks up a light source and alter the shader assigned to it. Basically each object has upto 6 shader lights and searched for any light sources that are in range. Combining this method with my Room Marker/Portal Culling method and object visiblilty culling, I could have a interior with hundreds of light sources and hundreds if not thousands objects. I edited the shader so it can have 9 light now and I added fog, but I have to play around with how many lights are need with in the shader.

Also, does anyone have any ideas of seeing if an object (plain) is behide another object?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Coldfire
15
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 17th Jan 2009 14:27 Edited at: 17th Jan 2009 14:46
awesome, fallout 3 was a great game.. now as long as you don't duplicate the crash on VATS bug the actual game had, lol!

very clever light work too


Edit:

and to check whether an object is behind another you could use a distance checking formula such as

sqrt ( dx^2 + dy^2 + dz^2 )

but sqrts get real slow, real fast. im actually looking into trying out some kinda lookup table, myself. i think that would be the fastest bet, but then you would have to pregenerate data like bsp engines do.

"They say beer will make me dumb / It are go good with pizza" - Psychostick
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 17th Jan 2009 14:58
Quote: "sqrt ( dx^2 + dy^2 + dz^2 )

but sqrts get real slow, real fast."


Are you sure? I can do 10,000 squareroot operations in a fraction of a millisecond, on a 1.8GHz single-core processor. Squreroots have this bad rep of being really slow, but I've never actually experienced this.

Coldfire
15
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 17th Jan 2009 17:52
recently i did an entry in the darkbasic programming challenges and i used that formula to test collision between spheres in a physics simulation.

before adding the collision, i could easily run 5000 physics objects at once, but after going through the array list calculating the distance it crippled it to the point to where it could barely run 256 of them.

i went through the array checking collision of only the objects further down the list also to minimalize repeat testing which optimized it a bit but it was still incredibly slow.

it is quite possible i had a bottleneck else where tho, i suppose. i just didnt wanna dedicate that much time to it, lol.

i ended up ripping the code out after that nasty side effect.

btw my specs were at that time amd athlon xp 2800+ with ati HD2600 pro and 3 gigs DDR-400

"They say beer will make me dumb / It are go good with pizza" - Psychostick
Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 17th Jan 2009 18:05
Checking the distance between two objects won't tell you if one of them is really behind the other one. If you are searching for some kind of occlusion test, you could maybe "extrude" the plain and see if all the vertices of the bounding box of the second object are between the four planes you have created. It should be a bit like frustum culling.

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 17th Jan 2009 18:08
Maybe it's just the physics that were the bottleneck and the distance checking made it worse.

3700+ Athlon 64 - Geforce 7600 GS - 2GbDDR2 RAM - 40Gb Hdd (In this pc) - Windows Vista Ultimate (x86)
Coldfire
15
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 17th Jan 2009 18:30
@math

if you are checking a vertex (or any other 3d float)you can. you could even make a function to interpolate between the points of a plane, too. however, if he wants to know if its occluded, that's a different matter all together.

i was assuming that he was calculating the nearest lights, in which case occlusion isn't totally essential depending on the implementation.

you are more than likely right though. after re-reading it it does seem as though hes more interested in occlusion than just seeing if an object is behind a plane

"They say beer will make me dumb / It are go good with pizza" - Psychostick
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 17th Jan 2009 19:14
@sasuke:
That looks amazing dude! Keep up the great work and I'll try the demo later when I can get to my pc,

@coldfire:
Surely if you move the square root to the other side of the equals would speed it up? Thats what I'm doing atm. Seems to help a bit.

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 17th Jan 2009 19:46 Edited at: 17th Jan 2009 19:46
That is the BOMB!

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 18th Jan 2009 00:34
@Sasuke
Yes indeedy, I've tried the demo, and It's awesome. I get a constant 83fps which is more than adequate

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Jan 2009 05:23 Edited at: 18th Jan 2009 05:26
79-83 fps here, except the area in the ss below causes ~60 for some reason. otherwise, very nice



Virtual Nomad @ California, USA
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit

Attachments

Login to view attachments
Violent Pigeon
16
Years of Service
User Offline
Joined: 30th Dec 2007
Location: London, Great Britain
Posted: 18th Jan 2009 15:18
I went into the hot room then a I went back into the other room long loading time, *8-10 seconds* and I got a FPS drop when I entered the ramp room shown above.

Stats:
2.8ghz processor
GeForce 8600
Windows XP

I wish I could program something even REMOTELY like this one day, and I would be happy


kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 19th Jan 2009 01:38 Edited at: 19th Jan 2009 01:39
hey your demo works jsut fine. i want to make a game. and i was wondering what did u use to make the roosm and everything. also how many lines of code did this take. by the way nice job man.

kuljot
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 19th Jan 2009 21:30
well... distance checks with 5,000 objects... if you check every object's distance to every other object, thats a huge amount of distance checks, thats 25 million checks per frame.


The engine looks really good so far. My only problem is with the fps. I get about 15 fps on the main, large room, but 85+ on the two smaller ones.
Quantum Fusion
15
Years of Service
User Offline
Joined: 1st Aug 2008
Location: The Great White North
Posted: 19th Jan 2009 21:36
But doesnt perpixel lighting make it unusable on a level that is a little more complex and higher polyed than just a boxy room?


Because whenever I use a shader that has lights it brings up the poly count exponentially in direct relation to the amount of lights (so 2 lights gives me 2x the poly count, 4 lights gives me 4x the poly count, etc).


Unless I'm doing something wrong?

Dual-Core Pentium D @ 3.00GHz, 1.0 GB nVidia GeForce 8500 GT, 20" Wide screen LCD @ 10,000:1 Contrast, 4.0 GB DDR2 SDRAM, Triple-boot: 32-bit Windows XP MCE, 64-bit Vista, 64-bit Linux Ubuntu
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 19th Jan 2009 22:56
Quote: "But doesnt perpixel lighting make it unusable on a level that is a little more complex and higher polyed than just a boxy room?"


Not really, it depends on the type of per-pixel lighting you're doing, if it's just basic normal mapping then the majority of the shader computation can be done in the vertex shader. If you're so concerned with expensive pixel shaders then you could just use deferred shading.

Quote: "Unless I'm doing something wrong?"


Clearly, light count has nothing to do with poly count, unless you're using a single pass per light?

Quantum Fusion
15
Years of Service
User Offline
Joined: 1st Aug 2008
Location: The Great White North
Posted: 19th Jan 2009 23:07 Edited at: 19th Jan 2009 23:13
Quote: "Clearly, light count has nothing to do with poly count, unless you're using a single pass per light?"


EDIT: Yeah I just checked you're right, its doing a single pass per light.

So can you do just one pass for six lights?

Dual-Core Pentium D @ 3.00GHz, 1.0 GB nVidia GeForce 8500 GT, 20" Wide screen LCD @ 10,000:1 Contrast, 4.0 GB DDR2 SDRAM, Triple-boot: 32-bit Windows XP MCE, 64-bit Vista, 64-bit Linux Ubuntu
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th Jan 2009 16:37 Edited at: 20th Jan 2009 17:10
I think the fastest possible distance check is vector based, which I'm sure someone could post an example off - should be 2 or 3 times faster than the old square root method. If nobody comes forth I'll post up and example later.

I think though that your taking a long way around optimisation in that method, because it relies on a distance calculation to remove detail that is probably taking less processor time than the mesh render itself (well, maybe not).

What I would do is make an indexed grid, if your scene is mostly on 1 level, then it would probably work out pretty nice.
Like your already using a grid, so if you imagine a list of objects at each grid location that you can actually see. Change grid location, change the visibility on the meshes. So firstly you'd check the current grid and hide everything at that location, then check the new grid position and show everything at that location. It's a bit rough and ready, but this technique is blindingly fast, you'd use a 2D array representing the grid, but storing the start object number.

It's getting complex to explain this, maybe psuedo code...

Dim cull_grid(64,64)
Dim cull_index(32000)

ind=0
for y=0 to 63
for x=0 to 63
cull_grid(x,y)=ind - Store the start of the list for current grid pos
for o=0 to 10000
if object_visible_from_grid then cull_index(ind)=o : inc ind,1 - Store the object number in the array
next o
cull_index(ind)=-1 : inc ind,1 - Store a -1 to signify the end of the list for the grid pos
next x
next y

Then you can get the cameras grid location and show the objects that are visible from there by simply...

- Hide the current level objects first
ind=cull_grid(x,y)
while cull_index(ind)>-1 and ind<10000
hide object cull_index(ind)
inc ind,1
wend

- Then update the grid X Y position

- Show the current grid objects
ind=cull_grid(x,y)
while cull_index(ind)>-1 and ind<10000
show object cull_index(ind)
inc ind,1
wend


Of course, the tricky part is working out if an object is visible from the grid location. You could use a range and angle check to get it up and running I suppose, but the benefits would come from only showing the visible objects. It could all be precalculated though, so you'd load in a level, with this BSP style grid index included - the workings out could be done in an editor.

At a push, I'd make a screen comparison check, like show all objects, render, then hide the object in question and render again, but compare it with the last render, if there's a change then the object is visible - that's one really slow solution but still an option. Rendering from different areas in the grid would make it nice and accurate.


Health, Ammo, and bacon and eggs!
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 20th Jan 2009 18:00
Quote: "I think the fastest possible distance check is vector based, which I'm sure someone could post an example off - should be 2 or 3 times faster than the old square root method."


Remember that it's only faster because DBPro is slow, the 'vector' method is the exact same as you'd use to find the distance normally, except written in C++.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th Jan 2009 18:17
Yeah, if Lee had a soul he'd add a distance check command .

When accuracy is not hugely important, I've found myself pre-calculating distances on a 2D array, then reference that instead.


Health, Ammo, and bacon and eggs!
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 20th Jan 2009 18:35 Edited at: 23rd Jan 2009 23:51
Cheers for the kind words everyone and thanks for trying out the demo. I see there are some similar results on the as you guys put it, ramp room or going into the ramp room. I'm not sure why this is happening but i'll look into it, maybe a collsion problem with the ramps or how large.

Quote: "after re-reading it it does seem as though hes more interested in occlusion than just seeing if an object is behind a plane - Coldfire"


Yeap, your right, I would like to see if anything is in the way of my portals. Basically I setup room markers which are box areas around rooms I want to cull when i'm either not in them or there not visible. But so I can see whats in another room marker from one, I setup portals between them linking the room markers. If I can see that portal then everything in that room marker is visble ofterwise it's not and everything is culled.

kuljot, all I did was make section of what would make the room, so a hall section, corner section, 3way section, incline section, and a big room section. Side Note: the big rooms mesh should really be slipt up into larger room sections, like hallBig section, wallBig section, cornerBig section etc...

Then all you do is load them and snap them together (position them together) if you want two or more corners, just load the corner section again or and rotate to whatever you want.

Van B, that sound pretty interesting, I think I might have a go at that.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 21st Jan 2009 00:52
what i meant was where did you get all those sections. did u downlaod them or make them. if you made them what program did u use to make the room sections.

kuljot
Kernunos
15
Years of Service
User Offline
Joined: 20th Jun 2008
Location:
Posted: 21st Jan 2009 05:42 Edited at: 21st Jan 2009 05:43
Im curious, why did you said Fallout 3 Engine?
Isent DarkBasic Pro an engine in itself? How do you define Engine?

P.S. Looks and moves fantastic. What tool did you use to build the levels? FPSCFree?
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 23rd Jan 2009 23:02 Edited at: 23rd Jan 2009 23:53
kuljot, oh sorry, I used 3dsMax for the models, but any 3d app could produce them, them are very basic. They were just test models, now i'm making the real thing, though at the moment my textures are just placeholders until I make my own.

Kernunos, DarkBasic Pro is a language, not an engine. An engine would be what you create using the language.

Query?
I found out why the first interior was taking so long to load, it was the loading of the fx file for every static object which made it hang for several seconds. If I remove the shaders the interiors load instantly. So my question is - should I preload fx files to be used later, but if theres something like 500 statics, thats alot of fx files sitting in memory. Any ideas?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 24th Jan 2009 13:42
Firstly, same questions as above because I'd really like to get your opinions and move on with the project.

Secondly, I figured out why the ramp room run slow, it because of that room is one big object and for some reason the shaders doesn't like it, but I've cut up the room into sections and everything run fine.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jan 2009 15:03
Poke me in the eye if I'm wrong... But doesn't saving an object as a DBO save out it's shader stuff as well?

Maybe converting to DBO and loading those instead would speed things up. I think FPSC actually saves out the whole scene as a DBO, maybe having a nose around the engine source for that would give you some ideas.


Health, Ammo, and bacon and eggs!
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 24th Jan 2009 15:24
Already converted them to DBO, but never knew about the shader part, have to look into that. Not sure about saving out the whole scene since my levels are made up of parts snapped together (just positioned next to each other). So if I wanted a square room I just load 4 of the same corner section, position and rotate them accordingly, thats how the levels are made up and because there small chunks of level all the files are rather small and load pretty quick, it's just the fx files which take long to load. But there might be some stuff in there that might help so i'll have a look at FPSC.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 24th Jan 2009 19:10
Sasuke, you will live to do great things. I'm going into computer animation and almost have my degree. If I ever encounter a situation where someone like you is needed, you will be the first on my list to talk to. And if I ever achieve my dream of creating my own game company, I will be hiring you to the engine development team. I am not joking. And if you ever decide to leave these forums are something, drop me a line before you go. I would want to keep in touch. You drive innovation and genius here. If you can't put that on a resume, I don't know what you should put on there!

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 30th Jan 2009 18:54 Edited at: 30th Jan 2009 18:55
Wow, thank for the lovely comment Sid and thanks for the offer, be keeping that in mind, cheers.

Update:

Made new models for the interior to resemble Fallout 3 and i'm make a reconstuction of Fort Independence if you ever been in the game.

Pic:


Question:
Same questions as before and a query, the 6 light per-pixel shader takes awhile to load, multiply that by 100 and it take about 10-15 seconds to load. I tried sectionning some of the code off using #ifdef <> #endif statments and they nearly loaded instant. Also, they seem to take up a ton of memory, more than anything else in the game, so my question is why is this, is this the norm for shaders?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.

Attachments

Login to view attachments
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 30th Jan 2009 19:18
It could be that the shaders texture footprint is a bit big, I think your pushing DBPro to it's limits with this, but it looks incredible!.

I think I would have given up or settled for lightmapping before now, hope you find a way to optimize it.


Health, Ammo, and bacon and eggs!
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 30th Jan 2009 20:07
Quote: "hope you find a way to optimize it."


Me too

Well its running at about 500-600 fps and about 2000 fps when everything is excluded, so performance isn't really the issue. The chunk of memory and the load times for the shaders alone are the problem.

Maybe I could create six shaders, one that has one light the second that has two lights and so on. Since loading a shader with one light is nearly instant and takes up hardly any memory it should work well. All I do is check to see if any objects have more than zero light source and swap out the shader for the correct amount of lights plus one since I need a light for gun fire etc...

Or maybe grid/cell based lighting, so so many lights to a grid and just share the shader between the objects within the grid. This would cut down on the amount of shaders i'd be loading, the only problem is if you have another part of the level within the grid but way above the lower part of the level, you'd have to make a 3d grid/cell system, which isn't a bad idea cause I could use it for culling aswell. Might look into this one.

Note: The image might look odd because I increased its contrast so you can see it, my moniter is really bright so it hard for me to tell what you can see or not.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 30th Jan 2009 21:44
I was thinking of making a WIP out of this, but i'm not sure if it's ready yet. What qualifies as a WIP now days?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 30th Jan 2009 23:01
I am working on an enhanced version of the Evolved's deferred shading, maybe it could help you. I added support for both point and spot lights (each of them in 3 flavours : ambient, normal, normal & specular), and spot lights can cast shadows. It is obviously slower than the simple normal mapping shader you use, but it allows a wider variety of surface shaders without having to recode the light shaders. If you are interested, just tell me, and I'll try to hurry up a bit in order to finish it properly.

Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 30th Jan 2009 23:22 Edited at: 30th Jan 2009 23:23
Thats very generous of you, but no need to hurry on my account

I'm going to try optimizing my method to it's limits to see if it holds any water and report back with my findings. This enhanced shader sounds interesting though, are you going to showcase it when it's done?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Anonymous User
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location:
Posted: 31st Jan 2009 23:15
Just loop through each cell checking the distance between each light and the cell, total the number of lights that the cell needs + 1 and then store that in the level file. Then just use a switch statement for the shader and modify the light code to handle the 5 new shaders. That might speed it up a little bit, but probably only by a few seconds.

???
EdzUp
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 1st Feb 2009 19:01
Admittedly I havent looked at shaders but couldnt you render the shaders around the player rather than everything?

-EdzUp
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Feb 2009 18:46
Anonymous, that was kind of what I was thinking, since all level data is store in the masterfile, it easy to load the correct shader for each cell, it's just the loading of the shaders thats the problem, once there loaded then it's fine.

EdzUp, well I could but i'd like to see lights off in the distance so I can't, also everything I see needs to match the ambient light level and fog distance of the shader so everything would have a shader on it, but that where culling (excluding) comes in.

New demo up soon to see if load time have improved and performance, also added a menu so you can edit the settings.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Feb 2009 20:19
Only just seen the discussion about loading multiple shaders in this thread.

Unless I've misunderstood (quite possible ), if you try to use a single loaded shader copy for, say 5 lights, then every object with 5 lights will have the same shader applied to them - and hence the same 5 light colours, etc. I guess that is not what you want.

If that is your problem then there are ways around that. For example, you can use a texture to supply the extra info per object. The simplest example would be to use a texture to change the light's colour. That way 100 objects could share a single shader and 100 differently coloured lights (because each object can have a different texture). The same idea can be applied to other quantities like light position (with a bit of difficulty perhaps ). The downside with that approach is that the shaders will have to do more work - it may be better to live with the extra one-off loading time that you've reported.

However, I wasn't aware that loading multiple copies of the same shader would have such a performance hit - but then I haven't tested this idea very far.

If you're interested I'll look at this more closely - but it would be handy to have some idea of how many objects, how many lights, how many polys, etc.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Feb 2009 21:09 Edited at: 5th Mar 2009 19:27
Quote: "If that is your problem then there are ways around that. For example, you can use a texture to supply the extra info per object. The simplest example would be to use a texture to change the light's colour. That way 100 objects could share a single shader and 100 differently coloured lights (because each object can have a different texture). The same idea can be applied to other quantities like light position (with a bit of difficulty perhaps ). The downside with that approach is that the shaders will have to do more work - it may be better to live with the extra one-off loading time that you've reported."


I believe you made a shader demo awhile ago that does this if I am correct, but that not the problem. I was seeing if I could simulate how a deffered shader works and noticed that for each light a pixel light shader was loaded. I got the idea to load a 6 light per-pixel shader for each object depending on size, biggest being map segments, smaller objects borrow the shader of the bigger objects closest to it. I then add light soucres in to the world and see what it hits, if there is a hit I find a free light within that objects shader, so I just keep track of how many lights have been applied to that object. Once I have this information then I update the shader with all the light position/range/color and set the light techniques by how many lights that are applied to the object.

Thats the method really, the problem is how load it take to load many per-pixel or now normal mapping shaders. You can do a quick test by seeing how long it takes to load 100 files and watch the amount of memory it takes up. Considering the amount of information that in a shader the amount of memory it takes up see insane by thats a guess cause memory allocation (is that the right word) isn't really my area (yet). As for polys, not alot a tool since each object is only a segment of the level, and lights... well I did a test on 50 lights (though each object has a 6 light limit so some object looked odd) with and interior I put together (just over 500 I think, can't quite remember since some object aren't affected by lights so they wouldn't apply to this) and it ran pretty well, just the load time was high, about 16 seconds. I edited the shader so it only did ambient and it loaded nearly instant.

If you download the demo thats near the top of 1st page you can see it in action, should run ok. If you do, move though the door (turned collision off them so you have this option) and you can see the whole interior.

Cheers for the help btw

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Feb 2009 21:32
Quote: "I edited the shader so it only did ambient and it loaded nearly instant."


That sounds like a clue as to the cause of your problem. My guess is that it has something to do with the extra data that DBPro computes for each object when you apply shaders to them. For example, normal mapping shaders usually need tangents and binormals to be calculated for each object. I believe this is done at load time. You could try turning off that feature and see what happens to your load times. The relevant command flag is briefly described in the latest U7.1 upgrade:

Quote: "LOAD EFFECT

This command will load an FX file.

Syntax
LOAD EFFECT Filename, Effect Number, Texture Flag, DoNotGenerateExtraData
LOAD EFFECT Filename, Effect Number, Texture Flag
Parameters
Filename
String
The FX filename must point to an FX file that is compatible with the DX9 effect framework and would
typically use the extension ".fx".
Effect Number
Integer
The FX can be stored and referred to by a number that identifies it. You can use this number to apply
an effect to an object previously loaded.
Texture Flag
Integer
If the Texture Flag is set to zero, the effect will use the textures already mapped to the model, and a
value of one will discard the current textures and load the textures specified in the FX file. Typically,
effects rely on the specified model and text
DoNotGenerateExtraData
Integer
Set this value to one to avoid generating tangent and binormal data, and set the value to two to
additionally strip out any secondary UV data, sometimes needed to allow a complex shader to create
a valid declaration.
"


Set the DoNotGenerateExtraData flag to one and see what happens. The lighting will probably look strange - but, for the moment, it's the load time that's the issue. Could you report back what happens?

I'll check out your demo in the meantime.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Feb 2009 22:26
Not at my computer at the moment sorry, so i'll be unable to test that but will add it to my list of things to do later. I've recently moved and don't have the net setup yet (soon though), so i'm round my mum on her laptop, which would have a core-attack (see what I did there) if I ran DBP.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Feb 2009 00:51
No rush, I've been dragged away, first for supper, then to watch a film.

As it happens your demo crashes on my PC (no surprises there ) and staggers along on my marginally better laptop. But looks good though.

Will return to this later - tomorrow if I'm still snowed in.

I'll try some simple experimenting of my own if I remember ( ).
qwe
20
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 4th Feb 2009 16:49
the program looks really nice. if you had that system in functions which are easily transferrable, i bet you could sell it and make money, or give it and make lots of happiness it'd be a useful beginning for an FPS type game
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 5th Feb 2009 18:21 Edited at: 5th Feb 2009 18:22
GG, having weird crashes when using U7.1, but I know whats causing it, when it's sorted I will report back.

qwe, Cheers, it works quite well in the way of easy map placement and keeping track of everything very quickly. My plan is to make a game out of this that i've already designed for about a 2 year now (780 page design document, that doesn't include concept art or dialog), but grow on the RPG elements of Fallout 3 to be more like Deus Ex but more handled like a shooter.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.

Login to post a reply

Server time is: 2024-04-19 08:01:37
Your offset time is: 2024-04-19 08:01:37