Solved Layer Parameter Questions

Question that is answered or resolved.

ABK

Well-known member
Ok so in theory i can use bglayer as panel ?

Cause now i cant use background layer as panel cause background layer has own hardcoded speed which is strange at this point since eveyrything else got so customised that background layer is still with autoscroll or without autoscroll but with own hardcoded speed and no control over it.
 
Solution
Wheres the quake thingy switch for bglayer and fglayer?
oh, I can't believe this isn't on the manual yet! I never realized it before and will fix it asap.

The manual contains this information:
fglayer {path} {z} {xratio} {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency} {alpha} {watermode} {amplitude} {wavelength} {wavespeed} {bgspeedratio}

  • This is for setting custom foreground layer in current level.
  • {path} is the location relative to data folder where the graphic is
  • Just like any image used by OpenBoR, fglayers must use paletted images. In 8 bit colourdepth (default), it must use same palette as 'background' (see above). In 16/32 bit, it can use different palette...
is strange at this point since eveyrything else got so customised that background layer is still with autoscroll or without autoscroll but with own hardcoded speed and no control over it.
I don't think so. Nothing can go beyond the Background, no matter what Z position you give to a fglayer, as the Background is the very first thing to be read by the engine code, so everything will be displayed on top of it. So there isn't much need of having that granular control, because you can use fglayer for that.

Ok so in theory i can use bglayer as panel ?
you would still need a panel file (which could be transparent) just for the engine to get how wide your stage is.
But yeah, you can use fglayer (and not bglayer) for pretty much everything. I use it for some stages.

By default, background has a xratio of 0.5 and a frontpanel has a xratio of 1.5
 
Wheres the quake thingy switch for bglayer and fglayer?
oh, I can't believe this isn't on the manual yet! I never realized it before and will fix it asap.

The manual contains this information:
fglayer {path} {z} {xratio} {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency} {alpha} {watermode} {amplitude} {wavelength} {wavespeed} {bgspeedratio}

  • This is for setting custom foreground layer in current level.
  • {path} is the location relative to data folder where the graphic is
  • Just like any image used by OpenBoR, fglayers must use paletted images. In 8 bit colourdepth (default), it must use same palette as 'background' (see above). In 16/32 bit, it can use different palette
  • Beware though, if bglayers use different palette than background, 'palette' command (see below) won't work
  • {z} sets location of the layer. Give positive value to make it closer to screen or negative value to make it farther from screen.
  • Other parameters ( {xratio}, {zratio}, {xposition}, {zposition}, {xspacing}, {zspacing}, {xrepeat}, {zrepeat}, {transparency}, {alpha} and {bgspeedratio} ) have same effect like in 'bglayer' above.
  • Currently {watermode}, {amplitude}, {wavelength} and {wavespeed} aren't working. Still, you need to fill them if you want to set {bgspeedratio}.

But there are some errors on it:
  • {watermode}, {amplitude}, {wavelength} and {wavespeed} ARE WORKING. for fglayers. You can see they working on this video bellow - notice that I am using two different fglayers to simulate water, and I've changed their settings to display how different they can be (the bottom one is moving slower and with a smaller amplitude). This is impossible to do with the native Water:

  • After {bgspeedratio} there are two additional settings: {quake} {neon}

    {quake}
    is a boolean setting. 0 (default) will make the layer to not shake when the screen a quake happens. 1 will make it to shake.

    {neon} is a path which point to the image to be used as a neon (uses 'pallete cycling': certain colors slowy change to different colors. To be more specific, colors 128 through 135 in the pallete will be cycled by two steps three times each second.)
Honestly, I can't get the neon setting on fglayers to work yet.

background layer is still with autoscroll or without autoscroll but with own hardcoded speed and no control over it.
Actually, according to the manual (which is new to me too) you can control it. I am making some tests and will report in few minutes
edit: ok, I made some tests and I have good news: Yes, you can control the background scroll xratio.
And I've discovered that, like fglayer, there are some undocumented settings aswell.

background {path} {xratio} {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency} {alpha}

but after alpha, we have all the same settings for fglayers: {alpha} {watermode} {amplitude} {wavelength} {wavespeed} {bgspeedratio}

So the complete settings would be:
background {path} {xratio} {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency} {alpha} {quake} {neon}

Here is a quick video showing all those settings in game:

I haven't recorded in the video above, but you can combine bgspeed and water mode for backgrounds too :)

