Go Back   www.tombraiderforums.com > Tomb Raider Modding > Tomb Raider Level Editor > Tutorials and Resources

Thread Tools
Old 09-05-15, 15:41   #1
Level NextGen
Level NextGen's Avatar
Join Date: Mar 2009
Location: France, Paris
Posts: 1,473
Default TRNG - [LOW] Less Objects in World to prevent framerate issue

TRNG - [LOW] Less Objects in World to prevent framerate issue
or the game: spot the differences...

This tutorial will help you to increase the framerate in game - especially on some agging computer - without decreasing the quality of your work on other computers.

LOW Option - the ability for player to increase or lower details in game (in real time):
TRNG allows us to play with statics and make them invisible, then visible. If you manage this with some condition GlobalTrigger and TriggerGroup, you can create a new option that able the player to choose the amount of detail viewable in the level... And so prevent some lagging on aging computers, still letting these players able to see - time by time - how was intended to be the level

Optimizing is the key:
Follow this link to read an useful handbook made by Titak and gathering tips to reduces lagging from other like teme9

;-- Enable LOW Option with F8 keyboard
GlobalTrigger=	21, IGNORE, GT_KEYBOARD_CODE, 66, IGNORE, 125, IGNORE
TriggerGroup=	125, $2000+TGROUP_SINGLE_SHOT_RESUMED, 204, $C, > 						;Remove text from GT22
			     $2000, 189, $xxx, [...], >								;Flipeffects hide statics 
 			     $2000, 345, $7F, $2000, 203, $10B, $2000, 374, $16, $2000, 375, $15 		;Enabled TG127, Print TextonScreen +GT22 -GT21
TriggerGroup=	127, $2000+TGROUP_SINGLE_SHOT_RESUMED, 189, $xxx, $2000, 189, $xxx, [...]			;Flipeffects hide following statics
The GlobalTrigger let the player press F8 Keyboard (66) and activate the TriggerGroup: 125. This last one is made of three different part.

The middle that gathers the flippeffect trigger to make invisible the static: "$2000, 189, $xxx" - 189 is the ID for Hide Static and the "xxx" has to be the number of your statics in hexadecimal, after the "$" symbol. You can get an hexadecimal convertor here, so no need to always export your script trigger.

The third line gather all the setting to print a text on screen - so player is awer he has hit F8 Keyboard. The text printed used the flippeffect: "$2000, 203, $10B" show ExtraNG string 11 (see below) with PARAM_PRINT_TEXT, 1. (Take care to not mistake with PARAM_WTEXT.)
Then we disable this GlobalTrigger:21 and enable the next one:22 with "$2000, 374, $16, $2000, 375, $15".

I also added a trigger to activate an other TriggerGroup:127 "$2000, 345, $7F". In fact, when you have too much flipeffect "Hide Static", the script won't work so well and can even crash. So I advise you to not exceed 70 triggers per TriggerGroup.

And of course the first line (that I deliberated forget) "$2000+TGROUP_SINGLE_SHOT_RESUMED, 204, $C" anticipate the next GlobalTrigger and erase its text that could print over - it prevent text to be unreadable at last. "$C" value is linked to the ExtraNG strings 12 (see below) which has to be clear from screen if still viewable.

;-- Disabled LOW Option with F9 keyboard
TriggerGroup=	126, $2000+TGROUP_SINGLE_SHOT_RESUMED, 204, $B, > 						;Remove text from GT21
			     $2000, 190, $xxx, [...], >								;Flipeffects show statics 
 			     $2000, 345, $80, $2000, 203, $10B, $2000, 374, $16, $2000, 375, $15 		;Enabled TG127, Print TextonScreen +GT22 -GT21
TriggerGroup=	128, $2000+TGROUP_SINGLE_SHOT_RESUMED, 190, $xxx, $2000, 190, $xxx, [...]			;Flipeffects show following statics
Well it's basically the same here, except that the GlobalTrigger is disabled at the beggining of the level with FGT_DISABLED.
Of course in both TriggerGroup enabled, I used TGROUP_SINGLE_SHOT_RESUMED to prevent

;-- Text to print
Here are some script line to show text in game and let know the player when he hit the keyboard (he could do it by accident - so a reminder is not so bad).

