-
Notifications
You must be signed in to change notification settings - Fork 701
Materials
(Just dumping information here at the moment, this will be more coherent)
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.land_shallow_topo_2048));
material.setColorInfluence(0);
50% diffuse texture, 50% blue color
Material material = new Material();
material.setColor(Color.BLUE);
Texture texture = new Texture("earth", R.drawable.land_shallow_topo_2048);
// -- Use 50% of the texture
texture.setInfluence(.5f);
// -- Use 50% blue
material.setColorInfluence(.5f);
material.addTexture(texture);
[/images/texture_diffuse_specular.png|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.land_shallow_topo_2048));
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setSpecularMethod(new SpecularMethod.Phong());
material.setColorInfluence(0);
Mixing two textures, 50% influence each.
Material material = new Material();
Texture texture1 = new Texture("earth", R.drawable.land_shallow_topo_2048);
// -- Use 50% of this texure
texture1.setInfluence(.5f);
material.addTexture(texture1);
Texture texture2 = new Texture("manila", R.drawable.cloud_combined_2048);
// -- Use 50% of this texture
texture2.setInfluence(.5f);
material.addTexture(texture2);
material.setColorInfluence(0);
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.land_shallow_topo_2048));
material.addTexture(new NormalMapTexture("earthNormal", R.drawable.pattern_normal_map));
// -- 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));
material.setColorInfluence(0);
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.land_shallow_topo_2048);
texture.setWrapType(ATexture.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);
material.setColorInfluence(0);
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.land_shallow_topo_2048);
// -- 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.
material.addTexture(texture);
material.setColorInfluence(0);
Refection maps six face images onto an object, as if the textures were mapped to a cube faces surrounding the object.
Cube Mapping enables objects to simulate reflecting incident illumination from the surrounding environment.
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);
Refection maps a polar image to an object, as if the polar image was mapped to two hemispheres surrounding the object.
Sphere Mapping enables objects to simulate reflecting incident illumination from the surrounding environment.
SphereMapTexture texture = new SphereMapTexture("env", R.drawable.polar1);
texture.isEnvironmentTexture(true);
Material material = new Material();
material.addTexture(texture);
material.setColorInfluence(0);
Reflection mapping on shapes other than a sphere:
Reflection simulated by an Environment Cube Map Combined With Color and a Diffuse Texture
int[] faces = {
R.drawable.sky_4,
R.drawable.sky_2,
R.drawable.sky_6,
R.drawable.sky_5,
R.drawable.sky_1,
R.drawable.sky_3
};
CubeMapTexture cubeMapTexture = new CubeMapTexture("env", faces);
cubeMapTexture.setInfluence(.4f);
cubeMapTexture.isEnvironmentTexture(true);
Texture texture = new Texture("gneiss", R.drawable.gneiss);
texture.setInfluence(.4f);
Material material = new Material();
// -- use 20% plain cyan color
material.setColor(Color.MAGENTA);
material.setColorInfluence(.2f);
material.addTexture(cubeMapTexture);
material.addTexture(texture);
Material material = new Material();
// -- add a diffuse texture
material.addTexture(new Texture("earth", R.drawable.land_shallow_topo_2048));
// -- add a specular map
material.addTexture(new SpecularMapTexture("earthSpec", R.drawable.circuit_specular));
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setSpecularMethod(new SpecularMethod.Phong(0xeeeeee, 200));
material.setColorInfluence(0);
Material material = new Material();
// -- add a diffuse texture
material.addTexture(new Texture("earthDiff", R.drawable.land_shallow_topo_2048));
// -- add a specular map
material.addTexture(new SpecularMapTexture("earthSpec", R.drawable.circuit_specular));
// -- add a normal map
material.addTexture(new NormalMapTexture("earthNorm", R.drawable.pattern_normal_map));
material.setColorInfluence(0);
Material material = new Material();
Texture texture = new Texture("earth", R.drawable.land_shallow_topo_2048);
material.addTexture(texture);
AlphaMapTexture alphaMap = new AlphaMapTexture("alphaMap", R.drawable.grid);
material.addTexture(alphaMap);
material.setColorInfluence(0);
Material material = new Material();
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Toon());
// or new DiffuseMethod.Toon(int color1, int color2, int color3, int color4);