I will update the manual asap
 
Last edited:
Solution
Honestly, I can't get the neon setting on fglayers to work yet.

@O Ilusionista,

That's because neon works by cycling the colors in the global palette. So for neon to work on an fglayer, it must be using the global palette (as in, using same palette as background). There's no switch for this, it's fully automated. If the fglayer and background palettes match exactly, then fglayer shares the background palette. This allows neon cycling and will cause the fglayer's palette to swap along with the background's. If they don't match, the fglayer gets its own, and neon/global palette swapping have no effect.

Here's an example using a lot of fglayers with neon and palette swapping. The "Metal Mesh Deathmatch" is an entity with scripted palette control (in hindsight a normal animation would have been a lot simpler), but the city lights are done with native neon function, and the day-to-night is a timed global palette swap:


These days I'd just prefer to use subscreens to get the same effects, but the old school stuff is there if you want it. :)

DC
 
Last edited:
That's because neon works by cycling the colors in the global palette. So for neon to work on an fglayer, it must be using the global palette (as in, using same palette as background).
ahhh I totally forgot about this, thanks for the info.

These days I'd just prefer to use subscreens to get the same effects, but the old school stuff is there if you want it.
Yeah there are some oldschool stuff that simple works, like this :)
 
For neon to work, the fglayer must be using the global palette (as in, using same palette as background). There's no switch for this, it's fully automated. If the fglayer and background palettes match exactly, then fglayer shares the background palette. If they don't, the fglayer gets its own.
'nother thing that has to be added to the manual

@O Ilusionista & @bWWd

that is why i was still using bglayers, on the older version of the forum i had found those extra settings except the quake thing,
on the forest level i wanted to shift the graphics of the panel to the right without editing the panel , but found that bglayers could do the job, but at the time i could not get the gblayer to behave exactly like a panel layer (the quake).
later on i did, but it was too late , i had edited the panel already.

Here is my idiot proof suggestion tho:
i made a tool in excel/Apache calc for backgrounds/fg/bg layers, (at the time my machine could not run Obeditor)

its kinda like this:

bglayer





















path




















(file
path)
Xratio


















how
fast
it
scrolls
Yratio

















how
fast
it
scrolls
Xposition















determine
where the
top left
corner of
the first
layer will
be
Zposition















determine
where the
top left
corner of
the first
layer will
be


xspacing















determine
how much
blank space
there will be
between
repeated
layers.
zspacing













determine
how much
blank space
there will
be between
repeated
layers.
Xrepeat


-
how many
times the
image will
repeat.
Setting 0
will make
layer not
drawn at
all (it will
become
palette
holder).
Setting -1
will make it
repeat
forever



Zrepeat




-
how many
times the
image will
repeat.
Setting 0
will make
layer not
drawn at
all (it will
become
palette
holder).
Setting -1
will make it
repeat
forever


Transparency



















- use 1 for {transparency}
to have your transparency
color not
appear -
In 16/32
bit mode,
pure black
color will
be used
instead
Alpha
















display the image using alpha transparency. It works just like for entities. Possible values are 0 to 6. Don't use it for background too
Watermode



0 = No water effect for this bglayer
1 = Water effect for this bglayer is on
3 = Mode 7 effect

if
watermode
3
amplitude
=
beginsize

wavelenght
=
endsize

wavespeed
=
perspective
Amplitude

















determines the amplitude of sine wave for water effect.

Only
apply if watermode is not 3
Wavelenght






















determines the moving speed of sine wave. Only apply if watermode is not 3
wavespeed




























bgspeedratio

determines the moving ratio of this bglayer relative to main background. Defaults to 0 (no movement)


















quake
























1 or
0 to
make it
quake like panel
neon



















For neon
to work,
the fglayer must be using the global palette
(as in,
using same palette as background).
beginsize









endsize









Perspective - defines z depth effect it should have
0 =
No effect (default)
1 = Perspective & tile
2 = Perspective & stretch









pathvaluesetc

the 3rd row gets filled with the path and values the user needs, and then you copy the whole row and paste to your lvel.txt

i dont know if the manual website could feature a Table cell columns type thing too, so users just punch in the numbers and such and copy the row values to their level.txt file...

looks much better on calc or excel

anyway , someone should tell @Piccolo ,
his modders tool might need an update
 
I advice you to use fglayers instead, because they have Z depth control, while bglayers doesn't.
At this point, i am wondering if by any chance bglayers might have some hidden thing that fglayers might not be able to do.

