How I can get my blender models receive ambient light at Scene in JME? I tried generate tangents, and enabling Ambient Shadow in blender to 1.0 (texture section) and also changing Ambient value in material section but still my models are totally black on side of model where is no light
have you tried actually adding an ambient light to your scene?
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:light_and_shadow
Yes, I have ambient light but it work only for Terrain and don’t know why:
[java] AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White);
rootNode.addChild(al);[/java]
Open your model in scene composer. Generate the material to make a j3m file. Look at the j3m file. Post it here.
Here you can download zipped .j3m from my testing cube. Download @ UppIT
I found there Ambient and when i set it to 1.0 it works now but it’s to strong i think? Or something other is wrong?
So ?
@Skatty said: Here you can download zipped .j3m from my testing cube. http://uppit.com/5vtwclkbiixd/test-Cube1.zip I found there Ambient and when i set it to 1.0 it works now but it's to strong i think? Or something other is wrong?
“When I set it to 1 it’s too strong” so don’t set it to 1.
So now I should fix all materials like this one? To set in .j3m ambient light?
@Skatty said: So now I should fix all materials like this one? To set in .j3m ambient light?
I haven’t seen the j3m because I don’t really have time to download and open a zip file. If the issue was that the material had no ambient color set and useMaterialColors was true… then the solution may also be to change the material in Blender. I don’t really know blender well enough.
You can also fix this in code just by iterating over your models when you load them and fixing their material setup. Or yeah, do as you’ve done with that one.
Bottom line: a material with 0 ambient won’t show any ambient.
@Kaelthas hello!
Can you tell why you generate your own shaders?
The materials which we get from blender are not usable at all.
Here is my feature request for materials:
- possibility to create j3m materials and save it in folder “materials” where the blend file is stored.
- possibility to assign Unshading, Lighting shaders. Or add our own shaders.
In other way the materials form blender are fully unusable. It would be even better to load models without materials at all.
Thanks.
Hey,
I have no idea how to create a custom shader. And if I do I am doing it without knowing it.
When I load materials from blender I use either:
“Common/MatDefs/Misc/Unshaded.j3md”
or
“Common/MatDefs/Light/Lighting.j3md”
material definition and set appropriate parameters to such material
like DiffuseColor, proper type of DiffuseShader or textures if available.
It is all made in com.jme3.scene.plugins.blender.materials.MaterialContext.
@Kaelthas said: @mifthHey,
I have no idea how to create a custom shader. And if I do I am doing it without knowing it.
When I load materials from blender I use either:
“Common/MatDefs/Misc/Unshaded.j3md”
or
“Common/MatDefs/Light/Lighting.j3md”
material definition and set appropriate parameters to such material
like DiffuseColor, proper type of DiffuseShader or textures if available.
It is all made in com.jme3.scene.plugins.blender.materials.MaterialContext.
Aha, I see.
That’s cool that you use JME shaders.
Then i think we have such an issue:
[java]material.setColor(“Ambient”, ambientColor);[/java]
This can case the issue for ambient lighting. At present when we add AmbientLight to the scene - your Ambient overrides it. Can you comment it?
Could you upload me an example file where I could see it ?
I made some tests a minute ago and to my confusion - I see no ambient light when I add the ambient light to the scene. I am pretty sure it worked before
I can comment this of course but I need to be sure it causes the problem. Maybe I will be able to find some other solution.
@Kaelthas said: @mifthCould you upload me an example file where I could see it ?
I made some tests a minute ago and to my confusion - I see no ambient light when I add the ambient light to the scene. I am pretty sure it worked before
I can comment this of course but I need to be sure it causes the problem. Maybe I will be able to find some other solution.
Sure. Here a test model:
https://dl.dropboxusercontent.com/u/26887202/JME/monkey.blend
Here is the code (ambient light should be RED):
[java]
BlenderKey bl = new BlenderKey(“Models/monkey.blend”);
Node model = (Node) assetManager.loadModel(bl);
rootNode.attachChild(model);
DirectionalLight dl = new DirectionalLight();
rootNode.addLight(dl);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.Red);
rootNode.addLight(al);
[/java]
@Kaelthas said: Could you upload me an example file where I could see it ?I made some tests a minute ago and to my confusion - I see no ambient light when I add the ambient light to the scene. I am pretty sure it worked before
I can comment this of course but I need to be sure it causes the problem. Maybe I will be able to find some other solution.
The result above has no ambient as I have no your sources. Can you comment that line and test?
@Kaelthas I downloaded sources and added your lib.
The issue causes Lines:
[java]
material.setBoolean(“UseMaterialColors”, Boolean.TRUE); // Line 142
…
material.setColor(“Ambient”, ambientColor); // Line 155
[/java]
If you comment these lines in MaterialContext.java - ambient light will work ok. But all base colors will be gray. Actueally it’s ok. When you load a model into Unity - all modsels are gray too.
Screen result:
So could you comment these 2 lines?
Where does the ambientColor come from in that line?
I could swear I’ve gotten ambient to transfer from blender once… but I’m a blender newb so I don’t remember how. I also could be imagining it.
@pspeed said: Where does the ambientColor come from in that line?I could swear I’ve gotten ambient to transfer from blender once… but I’m a blender newb so I don’t remember how. I also could be imagining it.
It comes from my previous post where i shared with the test model.
[java]
// Load a model
DirectionalLight dl = new DirectionalLight();
rootNode.addLight(dl);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.Red);
rootNode.addLight(al);
[/java]
No. You misunderstand me. You posted this code below. But I can’t see enough of the code to know where the “ambientColor” set on line 155 comes from. Is it loaded from the .blend file? Materialized out of thin air? E-mailed from an appropriate head of state? ??
@mifth said: @Kaelthas I downloaded sources and added your lib.The issue causes Lines:
[java]
material.setBoolean(“UseMaterialColors”, Boolean.TRUE); // Line 142
…
material.setColor(“Ambient”, ambientColor); // Line 155
[/java]If you comment these lines in MaterialContext.java - ambient light will work ok. But all base colors will be gray. Actueally it’s ok. When you load a model into Unity - all modsels are gray too.
Screen result:
So could you comment these 2 lines?
Pspeed thanks for tips with materials Now I generate material for each geometry and set there ambient light which is just perfect in game! But still got problem with soo shiny shores of water