2 texture blends, 2 UV sets.. whats the penalty?

Blitz3D Forums/Blitz3D Programming/2 texture blends, 2 UV sets.. whats the penalty?

ashmantle(Posted 2004) [#1]
Hey everyone!

I am thinking of creating every object in my world with 2 UV sets and 2 different textures.. I want to do this because then I can add,, say moss to a tree, while not needing to mess up the wood texture.. I can add seamlessness to a tile-looking texture by adding random spots of overlay..

Example.. if I have a room made up of a tiled brick texture..
boooring ^^ but then I add a Masked image of several tileable cement splats which I put here and there.. voila, not so boring ^^

The thing is... will this severly affect performance? Im talking EVERY object here..

This is the method Im gonna use:
cube=LoadMesh("test.b3d") 
PositionEntity cube,0,0,15 

; Load texture 
tex1=LoadTexture( "brucks.png" )
TextureCoords tex1,0
tex2=LoadTexture( "rainbow.png",4)
TextureCoords tex2,1

TextureBlend tex2,1

; Texture cube with texture 
EntityTexture cube,tex1,0,0
EntityTexture cube,tex2,0,1


No alpha... just mask..


Bouncer(Posted 2004) [#2]
no significant effect with never gfx-cards....


ashmantle(Posted 2004) [#3]
hmmm.. I have discovered a problem though..

the mask texture doesn't seem affected by vertex lights as the first layer is.. it looks fullbright all the way..

Anyone else had this problem?

In the manual it says that the higher index texture is blended with the one below it, and the result is blended with the mesh.. this is obvious not the case here.. :/

thanks for the reply Bouncer ^^

two images showing the problem:




sswift(Posted 2004) [#4]
Unfortunately, due to the way texture blending modes work, you can't have a masked texture affected by a light.

What you are doing is this:

1. Apply light to white pixel.
2. Multiply first texture color with lit pixel color.
3. Replace pixel with mask texture pixel where mask is opaque.

As you can seem the lighting information is lost where the mask replaces the color of the pixel below it.

You would need to be able to apply the pixel lighting as the last step rather than the first for this to work. However, I don't know if it would be possible to do that at all, and Blitz certainly does not support it. In addition, doing that would make other effects, such as making parts of a mesh glow despite not being lit, impossible.

To achieve the effect you want, what you will have to do instead is use a second surface with the masked texture on it. Then it will have it's own untarnished plain lit pixel to multiply with, resulting in the appearance of being lit like the rest of the mesh.

Unfortunately, each surface comes at a great cost, and you will be limited to around 200-400 surfaces visible at once on the screen in your game if you want to maintain an acceptable framerate.

Personally I reccomend that you just make two textures, one with moss, one without. It's much simpler, and you're not very likely to run out of texture ram unless you are making a huge project.


jfk EO-11110(Posted 2004) [#5]
or maybe just use a quad that was placed on the original mesh, containing the moss. That's the way the engine of hitman 2 handles it, for example.


ashmantle(Posted 2004) [#6]
hmm... thanks for the information..

depressing news ^^ but I will try that quad thing anyways.. thanks!