Odd VertexColor Behaviour

Blitz3D Forums/Blitz3D Programming/Odd VertexColor Behaviour

Midnight(Posted 2006) [#1]
I'm getting some odd results trying to set the alpha-value of individual verteces using VertexColor. Specifically, everything works fine as long as the camera is close enough to the object, but as soon as the camera moves away a little, any tris with alpha <0.5 no longer get rendered. Has anyone experienced this before?


Midnight(Posted 2006) [#2]
Actually, just to add to that - it's not just distance, it's also cameraangle. I turn the camera a little, and pieces with alpha <0.5 show up again.

Any clues? I'm definitely clueless.


Beaker(Posted 2006) [#3]
Which version of Blitz3D are you using? Also, what gfx card? Do you have the latest drivers?


Midnight(Posted 2006) [#4]
Ok, I tested it out a bit more. It's actually a very strange behaviour of VertexColor mixed with LoadTexture Flag=4. I'm also going to post this as a "bug" report, in case this is not known behaviour.

Try this out (needs any texture1.jpg and texture2.jpg in your directory). The program will create a series of quads with different alpha (set via Vertexcolor) and a sphere on top.

Now switch the texture1.jpg flag to 4, and all quads with alpha <0.5 disappear! You can make them "re-appear" by either removing the vertexcolor command, or by making the texture2.jpg flag equal to 1.

So is this a bug or known feature? Not allowing two textures with texture flag 4 when using vertexcolor?

I'm a little stumped. I'm running 1.91, and I tried this on two different computers (one with an ATI, one with onboard video).

Graphics3D 800,600
SetBuffer BackBuffer()
Global camera
camera=CreateCamera()

AmbientLight 255,255,255


; change this from to ("texture1",4) and the plane disappears
; for all alpha values <.5
tex2=LoadTexture("texture1.jpg",1) 

s=CreateSphere()
TranslateEntity s,0,0,5
EntityTexture s,tex2


Mesh=CreateMesh()
surface=CreateSurface(Mesh)

EntityFX Mesh,35
tex=LoadTexture("texture2.jpg",4)
EntityTexture Mesh,tex


Repeat

	n=0
	ClearSurface surface
	For i=-3 To 2
		For j=-3 To 2
			
			; make little squares (no texture coordinates - makes no diff)
			AddVertex(surface,i,j,5)
			AddVertex(surface,i+1,j,5)
			AddVertex(surface,i,j+1,5)
			AddVertex(surface,i+1,j+1,5)
			
			
			
			AddTriangle(surface,n*4,n*4+2,n*4+1)
			AddTriangle(surface,n*4+1,n*4+2,n*4+3)
	
	
			; remove these three lines and the plane will show up even if 
			; the above texture is loaded with flag=4
			; So somehow the combination of using VertexColor and TextureFlag 4 doesn't work
			For k=0 To 3
				VertexColor surface,n*4+k,255,255,255,Float(n)*0.04
			Next
			
	
			n=n+1
			
	
		Next
	Next

	UpdateNormals Mesh


	UpdateWorld
	RenderWorld
	Flip
Until KeyDown(1)
End