Change Texture Color

Blitz3D Forums/Blitz3D Programming/Change Texture Color

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Maybe you could use this, you need to grayscale the original texture. It uses a small 2nd texture to change the color.
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

camera= CreateCamera()
MoveEntity camera, 0, 0, -5

cube = CreateCube()

tex2 = MakeTexture(256, 256)
EntityTexture cube, tex2

tex1 = CreateTexture(2, 2)
EntityTexture cube, tex1, 0, 1

Repeat
	
	red = Cos(tme +   0) * 127 + 128
	grn = Cos(tme +  90) * 127 + 128
	blu = Cos(tme + 180) * 127 + 128
	tme = tme + 5
	
	FillTexture(tex1, red, grn, blu)
	
	RenderWorld()
	
	Flip
	
Until KeyHit(1)

End
	
	
Function MakeTexture(w, h)

	oldb = GraphicsBuffer()
	tex = CreateTexture(w, h)
	SetBuffer TextureBuffer(tex)
	For x = 0 To w
	For y = 0 To h
		c = Rand(255)
		Color c, c, c
		Plot x, y
	Next
	Next
	SetBuffer oldb
	
	Return tex

End Function

Function FillTexture(tex, r, g, b)
	
	oldb = GraphicsBuffer()
	SetBuffer TextureBuffer(tex)
	ClsColor r, g, b
	Cls
	SetBuffer oldb
End Function