Image Map - How to change pixels in an Image.
by Peterjohn Griffiths · in Technical Issues · 05/25/2011 (5:48 am) · 5 replies
Is it possible to change a pixel in an imagemap through script?.
IE make a pixel green or blue.
I would also like to save this out to a file after the script has amended the colour.
This would save me creating multiple images for the same item but with different colour tints and allow me to have one image and one image colour tint file to allow for an endless variation on colours.
If not, I will have to do this in C++ and create the script links to the functions.
Many thanks in advance.
IE make a pixel green or blue.
I would also like to save this out to a file after the script has amended the colour.
This would save me creating multiple images for the same item but with different colour tints and allow me to have one image and one image colour tint file to allow for an endless variation on colours.
If not, I will have to do this in C++ and create the script links to the functions.
Many thanks in advance.
#2
Maybe I should dig around in the C++ code and see if they do this anywhere there first and see if it traces through to script.
05/25/2011 (10:24 am)
Thanks Alain, I was wanting to use blending with the resulting image yes, but I need to dynamicaly create the image to blend first, pixel by pixel in script. Thats the part i'm stuck on.Maybe I should dig around in the C++ code and see if they do this anywhere there first and see if it traces through to script.
#3
05/25/2011 (10:26 am)
This functionality you are describing does not exist in the stock engine. Per-pixel manipulation would require new source code modifications.
#4
I will look into doing this through opengl, just wanted to avoid it if possible, opengl is not my strong point, but it will be quicker than CPU I would assume due to transfer rates.
Then all thats needed is to open this up to a script call.
05/25/2011 (12:14 pm)
Thanks Michael,I will look into doing this through opengl, just wanted to avoid it if possible, opengl is not my strong point, but it will be quicker than CPU I would assume due to transfer rates.
Then all thats needed is to open this up to a script call.
#5
You must create a CustomMaterial for each new mood and an unique premade CustomShader, then you pass to the shader the value to be overwrite to the masked pixels.
PseudoCode:
Anything is possible ;D
EDIT: If you must, you can also save on a new bitmap the result.
05/25/2011 (3:30 pm)
U can, but via a Pixel Shader.You must create a CustomMaterial for each new mood and an unique premade CustomShader, then you pass to the shader the value to be overwrite to the masked pixels.
PseudoCode:
float4 MASK1 = float4(1, 0, 0, 1) // RED PIXEL
float4 MASK1 = float4(0, 1, 0, 1) // BLUE PIXEL
uniform float4 ModValue1; // IMPORTED FROM SCRIPT
uniform float4 ModValue2; // IMPORTED FROM SCRIPT
main {
float4 CurrentPixel = tex2d(DiffMap, UV);
if (CurrentPixel == MASK1)
{
CurrentPixel = ModValue1;
}
if (CurrentPixel == MASK2)
{
CurrentPixel = ModValue2;
}
return CurrentPixel;
}Anything is possible ;D
EDIT: If you must, you can also save on a new bitmap the result.
Torque Owner Alain Labrie
Ware-Wolf Games
Good Luck