Separating Layers (Like in the editor)

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Separating Layers (Like in the editor)

Post by sheamkennedy »

I was wondering if there is an easy way to code the separation of layers in-game?

I noticed the new feature in the editor by which the layers can be separated from eachother at a given depth. To me this looks absolutely beautiful if things are layered nicely. It gives me all sorts of visual ideas about how underlying layers can be concealed and revealed from the top most layers and great visual effects could be pulled off if done in-game. But is there any way to do this? I suppose this would require the NPC/Hero Layer also to be bound to a specified layer so that they align properly while this effect is being carried out. Perhaps this is not possible, I'm just curious because I'd love to play around with it.

With this in mind I also noticed the editor seems to be capable of selective grey-scaling during this process. Is it possible to selectively greyscale or apply colour modifications in-game? I can only think of a few uses for this but it's interesting nonetheless.
Last edited by sheamkennedy on Fri Jul 13, 2018 7:02 am, edited 1 time in total.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
kylekrack
Liquid Metal Slime
Posts: 1240
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

First of all, there's a command to grayscale the master palette, or a section of it. http://hamsterrepublic.com/ohrrpgce/doc ... alepalette

Call that, and then call "update palette" and it'll work. I'm not sure how to get back to the original palette. Must be reset palette. But you can also use the other commands in that section of the dictionary to change the colors of the master palette while playing the game. People have used this to do things like day/night cycles where the game gets darker/redder/etc.

I'm not sure if you can move the map layers, or if it's safe to do so, but you could go ahead and try. http://hamsterrepublic.com/ohrrpgce/doc ... ookupslice

Look at the slice special codes here. You'll want to do something like set a variable to "lookup slice(sl:map layer 0)" and then move its y value up or down.
My pronouns are they/them
Ps. I love my wife
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

kylekrack wrote:First of all, there's a command to grayscale the master palette, or a section of it. http://hamsterrepublic.com/ohrrpgce/doc ... alepalette
I'm aware that the palette can be greyscaled with code. I'm wondering how the editor seems to achieve simultaneously using the original master palette in addition to a greyscaled version of it and if it's possible to have both a greyscale palette and a full colour master palette occurring this way in-game.

As for the code you provided for moving an individual layer, I'll try it out thanks!
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
kylekrack
Liquid Metal Slime
Posts: 1240
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

You can only use a maximum of 256 colors in your game. You can't use multiple master palettes simultaneously. You can, however, partition a segment of your master palette to be grayscaled.
My pronouns are they/them
Ps. I love my wife
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

kylekrack wrote:You can only use a maximum of 256 colors in your game. You can't use multiple master palettes simultaneously. You can, however, partition a segment of your master palette to be grayscaled.
Okay yeah that's what I thought, I only brought this up because the Custom seems to be able to do this simultaneously while Game can't. Just seemed weird to me when I saw it. Made me think there was a palette update that I missed.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

The editor is indeed doing some extra magic to grey out the layers. I don't remember the details and I can't look at the code today, but; Maybe!

Fetching the handles of the map layers and offsetting them by changing their x and y should work as you desire. You can also offset the heroes and NPCs layer the same way if you want
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

Bob the Hamster wrote:The editor is indeed doing some extra magic to grey out the layers. I don't remember the details and I can't look at the code today, but; Maybe!

Fetching the handles of the map layers and offsetting them by changing their x and y should work as you desire. You can also offset the heroes and NPCs layer the same way if you want
Great thanks! And yeah I look forward to seeing how that was carried out.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Those new map editor layer visualisations draw the map layers while doing an extra palette remapping. The extra remapping is a 256-color palette mapping into the master palette. (The limit of 16 colors per palette is very close to being removed entirely, so internally the map editor can already make use of this new feature). In other words, it treats the tilesets as being paletted instead of as using the master palette directly. I guess that ability could (and should!) be made available in-game too, adding some commands to tint map layer slices or to draw them with a custom palette.

But actually it wouldn't be straightforward to add script commands which would let you get the same tinting effects as are used in the map editor unless I just copied those specific effects directly instead of giving you more freedom to tint them how you want. The map editor palettes are actually quite complicated to compute, they're a combination of multiple operations (eg blending) on the master palette. I spent a long time playing with it to try to get them to look good. Even the simplest (darkening a layer) is two operations:

Code: Select all

FUNCTION layer_shadow_palette() as Palette16 ptr
 DIM ret as Palette16 ptr = palette16_new_identity(256)  'Direct map to master palette
 palette16_transform_n_match ret, copGreyscale
 DIM black as RGBcolor  'RGB 0,0,0
 palette16_mix_n_match ret, black, 0.60, mixBlend  'Darken by 60%
 RETURN ret
END FUNCTION
(It's still called Palette16 even though it has 256 colors...)

Ideally you could provide your own palette, and get access to all these palette-manipulation operations I wrote, so that you could create any effect. But we don't even yet have any script commands to let you manipulate "16 color" palettes (we need a new name for those!) on the fly. I did want to add some. Then you will be able to do the same tricks of appearing to use multiple master palettes at once.
Also, we're in the process of switching to 24-bit color, so then it would make more sense for you to provide a 24-bit ("master") palette for a map layer instead. I will also change the map editor to do that -currently, if your master palette only has a few colors, tinted map layers will look very bad.
Last edited by TMC on Sat Jul 14, 2018 7:01 pm, edited 8 times in total.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Re: naming

How about we call them "N color Pallettes"? Or "PaletteN"
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

As in, "N" is part of the name, not standing for the number of colors?
We do sometimes refer to master palettes as 256-color palettes though, so drawing attention to the number of colours might be confusing.

Another idea: sprite palettes. But that could be confusing if we allow sprites to have their own master palette in 24-bit color mode.

Another idea: subpalettes. That's a pretty natural name already used by plenty of other programs (but, it seems it actually gets used for all sorts of different stuff)

Another idea: indexed palettes (perhaps in contrast to "rgb palettes" such as the master palette - if we allow multiple rgb palettes at once so want to stop referring to those as master palettes?)
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Subpalettes and indexed both sound good. :)
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

As a programmer, I like "indexed palettes" more, though I think to a layperson it might make little sense. But subpalette is much shorter.
Last edited by TMC on Sun Jul 15, 2018 9:44 pm, edited 1 time in total.
Post Reply