Change Texture Color

Blitz3D Forums/Blitz3D Programming/Change Texture Color

KuRiX(Posted 2006) [#1]
I need one thing that i think it cannot be done easily and fast... but perhaps i am missing something.

I have a model with a simple texture. I want to add a second texture, to mask some parts. But what i want is to change the second texture color in realtime, so i can mask with differente colors the original texture.

I cannot use vertexcolors, because that would change all the colors of both textures.

Do you understand? Is it possible?


b32(Posted 2006) [#2]
You can create an empty texture using CreateTexture, and then draw to it using SetBuffer TextureBuffer:



KuRiX(Posted 2006) [#3]
Thanks, Mmm, well, but then, i need to create empty texture, read the mask texture, and change the color while writing... too slow...

more ideas?


Junkprogger(Posted 2006) [#4]
You can use a secound modell, set its alpha value to... 0.2? and then change the color of the secound modell. The only disadvantage is, you have double poly count...

Where's the since of this, by the way?


KuRiX(Posted 2006) [#5]
It is to change the color of the main models, but instead of having N textures with N different colors, i can change the texture color (colorize), and mask it over the model...


b32(Posted 2006) [#6]
Maybe you could use this, you need to grayscale the original texture. It uses a small 2nd texture to change the color.



KuRiX(Posted 2006) [#7]
Mmm, is is interesting... the thing is that texturebuffer could do the trick...

Thanks, i will try...

Offtopic: I love this forum, people is always trying to help. I am in a lot of programming forums, and this is by far the best (i had some troubles with other user in other forum recently...)


Stevie G(Posted 2006) [#8]
Here's how I would do it, not sure how similar it is to Brams.

For the parts of the model which need to be changed by the colour texture ... make sure they are grey scale only, leave the rest as is.

Using the second UV channel , change the coords for those vertices which are to remain untouched to 0,0 and those which will be effected by the second colour texture to .5, .5. The color texture should be pure white with a coloured square in the middle. Leave at least a 2 pixel white edge. An 8x8 texture size would be fine for this.

Simply apply the second texture using multiply blend.

You could either change the colour by overwriting the coloured rect in the middle of the second texture or just make one larger animtexture and re-texture the model each time using a different frame.

Make sense?

Stevie


KuRiX(Posted 2006) [#9]
I think i have understood it, but i cannot separate the parts that need to be colores using vertices... because for example a simple quad has some parts to be colored and some parts not...


EDITED: I got it working!!! in a slow mode, but it is enough. I load the texture as loadimage, and for every pixel, if pixel is not white, i assign the pixel the color i want, then copyrect to texturebuffer, then multitexture with blend.

Thanks to all!


b32(Posted 2006) [#10]
Instead of using pixel-pro-pixel for this, maybe you could use an image and set it's masking colour to white with MaskImage:



KuRiX(Posted 2006) [#11]
Wow, faster, indeed. Thanks!