Problem with alpha blending..
Blitz3D Forums/Blitz3D Beginners Area/Problem with alpha blending..
| ||
I have some problem with vertex alpha: I copy the surface (vertex position , normal, color and alpha too) I paint one surface with a texture, and bring the vertex alpha to 0.3 of the first texture. When i use entityfx 32 (force alpha blending) my mesh become in some part "invisible".. Did i wrong something? Now i don't have the code maybe tomorrow i can show you if need it. And after the alpha declaration i reset all the vertex of the original mesh at aplha 1. Need i to get a little bit down the surface i created? I just copy in the same position.. Sorry is the first time i do it! Aza |
| ||
You should use fx 32+2 ( alpha + vertex colours ). |
| ||
Thanks i did it, but i still have a problem. In my editor the surface i copy is always the same but in the game, just starting a few time (without any change) i see sometime the surfaces i normally copy are different.. I'll post my code i hope you can find error. Function demo() cielo=cubocielo() EntityParent cielo,cam_piv EntityFX cielo,8 nuv=nuvole() EntityAlpha nuv,0.6 nuv1=nuvole1() ;Creo mappa terrademo = LoadMesh(".\meshes\mappa1.b3d") PositionEntity terrademo,-500,-1500,200 EntityAlpha terrademo,1 EntityType terrademo,STRUTTURA1 EntityRadius terrademo,0.01 meshtemp=CreateMesh (terrademo) EntityFX meshtemp,32+2 surftemp=GetSurface(terrademo,2) texttemp1=LoadTexture(".\texture\erba1.bmp") texttemp2=LoadTexture(".\texture\Rock.jpg") surfatemp=CreateSurface (meshtemp) For i=0 To CountTriangles (surftemp)-1 ver0 = TriangleVertex(surftemp, i, 0) ver1 = TriangleVertex(surftemp, i, 1) ver2 = TriangleVertex(surftemp, i, 2) v0x# = VertexX(surftemp, ver0) v0y# = VertexY(surftemp, ver0) v0z# = VertexZ(surftemp, ver0) v0u# = VertexU(surftemp, ver0) v0v# = VertexV(surftemp, ver0) v0w# = VertexW(surftemp, ver0) v0nx# = VertexNX(surftemp, ver0) v0ny# = VertexNY(surftemp, ver0) v0nz# = VertexNZ(surftemp, ver0) v0red# = VertexRed(surftemp, ver0) v0green# = VertexRed(surftemp, ver0) v0blue# = VertexRed(surftemp, ver0) v0alpha# = VertexAlpha(surftemp, ver0) v1x# = VertexX(surftemp, ver1) v1y# = VertexY(surftemp, ver1) v1z# = VertexZ(surftemp, ver1) v1u# = VertexU(surftemp, ver1) v1v# = VertexV(surftemp, ver1) v1w# = VertexW(surftemp, ver1) v1nx# = VertexNX(surftemp, ver1) v1ny# = VertexNY(surftemp, ver1) v1nz# = VertexNZ(surftemp, ver1) v1red# = VertexRed(surftemp, ver1) v1green# = VertexRed(surftemp, ver1) v1blue# = VertexRed(surftemp, ver1) v1alpha# = VertexAlpha(surftemp, ver1) v2x# = VertexX(surftemp, ver2) v2y# = VertexY(surftemp, ver2) v2z# = VertexZ(surftemp, ver2) v2u# = VertexU(surftemp, ver2) v2v# = VertexV(surftemp, ver2) v2w# = VertexW(surftemp, ver2) v2nx# = VertexNX(surftemp, ver2) v2ny# = VertexNY(surftemp, ver2) v2nz# = VertexNZ(surftemp, ver2) v2red# = VertexRed(surftemp, ver2) v2green# = VertexRed(surftemp, ver2) v2blue# = VertexRed(surftemp, ver2) v2alpha# = VertexAlpha(surftemp, ver2) ver0 = AddVertex(surfatemp, v0x, v0y, v0z, v0u, v0v, v0w) ver1 = AddVertex(surfatemp, v1x, v1y, v1z, v1u, v1v, v1w) ver2 = AddVertex(surfatemp, v2x, v2y, v2z, v2u, v2v, v2w) VertexNormal surfatemp, v0, v0nx, v0ny, v0nz VertexNormal surfatemp, v1, v1nx, v1ny, v1nz VertexNormal surfatemp, v2, v2nx, v2ny, v2nz VertexColor surfatemp, ver0, v0red, v0green, v0blue, v0alpha VertexColor surfatemp, ver1, v1red, v1green, v1blue, v1alpha VertexColor surfatemp, ver2, v2red, v2green, v2blue, v2alpha AddTriangle surfatemp, ver0, ver1, ver2 Next surfatemp=GetSurface (meshtemp,1) For i=0 To CountVertices (surfatemp)-1 vre#=VertexRed(surfatemp, i) vgre#=VertexGreen(surfatemp, i) vbl#=VertexBlue(surfatemp, i) VertexColor surfatemp,i,vre#,vgre#,vbl#,0.4 Next brushtemp=CreateBrush () BrushTexture brushtemp,texttemp1 PaintSurface surfatemp,brushtemp surftemp=GetSurface (terrademo,1) surfatemp3=CreateSurface (meshtemp) For i=0 To CountTriangles (surftemp)-1 ver0 = TriangleVertex(surftemp, i, 0) ver1 = TriangleVertex(surftemp, i, 1) ver2 = TriangleVertex(surftemp, i, 2) v0x# = VertexX(surftemp, ver0) v0y# = VertexY(surftemp, ver0) v0z# = VertexZ(surftemp, ver0) v0u# = VertexU(surftemp, ver0) v0v# = VertexV(surftemp, ver0) v0w# = VertexW(surftemp, ver0) v0nx# = VertexNX(surftemp, ver0) v0ny# = VertexNY(surftemp, ver0) v0nz# = VertexNZ(surftemp, ver0) v0red# = VertexRed(surftemp, ver0) v0green# = VertexRed(surftemp, ver0) v0blue# = VertexRed(surftemp, ver0) v0alpha# = VertexAlpha(surftemp, ver0) v1x# = VertexX(surftemp, ver1) v1y# = VertexY(surftemp, ver1) v1z# = VertexZ(surftemp, ver1) v1u# = VertexU(surftemp, ver1) v1v# = VertexV(surftemp, ver1) v1w# = VertexW(surftemp, ver1) v1nx# = VertexNX(surftemp, ver1) v1ny# = VertexNY(surftemp, ver1) v1nz# = VertexNZ(surftemp, ver1) v1red# = VertexRed(surftemp, ver1) v1green# = VertexRed(surftemp, ver1) v1blue# = VertexRed(surftemp, ver1) v1alpha# = VertexAlpha(surftemp, ver1) v2x# = VertexX(surftemp, ver2) v2y# = VertexY(surftemp, ver2) v2z# = VertexZ(surftemp, ver2) v2u# = VertexU(surftemp, ver2) v2v# = VertexV(surftemp, ver2) v2w# = VertexW(surftemp, ver2) v2nx# = VertexNX(surftemp, ver2) v2ny# = VertexNY(surftemp, ver2) v2nz# = VertexNZ(surftemp, ver2) v2red# = VertexRed(surftemp, ver2) v2green# = VertexRed(surftemp, ver2) v2blue# = VertexRed(surftemp, ver2) v2alpha# = VertexAlpha(surftemp, ver2) ver0 = AddVertex(surfatemp3, v0x, v0y, v0z, v0u, v0v, v0w) ver1 = AddVertex(surfatemp3, v1x, v1y, v1z, v1u, v1v, v1w) ver2 = AddVertex(surfatemp3, v2x, v2y, v2z, v2u, v2v, v2w) VertexNormal surfatemp3, v0, v0nx, v0ny, v0nz VertexNormal surfatemp3, v1, v1nx, v1ny, v1nz VertexNormal surfatemp3, v2, v2nx, v2ny, v2nz VertexColor surfatemp3, ver0, v0red, v0green, v0blue, v0alpha VertexColor surfatemp3, ver1, v1red, v1green, v1blue, v1alpha VertexColor surfatemp3, ver2, v2red, v2green, v2blue, v2alpha AddTriangle surfatemp3, ver0, ver1, ver2 Next surfatemp3=GetSurface (meshtemp,2) For i=0 To CountVertices (surfatemp3)-1 vre#=VertexRed(surfatemp3, i) vgre#=VertexGreen(surfatemp3, i) vbl#=VertexBlue(surfatemp3, i) VertexColor surfatemp3,i,vre#,vgre#,vbl#,0.5 Next BrushTexture brushtemp,texttemp2 PaintSurface surfatemp3,brushtemp surftemp=GetSurface (terrademo,3) surfatemp2=CreateSurface (meshtemp) For i=0 To CountTriangles (surftemp)-1 ver0 = TriangleVertex(surftemp, i, 0) ver1 = TriangleVertex(surftemp, i, 1) ver2 = TriangleVertex(surftemp, i, 2) v0x# = VertexX(surftemp, ver0) v0y# = VertexY(surftemp, ver0) v0z# = VertexZ(surftemp, ver0) v0u# = VertexU(surftemp, ver0) v0v# = VertexV(surftemp, ver0) v0w# = VertexW(surftemp, ver0) v0nx# = VertexNX(surftemp, ver0) v0ny# = VertexNY(surftemp, ver0) v0nz# = VertexNZ(surftemp, ver0) v0red# = VertexRed(surftemp, ver0) v0green# = VertexRed(surftemp, ver0) v0blue# = VertexRed(surftemp, ver0) v0alpha# = VertexAlpha(surftemp, ver0) v1x# = VertexX(surftemp, ver1) v1y# = VertexY(surftemp, ver1) v1z# = VertexZ(surftemp, ver1) v1u# = VertexU(surftemp, ver1) v1v# = VertexV(surftemp, ver1) v1w# = VertexW(surftemp, ver1) v1nx# = VertexNX(surftemp, ver1) v1ny# = VertexNY(surftemp, ver1) v1nz# = VertexNZ(surftemp, ver1) v1red# = VertexRed(surftemp, ver1) v1green# = VertexRed(surftemp, ver1) v1blue# = VertexRed(surftemp, ver1) v1alpha# = VertexAlpha(surftemp, ver1) v2x# = VertexX(surftemp, ver2) v2y# = VertexY(surftemp, ver2) v2z# = VertexZ(surftemp, ver2) v2u# = VertexU(surftemp, ver2) v2v# = VertexV(surftemp, ver2) v2w# = VertexW(surftemp, ver2) v2nx# = VertexNX(surftemp, ver2) v2ny# = VertexNY(surftemp, ver2) v2nz# = VertexNZ(surftemp, ver2) v2red# = VertexRed(surftemp, ver2) v2green# = VertexRed(surftemp, ver2) v2blue# = VertexRed(surftemp, ver2) v2alpha# = VertexAlpha(surftemp, ver2) ver0 = AddVertex(surfatemp2, v0x, v0y, v0z, v0u, v0v, v0w) ver1 = AddVertex(surfatemp2, v1x, v1y, v1z, v1u, v1v, v1w) ver2 = AddVertex(surfatemp2, v2x, v2y, v2z, v2u, v2v, v2w) VertexNormal surfatemp2, v0, v0nx, v0ny, v0nz VertexNormal surfatemp2, v1, v1nx, v1ny, v1nz VertexNormal surfatemp2, v2, v2nx, v2ny, v2nz VertexColor surfatemp2, ver0, v0red, v0green, v0blue, v0alpha VertexColor surfatemp2, ver1, v1red, v1green, v1blue, v1alpha VertexColor surfatemp2, ver2, v2red, v2green, v2blue, v2alpha AddTriangle surfatemp2, ver0, ver1, ver2 Next surfatemp2=GetSurface (meshtemp,3) For i=0 To CountVertices (surfatemp2)-1 vre#=VertexRed(surfatemp2, i) vgre#=VertexGreen(surfatemp2, i) vbl#=VertexBlue(surfatemp2, i) VertexColor surfatemp2,i,vre#,vgre#,vbl#,0.5 Next BrushTexture brushtemp,texttemp2 PaintSurface surfatemp2,brushtemp terrademo1 = LoadMesh(".\meshes\componenti.b3d") PositionEntity terrademo1,-500,-1500,200 EntityType terrademo1,STRUTTURA1 EntityRadius terrademo1,0.01 terrademo2 = LoadMesh(".\meshes\fiume.b3d") PositionEntity terrademo2,-500,-1500,200 acqua= LoadMesh(".\meshes\acqua.b3d") EntityColor acqua,0,51,75 PositionEntity acqua,-500,-1500,200 EntityAlpha acqua,0.6 pietra = LoadMesh(".\meshes\pietra.b3d") PositionEntity terrademo2,-500,-1500,200 Water3 = LoadTexture("texture\WaterFoam0011_S.jpg") ScaleTexture Water3, .1, 1 EntityTexture terrademo2,water3,0,0 EntityAlpha terrademo2,0.9 cascata=LoadMesh(".\meshes\cascata.b3d") PositionEntity cascata,-500,-1500,200 Water1 = LoadTexture("texture\WaterFoam0011_S.jpg") EntityTexture cascata,water1 PositionTexture water1,0,1 EntityFX cascata,48 EntityAlpha cascata,0.6 EntityFX terrademo2,48 cascata1=LoadMesh(".\meshes\cascata1.b3d") PositionEntity cascata1,-500,-1500,200 Water2 = LoadTexture("texture\WaterFoam0011_S.jpg") EntityTexture cascata1,water2 EntityFX cascata1,48 EntityAlpha cascata1,0.5 End Function |