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 / Milking that extra bit of speed

Author
Message
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 8th Jan 2012 09:42
Hi all,

A lot of you probably know the project that this is referring to, since I never shut up about it, but I wanted to know any particular little tricks that people may know of to milk that extra bit of speed out of a project when using shaders and advanced lighting.

Currently, I'm making use of:

- frustrum culling
- hiding lights when not visible
- limiting shadows
- limiting the number of objects being used

Does anyone know of any other little tricks to give it just that little bit of extra sharpness?

I'd just like to note here that I'm only referring to use of SHADERS and ADVANCED LIGHTING here, as my game runs beautifully when advanced lighting is turned off...


WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 8th Jan 2012 09:47
Could you not fake bake some lightmaps into some scenes and objects? Some objects if they're always facing a certain direction could have the lighmap built into the object. And maybe swap some of the shaders for other objects that do a similar effect. I'd have to see some shader effects to see what alternatives there are though first.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 8th Jan 2012 10:06
Unfortunately, the game is procedurally generated, so baking can't happen. I do, however, pre-bake the lighting effects into the objects when the level loads, but then things change when enemies move past objects, casting shadows and making them have to be updated

I'm just using the Evolved Advanced Lighting system.


WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 8th Jan 2012 10:28
One thing I do need to eventually look into is the lightmapping at run-time because I'm heavy on procedurally generated levels too. Unfortunately, I haven't got any of those 'paid' for extras.

Decals could be used for some shadows maybe?

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 8th Jan 2012 10:29
Maybe, but it'd be tricky...


Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 8th Jan 2012 11:53
The DarkLights package features lightmapping on a seperate thread, so the game could continue as the lightmapper works in the background; but the process is generally slow; especially for landscapes.

Having the world split up in small segments gives you more freedom to prioritize, but if the world already features large objects & limbs then that will be a pain.

To complement shadow and lighting; having the textures created with low contrast and having a low ambience setting can be a complement of any real-time lighting environment; after all, the textures should only be textures, not light sources (unless static lightmapping was optional)

CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 8th Jan 2012 11:57
How about lowering the quality of shadows... Does anyone know how to do that with Evolved's advanced lighting? Currently they're high stencil, but if they were blurry, that might add speed...


cyril
18
Years of Service
User Offline
Joined: 6th Aug 2007
Location: 7 miles away from big ben
Posted: 8th Jan 2012 19:23
If I remember correctly Malevelence is gird based so maybe you could uses the static portal system in DarkBasic Pro, and are found in the Game Fx section of the help files. However am highly doubtfully whether it works in combination with Shaders (I haven't tested it with shaders yet), its the same system that the FPSC uses for culling, and the portal planes are in 100 unit intervals from world origin in all direction.

While this system can greatly speed up indoor levels, open-space outdoor levels tend to suffer as the need to attempt a culling calculation is greatly reduce, but you'll have no control over it if you use it. Alternatively you could code a portal culling system to meet your needs.
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 9th Jan 2012 06:12
Quote: "lowering the quality of shadows... Does anyone know how to do that with Evolved's advanced lighting?"
In the AdvancedLighting_SetUp() function, look for the comment that says "Directional light Shadow Map". Just below that, look for the set camera to image command, the "ImgScreenSizeX" and "ImgScreenSizeY" variables are used to define the directional shadowmap's size.

Quote: "Currently they're high stencil"
They aren't stencil shadows, Advanced lighting uses shadow mapping.
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 10th Jan 2012 01:04
@revenant - By stencil I was only referring to their appearance: As in that they are very crisp and clean looking. I also worked out that increasing the shadow size number helped make them fuzzy. Would reducing the shadow map size like you said effect the speed much do you think?

@cyril - The engine is sort of using it's own portal system. Since it's grid-based, I have been individually hiding and showing grid squares as they're required to minimise the number of objects in the scene. I don't think that's where the slowdown is happening though. I think it's in my use of the advanced lighting.


revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 10th Jan 2012 02:37
Quote: "Would reducing the shadow map size like you said effect the speed much do you think?"
It will make a difference, but probably not as much as you are hoping for.

Advanced lighting's directional lighting shader has 4 different "shadow quality modes" which can be used by calling the DirectionalLight_Set_Shadows(Shadow as integer) function. 0=no shadows and 4=highest quality. Each "mode" uses a different number of shadowmap samples which effects the shadow's "smoothness" (as well as the effect's performance). To be sure that it is the shadows which are slowing you down, you should try disabling the directional light's shadows altogether.

You could also try to decrease the directional light's shadow range using DirectionalLight_Set_Range(Range as float).

In my project I found that the terrain's polycount can have a huge impact on performance (though I am using an extremely old, heavily modified version of Advanced Lighting).
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 10th Jan 2012 03:17
Yeah, my models are quite low poly. No more than 300 poly's (except enemies, but I've put in the option to disable enemy shadows)

Perhaps I should just give in and put in an option to disable shadows altogether... Almost defeats the purpose of having advanced lighting though


revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 10th Jan 2012 09:01
What models? I think you somehow misread, I am not talking about the polycounts of anything except the terrain. It is completely possible to get your game running smoothly with full shadows using advanced lighting (click my web button).

Quote: "Perhaps I should just give in and put in an option to disable shadows altogether"
You definitely should add the option to disable shadows, just because it looks cool doesn't mean everyone's graphics card can handle it.
James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 10th Jan 2012 13:04
Having breifly read this thread I thought I would throw my 2 pennies worth in - some obvious ones and some are obviously trade offs - reduce resolution, increase terrain scale/reduce draw distance - too many triangles as per revenant; change the object masks - example, if you have a tree that is nowhere near water, it need not be rendered in relation to water ie refract/reflect, likewise beyond a certain distance an object that does require to be seen in a reflection/through refraction up close, no longer requires it so its mask should be changed or swap it out for an object thats the same that isnt included in the reflect/refract process. Objects outside the frustrum that require a shadow rendering need not be visible to all cameras - even look at using lower polly models where possible that are masked just to show a shadow, ground litter need never use scatter cam so mask there could be changed, change shadow cams view distance(directional light as per revenant) though iirc there is an issue of objects popping in/out of scene when different cameras have different view distances - worth relooking at perhaps
another thing to consider regarding shadows outside the frustrum - when the sun/moon is nearer to the horizon shadows are considerably longer - perhaps look at limiting that angle(can still reposition sun/moon correctly, just the light position/angle need be limited) so that you dont have to render objects from outside the visible shadow range due to the length of the afore mentioned shadows - this should help reduce the number of objects needed outside the frustrum for shadows. Also once an object is well and truly outside said range it no longer needs a shadow so swap out for an object not using shadows that is the same, or change the mask for it
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 14th Jan 2012 10:03
Thanks James. The problem that I'm having is with indoor environments.

@Rev - Sorry :S I misread. Never noticed your channel before. Some AMAZING stuff in there. It's a shame you don't live in Brisbane Aus, otherwise I'd definitely cook you dinner and go through some source code with you!


Login to post a reply

Server time is: 2026-07-09 17:19:55
Your offset time is: 2026-07-09 17:19:55