How to activate envimapping?

Hey there, it’s me again, with another basic question…

as the title tells: How do I “activate” the Envimap?
I’m doing something wrong I think.
I created a model, gave it a material (based on Common/MatDefs/Light/Lighting.j3md), set a diffuse and specular color (1.0f, 1.0f, 1.0f), set the shininess to a value between 1 and 128 (64 in my test case; don’t know if that matters anyway), added an EnvMap (*.dds file, no errors, creadted with the amd tool and serves well as a skybox of my scene) and put it in the scene.

Here’s my test material:
Material D8MAT : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
GlowColor : 0.0 0.0 0.0 1.0
Specular : 1 1 1 1.0
Diffuse : 1 1 1 1.0
UseMaterialColors : true
ParallaxHeight : 0.05
Ambient : 0.8 0.8 0.8 1.0
Shininess : 64.0
HighQuality : true
VTangent : false
LATC : false
UseAlpha : false
VertexLighting : false
Minnaert : false
UseVertexColor : false
SteepParallax : false
PackedNormalParallax : false
EnvMapAsSphereMap : false
SeparateTexCoord : false
LowQuality : false
HardwareShadows : false
WardIso : false
EnvMap : Models/D8/
FilterMode : 0
AdditionalRenderState {
FaceCull Back
Wireframe Off
DepthWrite On
PolyOffset 0.0 0.0
AlphaTestFalloff 0.0
Blend Off
PointSprite Off
ColorWrite On
DepthTest On

What I see then is the Object, in plain white with the correct lighting but no sign of any EnvMap.
What am I doing wrong? Do I have to turn on some filters or something?


Maybe try setting FresnelParams?

Ok, but to what for example?
What is this parameter doing? (or: where can I read more about it?)
I haven’t found it in the description of the Lighting.j3md File.

There is a design issue in texture loading in the j3m file structure. Textures are always loaded as 2D Textures when declared in the material file.
This may be your issue.

The work around is to load the texture by code with a TextureKey and do key.setAsCube(true);

an alternative is to fetch the texture from the material create a TextureCubeMap from its image data, then set the cubemap to the material
Texture tex = mat.getTextureParam(“TextureName”).getTextureValue();
TextureCubeMap newTex = new TextureCubeMap();

@nehon said: There is a design issue in texture loading in the j3md file structure. Textures are always loaded as 2D Textures when declared in the material definition file. This may be your issue.

The work around is to load the texture by code with a TextureKey and do key.setAsCube(true);

an alternative is to fetch the texture from the material create a TextureCubeMap from its image data, then set the cubemap to the material
Texture tex = mat.getTextureParam(“TextureName”);

I feel like I’ve corrected this one once before. :slight_smile:
Texture tex = mat.getTextureParam(“TextureName”).getTextureValue();

@pspeed said: I feel like I've corrected this one once before. :) Texture tex = mat.getTextureParam("TextureName").getTextureValue();
oh yes... true, you'll get the MatParam otherwise. I edited the post

Hi and thanks.
I tried it, but sadly with no success.
Here’s the code I added after loading the scene:

Node testObj = new Node();
testObj = (Node) level.getChild(“TestObj”);
if(testObj != null){
System.out.println(“TestObj found!”);
Geometry geom = (Geometry) testObj.getChild(“geom”);
if(geom != null){
System.out.println(“Geometry found!”);
Material mat = geom.getMaterial();
if(mat != null){
System.out.println(“Material '” + mat.getAssetName() + “’ found!”);
Texture tex = mat.getTextureParam(“EnvMap”).getTextureValue();
if(tex != null){
System.out.println(“Texture '” + tex.getName() + “’ found!”);
TextureCubeMap newTex = new TextureCubeMap();
mat.setTexture(“EnvMap”, newTex);

As you can see I added a few System.out lines, to check, if the thing is found…
Here’s the output:

[java]TestObj found!
Geometry found!
Material ‘Models/D8/D8_1.j3m’ found!
Texture ‘Models/D8/’ found![/java]

May be there is an error in my EnvMap? I use the same file as Skybox and there it shows up just fine…
But the object still is a white thing with no EnvMap.

I know it is unrelated to your original question, but from the name of the file I can guess that you are trying to create dice. You might find my models useful

plus metadata at

Smooth model is one used for rendering, hull is simplified one for physics system, controlPoints are ‘up’ vectors which correspond to particular die results. Every die excep d4 is using same texture, so replacing the decals should be quite easy. I’m using custom shader for them
which allows both decal and/or body to have metallic shine, but thats completely optional.

Die creation code is at

Dice throwing and result reading is unfortunately very application specific, so won’t be directly usable.


@noobgamedev you have to set the FresnelParam as @abies pointed out
look at

1 Like

@nehon Hey thanks!
That example code made my day!
I added the line
[java]mat.setVector3(“FresnelParams”, new Vector3f(0.05f, 0.18f, 0.11f));[/java]
after setting the EnvMap and that did it!

But still I don’t understand what this parameter is doing. Could you please explain it, or give a link where I can find out more about it?

Anyways, a BIG thanks to all of you!

@abies Thanks for the links. I’ll definetly check em out. You where right. It’s a d8 (Yes, I do play DnD, Shadowrun, Vampire, etc. as pen 'n paper games. :stuck_out_tongue_winking_eye: ). But i only used it for testing, cause of it’s relatively simple shape. As my test goes fine, I’m into more complex models.

Fresnel params parameter is modifying parameters of Fresnel function :wink:

refVec.w = m_FresnelParams.x + m_FresnelParams.y * pow(1.0 + dot(I, N), m_FresnelParams.z);

and refVec.w is indication how much of reflection versus normal specular reflection you will see. As you can see, x is constant parameter, while y and z are modifying reflection dependent on angle between surface normal and view direction (actually on cosine of the angle, so that component is biggest if you look on perpendicular surface).

Now, what they REALLY mean - I have no idea. Not sure if they have an intuitive intepretation. Best thing is to make a 3 sliders somewhere which control them and move these in realtime observing what effect it will have on your object in your scene.

those 3 parameters helps to compute the Fresnel formula for the reflection.
That’s complicated math stuff, I invite you to look at the wikipedia page on the matter.
This is how it’s used in JME :

we compute a reflection factor that is a formula implying those 3 params and the dot produc of the camera direction to the shaded vertex and the normal of the vertex.
fresnelFactor = fx + fy * (1 + dot(dir, norm)^fz
fx, fy and fz are the FresnelParam components.

this fresnelFactor is then used to mix the color of the env map with the specular color of the material.

So if the fresnelFactor is 0 there is no reflection at all. if it’s 1 you only see the env map as the specular color.
based on that and on the formula :
fx is the minimum value for the factor, setting it above 0 ensure that you’ll see at least a little your reflection map.
fy is a linear factor that will weight the difference of refraction depending on the angle between the camera direction and the surface normal.
fz is a bit like fy but it’s an exponential factor.

just know that dot(dir, norm) is 0 if dir and norm are orthogonal (this means in real life that you are looking to a surface from the side and the direction of the cam is parallel to the surface)

The idea behind all this is that the reflection factor variate with the angle.(as long as fy and fz are not 0)
Now it’s hard to picture what it’s gonna render on screen, but you can try to play with them.

So, simply saied:
Fresnel parameter influences the amount of reflection vs. envMap shown on the surface.
X is a constant value, like an offset,
Y and Z influence the anglebased amount depending on the point of view.
(I hope this is confirmed or declined before anyone like me reads this XD )

The slider-thing is a great idea! I think I’ll check that out too.

Thanks a lot!

P.S.: Since my problem has been solved and the answer can be seen, this topic may be closed I think.

hehe confirmed.

Sorry again,
I tried around a bit and figured out, that the Material-Editor from the SDK does its job perfectly!
I was just to stupid to get the right “spelling” of the values!

If anyone wants the easy way:

  • Open the material in the SDKs Material.Editor
  • Set an appropriate EnvMap (To create one, I used the amd tool and a so called “cube-cross” image to create a *.dds file)
  • Set the “FresnelParams (Vector3)” value, BUT WATCH OUT! You’ll have to type it EXACTLY like this: 0.05 0.18 0.11 (numbers with a “point”, pairs seperatet by a single “space”, no “(” oder anything at the beginning or end)

The Stringparser is a beast! You can see if the value is correct, if you see a result in the preview in the top left corner. If there is just a grey square, some value is wrong!

here some screenshots:

But if everything fails, the above code works just fine too!

So, enough of me… I hope… :stuck_out_tongue: