LOD issue

#1
Okay, I have come across a minor issue with the following code:
--------------------------------------------------------------

LIGHT_NAV_beta_MasterScale_1 label BGLCODE

IFIN1 LOD_01, 033Bh, 0,199
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00009Ch, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_01 LABEL WORD
IFIN1 LOD_02, 033Bh, 200,299
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00008Bh, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_02 LABEL WORD
IFIN1 LOD_03, 033Bh, 300,399
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00007Bh, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_03 LABEL WORD
IFIN1 LOD_04, 033Bh, 400, 499
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00006Ah, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_04 LABEL WORD
IFIN1 LOD_05, 033Bh, 500, 599
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF000059h, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_05 LABEL WORD
IFIN1 LOD_06, 033Bh, 600, 699
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF000048h, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_06 LABEL WORD
;BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF000038h, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)

LOD_CONTINUE LABEL WORD
BGL_RETURN

bgl_riff_end_LIGHT_NAV_beta label BGLCODE

------------------------------------------------------------------------

It works great visually. The issue is that when there is an airport full of these lights (about 3000), the frame rate drops a minimum of 50% and get worse the further away you get from the airport. Which is VERY odd.
I am wondering if the coding is causing the issue or is there something in FS9 that causes all the lights to be rendered even with an LOD range.

Thanx in advance.

Sean E.
 

rhumbaflappy

Moderator
Staff member
Resource contributor
#2
3000!

Ouch! How did you place all of them?

Are they individually placed by XML code?

Does the FPS recover when you go beyond the 699 meter limit of all the lights?

Also, does each light have a bounding box, and what is the size of that box?

The actual code would help... both the MDL's ASM and the placement XML.

FPS gets determined by what is in the viewport. For example, if a city's autogen is causing an FPS drop, going inside the city may have better FPS than viewing it from a distance, as more objects clutter the viewport.

Similarly, zooming in to such a scene will actually increase the FPS, while zooming out will decrease the FPS... as the outward zoom will include more actual objects.

So, at a distance from your airport, the lights should cause more FPS reduction than if your airplane was among the lights.

The NAV lights are actually an effect, which are sprite renderings, as I recall. DirectX may have an issue with large numbers of sprites displayed. Self-illuminated balls would not be sprites, and might make FPS a bit better.

Dick
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#3
Hi Sean,

The code looks correct to me.

But I remember that when I placed about 100 lightpoles in my scenery (having about 600 LIGHT_LAND in total) the framerate was also halfed. This was tested with the Fs2002 gamepack and all lights were placed as API macro with FsRegen (with optimal v1 and v2 etc). So from that I concluded that using too much lights is just not a good idea :D.
 
#4
Okay, well here is the entire asm file:
----------------------------------------------------------------------------

db 'R','I','F','F' ; RIFF file identifier
dd bgl_data_end - $ - 4 ; size of RIFF data
db 'M','D','L','9' ; file identifire (FS9 model)

db 'M','D','L','H'
dd visual_model_header_end - $ - 4
dd visual_model_header_end - $ - 4
dd 0
dd 0
dd 2
dd 0
dd 0
dd 156
db 'F','S','8','0'
dd 2304
visual_model_header_end label dword

db 'I','S','F','T'
dd ver_end - $ - 4
db "BGLC_9",0
ver_end label word

bounding_box_riff_start label word
db 'B','B','O','X'
dd bounding_box_riff_end - $ - 4
real4 -100.000, -100.000, -100.000
real4 100.000, 100.000, 100.000
bounding_box_riff_end label word


model_outside label BGLCODE
model_shadow label BGLCODE
model_inside label BGLCODE
exterior_riff_start_0 label BGLCODE
db 'E','X','T','E'
dd exterior_riff_end_0 - $ - 4
LOD_0L label BGLCODE

LIGHT_NAV_beta_top label BGLCODE

bgl_riff_start_LIGHT_NAV_beta label BGLCODE
db 'B','G','L',' '
dd bgl_riff_end_LIGHT_NAV_beta - $ - 4
LOD_0_LIGHT_NAV_beta label BGLCODE


; Alpha
LIGHT_NAV_beta_Alpha label BGLCODE
BGL_CALL_32 LIGHT_NAV_beta_MasterScale_1 ; Node 1 - MasterScale
BGL_END
BGL_RETURN


LIGHT_NAV_beta_MasterScale_1 label BGLCODE

IFIN1 LOD_01, 033Bh, 0,199
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00009Ch, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_01 LABEL WORD
IFIN1 LOD_02, 033Bh, 200,299
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00008Bh, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_02 LABEL WORD
IFIN1 LOD_03, 033Bh, 300,399
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00007Bh, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_03 LABEL WORD
IFIN1 LOD_04, 033Bh, 400, 499
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00006Ah, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_04 LABEL WORD
IFIN1 LOD_05, 033Bh, 500, 599
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF000059h, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_05 LABEL WORD
IFIN1 LOD_06, 033Bh, 600, 699
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF000048h, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_06 LABEL WORD
;BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF000038h, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)

LOD_CONTINUE LABEL WORD
BGL_RETURN


bgl_riff_end_LIGHT_NAV_beta label BGLCODE
exterior_riff_end_0 label BGLCODE


shadow_riff_start_0 label BGLCODE
db 'S','H','A','D'
dd shadow_riff_end_0 - $ - 4
SHADOW_0L label BGLCODE