i wonder if they will be deprecated on the next release (would certainly break a lot of modules tho)

while we are at this, is there any visual sample of this:
panel {norm} {neon} {scrn}


  • {norm}, {neon}, and {scrn} are paths which point to the normal, neon, and screen graphics for a panel. {neon} and {scrn} are optional fields. If you aren't using them, put the word 'none' in their place.
the scrn thing
 
At this point, i am wondering if by any chance bglayers might have some hidden thing that fglayers might not be able to do.

We've already explained this at least a dozen times over and then some. Internally, layers are layers. The newer versions (fglayer) just happen to have an extra parameter they can read (Z layer adjust) the others don't. That's it.

i wonder if they will be deprecated on the next release (would certainly break a lot of modules tho)

There's two parts to this. First, yes, eventually, I do plan on depreciating duplicate functionally because it creates a ton of code cruft, confusion (like, oh IDK, THIS THREAD), and maintenance headaches. IDGAF about older modules, because I'm not "breaking" anything. OpenBOR is an engine. it's not a console. You pack the engine and the game together and they run. It doesn't matter one whit if a newer version comes along that won't. Yeah, I know about the online players, retropie port, etc. that treat it like a console, but that's their mistake for ignoring my no forks policy, and very much not my problem.

However, it will be a long time yet and I'll provide documentation for upgrades.

DC
 
Yeah there are some oldschool stuff that simple works, like this :)
About cycling level assets I have a script that may help.

This is the main function. The logic is simple, the layer ID will be changed with a defined delay, use the frameDelay to adjust the time between frames and the cycleDelay to adjust the time between each cycle.
C:
void main()
{
    cycleSprite("bglayer", 0, 4, 12, 400);
    cycleSprite("bglayer", 7, 12, 12, 400);
    repeatSample("data/sounds/sor1_beach.wav", "sound", 2000);
}

void cycleSprite(void type, int startIndex, int endIndex, float frameDelay, float cycleDelay)
{//Apply simple sprite cycle effects to avoid creating new entities
    float timeCurrent    = openborvariant("elapsed_time");
    float timeCounter    = getlocalvar("timeCounter"+type+startIndex);
    int levelCurrent    = openborvariant("current_level");
    int levelPrevious    = getlocalvar("levelPrevious");
    int frameCurrent    = getlocalvar("frameCurrent"+type+startIndex);
    int frameNext        = getlocalvar("frameNext"+type+startIndex);
    int frameStart        = getlocalvar("frameStart"+type+startIndex);

    //CLEAR ALL LOCAL VARIABLES WHEN THE LEVEL CHANGES
    if(levelCurrent != levelPrevious){clearlocalvar();setlocalvar("levelPrevious", levelCurrent);}
 
    //START ALL VARIABLES
    if(timeCounter == NULL()){setlocalvar("timeCounter"+type+startIndex, timeCurrent+frameDelay);}
    if(frameCurrent == NULL()){setlocalvar("frameCurrent"+type+startIndex, endIndex);}
    if(frameNext == NULL()){setlocalvar("frameNext"+type+startIndex, startIndex);}
    if(frameStart == NULL()){setlocalvar("frameStart"+type+startIndex, startIndex);}

    //DISABLE ALL LAYERS EXCEPT FOR THE LAST, WHEN THE SCRIPT STARTS
    while(frameStart < endIndex-1){
        frameStart = getlocalvar("frameStart"+type+startIndex);

        changelayerproperty(type, frameStart, "enabled", 0);
        setlocalvar("frameStart"+type+startIndex, frameStart+1);
    }
 
    //DELAY REACHED THE LIMIT?? EXECUTE ALL TASKS
    if(timeCurrent > timeCounter){

        //DEFINE THE CURRENT FRAME
        if(frameCurrent < endIndex){
            setlocalvar("frameCurrent"+type+startIndex, frameCurrent+1);
            setlocalvar("timeCounter"+type+startIndex, timeCurrent+frameDelay);
        }
        else
        {
            if(cycleDelay != NULL()){setlocalvar("timeCounter"+type+startIndex, timeCurrent+frameDelay+cycleDelay);}
            setlocalvar("frameCurrent"+type+startIndex, startIndex);
        }

        //DEFINE THE NEXT FRAME
        if(frameNext < endIndex){
            setlocalvar("frameNext"+type+startIndex, frameNext+1);
            setlocalvar("timeCounter"+type+startIndex, timeCurrent+frameDelay);
        }
        else
        {
            if(cycleDelay != NULL()){setlocalvar("timeCounter"+type+startIndex, timeCurrent+frameDelay+cycleDelay);}
            setlocalvar("frameNext"+type+startIndex, startIndex);
        }

        //CHANGE LAYERS
        changelayerproperty(type, frameCurrent, "enabled", 0);
        changelayerproperty(type, frameNext, "enabled", 1);
    }
}

