Problem with shiny rock example

Hello! I have a problem with this example. I need a shiny light effect on a sphere, but after trying the example from the documentation, my rock is not shiny at all, and I don’t know why, I copy-pasted the code in my application. You can see in my screen shot that the rock is not shiny. I use an ATI RADEON 5470, but I tested the example also on another VGA . Cand someone tell me why is this happening? In the first screen-shot is what I get in jme frame:







On their example:



Can you post your code? It seems you have made modifications or there are more bugs than just the one… since the boxes are missing.



Also, what version of JME are you running? The latest beta + stable updates?

Sorry, I din’t said that I excluded the boxes from my source, but I said that I need the shiny rock, and not the boxes. I put Pond.jpg and Pond_normal.png in the Textures directory. Sure I’ll post my code. I downloaded jMonkeyEngine SDK beta version. Thanks for your post!

[java]

import com.jme3.app.SimpleApplication;

import com.jme3.light.DirectionalLight;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Sphere;

import com.jme3.util.TangentBinormalGenerator;



/**

*

  • @author Irina

    /

    public class TestGame extends SimpleApplication{

    public static void main(String[] args) {

    TestGame app = new TestGame();

    app.start();

    }



    @Override

    public void simpleInitApp() {



    /
    * A bumpy rock with a shiny light effect /

    Sphere rock = new Sphere(32,32, 2f);

    Geometry shiny_rock = new Geometry("Shiny rock", rock);

    rock.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres

    TangentBinormalGenerator.generate(rock); // for lighting effect

    Material mat_lit = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");

    mat_lit.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Pond.jpg"));

    mat_lit.setTexture("NormalMap", assetManager.loadTexture("Textures/Pond_normal.png"));

    mat_lit.setFloat("Shininess", 5f); // [1,128]

    shiny_rock.setMaterial(mat_lit);

    shiny_rock.setLocalTranslation(0,2,-2); // Move it a bit

    shiny_rock.rotate(1.6f, 0, 0); // Rotate it a bit

    rootNode.attachChild(shiny_rock);



    /
    * Must add a light to make the lit object visible! */

    DirectionalLight sun = new DirectionalLight();

    sun.setDirection(new Vector3f(1,0,-2).normalizeLocal());

    sun.setColor(ColorRGBA.White);

    rootNode.addLight(sun);

    }

    }





    [/java]

Which version of JME are you running?



It’s possible that you need to set the specular color on the material. The defaults as the relate to shininess have changed several times over the months as different GPU-specific fixes were tried.

I used the SDK 3.0 beta from October 22, 2011.

Well thats ancient ^^ Try using beta, also make sure to install the stable updates (will pop up in the lower right on first start).

I don’t understand, where from to download a newer version? I accessed http://hub.jmonkeyengine.org/downloads/?did=1 . Where I can find the beta that you mentioned? I also mentioned SDK 3.0 beta, so what beta are you talking about?

I think Normen misread… just make sure you have the stable updates.



And in your code, try setting the specular color on the material.



setColor(“Specular”, ColorRGBA.White);

No result with mat_lit.setColor(“Specular”, ColorRGBA.White); added, same unshiny sphere…

Maybe try also setting:

setBoolean(“UseMaterialColors”,true);

a little observation. The normals kind of look inverted in the first picture. In it it looks like the rocks are recessed, instead of the grooves (as in the second picture)

After adding setBoolean(“UseMaterialColors”,true); something strange happend. I think now is shiny, but is also dark…I don’t understand why…



That’s because it has no ambient or diffuse colors, either.



Try setting “Ambient” to gray or something… and “Diffuse” also.



I know, it’s kind of messed up. Shininess has always been problematic.

After

mat_lit.setColor(“Diffuse”, ColorRGBA.Gray); my rock is shiny. Thanks alot! You saved me!



