Jump to content

Blend mode to preserve argb channels


MercifulNinja

Recommended Posts

Im going to be using an image to encode game data for my world map. The basic gist is i will have 4 layers. One layer only using red channel, one for blue, one for green, and one for alpha (using black as the base color). I need to be able to merge the 4 layers into a single argb image without distorting each pixels values. So when i look at the final image the red, green, blue, and alpha channels of any given pixel match exactly to the corresponding pixels on each layer. Take the red value from the red layer(where gba are ignored), green value from green layer (rba ignored), blue value from blue channel  (rga ignored), and the alpha value from the alpha/black channel (rgb ignored). I hope this makes sense. My main concern is that for editing purposes the alpha value on the rgb layers will need to be opaque so i can see them clearly but the final alpha value must come from only the black/alpha layer.  Any thoughts on the layer stack order and blend modes of each layer would be much appreciated and a huge headache and time saver. Thanks in advance.

Edited by MercifulNinja
Link to comment
Share on other sites

Ok so I've decided to use the Green Layer for two of my data values and get rid of the need for the alpha Channel period so I'll only be using a red green and blue layer and then merging them down to one image. I would like to know if I'm thinking in the right direction with using the addition blend mode period because my thought is that if 2 out of 3 values on each layer are 0 then the addition blend will result in a conposit color with the correct rgb values from each layer. 

 please correct me if I'm wrong. Thanks in advance

Link to comment
Share on other sites

I don't quite understand how you intend to use the green layer for two different values. What you could do is have R, G, and B layers, and a grey-scale layer for alpha. You could merge the R, G, and B layers using Additive blending, then copy the grey layer to the clipboard, and merge it into the color layer using BoltBait's Paste Alpha plugin to paste the gray as alpha. That's not as convenient as just merging layers, but unfortunately there's no way of merging that will just transfer the alpha value.

Link to comment
Share on other sites

Sorry not 2 values for green. I meant use the greens value for 2 things in my game. Green is terrain type and i realized i could use it for movement speed adjustment as well as dungeon spawn locations. Thereby removing the need for the alpha channel altogether. So everything can be opaque rather than having transparency to represent the movement speed adjustments.

 

I figured the issue was the alpha and pondered my design a bit. Thanks for the reply.  So i was right in thinking additive for taking a R,0,0 layer and a 0,B,0 layer and a 0,0,G layer to flatten into a single RGB value without changing the actual values? If thats the case then problem solved :)

Edited by MercifulNinja
Link to comment
Share on other sites

27 minutes ago, MercifulNinja said:

 So i was right in thinking additive for taking a R,0,0 layer and a 0,B,0 layer and a 0,0,G layer to flatten into a single RGB value without changing the actual values?

 

Yes, that should work.

Link to comment
Share on other sites

I'm also working on some world maps (for an RPG).

 

 

What I've done is used entire layers to encode/save the information. One layer is topography, another is rainfall, a third is vegetation, towns & cities, travel routes, etc.., I'm up to seven layers and I'm still finding things to add (religion, political regions, races....).

 

Your idea of using the channels is

  • difficult to expand (more channels are not available)
  • limited in its ability to edit the channels individually

I strongly urge you to consider using layers and not channels. If I wish to change the rainfall - I simply edit the rainfall layer. Easy.

Link to comment
Share on other sites

1 hour ago, Ego Eram Reputo said:

I strongly urge you to consider using layers and not channels. If I wish to change the rainfall - I simply edit the rainfall layer. Easy.

 

I second and third this motion. I still can't understand how you are using the channels to do what you're doing. Layering is great.

 

 

 

1 hour ago, Ego Eram Reputo said:

 

 

 

Also, ERR I snagged that Gossamer and actually just the whole plugin pack, because I'm going to be doing this very thing on a card game I've been working on! So thanks.

ketenksEsignatureSmall2.png.f74cf40145e3a072030b070615ef1b93.png

Link to comment
Share on other sites

Everything else from towns,  politics, and so on is stored in an xml file. Which will eventually have a mini editor to manipulate. The only things i am using the data image for are thing relative to the players position on the world map. I wont need to expand the structure of the image. I only need to grabthe pixel from the image at the players position when moving, foraging, or at the time of a random encounter. Weather has no impact on my game as most of the gameplay is done in menus or when dungeon crawling. Thank you for the feedback though :)

Link to comment
Share on other sites

I am curious on the topic of layers and the pdn format. From what i gather it utilizes the .net framework for a lot of the saving and loading details. Are there any descriptive tutorials or documentation on the file format? My game is written for mobile using java and libgdx. The libgdx forums are telling me to load the image, parse the data, and store the information in a custom format rather than leaving it in a texture. Im guessing its due to the memory limits of the gpu on mobile devices. Which is odd considering the texure should be stored in ram after loading and is never drawn so it shouldnt be in the gpu, but i digress.  So if i need to write a custom loader could i not just parse the layer info from a native pdn file. Keep in mind im having to use paint.net due to the free factor. And have not had time to delve into all of its features. Any thoughts?

Link to comment
Share on other sites

The PNG should suffice at that will give you access to the RGBA channels on a per pixel basis.

 

The native PDN format is largely the result of data serialization. I don't recall anything specific having been posted on the format itself.

 

Aside: in my game I'll be using a 32" TV as a secondary monitor. I'll be showing the overland map directly in paint.net where I'll zoom in on the player position. The players get to see the visible structures (local topography, vegetation, towns, rivers and roads). I'll keep the other layers hidden below the visible layer(s). I drag the Layers Window and Colors Window to my (private) primary monitor so I can do color checks on specific layers without the players seeing which layer I'm checking or the result I get.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...