how do I mask texture only lets thru at spots I wa
Blitz3D Forums/Blitz3D Programming/how do I mask texture only lets thru at spots I wa
| ||
Here is the problem in pic: consider this: here there is only one texture, color texture. now this: here there are 2 textures, color and details texture which gives the extra detail. There is lots more detail in the second pics, but also the feeling of the snow is gone in the second pic. Is it possible to do let those details come out only at specific areas of texure. Can I use mask so I can paint out areas where there is snow so they are not affected by detail texture. Does anyone have any idea how to do it? I did some testing but was not succesfull, seems like Blitz doesn't allow this? Am I wrong or correct and blitz can't mask out snow areas and let the montains have extra details using mask maps? |
| ||
Masking for textures is just an alpha value of a pixel, that is below 128 (or above 127 i forget which). It doesn't really matter the color, just the alpha value at that particular pixel. If you wanna mask out certain parts, you'll need to know the (x,y) of the pixel you want to mask, and write alpha value of 0 (or 255) i forget which does which. |
| ||
Ross, you're talking about alpha transparency, not texture masking. It's an easy mistake because the vocabulary of 3D graphics is so muddled and inconsistent. For example, a "masked texture" is different from a "mask texture." Oi vay Blitz doesn't support texture masking such as you describe. That kind of effect CAN be done using vertex alpha. For example, ALE uses vertex alpha for painting tiled textures on terrain. ADDITION: Oh yeah, and have a look at this code sample of using vertex alpha to paint tiled textures onto terrain http://www.blitzcoder.com/cgi-bin/showcase/showcase_download.pl?id=world_creator03182003021343&fileurl=http://s93726732.onlinehome.us/blitz/transition.zip |
| ||
How do you mean? I'm talking about when you load a texture, with masking, flag 4. You can alter the parts which are masked, by changing the alpha values of the texels. Sorry if i'm on the wrong lines here :) |
| ||
How do you change the alpha value of the texels? |
| ||
You must write pixel data using The WritePixel(Fast) commands and include an alpha value. I can't find any off hand stuff, but i did write a few functions for doing this. You can pull the code for extracting the ARGB and recombining it again. http://www.blitzbasic.com/codearcs/codearcs.php?code=1013 In fact, screw it, i'll just put it here. RGB1=ReadPixelFast(loop,loop1,TextureBuffer(texture)) r=(RGB1 And $FF0000)shr 16;separate out the red g=(RGB1 And $FF00) shr 8;green b=RGB1 And $FF;and blue parts of the color a=(RGB1 And $FF000000)Shr 24 And for combining it again... newrgb= (a shl 24) or (r shl 16) or (g shl 8) or b ; combine the ARGB back into one value WritePixelFast(loop,loop1,newrgb,TextureBuffer(texture)); write back to the texture All taken from the functions i've given the link too. Hope that helps :) |
| ||
How can I use this to show parts of detail texure (which tiles it self btw) over the base color texture? I would like to use third mask texture that only lets thru what I paint on it? I've checked the vertex alpha demo, but I would need to build an editor to paint that way, dont have time to be building an editor just for this. |
| ||
I think if you use the alphablend on the texture, it should show through the masked parts. If i remember correctly though, it cause the texture to lighten just a bit, but it showed through. |
| ||
Global sprite=CreateSprite() Global base=LoadTexture("image.png",4) Global mask=LoadTexture("image1.png",4) EntityTexture sprite,base,0,1 EntityTexture sprite,mask,0 prepare_texture(mask) texture_mask_colour(mask,0,0,0,50) cube=CreateCube() PositionEntity cube,0,0,2 ScaleEntity cube,6,2,1 It works but not the way I asked for, here: There are 2 textures on the sprite, base and the mask texture that I put thru: prepare_texture(mask) texture_mask_colour(mask,0,0,0,50) Both textures dissappear, whic is not what I relly want. Or perhaps I did something wrong here, and I should see the base texture thru the mask? |