Kill_Shadow_top label BGLCODE
bgl_riff_start_Kill_Shadow label BGLCODE
db 'B','G','L',' '
dd bgl_riff_end_Kill_Shadow - $ - 4

LOD_0_Kill_Shadow label BGLCODE
BGL_END
BGL_RETURN

bgl_riff_end_Kill_Shadow label BGLCODE
shadow_riff_end_0 label BGLCODE


bgl_data_end label BGLCODE

---------------------------------------------------------------------------

You REALLY don't want to see the entire XML file. It is 1.49 meg big by itself. But here is a section of the code. Each light is coded exactly the same.

----------------------------------------------------------------------------

<SceneryObject
lat = "39.321945337076"
lon = "-94.720807523258"
alt = "0.0"
altitudeIsAgl = "TRUE"
pitch = "0.0"
bank = "0.0"
heading = "0.0"
imageComplexity = "VERY_SPARSE">
<LibraryObject
name = "6E25E4E34E2DA841070ABBFED8DADAE5" scale = "1.00"/>
</SceneryObject>

---------------------------------------------------------------------------

As you can see, I am using a library object.

Now, I do agree that 3000 lights might be a bit much for flight sim to handle. Thinking as a computer, it has to run through the code for every single light for every movement and that is a LOT of calculations.

I am continuing to work with the code and the program to see if I can pinpoint the issue and resolve it.

Thanx you guys for the input and ideas.

Sean E.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#5
Hi Sean,

Two things:

  1. The bounding box seems very big if it only contains one light, 100x100x100 meter is probably not the size of your light
  2. You could eliminate the BGL_CALL_32 command at the start of the BGL section of you moved the BGL_RETURN and BGL_END behind your lights and placed the lights code directly into the section. I think this would be faster for the scenery engine to process.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#6
Another idea. Have you tried to use less LOD levels? When you are far away now it will have to do all distance checks. Doing this for 3000 lights might very well have a worse influence on the framerate then just drawing the lights :).

So maybe you could use only 1 or 2 LOD levels?
 
#7
Okay, I made the suggested changes by Arno. It follows:
----------------------------------------------------------------------------

db 'R','I','F','F' ; RIFF file identifier
dd bgl_data_end - $ - 4 ; size of RIFF data
db 'M','D','L','9' ; file identifire (FS9 model)

db 'M','D','L','H'
dd visual_model_header_end - $ - 4
dd visual_model_header_end - $ - 4
dd 0
dd 0
dd 2
dd 0
dd 0
dd 156
db 'F','S','8','0'
dd 2304
visual_model_header_end label dword

db 'I','S','F','T'
dd ver_end - $ - 4
db "BGLC_9",0
ver_end label word

bounding_box_riff_start label word
db 'B','B','O','X'
dd bounding_box_riff_end - $ - 4
real4 -1.000, -1.000, -1.000
real4 1.000, 1.000, 1.000
bounding_box_riff_end label word


model_outside label BGLCODE
model_shadow label BGLCODE
model_inside label BGLCODE
exterior_riff_start_0 label BGLCODE
db 'E','X','T','E'
dd exterior_riff_end_0 - $ - 4
LOD_0L label BGLCODE

LIGHT_NAV_beta_top label BGLCODE

bgl_riff_start_LIGHT_NAV_beta label BGLCODE
db 'B','G','L',' '
dd bgl_riff_end_LIGHT_NAV_beta - $ - 4
LOD_0_LIGHT_NAV_beta label BGLCODE


; Alpha
LIGHT_NAV_beta_Alpha label BGLCODE


IFIN1 LOD_01, 033Bh, 0,199
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00009Ch, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_01 LABEL WORD
IFIN1 LOD_02, 033Bh, 200,299
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00008Bh, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_02 LABEL WORD
IFIN1 LOD_03, 033Bh, 300,399
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00007Bh, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_03 LABEL WORD
IFIN1 LOD_04, 033Bh, 400, 700
BGL_LIGHT LIGHT_NAV, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0FF00006Ah, 0.000000, 0.000000, 0.000000 ; Color is AB AB AB (rgb hex)
JUMP LOD_CONTINUE
LOD_04 LABEL WORD

LOD_CONTINUE LABEL WORD

BGL_END
BGL_RETURN


bgl_riff_end_LIGHT_NAV_beta label BGLCODE
exterior_riff_end_0 label BGLCODE


shadow_riff_start_0 label BGLCODE
db 'S','H','A','D'
dd shadow_riff_end_0 - $ - 4
SHADOW_0L label BGLCODE

Kill_Shadow_top label BGLCODE
bgl_riff_start_Kill_Shadow label BGLCODE
db 'B','G','L',' '
dd bgl_riff_end_Kill_Shadow - $ - 4

LOD_0_Kill_Shadow label BGLCODE
BGL_END
BGL_RETURN

bgl_riff_end_Kill_Shadow label BGLCODE
shadow_riff_end_0 label BGLCODE


bgl_data_end label BGLCODE

--------------------------------------------------------------------------

It compiles fine, but I am not getting any lights showing. This is all still very new to me. Even though I can program in 9 different languages, Assembly Language is VERY odd and I am still learning the syntax structure.

Thanx for the help.

Sean E.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#8
Hi Sean,

The looks ok, so maybe the bounding box is too small now? Normally it would be the size of your objects, but I have no idea what size a light point has. Maybe you can try to vary that a bit and see if it helps.

When they are not showing now, is the framerate better or still that bad?
 
Top