Must be called in the level update script event inside the level file, layers (bg/fg) need to be named and organized in the correct order to work properly.
C:
background        data/bgs/_empty.png
bglayer            data/bgs/sor1/st3a/bg00.png        0.6 0 0 0 0 0 -1 1 1 0 0 0 0 0 0 0 #ID 0
bglayer            data/bgs/sor1/st3a/bg01.png        0.6 0 0 0 0 0 -1 1 1 0 0 0 0 0 0 0
bglayer            data/bgs/sor1/st3a/bg02.png        0.6 0 0 0 0 0 -1 1 1 0 0 0 0 0 0 0
bglayer            data/bgs/sor1/st3a/bg03.png        0.6 0 0 0 0 0 -1 1 1 0 0 0 0 0 0 0
bglayer            data/bgs/sor1/st3a/bg00.png        0.6 0 0 0 0 0 -1 1 1 0 0 0 0 0 0 0 #ID 4
bglayer            data/bgs/sor1/st3a/bg04.png        0.2 0 0 0 0 0 -1 1 1 0 3 0.1 2 0 0
bglayer            data/bgs/sor1/st3a/bg05.png        0.4 0 0 0 0 0 -1 1 1 0 0 0 0 0 0 0
bglayer            data/bgs/sor1/st3a/bg06.png        0.4 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 #ID 7
bglayer            data/bgs/sor1/st3a/bg07.png        0.4 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0
bglayer            data/bgs/sor1/st3a/bg08.png        0.4 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0
bglayer            data/bgs/sor1/st3a/bg09.png        0.4 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0
bglayer            data/bgs/sor1/st3a/bg10.png        0.4 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0
bglayer            data/bgs/sor1/st3a/bg06.png        0.4 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 #ID 12
bglayer            data/bgs/sor1/st3a/bg11.png        0.05 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1
bglayer            data/bgs/sor1/st3a/bg12.png        0 0 0 0 0 0 -1 1 1 0 1 1 20 0.5
panel            data/bgs/sor1/st3a/_map.png        none    none
fglayer            data/bgs/sor1/st3a/_cop.png        -200 0 0 -240 0 0 0 1 1 1 0 0 0 0 0 0 1 #COP CALL
order            a
settime            99
stagenumber     3
spawn1            60 40 300
spawn2            90 60 300
spawn3            120 40 300
spawn4            150 60 300
updatescript    data/scripts/updatelevel/sor1_st3a.c

@danno Buddy, my post may derail the topic but I don't know how to split it 😅
EDIT: I moved to DC's topic, but I couldn't delete my other post.
 
@Kratus
wait, isn't this very much like DC's animated fglayers?

which reminds me, how could we apply this type of cycling trick to deco entities that have the type of trick used in rocket viper?

since OpenBOR does not have deltas to create vertical fglayer distortions like Mugen, that "cycling" trick has to be applied to walls created via frame/scroll syncronization scripting, in order to animate them...
 
About cycling level assets I have a script that may help.
Ah thanks, its like the method DC had posted some time ago.

Personally, I prefer to use an entity for this, especially because I can reuse the same entity for several animations in the same scenario and, if I used this method, it would be chaos.

In this video, I animate all the layers (with the exception of the capsules, which are obstacles) using the same entity, just changing its spawn animation.

Not to mention the granular (and much easier) control that I have using entities (like being able to use sounds, etc.) and I have cases where the scene's animations react to certain enemies.

But its always nice to learn new tricks :)
 
Says who?
I am aware that there is a method using screens, but wouldn't they be only limited to background or foreground stuff?

but still, for big "dynamic" crates (visual side textures), as components of doorways, and i can even go as far enties like fountains or cars or statues that have dynamic platforms shapes , by changing their platform values between frame by frame, ( or have a "clipping" entities or Boxels instead for the Physics instead)
deco entities have to be used, but how do you animate them if their frames are already destined to the scroll sync
 
Back
Top Bottom