Hole in the Ceiling

I recently upgraded my aweful metal ceiling texture to a nice wood one!.. but… I ran into a strange problem very soon after.

When I’m angling the camera just right, this big hole magically appears in the ceiling.

Sorry, it’s a little dark…

It happened right after switching textures, and my current texture has been cropped, so it isn’t perfectly square.

1 Like

What does it look like before “angling the camera just right”?

I’m not sure what it’s supposed to look like so I don’t know which part is “wrong”.

Here’s a clearer example of a hole, which shows that ~1/2 the ceiling is missing in that room.

Is the bright cyan color the framebuffer background or is there somehow another ceiling above the wooden one?

Edit: also, where does the ceiling geometry come from? Made in code, loaded from a file format, etc.?

viewPort.setBackgroundColor(ColorRGBA.Cyan);
Framebuffer

It’s a geometry that’s made and textured in my code.

When geometry disappears from random directions like this, it’s usually because the bounds were not updated and so the object is getting culled at camera angles where it should be visible.

The only other cause of things like this is when competing with a similarly placed transparent geometry… which doesn’t seem like the case here.

2 Likes

mesh.updateBound(); if you have custom mesh too.

geom.updateModelBound(); just for a Geom

My program only has the geometries on the first frame. Besides, why doesn’t this happen on any of my other geometries (floors and walls)?

dont see any code, so hard to tell.

its like “tell why my stomach hurts” without telling what i ate/did before it.

You might need provide us more information like some Code examples (Paul already managed to get some required information anyway, but its not enough for your second question)

To explain more, Model Bound when its “out of camera view” it cause Geometry to not render.
So it might help you find reason too.

Sorry, here’s the code that builds both the floor and the ceiling.

private void buildFloor() {
	Box b = new Box(w, 0.5f, d);
	Geometry g = new Geometry("floor", b);
	g.setLocalTranslation(new Vector3f(0, -height*0.5f, 0).add(pos));
	Material mat = new Material(manager, matType);
	mat.setTexture(lightType, manager.loadTexture(floorTex));
	g.setMaterial(mat);
	g.setShadowMode(RenderQueue.ShadowMode.Receive);
	room.attachChild(g);
}
private void buildCeil() {
	Box b = new Box(w, 0.5f, d);
	Geometry g = new Geometry("ceil", b);
	g.setLocalTranslation(new Vector3f(0, height*1.5f, 0).add(pos));
	Material mat = new Material(manager, matType);
	mat.setTexture(lightType, manager.loadTexture(ceilTex));
	g.setMaterial(mat);
	g.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
	room.attachChild(g);
}

Edit: This is the only code I could find dealing with either floor or ceiling.

except unknown lightType, height, w, d, ceilTex vars, it looks fine, so you probably have other code that cause issue.

Myself i had a lot of time issues that i didnt understand,

but its always easy to Debug when you will make easy TestCase, and suddently you might find issue yourself. (and even if not you can post more full-working code to us)

Anyway from my side, based on this code, IMO it should work. (except idk some param values)

My first guess would be that you have VERY BIG SCALE world, so camera frustrum(FAR) might cause some non-rendered mesh.

for example you might have code like rootNode.scale(100) Anywhere in code, and we would never know about it. Thats why TestCase is best option for you.

1 Like

Yep, I agree. At this point, the best bet is to make a simple single class test case that reproduces the problem. Start with just the ceiling and then start adding things back until the problem occurs.

Either you will figure out your problem or you’ll have complete code to post so we can point to the problem.

1 Like

Here’s my test case, but I can’t find anything wrong with it.

Main Class
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;

/**
 * 
 * @author codex
 */
public class Main extends SimpleApplication {
	
	BulletAppState bullet;
	Room test = new Room("Test", Vector3f.ZERO, Room.UNIT*5, Room.UNIT*5);
	Room test2 = new Room("Test2", new Vector3f(Room.UNIT*12, 0, 0), Room.UNIT*5, Room.UNIT*5);
	
    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        bullet = new BulletAppState();
		stateManager.attach(bullet);
		
		bullet.setDebugEnabled(true);
		
		viewPort.setBackgroundColor(ColorRGBA.Cyan);
		flyCam.setMoveSpeed(50);
		
		attachRoom(test);
		attachRoom(test2);
		
    }
    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code
    }
    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
	
	private void attachRoom(Room r) {
		r.setAssets(assetManager);
		r.buildRoom();
		rootNode.attachChild(r.getNode());
		for (RigidBodyControl i : r.getPhysics()) bullet.getPhysicsSpace().add(i);
	}
}
Room Class
package mygame;

import com.jme3.asset.AssetManager;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;
import java.util.ArrayList;

/**
 *
 * @author codex
 * 
 * @Purges
 * walls
 * lighting
 * decor
 * image textures
 */
public class Room {
	
	public static final float UNIT = 5;
	
	private final Node room;
	
	private final String name;
	private final Vector3f pos;
	private final float w;
	private final float d;
	
	private final float height = 8;	
	private final ArrayList<RigidBodyControl> physics = new ArrayList<>();	
	private AssetManager manager = null;
	
	
	Room(String name, Vector3f pos, float w, float h) {
		this.name = name;
		this.pos = pos;
		this.w = w;
		this.d = h;
		
		room = new Node("room:"+this.name);
    }
	
	
	protected void setAssets(AssetManager manager) {
		this.manager = manager;
	}
	
	protected void buildRoom() {
		RigidBodyControl phys = new RigidBodyControl(0);
		
		buildFloor();
		buildCeil();
		
		room.addControl(phys);
		physics.add(phys);
	}
	
	private void buildFloor() {
		Box b = new Box(w, 0.5f, d);
		Geometry g = new Geometry("floor", b);
		g.setLocalTranslation(new Vector3f(0, -height*0.5f, 0).add(pos));
		Material mat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
		//mat.setTexture("ColorMap", manager.loadTexture("Textures/hardwood.jpg"));
		mat.setColor("Color", ColorRGBA.Orange);
		g.setMaterial(mat);
		g.setShadowMode(RenderQueue.ShadowMode.Receive);
		room.attachChild(g);
	}
	private void buildCeil() {
		Box b = new Box(w, 0.5f, d);
		Geometry g = new Geometry("ceil", b);
		g.setLocalTranslation(new Vector3f(0, height*1.5f, 0).add(pos));
		Material mat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
		//mat.setTexture("ColorMap", manager.loadTexture("Textures/houseTilesDoor01.png"));
		mat.setColor("Color", ColorRGBA.Red);
		g.setMaterial(mat);
		g.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
		room.attachChild(g);
	}
	
	protected Node getNode() {
		return room;
	}
	protected ArrayList<RigidBodyControl> getPhysics() {
		return physics;
	}
}

I think I found the problem.

When I rebooted by computer, the problem went away. When I’d been using it for another heavy program then ran the program again, it got worse (even the walls were buggy).

Looks like I need to clean up my code. :stuck_out_tongue_winking_eye:

2 Likes

That sounds more like a GPU+Driver bug than something wrong with your application.

(Without knowing more about your problem specifically, I’d guess, in this order, your GPU is: intel or AMD/ATI)

Try


mat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);

Before setting the material to the geom

1 Like

Order doesn’t matter. It’s also not the issue.

Sometimes it appears… sometimes it doesn’t. And if you read the thread you can already see it’s a GPU-related problem.

1 Like