Terrain Multitexturing

Blitz3D Forums/Blitz3D Programming/Terrain Multitexturing

dirkduck(Posted 2003) [#1]
Hey everyone. I've been looking at the "Insaner" demo (samples/mak/insaner on how to multitexture a terrain to get a track image. Anyways, I've pretty much copied the texturing and setup and everything. The multitexturing seems like it is working, but instead of having one large track over the entire terrain, the track texture is tiled across the whole terrain. I'm not sure how to fix this, and my code is pretty much the same as the insaner demo, so I have no idea whats wrong with it.

Global Terrain=CreateTerrain(256)
ScaleEntity terrain,1,50,1
TerrainDetail terrain,5000,True
EntityFX terrain,1


tex0=LoadTexture( "CrackedStone_diff.bmp" )
ScaleTexture tex0,16,16
tex1=LoadTexture( "track.bmp" )
ScaleTexture tex1,256,256
tex2=LoadTexture( "MossyGround.bmp" )
ScaleTexture tex2,16,16
TextureBlend tex2,3


EntityTexture terrain,tex0,0,0
EntityTexture terrain,tex1,0,1
EntityTexture terrain,tex2,0,2



Thats all pretty much the same, except I took out the heightmap and the lightmap. Anyone know what im doing wrong? Thanks.

EDIT: I just noticed that if I "scaletexture" tex1 it has no effect. Any idea why?


killal4(Posted 2003) [#2]
try changing the EntityTexture terrain,tex0,0,0

EntityTexture terrain,tex1,0,1

EntityTexture terrain,tex2,0,2


to

EntityTexture terrain,tex0,0,0

EntityTexture terrain,tex1,1,1

EntityTexture terrain,tex2,2,2


killal4(Posted 2003) [#3]
if that dosent work try taking out the

TextureBlend tex2,3


dirkduck(Posted 2003) [#4]
Thanks for the reply, but that makes only tex0 show up, (I think that parameter is for the frame of the image...).

EDIT: Taking out the textureblend makes that texture not show up at all, still the same tiling problem though.


killal4(Posted 2003) [#5]
Heres my code for multitexturing:


level=LoadTerrain("sweeet.bmp")
land=LoadTexture("land.bmp")
terra_detail=400000
TerrainShading level,terra_shade
ScaleTexture land,100,100
EntityTexture level,land,0,0
d=LoadTexture("tex1.bmp")
EntityTexture level,d,1,3
ScaleTexture d,0.2,0.2
RotateEntity level,0,160,0
ScaleEntity level ,1000,500000,1000
EntityType level,type_level
EntityPickMode level,3,5
MoveEntity level,-150,-50,-500
d2=LoadTexture("tex1.bmp")
EntityTexture level,d2,0,2
ScaleTexture d2,50,50
d3=LoadTexture("tex1.bmp")
EntityTexture level,d3,0,3
ScaleTexture d3,5,5
While Not KeyHit(1)
If KeyDown(200) Then
MoveEntity camera,0,0,1
EndIf

hope this helps.


dirkduck(Posted 2003) [#6]
I think the problem is something with ScaleTexture not working right. I tried setting it to different values (100,100, like your code above for example), but it doesn't make any difference. Is there something that would prevent it from scaling? Thanks


killal4(Posted 2003) [#7]
I really dont know whats wronge but you could try moving your
each scaletexture code under each entitytexture code,sometimes that works.


dirkduck(Posted 2003) [#8]
I tried editing the code down to:
;tex0=LoadTexture( "CrackedStone_diff.bmp" )
;ScaleTexture tex0,16,16
tex1=LoadTexture( "track.bmp" )
ScaleTexture tex1,256,256
tex2=LoadTexture( "MossyGround.bmp" )
ScaleTexture tex2,16,16
TextureBlend tex2,3

;EntityTexture terrain,tex0,0,0
EntityTexture terrain,tex1,0,1
EntityTexture terrain,tex2,0,2


and that works, although it stretches tex2 out across the whole terrain. Then if I uncomment the lines (specifically the commented entitytexture), everything scales back down to be tiled. In the insaner demo it allows the track to be scaled big, while the other two are small. Not sure whats wrong now?


killal4(Posted 2003) [#9]
try this remove the ; from the code i think thats it.

;tex0=LoadTexture( "CrackedStone_diff.bmp" )

;ScaleTexture tex0,16,16

tex1=LoadTexture( "track.bmp" )

ScaleTexture tex1,256,256

tex2=LoadTexture( "MossyGround.bmp" )

ScaleTexture tex2,16,16

TextureBlend tex2,3



;EntityTexture terrain,tex0,0,0

EntityTexture terrain,tex1,0,1

EntityTexture terrain,tex2,0,2

to

tex0=LoadTexture( "CrackedStone_diff.bmp" )

ScaleTexture tex0,16,16

tex1=LoadTexture( "track.bmp" )

ScaleTexture tex1,256,256

tex2=LoadTexture( "MossyGround.bmp" )

ScaleTexture tex2,16,16

TextureBlend tex2,3



EntityTexture terrain,tex0,0,0

EntityTexture terrain,tex1,0,1

EntityTexture terrain,tex2,0,2


this


dirkduck(Posted 2003) [#10]
That's how I had it origionally, but it still does the 'tiling' to the track, arg!


killal4(Posted 2003) [#11]
i dont get it then it looks good to me, as a last resort try taking out the

TextureBlend tex2,3


dirkduck(Posted 2003) [#12]
Tried that too. Well thanks for the help anyways. I've been pulling hair out all day over this, ahh!


dirkduck(Posted 2003) [#13]
I've been adding the code to the insaner demo piece by piece, and this seems to be the line that causes the problem:
Global placer=CreateSphere()  ;placer sphere


If I edit that out it works ok, otherwise not. Any ideas about that?

EDIT: To see what I mean, try adding the line "a=createsphere()" to the insaner demo.

EDIT#2: I've been testing on some other computers, and they seem to render it correctly. Maybe it has something to do with my graphics card? Another computer with a GeForce2 MX runs it fine, while my ATI Radeon 7500 mobile gets the problem. The GF2 drivers are fairly old (on a pretty old computer, I havnt updated them that I remember). I think the ATI card has up to date drivers though. Is there a workaround to get the same effect?


dirkduck(Posted 2003) [#14]
Well I guess ATI just nput out some new drivers, and that fixes the problem! Thanks for the help killal4.


rsbrowndog(Posted 2003) [#15]
I think to fix it pre driver update, the following might have worked:

HWMultiTex False


Here's the description of this command from the docs:


Enables or disables hardware multitexturing.

Multitexturing is a technique used to display more than one texture on an object at once. Sometimes, 3D hardware has built-in support for this, so that using two textures or more per object will not be any slower than using just one.

However, some cards have problems dealing with hardware multitexturing, and for these situations you have the option of disabling it.

When hardware texturing isn't being used, Blitz3D will use its own software technique, which involves duplicating objects that just have one texture each.



You may want to include this as an option for other people who might not have the latest drivers!

Cheers,

Ryan


dirkduck(Posted 2003) [#16]
Hey rsbrowndog. I had played around with that before, both enabling and disabling, but it didn't make any difference on the problem.