terrain multitexturing

Blitz3D Forums/Blitz3D Programming/terrain multitexturing

stayne(Posted 2006) [#1]
If I have created a terrain, have 3 textures that are used in the terrain, and have the ability to export alphamaps for splatting... is it possible to load the alphamaps into blitz and apply each texture to each alphamap? for example, i have a path with a dirt texture, a hill with a rock texture and off-path is a grass texture.


stayne(Posted 2006) [#2]
This is what I have so far... still plugging at it.
	sandAmap=LoadTexture("sand.png",2)
	ScaleTexture sandAmap,512,512
	EntityTexture terr,sandAmap,0,0
	
	sand=LoadTexture("Sand00.png")
	ScaleTexture sand,5,5
	EntityTexture terr,sand,0,1
	
	rockAmap=LoadTexture("rock.png",2)
	ScaleTexture rockAmap,512,512
	EntityTexture terr,rockAmap,0,2

	rock=LoadTexture("Rock02.png")
	ScaleTexture rock,10,10
	EntityTexture terr,rock,0,3


btw, is this even a good idea? it seems i'll end up using as many as 6 texture layers (lightmap, detail map, and the above).


stayne(Posted 2006) [#3]
Ok here's a more in-depth explanation of my problem. First the code, then the screenshots:

;rockAmap=LoadTexture("rock.png",2)
;ScaleTexture rockAmap,512,512
;EntityTexture terr,rockAmap,0,0
;FreeImage rockAmap

;rock=LoadTexture("Rock02.png")
;ScaleTexture rock,5,5
;EntityTexture terr,rock,0,1
;FreeImage rock

sandAmap=LoadTexture("sand.tga",2)
ScaleTexture sandAmap,512,512
EntityTexture terr,sandAmap,0,2
FreeImage sandAmap
	
sand=LoadTexture("Sand00.png")
ScaleTexture sand,5,5
EntityTexture terr,sand,0,3
FreeImage sand


This shot is the result of the above code:


This is the sand alpha map:



This is the rock alpha map:



As you can see in the code and the above shot, the sand is turned on... shouldn't the black areas be transparent? Anyway, maybe someone can make sense of my shabby code.

Thanks


stayne(Posted 2006) [#4]
On your mark, get set, HELP!


Banshee(Posted 2006) [#5]
The black areas would only be transparent if the original picture file has black set as the transparency colour (an export option) or if you set entityBlend mode 3.

If I understand what you are trying to do you are using a map to set where you want a conventional texture to be drawn? I'm not convinced that would work tbh, I dont understand how you would combine the alpha 'map' of each texture with the texture itself.


Dreamora(Posted 2006) [#6]
It is possible. But you need to setup the texture layering correct:

1 BaseTexture
2 DetailTexture

3+4 first overblend texture with its "alphamap"
5+6 second overblend texture with its alphamap
7+8 third overblend texture with its alphamap

when I remember correctly, the uneven is your texture you want to have drawn and the even ones is the blend mask (could be vice versa, please don't nail me on that). But you need to set the blend masks blend correctly as well as have the correct load flat. With the mask above, you would need to use multiply blend, where white means "do nothing" and black removes the original texture completely. And you would need a texture loading flag of 1 or similar, but it MUST NOT include the MASK flag or the black parts will disappear which breaks the blending.


stayne(Posted 2006) [#7]
Thanks a ton, I'll let you know how it works out tonight.


stayne(Posted 2006) [#8]
the following code gives me a completely black terrain. do you think i may have exported my alpha maps wrong, or does it really matter since they are black and white?

	lightmap=LoadTexture("lmap.bmp")
	ScaleTexture lightmap,512,512
	TextureBlend lightmap,2

	detailmap=LoadTexture("Detail00.png")
	ScaleTexture detailmap,2,2
	TextureBlend detailmap,2
	
	rock=LoadTexture("Rock02.png")
	ScaleTexture rock,5,5
	
	rockAmap=LoadTexture("rock.png",1)
	ScaleTexture rockAmap,512,512
	TextureBlend rockAmap,2
	
	sand=LoadTexture("Sand00.png")
	ScaleTexture sand,5,5
	
	sandAmap=LoadTexture("sand.tga",1)
	ScaleTexture sandAmap,512,512
	TextureBlend sandAmap,2

	EntityTexture terr,lightmap,0,0
	EntityTexture terr,detailmap,0,1

	EntityTexture terr,rock,0,2
	EntityTexture terr,rockAmap,0,3

	EntityTexture terr,sand,0,4
	EntityTexture terr,sandAmap,0,5



stayne(Posted 2006) [#9]
This is as good as it's gonna get. I had to load an additional terrain. Sigh...




miez(Posted 2006) [#10]
Pretty nice shot - I'm particularly impressed by the water. Any clues on how you've accomplished that?


stayne(Posted 2006) [#11]
got andreyman's fx lib before CW poofed.


Chroma(Posted 2006) [#12]
Markd, I know some people have used vertex alpha to achieve nicely blended multi-texture terrains. The method you're using is more desirable imo. It 'should' be doable. I've tinkered around with it but I can't get the two to blend together like in the above shot. Either the white or black shows in every textureblend combination...unless I missed one somehow. =\


Naughty Alien(Posted 2006) [#13]
Hey MarkD...sorry becouse I am asking question not related to your thread...you said you use Andreymans lib..well, I have it too..well, here is my question..I create really outstanding water with his library BUT when I apply my HUD and HUD come sometimes over water surface generated by Andreymans library, its become refracted too (parts whats covering water surface)..I did try things with entityorder and stuff, but it wouldnt work..did you somehow manage this working fine, or I missed something regarding Andreymans libs??


miez(Posted 2006) [#14]
Sorry for the slightly off-topicness, but I've looked around a lot for andreyman's FX lib ... is it still available anywhere?


Naughty Alien(Posted 2006) [#15]
yes..its available for purchase..its excellent stuff...withing comming stencil shadow system, very very fast and glow filter, normalmapping, etc..great stuff..


stayne(Posted 2006) [#16]
i haven't loaded up a hud so i haven't came across that problem yet. are you using your own HUD system or a library like sprite candy? i'll try it out this weekend. scary. i have ran into a problem with camerazoom but i took a look at the lib and it appears to be pretty empowering.


Naughty Alien(Posted 2006) [#17]
I fix camerazoom problem and its working brilliant..I did try few options..AlphaGui , Sprite candy too, and my own..result is same..when HUD come across water surface its going to be refracted..I even tried to load sprited by Aloadsprite command with entityorder messing but not succeded..


miez(Posted 2006) [#18]
yes..its available for purchase..its excellent stuff...withing comming stencil shadow system, very very fast and glow filter, normalmapping, etc..great stuff..


Searched like a ferret for it, but exactly WHERE can I purchase it? Any help would be appreciated as this might just be what I'm looking for...


stayne(Posted 2006) [#19]
create a different camera for the HUD maybe? or perhaps hide/show the hud during render passes.


Naughty Alien(Posted 2006) [#20]
problem is that last render have to be postprocess render..you'll see..I dont know, maybe I didnt do something properly..i emailed Andreyman, but by now no respond..I really hope there is something I miss during set up, otherwise, it will be defficult to use system with HUD..


stayne(Posted 2006) [#21]
there is an fx camera. you could hide the hud from the fx camera like so... (i can't test this, sorry if it doesn't work):

showentity hud
showentity camera
hideentity fxcamera
renderworld()

hideentity hud
hideentity camera
showentity fxcamera
renderworld()


stayne(Posted 2006) [#22]
btw, here's the latest shot of me messing with this lib:




Naughty Alien(Posted 2006) [#23]
..nice shot..let me know if you manage this HUD issue..its really annoying..


Pinete(Posted 2006) [#24]
Hi,
I have a little question... nothing to do with your problem
because I don't know how to deal with it... sorry!
My question is focused on the water. How have you made it? it seems very cool!
I would like to know how to obtain that result..
Thanks in advance!

regards,


stayne(Posted 2006) [#25]
all his shots and demos are here, along with his email address:

http://agametech.nm.ru

Here's the place to purchase it:

https://www.plimus.com/jsp/buynow.jsp?templateId=43377&referrer=store&contractId=1667313


RifRaf(Posted 2006) [#26]
terrain looks nice, the trees on the other hand look very flat and out of place.. Good work on the terrain ! .


stayne(Posted 2006) [#27]
thanks rifraf. the trees are thrown in for testing.

Naughty Alien: i created a hud and have no problems. i loaded up sprite candy and DID have the exact problem you speak of. i prefer to create my own hud system anyway and i hope you have similar intentions lol.

i'm interested in how you worked out the camerazoom issue.