|
@@ -81,21 +81,24 @@ Every Material must have at least Material Colors or Textures. Some optional mat
|
|
|
To give an unshaded material a color:
|
|
To give an unshaded material a color:
|
|
|
|
|
|
|
|
. Specify the color property
|
|
. Specify the color property
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setColor("Color", ColorRGBA.Blue); // with Unshaded.j3md
|
|
mat.setColor("Color", ColorRGBA.Blue); // with Unshaded.j3md
|
|
|
----
|
|
----
|
|
|
-
|
|
|
|
|
|
|
++
|
|
|
|
|
|
|
|
To give an Phong-illuminated material a color:
|
|
To give an Phong-illuminated material a color:
|
|
|
|
|
|
|
|
. Activate material colors:
|
|
. Activate material colors:
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setBoolean("UseMaterialColors",true); // with Lighting.j3md
|
|
mat.setBoolean("UseMaterialColors",true); // with Lighting.j3md
|
|
|
----
|
|
----
|
|
|
-
|
|
|
|
|
|
|
++
|
|
|
. Specify at least Diffuse and Ambient colors. Set both to the same color in the standard case.
|
|
. Specify at least Diffuse and Ambient colors. Set both to the same color in the standard case.
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setColor("Diffuse", ColorRGBA.Blue ); // with Lighting.j3md
|
|
mat.setColor("Diffuse", ColorRGBA.Blue ); // with Lighting.j3md
|
|
@@ -148,12 +151,14 @@ A NormalMap (also called BumpMap) is an extra colored texture that describes the
|
|
|
To add a BumpMap (this only makes sense for illuminated Materials):
|
|
To add a BumpMap (this only makes sense for illuminated Materials):
|
|
|
|
|
|
|
|
. Generate normal vectors information for the Mesh (not for the Geometry!) using `com.jme3.util.TangentBinormalGenerator`.
|
|
. Generate normal vectors information for the Mesh (not for the Geometry!) using `com.jme3.util.TangentBinormalGenerator`.
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
TangentBinormalGenerator.generate(mesh);
|
|
TangentBinormalGenerator.generate(mesh);
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
. Specify the `NormalMap` texture for the Material.
|
|
. Specify the `NormalMap` texture for the Material.
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setTexture("NormalMap", assetManager.loadTexture("Textures/wood_normal.png")); // with Lighting.j3md
|
|
mat.setTexture("NormalMap", assetManager.loadTexture("Textures/wood_normal.png")); // with Lighting.j3md
|
|
@@ -169,12 +174,14 @@ To activate Shininess (this only makes sense for illuminated Materials):
|
|
|
|
|
|
|
|
. Specify the `Shininess` intensity the Material. +
|
|
. Specify the `Shininess` intensity the Material. +
|
|
|
Shininess is a float value between 1 (rough surface with blurry shininess) and 128 (very smooth surface with focused shininess)
|
|
Shininess is a float value between 1 (rough surface with blurry shininess) and 128 (very smooth surface with focused shininess)
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setFloat("Shininess", 5f);
|
|
mat.setFloat("Shininess", 5f);
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
. Activate material colors:
|
|
. Activate material colors:
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setBoolean("UseMaterialColors",true);
|
|
mat.setBoolean("UseMaterialColors",true);
|
|
@@ -182,6 +189,7 @@ mat.setBoolean("UseMaterialColors",true);
|
|
|
|
|
|
|
|
. Specify the `Specular` and `Diffuse` colors of the shiny spot. +
|
|
. Specify the `Specular` and `Diffuse` colors of the shiny spot. +
|
|
|
Typically you set Specular to the ColorRGBA value of the light source, often RGBA.White.
|
|
Typically you set Specular to the ColorRGBA value of the light source, often RGBA.White.
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setColor("Specular",ColorRGBA.White);
|
|
mat.setColor("Specular",ColorRGBA.White);
|
|
@@ -190,6 +198,7 @@ mat.setColor("Diffuse",ColorRGBA.White);
|
|
|
|
|
|
|
|
. (Optional) Specify a `SpecularMap` texture. +
|
|
. (Optional) Specify a `SpecularMap` texture. +
|
|
|
You optionally hand-draw this grayscale texture to outline in detail where the surface should be more shiny (whiter grays) and where less (blacker grays). If you don't supply a SpecularMap, the whole material is shiny everywhere.
|
|
You optionally hand-draw this grayscale texture to outline in detail where the surface should be more shiny (whiter grays) and where less (blacker grays). If you don't supply a SpecularMap, the whole material is shiny everywhere.
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setTexture("SpecularMap", assetManager.loadTexture("Textures/metal_spec.png")); // with Lighting.j3md
|
|
mat.setTexture("SpecularMap", assetManager.loadTexture("Textures/metal_spec.png")); // with Lighting.j3md
|
|
@@ -211,6 +220,7 @@ mat.setColor("Specular",ColorRGBA.Black);
|
|
|
To activate glow:
|
|
To activate glow:
|
|
|
|
|
|
|
|
. Add one <<jme3/advanced/bloom_and_glow#,BloomFilter PostProcessor>> in your simpleInitApp() method (only once, it is used by all glowing objects).
|
|
. Add one <<jme3/advanced/bloom_and_glow#,BloomFilter PostProcessor>> in your simpleInitApp() method (only once, it is used by all glowing objects).
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
FilterPostProcessor fpp=new FilterPostProcessor(assetManager);
|
|
FilterPostProcessor fpp=new FilterPostProcessor(assetManager);
|
|
@@ -221,6 +231,7 @@ viewPort.addProcessor(fpp);
|
|
|
|
|
|
|
|
. Specify a `Glow` color. +
|
|
. Specify a `Glow` color. +
|
|
|
A ColorRGBA value of your choice, e.g. choose a warm or cold color for different effects, or white for a neutral glow.
|
|
A ColorRGBA value of your choice, e.g. choose a warm or cold color for different effects, or white for a neutral glow.
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setColor("GlowColor",ColorRGBA.White);
|
|
mat.setColor("GlowColor",ColorRGBA.White);
|
|
@@ -228,6 +239,7 @@ mat.setColor("GlowColor",ColorRGBA.White);
|
|
|
|
|
|
|
|
. (Optional) Specify a `GlowMap` texture. +
|
|
. (Optional) Specify a `GlowMap` texture. +
|
|
|
This texture outlines in detail where the DiffuseMap texture glows. If you don't supply a GlowMap, the whole material glows everwhere.
|
|
This texture outlines in detail where the DiffuseMap texture glows. If you don't supply a GlowMap, the whole material glows everwhere.
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setTexture("GlowMap", assetManager.loadTexture("Textures/alien_glow.png"));
|
|
mat.setTexture("GlowMap", assetManager.loadTexture("Textures/alien_glow.png"));
|
|
@@ -284,19 +296,18 @@ mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
|
|
|
|
|
|
|
. Put the Geometry (not the Material!) in the appropriate render queue bucket. +
|
|
. Put the Geometry (not the Material!) in the appropriate render queue bucket. +
|
|
|
Objects in the translucent bucket (e.g. particles) are not affected by SceneProcessors (e.g. shadows). Objects in the transparent bucket (e.g. foliage) are affected by SceneProcessors (e.g. shadows).
|
|
Objects in the translucent bucket (e.g. particles) are not affected by SceneProcessors (e.g. shadows). Objects in the transparent bucket (e.g. foliage) are affected by SceneProcessors (e.g. shadows).
|
|
|
-**
|
|
|
|
|
|
|
+**
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
geo.setQueueBucket(Bucket.Translucent);
|
|
geo.setQueueBucket(Bucket.Translucent);
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
-**
|
|
|
|
|
|
|
+**
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
geo.setQueueBucket(Bucket.Transparent);
|
|
geo.setQueueBucket(Bucket.Transparent);
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
-
|
|
|
|
|
. (Optional) Specify other material settings.
|
|
. (Optional) Specify other material settings.
|
|
|
|
|
|
|
|
[cols="3", options="header"]
|
|
[cols="3", options="header"]
|