Alpha - different UV set ...

Blitz3D Forums/Blitz3D Programming/Alpha - different UV set ...

necky(Posted 2013) [#1]
Hi!

Is it possible to use a different UV set for the alpha channel on a model in Blitz3D? I really need to know how to do this but I can't seem to work it out.

Thanks!

Mike


jfk EO-11110(Posted 2013) [#2]
yes, 2 sets are possible. it's a while ago I used it the last time. It may help to search the online command reference with a term like "coord", so it will list all commands that contain the term. I also seem to remember therw have been an undocumented Texture Flag in relation to this, probably 65536 aka $ffff.


necky(Posted 2013) [#3]
Thank you! :D I'll take a look now :)


necky(Posted 2013) [#4]
I'm still struggling to get this to work unfortunately :( Can you clarify with a code example possibly how this is done?

thanks :)

Mike


jfk EO-11110(Posted 2013) [#5]
wait a sec, for the alpha channel?? actually, not really. With the fastlib you can use one texture for the alphachannel of an other texturelayer. But you cannot use an other coords set for the highest 8 Bit of eg. a 32 bit tga texture. you could copy it to an other texture and use it in a separate layer, but even then it won't act as alphachannel for the underlying layer.
What exactly do you want to do?


necky(Posted 2013) [#6]
Darn it :( Can this be done in Blitzmax possibly?


jfk EO-11110(Posted 2013) [#7]
Maybe there's an other way in blitz, obviously it wasn't required in DX7. So what is your goal?


necky(Posted 2013) [#8]
It's something I working on at the moment for the company I'm working for so I can't really go into it in too much detail :) But it is safe to say that I need to be able to have seperate UV coordinates for the alpha as it's hoping onto the back of an existing project where it was using them. I'll have to keep digging and see if there is a way, even if that means doing it in Blitzmax somehow :)

thanks for you help, it has been good to clarify if it was or wasn't possible to do :)

Mike


Kryzon(Posted 2013) [#9]
There's no out-of-the-box way to do this. You need FastExtention.

Setup two different textures: one is the diffuse and the other is the one that gives out alpha information (it can be an exact copy of the diffuse, but it can't be the same texture handle just used twice).

With FastEXT...
;ALPHA texture.
AlphaTexture = LoadTexture( "AlphaTexture.png", 1+2 )
TextureCoords( AlphaTexture, 0 )
TextureBlend( AlphaTexture, FE_ALPHAMODULATE )

;DIFFUSE texture.
DiffuseTexture = Loadtexture( "ColorTexture.png", 1 )
TextureCoords( DiffuseTexture, 1 )
TextureBlend( DiffuseTexture, FE_ALPHACURRENT )

EntityTexture( myEntity, AlphaTexture, 0, 0) ;Layer 0.
EntityTexture( myEntity, DiffuseTexture, 0, 1) ;Layer 1, on top of layer 0.

;Edit the vertices' UVs in channel 0 for the alpha. Channel 1 will contain the UVs for diffuse only.
- Reference


jfk EO-11110(Posted 2013) [#10]
As I said, the Fastlib can do it. http://www.blitzbasic.com/toolbox/toolbox.php?tool=219
It's only 12$. It's a useful dll, i use it eg. to render to a 2048x2048 pixel texture in order to edit full hd videos on a 800x600 Display in smk.
An other possibility may be Vertexalpha.


necky(Posted 2013) [#11]
Ah excellent! :D I've just bought this, so that should be spot on! FastExtention saves the day once again! :D

thanks
mike


necky(Posted 2013) [#12]
Almost there now :) Just one final issue. The alpha is now coming out as transparent. It's cutting away the top texture to reveal a solid colour underneath. Is there something I doing wrong?

thanks :)
mike


jfk EO-11110(Posted 2013) [#13]
just test the samples, that smiley cube. I remember one mode was using one texture to set the transparency of the underlying texture. At least, I'm pretty shure ...


Kryzon(Posted 2013) [#14]
I think the problem is on the first layer's blend mode.
A few things to try:

- Using EntityFX(myMesh, 32) to force alpha-blending.

- A different combination of blend operators for the layer zero, by calling the TextureBlendCustom() function (look in FastExt.bb and the D3DTOP_ constants). Focus on the alpha operator.

- Asking the author for support through the FastLibs website. Make sure to explain your case well, and include a link to a screenshot.


jfk EO-11110(Posted 2013) [#15]
solid color underneath? sounds like vertexcolor to me, maybe the texture needs that flag what was it again? 1? 2? let me know if you finally nailed it.

edit, maybe try
cleartexturefilters
texturefilter "",8
...


necky(Posted 2013) [#16]
Hi again!
I finally managed to achieve the effect I was after! Only small issue (hopefully) is the lighting seems to vanish from the object now for some reason. Here's the snipit of code below to see if anyone can shed any light on why the object is self illuminated and not recieving any shadows :)

thanks again!
Mike

<< CODE >>

Global model = CreateSphere()

;ALPHA texture
AlphaTexture = LoadTexture( "TextureAlphaTest.png", 2 )
TextureCoords( AlphaTexture, 0 )
TextureBlend( AlphaTexture, FE_ALPHAMODULATE )

;DIFFUSE texture
DiffuseTexture = LoadTexture( "TextureTest.bmp", 2 )
TextureCoords( DiffuseTexture, 1 )
TextureBlend( DiffuseTexture, FE_ALPHACURRENT )

EntityTexture( model, AlphaTexture, 0, 0) ;Layer 0.
EntityTexture( model, DiffuseTexture, 0, 1) ;Layer 1, on top of layer 0.

EntityTexture model,DiffuseTexture,0,0
EntityTexture model,AlphaTexture,0,1
EntityFX MODEL,32


jfk EO-11110(Posted 2013) [#17]
Can't test this atm., but isn't there a command to fake-shade a mesh, shademesh or something? No wait, that's for terrains. This missung shading could be any little bit somewhere, before you hack a long time, try to search the forum, maybe this was already discussed. Or maybe you can contact the author, if it's a fastext bug, he shure would know about it.