Yes, because alpha stuff can not use the Z buffer it is depth sorted at the entity level. So if the origin of the grass is closer to the camera than the origin of the fence it will be drawn after the fence and if it is further away it will be drawn before the fence.
The fix is to use masked textures as already suggested unless you want major headaches.
Here is a quick example that demonstrates how alpha objects are sorted and how using masking instead resolves the issue. Note how I avoid a dirty mask caused by bilinear filtering by setting the mask color to a color close to the unmasked color. Masking usually only masks out black on loaded textures, but you could get around that by loading as alpha then copying to masked, bearing in mind that any pixel with an alpha value less than 129 will be masked out.
The fix is to use masked textures as already suggested unless you want major headaches.
Here is a quick example that demonstrates how alpha objects are sorted and how using masking instead resolves the issue. Note how I avoid a dirty mask caused by bilinear filtering by setting the mask color to a color close to the unmasked color. Masking usually only masks out black on loaded textures, but you could get around that by loading as alpha then copying to masked, bearing in mind that any pixel with an alpha value less than 129 will be masked out.
Graphics3D 640,480,0,2 texture1=CreateTexture(256,256,1+4) SetBuffer TextureBuffer(texture1) For i=0 To 256 Step 4 Color 255,255,255 : Rect i,0,2,256 Color 254,254,254 : Rect i+2,0,2,256 Next Color 255,255,255 : Rect 0,20,256,8 : Rect 0,200,256,8 SetBuffer BackBuffer() Color 254,254,254 Setcoloralpha(texture1,0) texture2=CreateTexture(256,256,1+4+16+32) SetBuffer TextureBuffer(texture2) Color 60,140,0 : Rect 0,0,256,256 Color 0,100,0 : Rect 124,60,12,256 For i=0 To 60 x=Rand(40,190) : y=Rand(40,200) w=Rand(30,60) : h=Rand(20,30) r=Rand(50,120) : g=Rand(100,150) Color 0,100,0 Line 128,y+40,x+w/2,y+h/2 Line 128-1,y+40,x+w/2-1,y+h/2 Line 128,y+40,x+w/2+1,y+h/2 Color r,g,0 : Oval x,y,w,h Color 255,255,0 : Oval x+w/2-4,y+h/2-2,8,4 Next SetBuffer BackBuffer() Color 60,140,0 Setcoloralpha(texture2,0) camera=CreateCamera() CameraClsColor camera,0,0,100 plane=CreatePlane() EntityColor plane,0,100,0 PositionEntity plane,0,-5,0 light=CreateLight() RotateEntity light,45,45,0 fence=CreateCube() EntityColor fence,200,100,0 EntityTexture fence,texture1 ScaleMesh fence,0.01,5,50 PositionEntity fence,0,0,20 RotateEntity fence,0,-20,0 trifid=CreateSprite() ScaleSprite trifid,2,4 EntityBlend trifid,1 PositionEntity trifid,0,-1,10 EntityTexture trifid,texture2 Alpha=False Repeat If KeyHit(57) Then alpha=Not alpha If alpha Then EntityAlpha fence,0.5 EntityAlpha trifid,0.9 Else EntityAlpha fence,1 EntityAlpha trifid,1 EndIf TurnEntity trifid,0,1,0 TranslateEntity trifid,(KeyDown(205)-KeyDown(203))*0.1,0,(KeyDown(200)-KeyDown(208))*0.1 RenderWorld Color 255,255,255 Text 0,0,"Move trifid with arrow keys, toggle alpha with spacebar" If alpha Then Text 0,12,"Alpha is on" Else Text 0,12,"Alpha is off" Text 0,24,"Fence Distance "+EntityDistance(camera,fence) Text 0,36,"trifid Distance "+EntityDistance(camera,trifid) TFormPoint 0,0,0,trifid,fence If TFormedX()>2 Then Text 0,48, "Trifid on our side of the fence!" ElseIf TFormedX()<-2 Then Text 0,48, "Trifid on the other side of the fence!" Else Text 0,48, "Trifid is on the fence!" EndIf Flip Until KeyHit(1) End Function Setcoloralpha(texture,alpha) Local r=ColorRed(), g=ColorGreen(), b=ColorBlue(), rgb=r Shl 16 Or g Shl 8 Or b Local buffer=TextureBuffer(texture), w=TextureWidth(texture), h=TextureHeight(texture) Local i,j,pixel alpha=alpha Shl 24 For i=0 To w-1 For j=0 To h-1 pixel=ReadPixel(i,j,buffer) And $FFFFFF If pixel=rgb Then WritePixel i,j,alpha Or rgb,buffer Next Next End Function