Archive 17/01/2023.

Model disapearing when changing angle

claudeHasler

Im displaying a model which works fine most of the time, but occasionally when i change the position and direction of the camera, the model disapears:



I dont understand how this can be happening, two of those images are in very similar positions so i dont believe it is the lighting, what else could cause this kind of effect? What i have noticed is that when the model is in the upper third of the screen it seems to disapear

SirNate0

I would guess a bounding box issue is probably the cause. Or possibly occlusion - is the white square an occluder?

claudeHasler

no the white box is simply some debugrenderer output so i have some frame of reference.

How could a boundingbox be an issue? being outside the camera clip range?

SirNate0

Yes. If the bounding box doesn’t actually contain all of the model for whatever reason and ends up outside the camera’s frustum then the model won’t display even though it should visually. Hopefully the import process got that correct, but it’s worth checking to see for problems like these.

claudeHasler

So it turns out the model is not to blame, instead it is because i am using a large projection offset, almost half of my screen dimensions. The reason for this is that i am developing a projected reality application, and the projector (an inverse camera) calibration demands this offset.

cameraNode_->GetComponent<Camera>()->SetProjectionOffset(Vector2(offsetX,offsetY)); 

Is there a way to get this to render anyway?

SirNate0

You did remember to divide by the viewport dimensions, right? From the documentation for SetProjectionOffset: “Set projection offset. It needs to be calculated as (offset in pixels) / (viewport dimensions.)”

WangKai

Maybe you should check the far clip distance of the camera to make sure it is far than your model.

claudeHasler

Both the distance and the projection offset are correct

viewport->SetCullCamera(cullCamera);

I solved the issue by setting a separate cullCamera with a large FoV

SirNate0

Would you mind sharing the parameters you set for the camera? I’d like to look into the issue a bit more as your solution sounds more like a band-aid hiding the underlying issue (which probably works fine for your application, but it would be best to fix it if it is a bug).

claudeHasler

sure:

position
141.693 -60.6896 -107.592
rotation matrix
0.741284 -0.0941694 -0.664552 0.238699 0.962368 0.129889 0.627312 -0.254913 0.735866
Fov:21.1675
OffsetX:-0.009375 OffsetY:-0.32963

Its the offsetY which seems to be the problem. Let me know if you need anything else

George1

You should enable debug line to show model bounding box.
Also play with set far and near clip.

Sinoid

Use debug-draw to show your Octree as well. Assuming your type derives from Drawable add a debug-draw override to draw a line from itself to the center of it’s Octant.

Your mesh is being assigned to an Octant not in view.