Originally Posted by ExtraNG String 11
LOW Option On - Press F9 to disable this option
Originally Posted by ExtraNG String 12
LOW Option Off - Press F8 to enable this option
These ones are related to each GlobalTrigger descripted upper.

Originally Posted by ExtraNG String 13
You can press F8 option to prevent framerate issue. It will enable the LOW Option that decreases high number of detail in scene.
You can trigger a "Flippeffect Text" Print horizontal ExtraNG with PARAM_PRINT_TEXT, 2. Just set this trigger on the first square where Lara start to advise the player of this new option.

Customizable and Advise:
;-- Improve
Of course you could improve the script. Maybe you could use a Switch or Organizer line script to only use one Keyboard. The fact is if you want to only use one keyboard you have to take care player won't hit the keyboard too long time and freeze the game between the two GlobalTrigger.

Though you could use variable to set some more conditions to be checked - especially if you use flipmap or... who's know.
But we only have a limited number of variable

You can also use this setting to render an automic "MIP" option... But as much as I've looked for this - it seems it won't really be possible. More investigation to come

;-- Test & Test
Sometimes it will crash because you type the wrong hexa number (when you write up to 200 of those it happens). So keep calm and delete line by line to spot where it crashes... then trigger by trigger.

You'de better use the ",>" symbole to skip lines as I did.

One good point, is that there's mostly no need to compile level since it's only scripting.

;-- Flipmap

Take care with flipmapping it seems, you could get some "issues". For what I've tested some statics I set invisible in the the first room where already set invisible in the flipmap... but I didn't set those ones - from the flipmap - as invisible in my script.

