Tinting the Mesh

Software: Away3D 4.x

marronnier, Newbie
Posted: 13 May 2015 02:48 PM   Total Posts: 17

Is there a way to tint a Mesh? Not material.
I have a lot of meshes sharing single material, but each of them should have own color.

   

Avatar
Fabrice Closier, Administrator
Posted: 13 May 2015 04:26 PM   Total Posts: 1265   [ # 1 ]

you have 2 options: making more materials or have a TextureMaterial with squares of different colors and you offset/scale the meshes uvs accordingly.

Giving a color to a mesh is actually what the ColorMaterial does. Underneath, the material holds 3x values 0-1 for each channel extracted from your hexadecimal color value and this constants are being used by the AGAL shader.

Note that ColorMaterials are very light, so you can have a shit load of these without problems.

 

   

marronnier, Newbie
Posted: 14 May 2015 11:29 AM   Total Posts: 17   [ # 2 ]

Thanks Fabrice
I have one big TextureMaterial (with specular & normal maps). A texture.. An atlas with font: all characters I need in good resolution. They all are in black&white; and I hoped to apply a tint to colorize separate characters/words.
So I should have all character sets in all colors… :(
Or is there other way?

 

   

Avatar
Fabrice Closier, Administrator
Posted: 14 May 2015 11:36 AM   Total Posts: 1265   [ # 3 ]

yes well, you have more options like use the ColorMatrixMethod.
You simply make a new material, where you do reuse the normal and diffuse map texture. if you don’t you will use lots of memory. and have a a dedicated color matrix method per material.

Another one, economical and probably best if you have all black and white is to add and share a lightmap to mutiple colormaterials.
if you have made an atlas, it will work out of the box in both cases.

 

   

marronnier, Newbie
Posted: 14 May 2015 03:07 PM   Total Posts: 17   [ # 4 ]

* Using LightMapMethod on PlaneGeometry cause black background (may be I miss something? I haven’t used LightMap earlier)

* As I understand, using ColorMatrixMethod or ColorTransform on material, I need to create a new TextureMaterial for each character, and have shared texture, normal & specular BitmapTextures.
Won’t this use a lot of memory? Because the target is mobile platform.

//LightMapMethod
   //pink
   
var m1:Mesh = new Mesh(new PlaneGeometry(256256), new ColorMaterial(0xFF0080));
   
m1.material.lightPicker light;
   
ColorMaterial(m1.material).alphaBlending true;
   
ColorMaterial(m1.material).addMethod(new LightMapMethod(Cast.bitmapTexture(chTexture)));
   
m1.= -150;
   
m1.150;
   
_view.scene.addChild(m1);
   
   
//ColorMatrixMethod
   
var mTexture:BitmapTexture Cast.bitmapTexture(chTexture);
   
//red
   
var m2texture:TextureMaterial = new TextureMaterial(mTexture);
   
m2texture.lightPicker light;
   
m2texture.alphaBlending true;
   var 
m2:Mesh = new Mesh(new PlaneGeometry(256256), m2texture);
   
m2texture.addMethod(new ColorMatrixMethod([1,0,0,0,00,0,0,0,00,0,0,0,00,0,0,1,0]));
   
m2.150;
   
m2.150;
   
_view.scene.addChild(m2);
   
//grey
   
var m3texture:TextureMaterial = new TextureMaterial(mTexture);
   
m3texture.alphaBlending true;
   var 
m3:Mesh = new Mesh(new PlaneGeometry(256256), m3texture);
   
m3.150;
   
m3.= -150;
   
_view.scene.addChild(m3);
   
//blue
   
var m4texture:TextureMaterial = new TextureMaterial(mTexture);
   
m4texture.alphaBlending true;
   
m4texture.colorTransform = new ColorTransform(00.51);
   var 
m4:Mesh = new Mesh(new PlaneGeometry(256256), m4texture);
   
m4.= -150;
   
m4.= -150;
   
_view.scene.addChild(m4); 

PS: a very simple example in attachment.

 

File Attachments
coloring.zip  (File Size: 13KB - Downloads: 205)
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X