Skip to content
Dennis Ippel edited this page Sep 2, 2013 · 15 revisions

(Anchor Steam) Materials

(Just dumping information here at the moment, this will be more coherent)

Creating a color material without using lighting

Unlit Material

No lights, no textures, just a color.

Material material = new Material();
material.setColor(Color.GREEN);
// or
material.setColor(0xff009900); 

Creating a color material with diffuse lighting

Material with diffuse lighting

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());

Creating a color material with diffuse lighting and specular highlights

Material with diffuse lighting and specular highlights

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());

Using a diffuse texture

Diffuse texture

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));

Mixing diffuse texture with color

Diffuse texture mixed with a color

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);

Using a diffuse texture with diffuse lighting and specular highlights

Texture with diffuse lighting and specular highlights

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 diffuse textures

Mixing two textures

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);

Using a normal map

Using a normal map

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 textures

Texture repeating

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);

Texture offset

Texture offset

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 frame in the onDrawFrame()
//    method in your renderer class.

Environment Cube Map

Environment cube map

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);

Environment Sphere Map

Environment sphere map

Material material = new Material();
SphereMapTexture texture = new SphereMapTexture("sphereMap", R.drawable.sphere_map);
texture.isEnvironmentTexture(true);
material.addTexture(texture);

Environment Sphere Map Combined With Color and a Diffuse Texture

Sphere map with color & 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);

Diffuse Texture & Specular Map

Diffuse Texture & Specular Map

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));

Diffuse Texture, Specular Map & Normal Map

Diffuse Texture, Specular Map & Normal Map

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));

Diffuse Texture & Alpha Map

Diffuse Texture, Specular Map & Normal Map

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);

Toon Material

Toon Material

Material material = new Material();
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Toon());
// or new DiffuseMethod.Toon(int color1, int color2, int color3, int color4);
Clone this wiki locally