-
Notifications
You must be signed in to change notification settings - Fork 707
v0.9 Tutorial 03 Materials
A basic material is just a color or a texture without any lighting enabled. This renders a green cube:
Material simple = new Material();
simple.setColor(Color.GREEN);
mCube.setMaterial(simple);
This renders a textured cube:
Texture texture = new Texture("unique_identifier", R.drawable.mytexture);
Material simple = new Material();
simple.addTexture(texture);
mCube.setMaterial(simple);
Use this material to emulate diffusely reflecting surfaces. See this article on Wikipedia.
DirectionalLight mLight = new DirectionalLight(-3,-6,-3);
getCurrentScene().addLight(mLight);
Material lambert = new Material();
lambert.setColor(Color.YELLOW);
lambert.setDiffuseMethod(new DiffuseMethod.Lambert());
lambert.enableLighting(true)
mCube.setMaterial(lambert);
Use this material to get nice specular highlights. See this article on Wikipedia.
DirectionalLight mLight = new DirectionalLight(-3,-6,-3);
getCurrentScene().addLight(mLight);
Material phong = new Material();
phong.setColor(Color.YELLOW);
phong.setSpecularMethod(new SpecularMethod.Phong());
phong.enableLighting(true)
mCube.setMaterial(lambert);
Image maps can be applied to materials to simplify alpha, specular, and normal mapping.
Here is an example of how mapping is utilized:
Texture texture = new Texture("drawableTexture", R.drawable.texture);
NormalMapTexture normalMap = new NormalMapTexture("normalMap", R.drawable.normal);
SpecularMapTexture specularMap = new SpecularMapTexture("specularMap", R.drawable.specular);
AlphaMapTexture alphaMap = new AlphaMapTexture("alphaMap", R.drawable.alpha);
Material myMappedMaterial = new Material();
myMappedMaterial.addTexture(texture);
myMappedMaterial.addTexture(normalMap); //RGB normal map
myMappedMaterial.addTexture(specularMap); //Black and white alpha map where white is shiny
myMappedMaterial.addTexture(alphaMap); //Black and white alpha map where white is opaque
Object3D mObject = new Cube();
mObject.setMaterial(myMappedMaterial);
getCurrentScene().addChild(mObject);
See https://github.com/Rajawali/Rajawali/wiki/Tutorial-05-Skybox
See https://github.com/MasDennis/Rajawali/wiki/Tutorial-14-Bump-Normal-Mapping
See https://github.com/MasDennis/Rajawali/wiki/Tutorial-11-Particles
See https://github.com/MasDennis/Rajawali/wiki/Tutorial-09-Creating-a-Custom-Material---GLSL-Shader
Use this material to emulate a cartoon-style effect. Read more about this in this Wikipedia article.
DirectionalLight mLight = new DirectionalLight(-3,-6,-3);
getCurrentScene().addLight(mLight);
Material toon = new Material();
toon.setDiffuseMethod(new DiffuseMethod.Toon());
toon.enableLighting(true);
toon.setColorInfluence(0);
mCube.setMaterial(toon);