Problem with shiny rock example

Nothing happens with [java]mat_lit.setColor("m_Specular", ColorRGBA.White);[/java], but thanks for the hint!

Well, first, it would be “Specular”, without the “m_”.



I just tried the following (a colored sphere next to a textured one, both shiny) and got no shininess on the textured one either… That’s weird, because that’s basically the code I used to take the screenshots in the tutorials. :? :?



[java]Geometry shiny_sphere3 = new Geometry(“Smooth sphere”, sphere);

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

mat_lit3.setBoolean(“UseMaterialColors”,true);

mat_lit3.setColor(“Ambient”, ColorRGBA.Black );

mat_lit3.setColor(“Diffuse”, ColorRGBA.Cyan );

mat_lit3.setFloat(“Shininess”, 128f); // [0,128]

mat_lit3.setColor(“Specular”, ColorRGBA.White );

shiny_sphere3.setMaterial(mat_lit3);

shiny_sphere3.move(2.5f, 0, 0);

rootNode.attachChild(shiny_sphere3);



DirectionalLight sun = new DirectionalLight();

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

sun.setColor(ColorRGBA.White);

rootNode.addLight(sun);



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

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/Terrain/road.png”));

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

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

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

shiny_rock.setMaterial(mat_lit);

rootNode.attachChild(shiny_rock);[/java]

I think alpha overrides everything. So if you have alpha 0 it doesn’t matter how much specular the point has because it won’t be visible.



I have no idea why @zathras’s case isn’t working since the original textured example worked fine if you manually setup all of the material colors.

If alpha overrides everything, from what I understand I can’t have a shiny transparent object? Maybe a sugestion for a halo for a sphere?

You would have to write your own shader for this, I think. You could base it on lighting.j3md and just modify the .vert shader to treat alpha differently, I guess.



But yes, otherwise, with standard lighting.j3md you cannot have specular on transparent pixels as this would mostly mess other cases up (for example when transparency represents holes in the object).



Are you trying to make the earth look like it’s in a glass ball? The real atmosphere is not reflective like that, really. Though the surface of the oceans is.

Sort of…I need something special for atmosphere, I was thinking at a sort of halo, maybe something glowing…

Did you see this thread?

http://hub.jmonkeyengine.org/groups/user-code-projects/forum/topic/planet-shader-and-atmosphere-scattering/

Shininess will not get you to glowing. You have to use glow for that… which traditionally is a combination of setting the glow color and using the bloom post-processor.



But really, there have been atmosphere effects posted to the forums in the past… maybe you find one there that is suitable. There used to be something included that was used for one of the old JMP splash screens. I don’t know where it is or how to use it, though.



Edit: Yeah, what that poster said. :slight_smile:

Yes, I already tested that example, but unfortunately I can’t find any documentation for that, I found that project complex and nothing about the implementation, only the final result.