Secondary Texture Set

Blitz3D Forums/Blitz3D Programming/Secondary Texture Set

Banshee(Posted 2006) [#1]
I'm trying to use B3D's secondary texture co-ords, my graphics card supports 8 texture layers but i've no idea where I would look up texture co-ordinate sets supported.

I create the texture.
...Global shadowTexture=CreateTexture(4,4)

Set it to use texture set 1.
...TextureCoords shadowTexture,1

Temporarily colour the texture red so I can see the effect.
...SetBuffer TextureBuffer(shadowTexture)
... Color 255,0,0
... For x=0 To TextureWidth(shadowTexture)
... For z=0 To TextureHeight(shadowTexture)
... Plot x,z
... Next
... Next
...SetBuffer BackBuffer()

I tnen apply the texture to an object.
...EntityTexture u\o,shadowTexture,0,1

Unfortunately I do not see the secondary texture layer at all. Can anyone tell me if I am missing something please?


Mustang(Posted 2006) [#2]
Umm... are you sure that you have two sets of (different) UVs in your 3D object for starters?


Banshee(Posted 2006) [#3]
This is probably the problem, i'm creating the secondary texture co-ordinates with the vertexTexCoords command, i've tried various things such as randomly assigning co-ordinates for the second set.

for example:
...VertexTexCoords vl\surface,vl\vertex,0.1,Rnd(1),0,1

Is there a way to check or edit the FVF format to make sure a secondary texture coordinate set is supported?


big10p(Posted 2006) [#4]
The above code works here when I apply it to a blitz sphere.

What's the FVF format?


Banshee(Posted 2006) [#5]
I wonder if it is my graphics card, could you check the following program please?

Graphics3D 640,480,0,2

Global firstTexture=CreateTexture(4,4)
colourTex(firstTexture,255,0,0)

Global shadowTexture=CreateTexture(4,4)
TextureCoords shadowTexture,1
colourTex(shadowTexture,0,255,0)

SetBuffer BackBuffer()
sphere=CreateSphere(4)
EntityTexture sphere,firstTexture      ; Disable Line A
EntityTexture sphere,shadowTexture,0,1 ; Disable Line B

camera=CreateCamera()
PositionEntity sphere,0,0,4

Repeat
	RenderWorld
	Flip 0
Until KeyDown(1)

Function colourTex(texture,r,g,b)
SetBuffer TextureBuffer(texture)
Color r,g,b
For x=0 To TextureWidth(texture)
For z=0 To TextureHeight(texture)
Plot x,z
Next
Next
SetBuffer BackBuffer()
End Function


When I disable the line marked "disable line" a or b the sphere appears, but when I use both texture layers together it does not.

FVF is Flexible Vertex Format, it is a mask used in DirectX to state what features are enabled or disabled in the object, but thinking more clearly now B3D uses it's own b3d thingamy and handles the FVF for us, so I was barking up the wrong tree on that one.


Ross C(Posted 2006) [#6]
It's your two textures producing a strange result when blended.

add in

TextureBlend firsttexture,3



Ross C(Posted 2006) [#7]
Giving each texture a different blend mode produces a better result. I think it might be something to do with you changing the textures colour. Maybe to do with alpha values in the texture?

Graphics3D 640,480,0,2

Global firstTexture=CreateTexture(4,4)
colourTex(firstTexture,255,0,0)

Global shadowTexture=CreateTexture(4,4)
TextureCoords shadowTexture,1
colourTex(shadowTexture,0,255,0)

SetBuffer BackBuffer()
sphere=CreateSphere(4)
EntityTexture sphere,firstTexture      ; Disable Line A
TextureBlend firsttexture,1
EntityTexture sphere,shadowTexture,0,1 ; Disable Line B
TextureBlend shadowtexture,3


camera=CreateCamera()
PositionEntity sphere,0,0,4

Repeat
	RenderWorld
	Flip 0
Until KeyDown(1)


Function colourTex(texture,r,g,b)
SetBuffer TextureBuffer(texture)
Color r,g,b
For x=0 To TextureWidth(texture)
For z=0 To TextureHeight(texture)
Plot x,z
Next
Next
SetBuffer BackBuffer()
End Function



big10p(Posted 2006) [#8]
Yeah, it seems the default blend mode is Multiply. That causes the sphere to be rendered completely black.


Banshee(Posted 2006) [#9]
Thank you, the sphere sample now works - i'm now trying (in vein) to get it working with my animMesh.


Banshee(Posted 2006) [#10]
My problem in the main game turned out to be because of failing to assign the shadowTexture to the child meshes. I'll put a post in the showcase showing the finished result... :)


Ross C(Posted 2006) [#11]
Yeah, you would really need to recursively search and apply that. Look forward to seeing it :o)