I also had very few other statics linked to a flipmap being invisible (that they shouldn't) when I wrote in my script both statics (in normal and flipmap room) have to be invisible. It seems object ID from a normal room to a flipmap room can be tricky!

It needs more test from me - but my level had some issues not related to this feature. So that my be the reason why.

NOTA BENE: Still in work! Do not reply here... you can discussed of this on my personal thread or open a new thread in the NGLE Section.
"You nailed it!"

Last edited by Level NextGen; 09-05-15 at 16:48.
Level NextGen is offline   Reply With Quote
Old 09-05-15, 15:51   #2
Level NextGen
Level NextGen's Avatar
Join Date: Mar 2009
Location: France, Paris
Posts: 1,473

Automatic LOW Option:

You are fed up to trigger every flame emitter ON and OFF when you get out and enter a room. Here is a way to do so automatically. Of course it's based on this "LOW option".

All you need is scripting and it can be done with moveable and static. Though you might write lots of lines.

;-- The Script
GlobalTrigger=	31, IGNORE, GT_DISTANCE_FROM_ITEM, 83887547, IGNORE, 160, 161				;From 10blocks Flame1467
TriggerGroup=	160, $5000+TGROUP_SINGLE_SHOT_RESUMED, 2147, $2B							;Trigger
TriggerGroup=	161, $5000+TGROUP_SINGLE_SHOT_RESUMED, 2147, $80E							;Untrigger
So I use a GlobalTrigger with the GT_DISTANCE_FROM_ITEM to trigger and untrigger the Flame Emitter.

The formula has to be set in the Parameter field and work that way
Originally Posted by Doctor TRNG
The new formula to use is:

MoveableIndex + (RealUnitDistance * 8192)

For RealUnitDistance we mean the units used in the game, instead using the number of sectors or clicks.
For example, since one sector = 1024, and one click = 256, if you wish check the distance of two sectors the value will be 2048 and you type it in the formula for Parameter in this way:

ItemIndex + 8192 * 2048

Let say the itemindex = 307, the result will be:

307 + 8192*2048 = 16777523

The max value you can use as distance is 130048, that it is 127 sectors.
TG160 will enable the flame emitter with an Action "Trigger. (Moveable) Activate" when Lara is less than 10 sectors.
And TG161 will kill the flame emitter with an Action Trigger "Enemy. Kill object in Disable emitter way" when Lara is away.

I've tried to set a FGT_SINGLE_SHOT_RESUMED but it doesn't work properly with GT_DISTANCE, so you will have to set in TriggerGroup +TGROUP_SINGLE_SHOT_RESUMED (so your GlobalTrigger won't play indifinetly until the next condition).

;-- Moveable or Static
If you want to do so with a static, it won't be the same as a moveable. You will have to use for :
  • moveables : GT_DISTANCE_FROM_ITEM

The formula is of course the same.

What has been told in the previous part with statics made invisible by player, is now possible in an automatic way when Lara is not near them. If you combine this with a fog you can create smooth render.

;-- Too much objects to do?
If you have too much object to verify and there are near each other. I advise you to use one (centered) as a dummy to trigger and untrigger every one.

Or you could use another dummy invisible item as the condition distance to verify.

Here is an example made by me:
GlobalTrigger=	28, IGNORE, GT_DISTANCE_FROM_ITEM, 41944310, IGNORE, 154, 155				;From 5blocks WaterfallTrapdoor Steams 1270(+3 next to it)
TriggerGroup=	154, $5000+TGROUP_SINGLE_SHOT_RESUMED, 1277, $2B,  $5000, 1272, $2B, $5000, 1270, $2B,   $5000, 1274, $2B 	;Trigger
TriggerGroup=	155, $5000+TGROUP_SINGLE_SHOT_RESUMED, 1277, $80E, $5000, 1272, $80E, $5000, 1270, $80E, $5000, 1274, $80E	;Untrigger
;-- Height distance and other conditions
Of course you can still use the Condition trigger field to check if there are other conditions. It can be useful when you have many rooms next each other but separated with walls.

Like in this example, you would prefere that flame emitter in the next room aren't triggered. So you can either make disabled the GT with FGT_DISABLED and set a Enable GT Trigger when you enter this room or aera.
But wait it can be like the automatic option is finaly useless

So you can use a Condition trigger to check if Lara is in those rooms.
Well I don't really understand how it works for now but I'm sure it links to this trigger - some more test to be done :
Originally Posted by Doctor NGLE
; Set Trigger Type - FLIPEFFECT 298
; Exporting: TRIGGER(0:0) for FLIPEFFECT(298)
; <#> : Variables. Convert the Tomb Room Index to NGLE Room Index in CurrentValue
; <&> : [000] Room0
; (E) :
; Values to add in script command: $2000, 298, $0

You can also use this extra line when you want to only use the GT-Distance in a planar mode : GTD_IGNORE_HEIGHT

Let's hear what Doctor TRNG has to say
Originally Posted by Doctor TRNG
if you wish ignore the different height (Y coordinates) you can add to the formula the constant value GTD_IGNORE_HEIGHT

For example in above example it will become:


A possible reason to use the GTD_IGNORE_HEIGHT mode, is when you wish having a fine precision on whole side of an object, like a column. In this case, if you omit the GTD_IGNORE_HEIGHT value and therefor the compute enclosed also the Y value, when lara is above of some click respect to the columne she will seem like more far from it because there is yet the distance between the y coordinate of Lara and the Y coordinate of column, on the base of the floor.
Differently, if you use the GTD_IGNORE_HEIGHT value the distance will be computed only in planar way.
Remark: when you use the GTD_IGNORE_HEIGHT value you should use also a conditional trigergroup to verify if Lara is in the correct room or in a correct height limit (vertical condition trigger) to avoid that the condition resulted true also when lara is many room over or below the item but only because she is in same x,z position in planar view.

Which Object should I make invisible:
You might ask what had to be set invisible/disabled in large distance. Here are some tips

;-- Semi-Transparent & Magenta
These are the ones that can reduce the framerate of the game. If you have lots of semi-transparent objects, the engine will take more time to compute them.

So you better reduce there numbers with those technic explained.
Same with shiney textures.

;-- Hi-poly
Of course Hi-poly object can reduce

A tip is to use the LOW option as a MIP option (mostly for statics because there's an ANIMATING_MIP script command), instead of just making invisible the object you can replace it by a lower-poly one.
Or make your objects as different parts. Imagine a tree with less leaves, and an "add-on" with more leaves and roots that you can disable in distance

Take care with the limits of objects per room...

;-- Animatings or Statics?
And so Animatings or Statics?

Static! mostly because they take more time to be computed as they have an inner lighting - they do not react to the room lighting.

But you can still do so with animatings that used lots of semi-transparent or shiney textures
"You nailed it!"

Last edited by Level NextGen; 16-05-15 at 16:55.
Level NextGen is offline   Reply With Quote


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT. The time now is 23:18.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.