The reason why I needed a shiny sphere was that I need to make a planet with atmosphere, and based on this example I wanted to make the atmosphere shiny, to create some kind of halo. So, in my example I have a sphere with the material Unshaded, with the texture for the ground. On top of this sphere I have another one, a transparent one, with clouds texture, created based on the example we disscused about. The problem is that my atmosphere is still unshiny. Please try to ignore that the spheres aren’t rotated.





Can someone tell me what I’m doing wrong here? For the atmosphere I also use a DiffuseMap with a cloud texture, and the normal map for this, but is not like the rock in the example. Could it be because my atmosphere sphere is transparent?

It could be.



Without being able to see your code, these things are much harder to debug.

Hello! Here is the source code I use and the files for the textures. Thanks for helping me!



[java]

package mygame;



import com.jme3.app.SimpleApplication;

import com.jme3.light.DirectionalLight;

import com.jme3.material.Material;

import com.jme3.material.RenderState.BlendMode;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.renderer.queue.RenderQueue.Bucket;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Sphere;

import com.jme3.util.TangentBinormalGenerator;



/**

  • test

    /

    public class Main extends SimpleApplication {



    public static void main(String[] args) {

    Main app = new Main();

    app.start();

    }

    @Override

    public void simpleInitApp() {

    /
    * A bumpy rock with a shiny light effect /

    Sphere matrock = new Sphere(32,32, 2f);

    Geometry mat_rock = new Geometry(“Mat rock”, matrock);

    matrock.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres

    TangentBinormalGenerator.generate(matrock); // for lighting effect

    Material mat_litG = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

    mat_litG.setTexture(“ColorMap”, assetManager.loadTexture(“Textures/land_ocean_ice_2048.jpg”));



    mat_rock.setMaterial(mat_litG);

    mat_rock.setLocalTranslation(0,2,-2); // Move it a bit

    // mat_rock.rotate(-1f, 0.7f, 0); // Rotate it a bit

    mat_rock.rotate(1.6f, 0f, 0f);

    rootNode.attachChild(mat_rock);





    /
    * A bumpy rock with a shiny light effect /

    Sphere rock = new Sphere(32,32, 2.01f);

    Geometry shiny_rock = new Geometry(“Shiny rock”, rock);

    rock.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres

    shiny_rock.setQueueBucket(Bucket.Transparent);

    TangentBinormalGenerator.generate(rock); // for lighting effect

    Material mat_lit = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

    mat_lit.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/cloudimage.png”));

    mat_lit.setTexture(“NormalMap”, assetManager.loadTexture(“Textures/cloudimage_NRM.png”));

    mat_lit.setFloat(“Shininess”, 15f); // [1,128]

    mat_lit.setColor(“Ambient”, ColorRGBA.White);

    mat_lit.setColor(“Diffuse”, ColorRGBA.White);

    mat_lit.setBoolean(“UseMaterialColors”,true);

    mat_lit.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

    mat_lit.setTransparent(true);

    shiny_rock.setMaterial(mat_lit);

    shiny_rock.setLocalTranslation(0,2,-2); // Move it a bit

    // shiny_rock.rotate(-1f, 0.7f, 0); // Rotate it a bit


    shiny_rock.rotate(1.6f, 0f, 0f);





    rootNode.attachChild(shiny_rock);





    /** Must add a light to make the lit object visible! */

    DirectionalLight sun = new DirectionalLight();

    sun.setDirection(new Vector3f(1,0,-2).normalizeLocal());

    sun.setColor(ColorRGBA.White);

    rootNode.addLight(sun);

    }

    }



    [/java]













@pspeed said:
It could be.

Without being able to see your code, these things are much harder to debug.

I posted the source code. Please fill free to make sugestions if you have an ideea. Thank you!

I don’t know the answer but anyone helping would need the info I asked for. Nothing jumped out at me in a quick scan, though.



Oh, I don’t see a specular color being set. Specular is what controls the color of the shine. Without setting it then the shine is black, ie: nothing.