masking textures
Blitz3D Forums/Blitz3D Beginners Area/masking textures
| ||
hello all. i have two planes in my game engine, both of which i have textured with a forest scene. i want to lay one over the other and make the front one semi-transparent so it gives a kind of depth-effect. i have two images - one is the normal forest scene and the other is black and white mask version with the white area being the part of the forest that i want to display. ive checked that the black area is 0,0,0 too. right. heres my code: ; load texture for main picture... Global treetex = LoadTexture("winter.jpg",1) ; load mask texture, with ",4" for a mask Global othertex = LoadTexture("winter1.jpg",4) Global brush = CreateBrush() ; lay the normal texture on layer 0 of the brush... BrushTexture brush,treetex,0,0 ; then the mask on layer 1... BrushTexture brush,othertex,0,1 {several hundred lines later...} PaintEntity wall1,brush PaintEntity wall2,brush EntityAlpha wall2,0.6 ; set the front wall to semi transparent. when i run this i can still see the black of the mask. what am i doing wrong???? cheers neil |
| ||
Set the textureblend of the second texture to multiply bend but load it unmasked should work. There'll be other ways of doing it which I'm sure others will mention. Stevie |
| ||
er ok. i dont quite get what u mean, is it this?? Global treetex = LoadTexture("winter.jpg",1) Global othertex = LoadTexture("winter.jpg",1);now the same Global brush = CreateBrush() TextureBlend othertex,2 BrushTexture brush,treetex,0,0 BrushTexture brush,othertex,0,1 neil |
| ||
Pretty much .. you're other texture should be "winter1.jpg" as this is the black & white version. Simple example .. Graphics3D 640,480,16,1 ;create texture1 Tex1 = CreateTexture( 128,128 ) SetBuffer TextureBuffer( Tex1 ) For y = 0 To 127 For x= 0 To 127 Color 64,Rnd(64,192), 64 Plot x, y Next Next ;create texture2 (mask) Tex2 = CreateTexture( 128,128 ) TextureBlend Tex2, 2 SetBuffer TextureBuffer( Tex2 ) Color 255,255,255 Oval 0,0,128,128,1 SetBuffer BackBuffer() ;camera Camera = CreateCamera() PositionEntity Camera, 0, 0, -10 ;background Plane1 = CreatePlane() RotateEntity Plane1, -90,0,0 PositionEntity Plane1, 0, 0, 1 EntityTexture Plane1, Tex1, 0, 0 ;foreground Plane2 = CreatePlane() RotateEntity Plane2, -90,0,0 EntityTexture Plane2, Tex1, 0, 0 EntityTexture Plane2, Tex2, 0, 1 EntityAlpha Plane2, .25 While Not KeyDown(1) RenderWorld() Flip Wend Stevie |
| ||
First of all: never use jpg for masked textures. You cannot prevent the formerly 0,0,0 black pixels from becoming other almost black shades that won't work as a mask. Use bmp or png. Unfortunately you still have to use black as the mask color here. The only exception is DDS. If you have photoshop or gimp there are export plugins. You need to leave the masked parts unpainted. With the lasso you can easily cut out to-be-masked parts. In photoshop the checkerboard will then shine trough and represent a transparent or "non-painted" area. Blur the contours, then save it as DXT3 DDS with alpha information, then load it in BLitz with the mask flag. Currently that's the best masked textures you can get in BLitz3D. EDIT: oops I just see you want to use an alpha filter and not really masks. However, these notes may be useful noneless. |
| ||
thats cool - thankyou. im really new to b3d and have to use it for a uni project. theres only so far b+ experience can get you... thanks again. neil |
| ||
Ya Thanks JFK, that is some verry helpful information at this time. How Blitz and graphics cards handle alpha and masking is way underdocumented. So what is a DDS? |
| ||
It doesn't matter what colour you use for a mask. It's all to do with the alpha values in that texture. You can change them :o) Or am i missing something here? |