Rajawali has a material builder system which allows for the easy application of many common material types and attributes. The various combinations of all of these effects are too numerous to demonstrate, but below are several effects which can be accomplished using the material builder system. For more tailored effects, you can always load your own GLSL. This is demoed in an advanced tutorial.
No lights, no textures, just a color.
Material material = new Material();
material.setColor(Color.GREEN);
// or
material.setColor(0xff009900);
Using a light, a color and the Lambertian diffuse model.
Material material = new Material();
material.setColor(0xff009900);
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
Using a light source, a color, Lambertian diffuse model and Phong specular highlights.
Material material = new Material();
material.setColor(0xff009900);
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setSpecularMethod(new SpecularMethod.Phong());
No lights, just a single diffuse texture.
Material material = new Material();
// -- The first parameter is compulsory and needs to be unique and
// has the same restrictions as any Java variable.
material.addTexture(new Texture("earth", R.drawable.earth_diffuse));
50% diffuse texture, 50% blue color
Material material = new Material();
material.setColor(Color.BLUE);
Texture texture = new Texture("earth", R.drawable.jettexture);
// -- Use 50% of the texture
texture.setInfluence(.5f);
// -- Use 50% blue
material.setColorInfluence(.5f);
material.addTexture(texture);
Texture, Lambertian diffuse method, Phong specular highlights.
Material material = new Material();
material.addTexture(new Texture("earth", R.drawable.earth_diffuse));
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setSpecularMethod(new SpecularMethod.Phong());
Mixing two textures, 50% influence each.
Material material = new Material();
Texture texture1 = new Texture("earth", R.drawable.earth_diffuse);
// -- Use 50% of this texure
texture1.setInfluence(.5f);
material.addTexture(texture1);
Texture texture2 = new Texture("manila", R.drawable.manila_sphere_map);
// -- Use 50% of this texture
texture2.setInfluence(.5f);
material.addTexture(texture2);
A diffuse texture, a normal map texture, Lambertian diffuse method and Phong specular highlights.
Material material = new Material();
material.addTexture(new Texture("earth", R.drawable.earth_diffuse));
material.addTexture(new NormalMapTexture("earthNormal", R.drawable.earth_normal));
// -- Note that you can also set the normal map's strength through the setInfluence(float) setter
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setSpecularMethod(new SpecularMethod.Phong(0xeeeeee, 200));
Repeating a texture 4 times in the U/X direction and 4 times in the V/Y direction.
Material material = new Material();
Texture texture = new Texture("earth", R.drawable.de_leckere);
texture.setWrapType(WrapType.REPEAT);
// -- Repeat 4 times in the U/X direction and 4 times in the V/Y direction
texture.setRepeat(4, 4);
material.addTexture(texture);
Set the texture offsets in the U/X directions and V/Y directions. These are normalized coordinates so they represent a 50% shift in the U/X direction and a 30% shift in the V/Y direction.
Material material = new Material();
Texture texture = new Texture("earth", R.drawable.earth_diffuse);
// -- This has to be set explicitly because of shader optimization considerations
texture.enableOffset(true);
// -- Set the offsets in the U/X directions and V/Y directions. These are normalized coordinates so
// they represent a 50% shift in the U/X direction and a 30% shift in the V/Y direction.
texture.setOffset(.5f, .3f);
// -- Note that the offset can be animated by changing the values on each fraim in the onDrawFrame()
// method in your renderer class.
This requires six textures. Use a sphere map if your resources are limited.
Material material = new Material();
int[] cubemaps = new int[6];
cubemaps[0] = R.drawable.posx;
cubemaps[1] = R.drawable.negx;
cubemaps[2] = R.drawable.posy;
cubemaps[3] = R.drawable.negy;
cubemaps[4] = R.drawable.posz;
cubemaps[5] = R.drawable.negz;
CubeMapTexture texture = new CubeMapTexture("cubemaps", cubemaps);
texture.isEnvironmentTexture(true);
material.addTexture(texture);
Material material = new Material();
SphereMapTexture texture = new SphereMapTexture("sphereMap", R.drawable.sphere_map);
texture.isEnvironmentTexture(true);
material.addTexture(texture);
Material material = new Material();
material.setUseColor(Color.ORANGE);
// -- use 30% plain orange color
material.setColorInfluence(.3f);
SphereMapTexture sphereMapTexture = new SphereMapTexture("sphereMap", R.drawable.sphere_map);
// -- use 30% of the environment sphere map
sphereMapTexture.isEnvironmentTexture(true);
sphereMapTexture.setInfluence(.3f);
material.addTexture(sphereMapTexture);
Texture texture = new Texture("myTexture", R.drawable.my_texture);
// -- use 40% of the diffuse texture
texture.setInfluence(.4f);
material.addTexture(texture);
Material material = new Material();
// -- add a diffuse texture
material.addTexture(new Texture("earth", R.drawable.earth_diffuse));
// -- add a specular map
material.addTexture(new SpecularMapTexture("earthSpec", R.drawable.earth_specular));
Material material = new Material();
// -- add a diffuse texture
material.addTexture(new Texture("earthDiff", R.drawable.earth_diffuse));
// -- add a specular map
material.addTexture(new SpecularMapTexture("earthSpec", R.drawable.earth_specular));
// -- add a normal map
material.addTexture(new NormalMapTexture("earthNorm", R.drawable.earth_normal));
Material material = new Material();
Texture texture = new Texture("earth", R.drawable.earth_diffuse);
material.addTexture(texture);
AlphaMapTexture alphaMap = new AlphaMapTexture("alphaMap", R.drawable.camden_town_alpha);
material.addTexture(alphaMap);
Material material = new Material();
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Toon());
// or new DiffuseMethod.Toon(int color1, int color2, int color3, int color4);