"Mixing" Textures

Blitz3D Forums/Blitz3D Beginners Area/"Mixing" Textures

Dripht(Posted 2006) [#1]
Say I have two greyscale hightmaps and before I make a terrain out of them, I need to mix them into one texture, maybe 50% of one and 50% of the other. How can this be done?

I'd assume I'd have to create a new texture, and go into it's buffer, but im lost beyond that.


big10p(Posted 2006) [#2]
Just run through all the pixels in the two hightmap images and add the RGB components of the two corresponding pixels together separately, then divide these values by two to find the RGB of the new hightmap pixel. If you want to do this to use with the LoadTerrain command, you only have to deal with the red channel, I believe.


stayne(Posted 2006) [#3]
Load one up in photoshop and set the opacity of its layer to 50%. load up the other, select all/copy, then paste onto the original's layer, which will create a new layer. set the opacity of that layer to 50%. export to .bmp, .jpg or whatever format you want.


Dripht(Posted 2006) [#4]
Big10p: Is that fast enough to do in real time? every frame?

Markd: I need to mix several textures, I'd have literally hundreds of bitmaps if I did that. But that's exactly what I need it to do, just in game.


big10p(Posted 2006) [#5]
Is that fast enough to do in real time? every frame?
Depends on the size of the hightmaps involved and how many you want to do each frame, but generally speaking, no.


Shifty Geezer(Posted 2006) [#6]
I've never tried realtime write-to-texture work, but from the few demos I've seen, what's capable is very limited if you want a smooth frame rate. On modern fast cards you should have loads of BW to play with and do this in pixel shaders. In Blitz you're limited (I believe) to processing the textures of the CPU. As an author of Photoshop graphics plugins I can tell you that per pixel processing on a CPU is SLOW. I'll be surprised if you can get this working.


Matty(Posted 2006) [#7]
Alternatively you could use the blitz3d texture blending features to do this:

Create texture which is all r,g,b=128,128,128, multiply blend this with your first texture. Repeat with second texture. Then add the two resultant textures together using an additive blend mode and save the resultant image.