Sign in to follow this  
Scouting Ninja

Storing 64 images in BW, how to find one?

Recommended Posts

So I am doing weather effects in a open world game.

I am using a BW image to define what parts are effected how much. The range is 4 values (little, normal, allot and extreme), the shader uses these values per pixel in combo with the height map(Used for terrain generation) and normal map(for terrain details).

So all I need for each BW is a color depth of 4 and because it can store a intensity of 256 in one texture I can store 64 maps in a single texture. I wan't to use textures for easy editing and baking.

However now I can't pull out an exact one need, I know it should be easy as I did it before, however I just can't remember how.

Share this post


Link to post
Share on other sites

you need store 2 bits (4 values) and extract them? not 64 images, only 4

with 8 bits color you can store 4 images of 2bits in 1 image of 8bits

when you get the 8 bit value:

for extract the imagen 1 is $3 and,

2 is 2 >> $3 and

3 is 4 >> $3 and

4 is 6 >> $3 and

 

for store you need mask the "2 bit chanell" and or the value

Edited by pabloreda

Share this post


Link to post
Share on other sites

So all I need for each BW is a color depth of 4 and because it can store a intensity of 256 in one texture I can store 64 maps in a single texture.

That's not how it works. 4 values is 2 bits, while 256 values is 8 bits. With 256 values, you can only store 4 separate maps of 4 values each. You'll do this with bit masking and shifting. To store 64 maps overlaid in this manner, you'd need to pack the data into four 32bit values, hardly a practical solution.

Share this post


Link to post
Share on other sites
Not to be pedantic, but we need to define the difference between black and white and grey scale. Black and white (B/W) is literally black and white, i.e., no shades of grey. If you truly need B/W, you only need one bit per pixel.

Share this post


Link to post
Share on other sites
Not to be pedantic, but we need to define the difference between black and white and grey scale. Black and white (B/W) is literally black and white, i.e., no shades of grey. If you truly need B/W, you only need one bit per pixel.

Thanks will keep that in mind.

you need store 2 bits (4 values) and extract them? not 64 images, only 4
 
That's not how it works. 4 values is 2 bits, while 256 values is 8 bits. With 256 values, you can only store 4 separate maps of 4 values each. You'll do this with bit masking and shifting. To store 64 maps overlaid in this manner, you'd need to pack the data into four 32bit values, hardly a practical solution.

You are right about this, however I did store it before in a channel like this. All I remember is that it was a key and the key would find the texture I needed based on a simple math formula. Something to do with maths used for grid placement.

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites

Thanks to everyone helping, I found the code and can't use it. It's isn't my property also decoding the texture took way to long. I will just use normal saves to store the data as buffers.

Also I am not under NDA so this is how it works: It merges two colors into one as normal(so 4 colors would result in 16 new ones). Then it merges every second color resulting in half the end result, it then generates a key based on the difference between each color. So if your buffer was [1, 0.5, 1, 1] it would store the first number followed by difference 1(0.5,0.5,0) it would repeat till all numbers reach 0 storing that as a key. The key is used as the name for the file.

Note it compresses a lot of the texture away and uses the difference key to re-generate it, very noisy results.

Only saves on physical memory, was used for AO maps in a voxel engine.

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites

I'm afraid lossy compression isn't compatible with your 2bpp subimages; the ones in the least significant bits of the byte are going to be severely altered. Can you load textures from lossless image formats (PNG, BMP, Targa etc.) instead?

Share this post


Link to post
Share on other sites
I'm afraid lossy compression isn't compatible with your 2bpp subimages; the ones in the least significant bits of the byte are going to be severely altered. Can you load textures from lossless image formats (PNG, BMP, Targa etc.) instead?

 

The problem wasn't with the noise or accuracy, this packing was made for a voxel engine that had to store 4096*4096*4096 textures. 

It did this by merging two and compressing to half, this allowed the engine to store it's AO maps into 40-50 textures. Then at the start it would unpack using a key that is 1000-2000 characters long.

It had to do this only once at startup before, now I have to do it each time I call a texture. It freezes the game every time a part of the terrain is loaded. Tales roughly 1-2 seconds to unpack and find the texture I want.

My textures are 2048*2048, not voxel.

 

I have decided to just store everything into the vertex data of the terrain. So now I just use the averaged value and combined that with the height map and normal map.

Originally I wanted to use the terrain vertices to map what parts of the terrain could burn, however I now realized that I could just use the grass texture to check. For objects I just check what parts isn't metal, using the metal map.

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this