parts of a Texture

Blitz3D Forums/Blitz3D Programming/parts of a Texture

Jack(Posted 2010) [#1]
Here is waht I would like to do.

Make a texture in a paint program colored with around 10-12 brushes.

Apply that texture to a flat mesh in blitz.

Locate a spot on the mesh and identify the brush used in that area.

I am able to do this if I make the brushes and apply them in a program like Milkshape or Blender and save the mesh. And export of course.

But.... I would rather be able to apply the texture from blitz as made in a paint program.


K(Posted 2010) [#2]
I don't quite understand, but judging by just what you said you seem to be confusing a "Brush" used in an image editor and a "Brush"(or Material,i.e. Surface) in Blender. Supposing you're using JPG etc. the brushes in the image editor merely become pixel data.

However, assuming your brushes have vastly different colors you could use GetColor on the buffer detect ranges.If your brushes are nicely laid out in a grid you could select based on world coords.

I could be way off on this.Correct me if I'm wrong.


Jack(Posted 2010) [#3]
I am not confusing the "Brush" term but I couldnt figure out how to explain my problem. There are paint programs were you can in effect paint with a "texture or "brush".Like a photograph.

So I want to take a .bmp which I have created with a number of these "brushes" and apply it to a mesh. I easily can get the color of any pixel but that doesn't solve the deal. Each "brush" will have many colors.Any are not in an easily defined area.


Thanks for the answer "K".


K(Posted 2010) [#4]
All that I can think would be to map out your image and grab texcoords using VertexU()+VertexV() and compare to that map.That's for retieval,
for texturing you could use said map to set which brush is used using VertexTexCoords. Again correct me if I'm not getting the point.

EDIT: here's a question, Are they nicely laid out in the image?That would make the above easier.

Last edited 2010


Vorderman(Posted 2010) [#5]
I did a similar thing for a wargame project I worked on for a while - I wanted to tag up areas of the ground as mud, rock etc.. so I made a custom texture-painting program that could store the type of image painted down as you painted.

What I did was simply to store the ground type in a huge 2D array the size of the texture (so in this case 2048 x 2048) - this array was prepared in advance (by my texture painting program) so the main program could just read from it much quicker than reading pixels from a texture.

I increased the array to hold more elements later, so I could pre-calc stuff like lighting levels, whether than spot was in cover etc.. so the array became 2048 x 2048 x 8 or something.

I would pre-process your texture using whatever slow method works, then save that to a file and load it into a big array at runtime.

Then all you need to do is convert the position you want to check into a UV coord, then look that up in the array, so pixels on the X axis from 0 to 2047 become UVs on the X axis from 0 to 1.0.


Jack(Posted 2010) [#6]
K and Vorderman both ideas might be the deal.

Voderman... so a hugh array of 2048 x 2048 would fit in blitz. Ithought
the array size was lower by far. Don't know where I got that idea.

So this would be faster than a "linepick" command. Didn't imagine
that either but it makes sense. This would be just super.

It would not make much difference if filling the array in texture construction took some time since you could use a different solid color in each area to fill the array.Then later "paint" over a particular type ground-cover with the final texture makeup.

I'm anxious to give this a try. Maybe make a function in my progam to read a bitmap and store as you suggest.


K(Posted 2010) [#7]
If your render time shoots up, you can speed it slightly by using a bank instead of an array,but only a little.