[free]TextureTools

Posted By: bstudio

[free]TextureTools - 08/17/07 09:43

This is a little program I created, still verry WIP but you can generate normal maps, invert an image, and greyscale it. My own beta version also includes a seamless texture generator, but it doesn't blur the edges correctly yet so it shows with seams in the middle . It can save images in jpeg format, bmp format and gif format (not the most usefull ones) but the next version will include TGA and PCX.

Download TextureTools
Posted By: RedPhoenix

Re: [free]TextureTools - 08/17/07 10:43

It doesn't start on my pc.
Posted By: bstudio

Re: [free]TextureTools - 08/17/07 11:33

Ok, now you just have to run setup.exe (the build didn't succeed last time )
Posted By: RedPhoenix

Re: [free]TextureTools - 08/18/07 16:04

Nice tool, works great as far as I can say.
Posted By: msl_manni

Re: [free]TextureTools - 08/19/07 07:35

Have not been able to install the application.
It generates error -

Unable to install or run the application. The application requires that assembly Microsoft.DirecxtX.Direct3D version 1.0.2902 be installed in the Global Assembly Cache(GAC) first. Please contact your system administrator.

I would like to know system requirements for your software.
I am using XP1.
Posted By: MrCode

Re: [free]TextureTools - 08/19/07 08:54

It's working for me, but the Normal map function freezes the program.
Posted By: bstudio

Re: [free]TextureTools - 08/19/07 13:54

Do you use vista? Because if you do you'll have to run it in administrator mode
Posted By: msl_manni

Re: [free]TextureTools - 08/19/07 14:24

Quote:

Do you use vista? Because if you do you'll have to run it in administrator mode




Already said, using xp1 not vista.
Posted By: bstudio

Re: [free]TextureTools - 08/19/07 17:06

Oh wait, I've got the problem. I used some DirectX dependency's to test a little but didn't use them further. Problem solved (I hope )
Posted By: msl_manni

Re: [free]TextureTools - 08/20/07 05:14

It works GREAT, and I like the procedure for generating the Normal map. It would be great if one can draw on map too. And please make it so that the shader on a model can be loaded as seen in realtime too. There should be an option for intensity of normal too.
Posted By: bstudio

Re: [free]TextureTools - 08/20/07 06:49

I'm working on options for the normal map and a realtime viewer with a shader, I just have to integrate the 3dgs window within my C# application. So I need to write a wrapper :|
Posted By: RedPhoenix

Re: [free]TextureTools - 08/20/07 11:18

Would you like to share the code of your normalmapping calculations?
I need a code for creating normalmaps in an editorlike project of mine, but have no idea of how this should look like
Posted By: bstudio

Re: [free]TextureTools - 08/20/07 11:21

Happy to share my source but it's all C#, so if you need it in another language better convert it. I'll comment it for you too just wait a minute

Edit:
Here you go
Code:

class SobelFilter
{
public float scale = 1.0f;

Bitmap b, b1;
public Image apply(Image im)
{
float dx; //Current x pixel
float dy; //Current y pixel
int[] pix = { 0, 0, 0 }; //Color of the pixel
float nx; //normal X
float ny; //normal Y
float nz; //normal Z
float length; //length

b = (Bitmap)im; //Source bitmap
Bitmap b1 = new Bitmap(im); //Target bitmap
for (int y = 1; y < b.Height - 1; y++) // loop for the image pixels height
{
for (int x = 1; x < b.Width - 1; x++) // loop for image pixels width
{
pix[0] = b.GetPixel((x - 1 + b.Width) % b.Width, (y + 1) % b.Height).R; //Get R value
pix[1] = b.GetPixel((x - 1 + b.Width) % b.Width, (y + 1) % b.Height).G; //Get G value
pix[2] = b.GetPixel((x - 1 + b.Width) % b.Width, (y + 1) % b.Height).B; //Get B value
dy = pix[0] / 225.0f * -1.0f; //Calculate value of R color
//Same here for other pixels
pix[0] = b.GetPixel(x % b.Width, (y + 1) % b.Height).R;
pix[1] = b.GetPixel(x % b.Width, (y + 1) % b.Height).G;
pix[2] = b.GetPixel(x % b.Width, (y + 1) % b.Height).B;
dy += pix[0] / 225.0f * -2.0f;

pix[0] = b.GetPixel((x + 1) % b.Width, (y + 1) % b.Height).R;
pix[1] = b.GetPixel((x + 1) % b.Width, (y + 1) % b.Height).G;
pix[2] = b.GetPixel((x + 1) % b.Width, (y + 1) % b.Height).B;
dy += pix[0] / 225.0f * -1.0f;

pix[0] = b.GetPixel((x - 1 + b.Width) % b.Width, (y - 1 + b.Height) % b.Height).R;
pix[1] = b.GetPixel((x + 1) % b.Width, (y + 1) % b.Height).G;
pix[2] = b.GetPixel((x + 1) % b.Width, (y + 1) % b.Height).B;
dy += pix[0] / 225.0f * 1.0f;

pix[0] = b.GetPixel(x % b.Width, (y - 1 + b.Height) % b.Height).R;
pix[1] = b.GetPixel(x % b.Width, (y - 1 + b.Height) % b.Height).G;
pix[2] = b.GetPixel(x % b.Width, (y - 1 + b.Height) % b.Height).B;
dy += pix[0] / 225.0f * 2.0f;

pix[0] = b.GetPixel((x + 1) % b.Width, (y - 1 + b.Height) % b.Height).R;
pix[1] = b.GetPixel(x % b.Width, (y - 1 + b.Height) % b.Height).G;
pix[2] = b.GetPixel(x % b.Width, (y - 1 + b.Height) % b.Height).B;
dy += pix[0] / 225.0f * 1.0f;

//x filter
pix[0] = b.GetPixel((x - 1 + b.Height) % b.Width, (y - 1 + b.Height) % b.Height).R;
pix[1] = b.GetPixel((x - 1 + b.Height) % b.Width, (y - 1 + b.Height) % b.Height).G;
pix[2] = b.GetPixel((x - 1 + b.Height) % b.Width, (y - 1 + b.Height) % b.Height).B;
dx = pix[0] / 225.0f * -1.0f;

pix[0] = b.GetPixel((x - 1 + b.Width) % b.Width, y % b.Width).R;
pix[1] = b.GetPixel((x - 1 + b.Width) % b.Width, y % b.Width).G;
pix[2] = b.GetPixel((x - 1 + b.Width) % b.Width, y % b.Width).B;
dx += pix[0] / 225.0f * -2.0f;

pix[0] = b.GetPixel((x - 1 + b.Width) % b.Width, (y + 1) % b.Height).R;
pix[1] = b.GetPixel((x - 1 + b.Width) % b.Width, (y + 1) % b.Height).G;
pix[2] = b.GetPixel((x - 1 + b.Width) % b.Width, (y + 1) % b.Height).B;
dx += pix[0] / 225.0f * -1.0f;

pix[0] = b.GetPixel((x + 1) % b.Width, (y - 1 + b.Height) % b.Height).R;
pix[1] = b.GetPixel((x + 1) % b.Width, (y - 1 + b.Height) % b.Height).G;
pix[2] = b.GetPixel((x + 1) % b.Width, (y - 1 + b.Height) % b.Height).B;
dx += pix[0] / 225.0f * 1.0f;

pix[0] = b.GetPixel((x + 1) % b.Width, y % b.Height).R;
pix[1] = b.GetPixel((x + 1) % b.Width, y % b.Height).G;
pix[2] = b.GetPixel((x + 1) % b.Width, y % b.Height).B;
dx += pix[0] / 225.0f * 2.0f;

pix[0] = b.GetPixel((x + 1) % b.Width, (y + 1) % b.Height).R;
pix[1] = b.GetPixel((x + 1) % b.Width, (y + 1) % b.Height).G;
pix[2] = b.GetPixel((x + 1) % b.Width, (y + 1) % b.Height).B;
dx += pix[0] / 225.0f * 1.0f;

//Cross product of values
nx = dx;
ny = dy;
nz = 1 / this.scale;

//Normalize
length = 1.0f;
nx *= length;
ny *= length;
nz *= length;

//convert to float
pix[0] = floatToByte(nx);
pix[1] = floatToByte(ny);
pix[2] = floatToByte(nz);

//make sure we have no negative values or values above 255
if (pix[0] > 255)
pix[0] = 255;
if (pix[1] > 255)
pix[1] = 255;
if (pix[2] > 255)
pix[2] = 255;

if (pix[0] < 0)
pix[0] = 0;
if (pix[1] < 0)
pix[1] = 0;
if (pix[2] < 0)
pix[2] = 0;

//create the color for the pixel
Color c = Color.FromArgb(pix[0],pix[1],pix[2]);

//write the color for the pixel
b1.SetPixel(x,y,c);
}
}
return (Image)b1; //return generated image

}

private int floatToByte(float inValue) {
return (int)((inValue + 1.0f) / 2.0f * 255.0f);
}
}


Posted By: msl_manni

Re: [free]TextureTools - 08/20/07 13:19

I thought you were using bmap_to_normals for creating the normalmap.

bmap_to_normals(BMAP* bmap,var factor)

if (pix[0] > 255)
pix[0] = 255;

I see that you are truncating the color components of nornalmap, wouldn't it make the normal calc of those pixels incorrect. Though I doubt that there would be any need for alteration if done correctly.
Posted By: bstudio

Re: [free]TextureTools - 08/20/07 13:30

This was indeed a little quick fix, for some reason my pixel colors do seem to get a value of -14 and 256, still need to find out why
Posted By: RedPhoenix

Re: [free]TextureTools - 08/20/07 13:54

Nice thank you very much! If I ever get something finished I'll mention you
© 2024 lite-C Forums