Hi,guys:
I’m trying to use PBR in my project.
I downloaded PBR materials from free material site, this is what I got:
these are material samples
something is wrong, I think



sApp = (SimpleApplication) app;
sApp.getFlyByCamera().setUpVector(Vector3f.UNIT_Z);
ArrayList <ByteBuffer> data = new ArrayList<>();
data.add(ByteBuffer.allocateDirect(320*240*4));
ima = new Image(Image.Format.RGBA8,320,240,32, data, ColorSpace.Linear);
t2d = new Texture2D(ima);
Box b = new Box(1, 1, 1);
Quad qd = new Quad(2,2);
Sphere sph = new Sphere(20,20,.6f);
Geometry geomBox = new Geometry("box", b);
Geometry geomSphere = new Geometry("qd",sph);
Geometry geomSphere1 = new Geometry("qd1",sph);
BaseGsw geomSurface = new BaseGsw("surface",rowx,columy,(20f/rowx),(20f/columy),
1f,BaseGsw.CwType.POLYGONMIRRO);
this.sur = geomSurface;
Material mat00 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat00.setColor("Color", ColorRGBA.Blue);
Material mat01 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat01.setTexture("ColorMap", app.getAssetManager().loadTexture("Textures/icon/am10.png"));
Material mat10 = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat10.setColor("GlowColor", new ColorRGBA(0f,1f,0,0.17f));
Material mat20 = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat20.setBoolean("UseMaterialColors",true);
mat20.setFloat("Shininess", 1f);
mat20.setColor("Diffuse", ColorRGBA.Brown ); // with Lighting.j3md
mat20.setColor("Ambient", ColorRGBA.Pink );
mat20.setColor("Specular", ColorRGBA.Green );
Material mat21 = new Material(app.getAssetManager(), "Common/MatDefs/Light/PBRLighting.j3md");
mat21.setTexture("MetallicMap",app.getAssetManager().loadTexture("Textures/pbr/badlands-boulders-bl/metallic.png"));
mat21.setTexture("RoughnessMap",app.getAssetManager().loadTexture("Textures/pbr/badlands-boulders-bl/roughness.png"));
mat21.setTexture("NormalMap",app.getAssetManager().loadTexture("Textures/pbr/badlands-boulders-bl/normal-ogl.png"));
mat21.setTexture("BaseColorMap",app.getAssetManager().loadTexture("Textures/pbr/badlands-boulders-bl/albedo.png"));
mat21.setTexture("LightMap",app.getAssetManager().loadTexture("Textures/pbr/badlands-boulders-bl/ao.png"));
mat21.setTexture("ParallaxMap",app.getAssetManager().loadTexture("Textures/pbr/badlands-boulders-bl/height.png"));
mat21.setBoolean("LightMapAsAOMap",true);
mat21.setFloat("NormalType",1.0f);
Material mat22 = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat22.setTexture("NormalMap",app.getAssetManager().loadTexture("Textures/pbr/steelplate1-ue/normal-dx.png"));
mat22.setTexture("DiffuseMap",app.getAssetManager().loadTexture("Textures/pbr/steelplate1-ue/albedo.png"));
mat22.setTexture("ParallaxMap",app.getAssetManager().loadTexture("Textures/pbr/steelplate1-ue/height.png"));
Material mat23 = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat23.setTexture("DiffuseMap",t2d);
if(true){
sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
((DirectionalLight)sun).setDirection(new Vector3f(0,0,-1f).normalizeLocal());
sApp.getRootNode().addLight(sun);
if(false){
int shadlesize = 16;
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(app.getAssetManager(), shadlesize,3);
dlsr.setLight((DirectionalLight)sun);
app.getViewPort().addProcessor(dlsr);
sApp.getRootNode().setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
}
}else if(true){
Light sun2 = new PointLight();
sun2.setColor(ColorRGBA.White);
((PointLight)sun2).setRadius(40);
((PointLight)sun2).setPosition(new Vector3f(3f,3f,23f));
sApp.getRootNode().addLight(sun2);
if(false){
int shadlesize = 1024;
PointLightShadowRenderer plsr = new PointLightShadowRenderer(app.getAssetManager(), shadlesize);
plsr.setLight((PointLight) sun2);
app.getViewPort().addProcessor(plsr);
sApp.getRootNode().setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
}
}
geomBox.setMaterial(mat21);
geomBox.setQueueBucket(RenderQueue.Bucket.Translucent);
geomSurface.setMaterial(mat22);
geomSphere.setMaterial(mat22);
geomSphere.setQueueBucket(RenderQueue.Bucket.Translucent);
geomSphere1.setMaterial(mat22);
geomSphere1.setQueueBucket(RenderQueue.Bucket.Translucent);
geomSurface.move(-3,-3,3);
geomSphere.move(1,1,7);
geomSphere1.move(3,5,8);
geomBox.move(4f,4f,7f);
// GUI part
Locale locale = Locale.getDefault();
rb = ResourceBundle.getBundle("message",locale);
BitmapFont myFont = app.getAssetManager().loadFont("Interface/Fonts/b32.fnt");
hudText = new BitmapText(myFont,false, false);
//hudText.setSize(guiFont.getCharSet().getRenderedSize()); // font size
hudText.setColor(ColorRGBA.Orange); // font color
hudText.setText(rb.getString("a2")); // the text
hudText.setLocalTranslation(300, hudText.getLineHeight(), 0); // position
//sApp.getGuiNode().attachChild(hudText);
geomSurface.getMesh().updateBound();
sApp.getRootNode().attachChild(geomBox);
sApp.getRootNode().attachChild(geomSurface);
sApp.getRootNode().attachChild(geomSphere);
sApp.getRootNode().attachChild(geomSphere1);
sApp.getCamera().lookAt(geomBox.getWorldTranslation(),Vector3f.UNIT_Z);
InputManager im = sApp.getInputManager();
im.addMapping("touched",new TouchTrigger(TouchInput.ALL));
im.addListener(new TouchListener() {
@Override
public void onTouch(String name, TouchEvent event, float tpf) {
if(event.getType()== TouchEvent.Type.SCALE_MOVE){
hudText.setText("Scale Move "+ name);
}
if(event.getType()== TouchEvent.Type.MOVE){
hudText.setText("Move "+ name);
}
}
},"touched");