Ok, I will try now to give you more information.
Here two screens of the current result (as you see I could set the Nearest Neighbor 4x pixelation for the bacground texture, but I should set it even for main character and for invisible scene, otherwise when an obstacle cover the actor it’s possible to see the lack of pixelation):
Current Result:
Wireframe and visible scene:
Here my code
[java]
@Override
public void simpleInitApp() {
initKeys();
assetManager.registerLocator("/", FileLocator.class);
// Static background
renderViewPort = renderManager.createPreView("Render", getCamera());
renderViewPort.setClearFlags(true, true, true);
Quad quad = new Quad(1, 1);
viewPort.setClearFlags(false, true, false);
Geometry render = new Geometry("Render", quad);
render.setMaterial(assetManager.loadMaterial("Materials/Sala_2.j3m"));
// Texture is 320x180 (screen is 4x, 1280x720)
Texture2D tex = (Texture2D) getAssetManager().loadTexture("Textures/Sala_2.png");
tex.setMagFilter(MagFilter.Nearest);
tex.setMinFilter(MinFilter.Trilinear);
render.getMaterial().setTexture("Texture", tex);
renderRootNode = new Node("HD-RenderRootNode");
renderRootNode.attachChild(render);
renderViewPort.attachScene(renderRootNode);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(0.9f));
rootNode.addLight(al);
BlenderKey roomKey = new BlenderKey("Models/SH_Home_p2/SH_Home_p2.blend");
roomKey.setFixUpAxis(false);
Material hide = assetManager.loadMaterial("Materials/Unshaded.j3m");
hide.getAdditionalRenderState().setDepthWrite(true);
hide.getAdditionalRenderState().setColorWrite(false);
sceneNode = new Node("SceneNode");
Spatial sceneSpatial = (Spatial) assetManager.loadModel(roomKey);
sceneSpatial.setMaterial(hide);
sceneNode.attachChild(sceneSpatial);
cameraNode = (CameraNode) sceneNode.getChild("Camera_Sala_2");
Quaternion rot3 = cameraNode.getLocalRotation();
cameraNode.setLocalRotation(new Quaternion(-rot3.getZ(), rot3.getW(), rot3.getX(), -rot3.getY()));
rootNode.attachChild(sceneNode);
Spatial playerSpat = (Spatial) assetManager.loadModel("Models/SH_Anim/SH_Anim.mesh.j3o");
// Player material
List<Spatial> playerSubSpatList = (List<Spatial>) ((Node) playerSpat).getChildren();
List<Geometry> playerGeomList = new ArrayList<Geometry>();
for (Spatial s : playerSubSpatList) {
playerGeomList.add((Geometry) s);
}
for (Geometry g : playerGeomList) {
Material m = g.getMaterial();
m.getAdditionalRenderState().setWireframe(true);
}
playerNode = new Node("Player");
playerNode.attachChild(playerSpat);
playerNode.setLocalTranslation(0f, 0f, 0.02f);
playerNode.scale(0.4f);
AnimControl control = playerSpat.getControl(AnimControl.class);
control.addListener(this);
try {
channel = control.createChannel();
channel.setAnim("SH_Walk");
channel.setTime(0);
channel.setSpeed(0);
} catch (Exception e) {
e.printStackTrace();
}
rootNode.attachChild(playerNode);
}
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
}
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
}
@Override
public void simpleUpdate(float tpf) {
renderRootNode.updateGeometricState();
renderRootNode.updateLogicalState(tpf);
// Static cameras are taken from the blend file, in blend file resolution is set to 320x180, so viewport is extended 4x
getCamera().copyFrom(cameraNode.getCamera());
getCamera().setViewPort(0, 4, 0, 4);
Quaternion rot = playerNode.getWorldRotation();
Vector3f direction = new Vector3f();
rot.mult(Vector3f.UNIT_Y.negate(), direction);
Quaternion rot2 = playerNode.getWorldRotation().add(new Quaternion().fromAngleAxis(FastMath.HALF_PI / 2, Vector3f.UNIT_Z.negate()));
Vector3f sideDirection = new Vector3f();
rot2.mult(Vector3f.UNIT_Y.negate(), sideDirection);
Ray rayFront = new Ray(new Vector3f(playerNode.getLocalTranslation().x, playerNode.getLocalTranslation().y, playerNode.getLocalTranslation().z + 0.0f), direction.normalize());
Ray rayBack = new Ray(playerNode.getLocalTranslation(), direction.negate().normalize());
checkCollision(rayFront, "Front", frontWalk, tpf, 0.5f, true);
checkCollision(rayBack, "Back", backWalk, tpf, 0.5f, true);
playerNode.rotate(0.0f, 0.0f, rotation * tpf);
}
[/java]
Maybe in this case I could leave the render viewport in this way, and attach a pixelation filter for player and scene, but I got some problem using the filter with multuples viewport, and also the filter effect it seems a bit aliased (there’s a smoothed pixelation). Otherwise I don’t know how to do this